Sha256: 308bcfd877848647c95b0d96cd07c12578afd5ae392b045f682d0a714de54f85

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

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

describe FloatFromIntInstruction do
  
  it_should_behave_like "every Nudge Instruction"
  
  before(:each) do
    @context = Interpreter.new
    @i1 = FloatFromIntInstruction.new(@context)
    @context.clear_stacks
  end
  
  it "should check that there are enough parameters" do
    @context.push(:int, "12")
    @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
    @context.push(:int, "2")
    @i1.should_receive(:cleanup)
    @i1.go
  end
  
  it "should create and push the new (expected) value to the right place" do
    @context.push(:int, "-21")
    @i1.go
    @context.depth(:float).should == 1
    @context.peek_value(:float).should == -21.0
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nudge-0.2.9 spec/instructions/float/float_from_int_spec.rb
nudge-0.2.8 spec/instructions/float/float_from_int_spec.rb
nudge-0.2.7 spec/instructions/float/float_from_int_spec.rb
nudge-0.2.6 spec/instructions/float/float_from_int_spec.rb
nudge-0.2.5 spec/instructions/float/float_from_int_spec.rb
nudge-0.2.4 spec/instructions/float/float_from_int_spec.rb
nudge-0.2.3 spec/instructions/float/float_from_int_spec.rb
nudge-0.2.2 spec/instructions/float/float_from_int_spec.rb