Sha256: 9a285cb3fb2d82a3f6fc6553cf68feafbf04ed596e9e86632fd2e40adb5dd4ab

Contents?: true

Size: 1.58 KB

Versions: 14

Compression:

Stored size: 1.58 KB

Contents

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


describe CodeQuoteInstruction do
  it_should_behave_like "every Nudge Instruction"
  
  before(:each) do
    @context = Interpreter.new
    @i1 = CodeQuoteInstruction.new(@context)
  end
  
  
  describe "\#go" do
    before(:each) do
      @context = Interpreter.new
      @i1 = CodeQuoteInstruction.new(@context)
    end
    
    after(:each) do
      @context.clear_stacks
    end
    
    describe "\#preconditions?" do
      it "should need at least one item on the :exec stack" do
        @context.stacks[:exec].push(ReferencePoint.new("hi_there"))
        @i1.preconditions?.should == true
      end
    end

    describe "\#cleanup" do
      it "should the top thing from :exec onto the :code stack as a ValuePoint" do
        @context.stacks[:exec].push(ReferencePoint.new("hi_there"))
        @i1.go
        @context.stacks[:exec].depth.should == 0
        @context.stacks[:code].depth.should == 1
        @context.stacks[:code].peek.value.should == "ref hi_there"
        
        @context.stacks[:exec].push(ValuePoint.new("lolcat","haz cheezburger"))
        @i1.go
        @context.stacks[:code].depth.should == 2
        @context.stacks[:code].peek.value.should == "value «lolcat» \n«lolcat» haz cheezburger"
        
        @context.stacks[:exec].push(CodeblockPoint.new([ReferencePoint.new("a"),InstructionPoint.new("b")]))
        @i1.go
        @context.stacks[:code].depth.should == 3
        @context.stacks[:code].peek.value.should == "block {\n  ref a\n  do b}"
        
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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