File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 14551455 # Tests that NaN is not a finite value.
14561456 nan.is-finite.not > [] +> nan-is-not-finite
14571457
1458+ # Tests that converting a number far outside i64 range to i64 throws an error,
1459+ # instead of silently saturating to Long.MAX_VALUE.
1460+ [] +> throws-on-converting-huge-number-to-i64
1461+ 1.0e30.as-i64 > @
1462+
14581463 # Tests that NaN is not an integer.
14591464 nan.is-integer.not > [] +> nan-is-not-integer
Original file line number Diff line number Diff line change @@ -21,14 +21,14 @@ public final class EOnumber$EOas_i64 extends PhDefault implements Atom {
2121 @ Override
2222 public Phi lambda () {
2323 final Phi num = Phi .Φ .take ("i64" ).copy ();
24- num . put (
25- 0 ,
26- new Data . ToPhi (
27- new BytesOf (
28- new Expect . Number ( Expect . at ( this , Phi . RHO )). it (). longValue ( )
29- ). take ( )
30- )
31- );
24+ final long value = Expect . at ( this , Phi . RHO )
25+ . that ( phi -> new Dataized ( phi ). asNumber ())
26+ . otherwise ( "must be a number" )
27+ . must ( number -> number >= Long . MIN_VALUE && number <= Long . MAX_VALUE )
28+ . otherwise ( "must fit into long range" )
29+ . that ( Double :: longValue )
30+ . it ();
31+ num . put ( 0 , new Data . ToPhi ( new BytesOf ( value ). take ()) );
3232 return num ;
3333 }
3434}
You can’t perform that action at this time.
0 commit comments