Sha256: 04db8e2c7b61d6c1a379c21305a3608a7081bd3ef2f297741ef70215853ca5fd

Contents?: true

Size: 769 Bytes

Versions: 3

Compression:

Stored size: 769 Bytes

Contents

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

describe Parsing::NonnegativeFloatParser do
  parser = Parsing::NonnegativeFloatParser .new

  ["0.0","0e1","2e2","1.0","0.50","05.003e-10","1.555e+2","3.443214","0.001","0000.0030000"].each do |str|
    res = parser.parse(str)
    f = str.to_f
    
    it "should parse '#{str}'" do
      res.should_not be nil
    end

    it 'should return node that is convertible to float using #to_f method' do
      res.to_f.should eq(f)
    end
    
    it 'should return node that is convertible to float using #to_num method' do
      res.to_num.should eq(f)
    end
  end
  
  ["-1.0","-0e1"].each do |str|
    it "should not parse '#{str}'" do
      parser.should_not parse(str)
    end    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
music-transcription-0.21.0 spec/parsing/numbers/nonnegative_float_spec.rb
music-transcription-0.20.0 spec/parsing/numbers/nonnegative_float_spec.rb
music-transcription-0.19.0 spec/parsing/numbers/nonnegative_float_spec.rb