Sha256: 0cc194251fad72db37efd81517a1a2f9fde7d8f9fdfe06c0a07e1a09d719a9e8

Contents?: true

Size: 1.15 KB

Versions: 14

Compression:

Stored size: 1.15 KB

Contents

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


describe CodeInstructionsInstruction do
  
  it_should_behave_like "every Nudge Instruction"
  
  before(:each) do
    @context = Interpreter.new
    @i1 = CodeInstructionsInstruction.new(@context)
  end
  
  
  describe "\#go" do
    before(:each) do
      @context = Interpreter.new
      @i1 = CodeInstructionsInstruction.new(@context)
    end
    
    describe "\#preconditions?" do
      it "doesn't need any preconditions to be met, actually" do
        lambda{@i1.preconditions?}.should_not raise_error
      end
    end
    
    describe "\#cleanup" do
      it "should push a block containing every active instruction" do
        @context.disable_all_instructions
        @context.enable(CodeInstructionsInstruction)
        @context.enable(IntAddInstruction)
        @i1.go
        @context.stacks[:code].peek.value.should == "block { do code_instructions do int_add}"
        
        @context.enable(ExecPopInstruction)
        @i1.go
        @context.stacks[:code].peek.value.should == "block { do code_instructions do int_add do exec_pop}"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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