]> git.kaiwu.me - njs.git/commitdiff
Fixed parseInt('-0').
authorArtem S. Povalyukhin <artem.povaluhin@gmail.com>
Sat, 22 Jun 2019 20:35:52 +0000 (23:35 +0300)
committerArtem S. Povalyukhin <artem.povaluhin@gmail.com>
Sat, 22 Jun 2019 20:35:52 +0000 (23:35 +0300)
njs/njs_number.c
njs/test/njs_unit_test.c

index 8e16f7da720382b9dd4953fdebc0518db1eaf25a..2287472db23563b64d777b902025adc21ca5ef25 100644 (file)
@@ -802,7 +802,8 @@ njs_number_parse_int(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
         n = njs_number_radix_parse(&p, end, radix);
 
         if (n >= 0) {
-            num = minus ? -n : n;
+            num = n;
+            num = minus ? -num : num;
         }
     }
 
index 2e0624dc62ad60763e4c661107cd34b2497add19..f62c6589c518b0f5169f34b050006bfb14ca3901 100644 (file)
@@ -11744,6 +11744,9 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("parseInt('0', 37)"),
       nxt_string("NaN") },
 
+    { nxt_string("1/parseInt('-0')"),
+      nxt_string("-Infinity") },
+
     { nxt_string("parseFloat.name"),
       nxt_string("parseFloat") },