All pastes #751974 Raw Edit

Anonymous

public javascript v1 · immutable
#751974 ·published 2007-10-27 22:18 UTC
rendered paste body
class StackSpecifications //extends Specification<Account>{	var account : NewSpec;		function newStack() {		stack = new Stack();	}	/** A new empty stack **/	function EmptyStack()	{		Describe_as("an empty Stack");		beforeEach = newStack;		afterEach  = newStack;		Uses(stack);				It("should be empty");		The(stack.length).should.equal(0);				It("should NOT remove the top item when sent #peek");	    Calling("peek").withArgs().should.give(last_item_added);		Calling("peek").withNoArgs.should.give(last_item_added);				It("should return the top item when sent #pop");		Calling('pop').should.give(last_item_added);				It("should throw an EmptyStack exception when popping with no more items left");		Calling('pop').should.raise(Error.EmptyStack);				Should_behave_like(EmptyStack); // Infinite loop for the sake of example	}	}// Or the less dynamic wayclass StackSpecifications //extends Specification<Account>{	var account : NewSpec;		function begin()	{		var define = Mock.method;		var m = Mock.begin(User, "a new account user");			define(m.delete).will_return.	}		function newStack() {		stack = new Stack();	}	/** A new empty stack **/	function EmptyStack()	{		Describe_as("an empty Stack");		beforeEach = newStack;		afterEach  = newStack;				It("should be empty");		The(stack.length).should.equal(0);				It("should NOT remove the top item when sent #peek");	    Calling(stack.peek()).should.give(last_item_added);		Calling(stack.peek()).should.give(last_item_added);				It("should return the top item when sent #pop");		Calling(stack.pop).should.give(last_item_added);				It("should throw an EmptyStack exception when popping with no more items left");		Calling(stack.pop).should.raise(Error.EmptyStack);				Should_behave_like(EmptyStack); // Infinite loop for the sake of example	}	}