[njs] The undefined values must be equal.
Igor Sysoev
igor at sysoev.ru
Tue Mar 21 13:22:20 UTC 2017
details: http://hg.nginx.org/njs/rev/ee391489a56d
branches:
changeset: 316:ee391489a56d
user: Igor Sysoev <igor at sysoev.ru>
date: Tue Mar 21 16:09:09 2017 +0300
description:
The undefined values must be equal.
diffstat:
njs/njs_vm.c | 7 ++++++-
njs/test/njs_unit_test.c | 18 +++++++++++++++---
2 files changed, 21 insertions(+), 4 deletions(-)
diffs (48 lines):
diff -r 9ee2a6eb381c -r ee391489a56d njs/njs_vm.c
--- a/njs/njs_vm.c Tue Mar 21 16:02:03 2017 +0300
+++ b/njs/njs_vm.c Tue Mar 21 16:09:09 2017 +0300
@@ -2046,7 +2046,12 @@ njs_values_strict_equal(const njs_value_
}
if (njs_is_numeric(val1)) {
- /* NaNs and Infinities are handled correctly by comparision. */
+
+ if (val1->type == NJS_VOID) {
+ return 1;
+ }
+
+ /* Infinities are handled correctly by comparision. */
return (val1->data.u.number == val2->data.u.number);
}
diff -r 9ee2a6eb381c -r ee391489a56d njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue Mar 21 16:02:03 2017 +0300
+++ b/njs/test/njs_unit_test.c Tue Mar 21 16:09:09 2017 +0300
@@ -1034,12 +1034,24 @@ static njs_unit_test_t njs_test[] =
/**/
+ { nxt_string("undefined == undefined"),
+ nxt_string("true") },
+
+ { nxt_string("undefined != undefined"),
+ nxt_string("false") },
+
+ { nxt_string("undefined === undefined"),
+ nxt_string("true") },
+
+ { nxt_string("undefined !== undefined"),
+ nxt_string("false") },
+
+ { nxt_string("undefined < undefined"),
+ nxt_string("false") },
+
{ nxt_string("undefined < null"),
nxt_string("false") },
- { nxt_string("undefined < undefined"),
- nxt_string("false") },
-
{ nxt_string("undefined < false"),
nxt_string("false") },
More information about the nginx-devel
mailing list