Sha256: 8af24977cbe056cd2e33ca8d4a689d5d1e07dd8b7390d38a506d51a6cb9289f3
Contents?: true
Size: 1.65 KB
Versions: 14
Compression:
Stored size: 1.65 KB
Contents
#encoding: utf-8 require File.join(File.dirname(__FILE__), "../../spec_helper") include Nudge describe "FloatGreaterThanQInstruction" do it_should_behave_like "every Nudge Instruction" before(:each) do @context = Interpreter.new @i1 = FloatGreaterThanQInstruction.new(@context) @float1 = ValuePoint.new("float", 1.0) @float2 = ValuePoint.new("float", 2.0) end it "should check that there are enough parameters" do 6.times {@context.stacks[:float].push(@float1)} @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[:float].push(@float1)} @i1.should_receive(:cleanup) @i1.go end it "should pop all the arguments" do @context.clear_stacks 5.times {@context.stacks[:float].push(@float1)} @i1.stub!(:cleanup) # and do nothing @i1.go @context.stacks[:float].depth.should == 3 end it "should push the result" do @context.clear_stacks @context.stacks[:float].push(@float1) @context.stacks[:float].push(@float1) @i1.go @context.stacks[:bool].peek.value.should == false @context.stacks[:float].push(@float1) @context.stacks[:float].push(@float2) @i1.go @context.stacks[:bool].peek.value.should == false @context.stacks[:float].push(@float2) @context.stacks[:float].push(@float1) @i1.go @context.stacks[:bool].peek.value.should == true end end
Version data entries
14 entries across 14 versions & 1 rubygems