Skip to content

Instantly share code, notes, and snippets.

@conorfennell
Created January 24, 2016 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conorfennell/45282597e422ab2dde88 to your computer and use it in GitHub Desktop.
Save conorfennell/45282597e422ab2dde88 to your computer and use it in GitHub Desktop.
scalatest FunSpec
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