[njs] Fixed type of Date.prototype.

Dmitry Volyntsev xeioex at nginx.com
Fri Oct 11 12:34:50 UTC 2019


details:   https://hg.nginx.org/njs/rev/9944f6e9f33a
branches:  
changeset: 1181:9944f6e9f33a
user:      Artem S. Povalyukhin <artem.povaluhin at gmail.com>
date:      Fri Oct 11 08:01:03 2019 +0300
description:
Fixed type of Date.prototype.

This closes #237 issue on Github.

diffstat:

 src/njs_builtin.c        |   3 +--
 src/test/njs_unit_test.c |  12 +++---------
 2 files changed, 4 insertions(+), 11 deletions(-)

diffs (44 lines):

diff -r eb57c1e27495 -r 9944f6e9f33a src/njs_builtin.c
--- a/src/njs_builtin.c	Thu Oct 10 20:54:03 2019 +0300
+++ b/src/njs_builtin.c	Fri Oct 11 08:01:03 2019 +0300
@@ -190,8 +190,7 @@ const njs_object_prototype_t  njs_protot
 
     { .object =       { .type = NJS_REGEXP } },
 
-    { .date =         { .time = NAN,
-                        .object = { .type = NJS_DATE } } },
+    { .object =       { .type = NJS_OBJECT } },
 
     { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
                         .object = { .type = NJS_OBJECT } } },
diff -r eb57c1e27495 -r 9944f6e9f33a src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c	Thu Oct 10 20:54:03 2019 +0300
+++ b/src/test/njs_unit_test.c	Fri Oct 11 08:01:03 2019 +0300
@@ -12002,12 +12002,6 @@ static njs_unit_test_t  njs_test[] =
                  "Date.prototype.toJSON.call(o, 1)"),
       njs_str("OK") },
 
-    { njs_str("var d = new Date; d.__proto__"),
-      njs_str("Invalid Date") },
-
-    { njs_str("var d = new Date(); d.__proto__"),
-      njs_str("Invalid Date") },
-
     { njs_str("var d = new Date(); d.__proto__ === Date.prototype"),
       njs_str("true") },
 
@@ -12049,11 +12043,11 @@ static njs_unit_test_t  njs_test[] =
     { njs_str("Date.prototype.__proto__ === Object.prototype"),
       njs_str("true") },
 
-    { njs_str("Date.prototype"),
-      njs_str("Invalid Date") },
+    { njs_str("njs.dump(Date.prototype)"),
+      njs_str("{}") },
 
     { njs_str("Date.prototype.valueOf()"),
-      njs_str("NaN") },
+      njs_str("TypeError: cannot convert object to date") },
 
     { njs_str("Date.constructor === Function"),
       njs_str("true") },


More information about the nginx-devel mailing list