spec/parsing/numbers/nonnegative_float_spec.rb in music-transcription-0.17.1 vs spec/parsing/numbers/nonnegative_float_spec.rb in music-transcription-0.19.0

- old
+ new

@@ -1,11 +1,28 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Parsing::NonnegativeFloatParser do parser = Parsing::NonnegativeFloatParser .new - ["1.0","0.50","05.003e-10","1.555e+2","3.443214"].each do |str| + ["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 - parser.parse(str).should_not be nil + 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