Created
January 24, 2016 19:38
-
-
Save conorfennell/45282597e422ab2dde88 to your computer and use it in GitHub Desktop.
scalatest FunSpec
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
import org.scalatest.FunSpec | |
import scala.collection.mutable.Stack | |
class ExampleSpec extends FunSpec { | |
describe("A Stack") { | |
it("should pop values in last-in-first-out order") { | |
val stack = new Stack[Int] | |
stack.push(1) | |
stack.push(2) | |
assert(stack.pop() === 2) | |
assert(stack.pop() === 1) | |
} | |
it("should throw NoSuchElementException if an empty stack is popped") { | |
val emptyStack = new Stack[Int] | |
intercept[NoSuchElementException] { | |
emptyStack.pop() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment