Sha256: 1be73ffd4f26db143330e670ecf34185f4be499a6ee88ba047197b7cff3efdb9

Contents?: true

Size: 887 Bytes

Versions: 2

Compression:

Stored size: 887 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe V8::Number do 
  subject { V8::Number }
  setup_context
  
  it "inherits V8::Primitive" do
    subject.new(10.5).should be_kind_of(V8::Primitive)
  end

  describe ".new" do
    it "creates new v8 number based on passed value" do
      subject.new(10.5).should == 10.5
      subject.new(-10.5).should == -10.5
    end
  end

  describe "#to_i" do
    it "returns fixnum value of referenced number" do
      subject.new(10.5).to_i.should == 10
    end
  end

  describe "an instance" do
    it "is comparable" do
      num = subject.new(10.5)
      num.should == 10.5
      num.should_not == 20.5
      num.should > 5.5
      num.should < 15.5
      num.should <= 10.5
      num.should >= 10.5
    end
    
    it "is delegated properly" do
      num = subject.new(3.4)
      num.delegate.should == num.to_f
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mustang-0.1.1 spec/v8/number_spec.rb
mustang-0.1.0 spec/v8/number_spec.rb