-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0844ccf
commit d327c12
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/test/scala/com/github/mogproject/redismock/util/ops/BooleanOpsSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.github.mogproject.redismock.util.ops | ||
|
||
import org.scalatest.{Matchers, FunSpec} | ||
|
||
class BooleanOpsSpec extends FunSpec with Matchers { | ||
|
||
describe("BooleanOps#whenTrue") { | ||
it("should return false with no side effect") { | ||
var x = 0 | ||
false whenTrue (x += 1) shouldBe false | ||
x shouldBe 0 | ||
} | ||
it("should return true with side effect") { | ||
var x = 0 | ||
true whenTrue (x += 1) shouldBe true | ||
x shouldBe 1 | ||
} | ||
} | ||
|
||
describe("BooleanOps#whenFalse") { | ||
it("should return false with side effect") { | ||
var x = 0 | ||
false whenFalse (x += 1) shouldBe false | ||
x shouldBe 1 | ||
} | ||
it("should return true with no side effect") { | ||
var x = 0 | ||
true whenFalse (x += 1) shouldBe true | ||
x shouldBe 0 | ||
} | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/test/scala/com/github/mogproject/redismock/util/ops/IdOpsSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.github.mogproject.redismock.util.ops | ||
|
||
import org.scalatest.{Matchers, FunSpec} | ||
|
||
class IdOpsSpec extends FunSpec with Matchers { | ||
|
||
describe("IdOps#|>") { | ||
it("should pipe operations") { | ||
3 |> (_ * 2) shouldBe 6 | ||
3 |> (_ * 2) |> (_ - 1) shouldBe 5 | ||
} | ||
} | ||
|
||
describe("IdOps#<|") { | ||
it("should do with side effect and return the original value") { | ||
true <| { x => assert(x) } shouldBe true | ||
123 <| { x => assert(x == 123) } shouldBe 123 | ||
} | ||
} | ||
|
||
} |