Sha256: 7826c4496a1b8ef7bd8dfa8efc43c890b5a55c3df37f78e3c4733ec4c40cece6

Contents?: true

Size: 577 Bytes

Versions: 4

Compression:

Stored size: 577 Bytes

Contents

require 'minitest_helper'

describe Rasti::Types::Float do

  [100, '200', Time.now,2.0,"12.5"].each do |value|
    it "#{value.inspect} -> #{value.to_i}" do
      Rasti::Types::Float.cast(value).must_equal value.to_f
    end
  end

  [nil, 'text', :symbol, '999'.to_sym, [1,2], {a: 1, b: 2}, Object.new, "1.", ".2","."].each do |value|
    it "#{value.inspect} -> CastError" do
      error = proc { Rasti::Types::Float.cast(value) }.must_raise Rasti::Types::CastError
      error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Types::Float"
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rasti-types-1.1.2 spec/float_spec.rb
rasti-types-1.1.1 spec/float_spec.rb
rasti-types-1.1.0 spec/float_spec.rb
rasti-types-1.0.0 spec/float_spec.rb