Sha256: 8519b3611e1373f77d9d4d713023cf10c2e228462760812050760b34d767dad2

Contents?: true

Size: 1.69 KB

Versions: 14

Compression:

Stored size: 1.69 KB

Contents

require File.join(File.dirname(__FILE__), "../../spec_helper")
include Nudge

describe NameRandomBoundInstruction do
  
  it_should_behave_like "every Nudge Instruction"
  
  before(:each) do
    @context = Interpreter.new
    @i1 = NameRandomBoundInstruction.new(@context)
  end
  
  
  describe "\#go" do
    before(:each) do
      @i1 = NameRandomBoundInstruction.new(@context)
      @bar = ValuePoint.new("int", 99)
      @context.reset
    end
    
    describe "\#preconditions?" do
      it "should check that there are any bound variables or names" do
        @i1.preconditions?.should == false
        
        @context.bind_variable("d", @bar)
        @i1.preconditions?.should == true
        
        @context.reset_variables
        @context.bind_name("r", @bar)
        @i1.preconditions?.should == true
      end
    end
    
    describe "\#cleanup" do
      it "should push a random sample of the bound references in @context" do
        @context.bind_variable("d", @bar)
        @i1.go
        @context.stacks[:exec].depth.should == 1
        @context.stacks[:exec].peek.should be_a_kind_of(ReferencePoint)
        @context.stacks[:exec].peek.value.should == "d"
        
        @context.reset_variables
        @context.bind_name("e", @bar)
        @i1.go
        @context.stacks[:exec].depth.should == 2
        @context.stacks[:exec].peek.should be_a_kind_of(ReferencePoint)
        @context.stacks[:exec].peek.value.should == "e"
        
        @context.reset_names
        @i1.go # nothing should happen
        @context.stacks[:exec].depth.should == 2
        @context.stacks[:exec].peek.should be_a_kind_of(ReferencePoint)
        @context.stacks[:exec].peek.value.should == "e"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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