Skip to content

Commit a40f4aa

Browse files
author
Krzysztof Wrzalik
committed
Test conversion of Float to BigNum
1 parent b854626 commit a40f4aa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

spec/coerce_spec.rb

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class Param2 < T::Struct
159159
T.assert_type!(TypeCoerce[Integer].new.from(1), Integer)
160160
T.assert_type!(TypeCoerce[Integer].new.from('1.0'), Integer)
161161
T.assert_type!(TypeCoerce[T.nilable(Integer)].new.from(nil), T.nilable(Integer))
162+
T.assert_type!(TypeCoerce[BigDecimal].new.from('1.0'), BigDecimal)
162163
end
163164

164165
it 'coreces correctly' do
@@ -176,6 +177,8 @@ class Param2 < T::Struct
176177
expect(TypeCoerce[T.nilable(Integer)].new.from('')).to be nil
177178
expect{TypeCoerce[T.nilable(Integer)].new.from([])}.to raise_error(TypeCoerce::CoercionError)
178179
expect(TypeCoerce[T.nilable(String)].new.from('')).to eql ''
180+
181+
expect(TypeCoerce[BigDecimal].new.from(123.321)).to eql BigDecimal(123.321, 0)
179182
end
180183
end
181184

0 commit comments

Comments
 (0)