[njs] Using more approprite name for undefined value in exceptions.

Dmitry Volyntsev xeioex at nginx.com
Tue Nov 6 17:58:13 UTC 2018


details:   http://hg.nginx.org/njs/rev/5766e459c203
branches:  
changeset: 638:5766e459c203
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Nov 06 20:57:52 2018 +0300
description:
Using more approprite name for undefined value in exceptions.

diffstat:

 njs/njs_vm.c                    |   2 +-
 njs/test/njs_interactive_test.c |   2 +-
 njs/test/njs_unit_test.c        |  18 +++++++++---------
 3 files changed, 11 insertions(+), 11 deletions(-)

diffs (98 lines):

diff -r 1df0fea011d1 -r 5766e459c203 njs/njs_vm.c
--- a/njs/njs_vm.c	Tue Nov 06 20:30:49 2018 +0300
+++ b/njs/njs_vm.c	Tue Nov 06 20:57:52 2018 +0300
@@ -2207,7 +2207,7 @@ njs_type_string(njs_value_type_t type)
         return "null";
 
     case NJS_VOID:
-        return "void";
+        return "undefined";
 
     case NJS_BOOLEAN:
         return "boolean";
diff -r 1df0fea011d1 -r 5766e459c203 njs/test/njs_interactive_test.c
--- a/njs/test/njs_interactive_test.c	Tue Nov 06 20:30:49 2018 +0300
+++ b/njs/test/njs_interactive_test.c	Tue Nov 06 20:57:52 2018 +0300
@@ -140,7 +140,7 @@ static njs_interactive_test_t  njs_test[
 
     { nxt_string("function f(o) {return Object.keys(o)}" ENTER
                  "f()" ENTER),
-      nxt_string("TypeError: cannot convert void to object\n"
+      nxt_string("TypeError: cannot convert undefined to object\n"
                  "    at Object.keys (native)\n"
                  "    at f (:1)\n"
                  "    at main (native)\n") },
diff -r 1df0fea011d1 -r 5766e459c203 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Tue Nov 06 20:30:49 2018 +0300
+++ b/njs/test/njs_unit_test.c	Tue Nov 06 20:57:52 2018 +0300
@@ -3071,7 +3071,7 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("") },
 
     { nxt_string("Array.prototype.slice.call(undefined)"),
-      nxt_string("TypeError: cannot convert void to object") },
+      nxt_string("TypeError: cannot convert undefined to object") },
 
     { nxt_string("Array.prototype.slice.call(1)"),
       nxt_string("") },
@@ -5528,10 +5528,10 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("1552553") },
 
     { nxt_string("[].join.call()"),
-      nxt_string("TypeError: cannot convert void to object") },
+      nxt_string("TypeError: cannot convert undefined to object") },
 
     { nxt_string("[].slice.call()"),
-      nxt_string("TypeError: cannot convert void to object") },
+      nxt_string("TypeError: cannot convert undefined to object") },
 
     { nxt_string("function f(a) {} ; var a = f; var b = f; a === b"),
       nxt_string("true") },
@@ -7071,7 +7071,7 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("false") },
 
     { nxt_string("Object.create()"),
-      nxt_string("TypeError: prototype may only be an object or null: void") },
+      nxt_string("TypeError: prototype may only be an object or null: undefined") },
 
     { nxt_string("Object.create(1)"),
       nxt_string("TypeError: prototype may only be an object or null: number") },
@@ -7093,7 +7093,7 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("b") },
 
     { nxt_string("Object.keys()"),
-      nxt_string("TypeError: cannot convert void argument to object") },
+      nxt_string("TypeError: cannot convert undefined argument to object") },
 
     { nxt_string("Object.keys('a')"),
       nxt_string("TypeError: cannot convert string argument to object") },
@@ -7214,7 +7214,7 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("2") },
 
     { nxt_string("var o = {}; Object.defineProperty()"),
-      nxt_string("TypeError: cannot convert void argument to object") },
+      nxt_string("TypeError: cannot convert undefined argument to object") },
 
     { nxt_string("var o = {}; Object.defineProperty(o)"),
       nxt_string("TypeError: descriptor is not an object") },
@@ -7430,10 +7430,10 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("1,1,-1") },
 
     { nxt_string("Object.getOwnPropertyDescriptor()"),
-      nxt_string("TypeError: cannot convert void argument to object") },
+      nxt_string("TypeError: cannot convert undefined argument to object") },
 
     { nxt_string("Object.getOwnPropertyDescriptor(undefined)"),
-      nxt_string("TypeError: cannot convert void argument to object") },
+      nxt_string("TypeError: cannot convert undefined argument to object") },
 
     { nxt_string("var o = {}; o[void 0] = 'a'; Object.getOwnPropertyDescriptor(o).value"),
       nxt_string("a") },
@@ -8092,7 +8092,7 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("Invalid Date") },
 
     { nxt_string("[0].map(new Date().getDate)"),
-      nxt_string("TypeError: cannot convert void to date") },
+      nxt_string("TypeError: cannot convert undefined to date") },
 
     { nxt_string("new Date(eval)"),
       nxt_string("Invalid Date") },


More information about the nginx-devel mailing list