Spock Web Console

subscribe to the feed Subscribe
Let's play with stack (via #spockwebconsole)
tweet this script Tweet

Let's play with stack

Published 2 months ago by lajos with tags spock
Actions  ➤ Edit In Console Back To Console Show/Hide Line Numbers View Recent Scripts
import spock.lang.*

class MyFirstSpec extends Specification {
  
  def "let's play with stack"() {
    given: "an empty stack and an element"
    def stack = new Stack()
    def elem = "push me"
    
    when: "we push the element into the stack"
    stack.push(elem)

    then: "the stack is not empty and contains only the elemet"
    !stack.isEmpty()
    stack.size() == 1
    stack.peek() == elem
  }

}