]> git.kaiwu.me - njs.git/commitdiff
Fixed accesing global function and objects in modules.
authorDmitry Volyntsev <xeioex@nginx.com>
Sat, 23 Mar 2019 13:39:40 +0000 (16:39 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Sat, 23 Mar 2019 13:39:40 +0000 (16:39 +0300)
njs/njs_variable.c
njs/test/module/normal.js

index ddaa531841f30d62c7c69ec0e34f89aacbb0e700..b692b6f17b13d8c0c518e4dd9a3b5b4782baa052 100644 (file)
@@ -488,7 +488,7 @@ njs_variable_reference_resolve(njs_vm_t *vm, njs_variable_reference_t *vr,
             return NXT_OK;
         }
 
-        if (scope->module || scope->parent == NULL) {
+        if (scope->parent == NULL) {
             /* A global scope. */
             vr->scope = scope;
 
index 32e4964d633a8c1ccd66ebdd94aa90a2d43be55d..675b391f490885e0e97c3a26fde4502c1e20ca84 100644 (file)
@@ -6,30 +6,36 @@ import crypto from 'crypto';
 var h = crypto.createHash('md5');
 var hash = h.update('AB').digest('hex');
 
+var fails = 0;
 if (lib1.hash() != hash) {
-    console.log("failed!");
+    fails++;
 }
 
 if (lib2.hash() != hash) {
-    console.log("failed!");
+    fails++;
 }
 
 if (lib1.get() != 0) {
-    console.log("failed!");
+    fails++;
 }
 
 if (lib1_2.get() != 0) {
-    console.log("failed!");
+    fails++;
 }
 
 lib1.inc();
 
 if (lib1.get() != 1) {
-    console.log("failed!");
+    fails++;
 }
 
 if (lib1_2.get() != 1) {
-    console.log("failed!");
+    fails++;
 }
 
-console.log("passed!");
+if (JSON.stringify({}) != "{}") {
+    fails++;
+}
+
+setImmediate(console.log,
+             fails ? "failed: " + fails : "passed!");