Skip to content

Instantly share code, notes, and snippets.

@agemooij
Created March 29, 2010 20:43
Show Gist options
  • Save agemooij/348385 to your computer and use it in GitHub Desktop.
Save agemooij/348385 to your computer and use it in GitHub Desktop.
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
class StackSpec extends FlatSpec with ShouldMatchers {
"A Stack" should "pop values in last-in-first-out order" in {
val stack = new Stack[Int]
stack.push(1)
stack.push(2)
stack.pop() should equal (2)
stack.pop() should equal (1)
}
it should "throw NoSuchElementException if an empty stack is popped" in {
val emptyStack = new Stack[String]
evaluating { emptyStack.pop() } should produce [NoSuchElementException]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment