Sha256: eeddd743375a7277b8d42f66e230005e04ea16ee1a5fbe516ec062e72b32b8db
Contents?: true
Size: 1.6 KB
Versions: 14
Compression:
Stored size: 1.6 KB
Contents
#encoding: utf-8 require File.join(File.dirname(__FILE__), "../../spec_helper") include Nudge describe "IntGreaterThanQInstruction" do it_should_behave_like "every Nudge Instruction" before(:each) do @context = Interpreter.new @i1 = IntGreaterThanQInstruction.new(@context) @int1 = ValuePoint.new("int", 1) @int2 = ValuePoint.new("int", 2) end it "should check that there are enough parameters" do 6.times {@context.stacks[:int].push(@int1)} @i1.preconditions?.should == true end it "should raise an error if the preconditions aren't met" do @context.clear_stacks # there are no params at all lambda{@i1.preconditions?}.should raise_error(Instruction::NotEnoughStackItems) end it "should successfully run #go only if all preconditions are met" do 5.times {@context.stacks[:int].push(@int1)} @i1.should_receive(:cleanup) @i1.go end it "should pop all the arguments" do @context.clear_stacks 5.times {@context.stacks[:int].push(@int1)} @i1.stub!(:cleanup) # and do nothing @i1.go @context.stacks[:int].depth.should == 3 end it "should push the result" do @context.clear_stacks @context.stacks[:int].push(@int1) @context.stacks[:int].push(@int1) @i1.go @context.stacks[:bool].peek.value.should == false @context.stacks[:int].push(@int1) @context.stacks[:int].push(@int2) @i1.go @context.stacks[:bool].peek.value.should == false @context.stacks[:int].push(@int2) @context.stacks[:int].push(@int1) @i1.go @context.stacks[:bool].peek.value.should == true end end
Version data entries
14 entries across 14 versions & 1 rubygems