[njs] Improved text for method frame exception.

Dmitry Volyntsev xeioex at nginx.com
Thu Apr 25 16:50:39 UTC 2019


details:   https://hg.nginx.org/njs/rev/65d6076eb349
branches:  
changeset: 929:65d6076eb349
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu Apr 25 19:33:35 2019 +0300
description:
Improved text for method frame exception.

diffstat:

 njs/njs_vm.c                 |  3 ++-
 njs/test/njs_expect_test.exp |  2 +-
 njs/test/njs_unit_test.c     |  9 ++++++---
 3 files changed, 9 insertions(+), 5 deletions(-)

diffs (60 lines):

diff -r 9ca942bc0792 -r 65d6076eb349 njs/njs_vm.c
--- a/njs/njs_vm.c	Thu Apr 25 15:56:44 2019 +0300
+++ b/njs/njs_vm.c	Thu Apr 25 19:33:35 2019 +0300
@@ -1997,7 +1997,8 @@ njs_vmcode_method_frame(njs_vm_t *vm, nj
 
     if (value == NULL || !njs_is_function(value)) {
         njs_string_get(name, &string);
-        njs_type_error(vm, "\"%V\" is not a function", &string);
+        njs_type_error(vm, "(intermediate value)[\"%V\"] is not a function",
+                       &string);
         return NXT_ERROR;
     }
 
diff -r 9ca942bc0792 -r 65d6076eb349 njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp	Thu Apr 25 15:56:44 2019 +0300
+++ b/njs/test/njs_expect_test.exp	Thu Apr 25 19:33:35 2019 +0300
@@ -224,7 +224,7 @@ njs_test {
 
 njs_test {
     {"console.ll()\r\n"
-     "console.ll()\r\nTypeError: \"ll\" is not a function"}
+     "console.ll()\r\nTypeError: (intermediate value)\\\[\"ll\"] is not a function"}
 }
 
 njs_test {
diff -r 9ca942bc0792 -r 65d6076eb349 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Thu Apr 25 15:56:44 2019 +0300
+++ b/njs/test/njs_unit_test.c	Thu Apr 25 19:33:35 2019 +0300
@@ -1645,6 +1645,9 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("'-1' < {valueOf: function() {return -2}}"),
       nxt_string("false") },
 
+    { nxt_string("new 0[isNaN]"),
+      nxt_string("TypeError: (intermediate value)[\"[object Function]\"] is not a function") },
+
     /**/
 
     { nxt_string("var a; a = 1 ? 2 : 3"),
@@ -5990,7 +5993,7 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("TypeError: number is not a function") },
 
     { nxt_string("var o = {a:1}; o.a()"),
-      nxt_string("TypeError: \"a\" is not a function") },
+      nxt_string("TypeError: (intermediate value)[\"a\"] is not a function") },
 
     { nxt_string("(function(){})()"),
       nxt_string("undefined") },
@@ -7444,10 +7447,10 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("SyntaxError: Unexpected token \"null\" in 1") },
 
     { nxt_string("'a'.f()"),
-      nxt_string("TypeError: \"f\" is not a function") },
+      nxt_string("TypeError: (intermediate value)[\"f\"] is not a function") },
 
     { nxt_string("1..f()"),
-      nxt_string("TypeError: \"f\" is not a function") },
+      nxt_string("TypeError: (intermediate value)[\"f\"] is not a function") },
 
     { nxt_string("try {}"),
       nxt_string("SyntaxError: Missing catch or finally after try in 1") },


More information about the nginx-devel mailing list