Sha256: ea20f640cb6d958c79038179a5ff5043382e945a08254f422ff59ee754fba920

Contents?: true

Size: 1.59 KB

Versions: 14

Compression:

Stored size: 1.59 KB

Contents

#encoding: utf-8
require File.join(File.dirname(__FILE__), "../../spec_helper")
include Nudge


describe ExecEqualQInstruction do
  
  it_should_behave_like "every Nudge Instruction"
  
  before(:each) do
    @context = Interpreter.new
    @i1 = ExecEqualQInstruction.new(@context)
  end
  
  
  it "should check that there are enough parameters" do
    thing1 = ValuePoint.new("code", "block {ref x}")
    @context.stacks[:exec].push thing1
    @context.stacks[:exec].push thing1
    @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 push the correct result to the :bool stack" do
    thing1 = ValuePoint.new("code", "ref x")
    thing2 = ValuePoint.new("code", "block {ref x}")
    @context.stacks[:exec].push thing1
    @context.stacks[:exec].push thing1
    @i1.go
    @context.stacks[:bool].peek.value.should == true
    
    @context.stacks[:exec].push thing1
    @context.stacks[:exec].push thing2
    @i1.go
    @context.stacks[:bool].peek.value.should == false
  end
  
  it "should not depend on the values, but the tidied program blueprints of the :code items" do
    thing1 = NudgeProgram.new("block { value   «int» ref a  }\n«int» 9182").linked_code
    thing2 = NudgeProgram.new("block {\nvalue   «int»\tref \na  }\n«int» 9182").linked_code
    @context.stacks[:exec].push thing1
    @context.stacks[:exec].push thing2
    @i1.go
    @context.stacks[:bool].peek.value.should == true
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
nudge-0.2.9 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.8 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.7 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.6 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.5 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.4 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.3 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.2 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.1 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.2.0 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.1.3 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.1.2 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.1.1 spec/instructions/exec/exec_equal_q_spec.rb
nudge-0.1.0 spec/instructions/exec/exec_equal_q_spec.rb