]> gitweb.factorcode.org Git - factor.git/commitdiff
math.parser: fix "most-negative-fixnum number>string string>number fixnum?".
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Jul 2015 03:03:33 +0000 (20:03 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Jul 2015 03:03:33 +0000 (20:03 -0700)
core/math/parser/parser-tests.factor
core/math/parser/parser.factor

index dbc24f6f668b24d1badbfed2915c3f1e668def3d..909c630265faca3eccedfabf21d26616cd1bc179 100644 (file)
@@ -1,4 +1,5 @@
-USING: kernel literals math math.parser sequences tools.test ;
+USING: kernel layouts literals math math.parser sequences
+tools.test ;
 IN: math.parser.tests
 
 { f }
@@ -359,3 +360,6 @@ unit-test
 { f } [ "0b0" bin> ] unit-test
 { f } [ "0o0" bin> ] unit-test
 { f } [ "0x0" bin> ] unit-test
+
+{ t } [ most-positive-fixnum number>string string>number fixnum? ] unit-test
+{ t } [ most-negative-fixnum number>string string>number fixnum? ] unit-test
index c10ac80cd5e5d148a231e22d250dbe6abd3925ae..8502e6ae5f5f24467f7b92b30fab8adeb08a4833 100644 (file)
@@ -98,7 +98,12 @@ TUPLE: float-parse
     } cond ;
 
 : ?neg ( n/f -- -n/f )
-    [ neg ] [ f ] if* ; inline
+    [
+        dup bignum? [
+            dup first-bignum bignum=
+            [ drop most-negative-fixnum ] [ neg ] if
+        ] [ neg ] if
+    ] [ f ] if* ; inline
 
 : ?add-ratio ( m n/f -- m+n/f )
     dup ratio? [ + ] [ 2drop f ] if ; inline