Skip to content

Commit

Permalink
add tests for util.ops closes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
mogproject committed Apr 29, 2015
1 parent 0844ccf commit d327c12
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
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
}
}

}
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
}
}

}

0 comments on commit d327c12

Please sign in to comment.