Welcome! Log In Create A New Profile

Advanced

[njs] Fixed accesing global function and objects in modules.

Dmitry Volyntsev
March 23, 2019 11:48AM
details: https://hg.nginx.org/njs/rev/81303df0fd67
branches:
changeset: 839:81303df0fd67
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Sat Mar 23 16:39:40 2019 +0300
description:
Fixed accesing global function and objects in modules.

diffstat:

njs/njs_variable.c | 2 +-
njs/test/module/normal.js | 20 +++++++++++++-------
2 files changed, 14 insertions(+), 8 deletions(-)

diffs (59 lines):

diff -r aaf68d999559 -r 81303df0fd67 njs/njs_variable.c
--- a/njs/njs_variable.c Sat Mar 23 14:57:52 2019 +0300
+++ b/njs/njs_variable.c Sat Mar 23 16:39:40 2019 +0300
@@ -488,7 +488,7 @@ njs_variable_reference_resolve(njs_vm_t
return NXT_OK;
}

- if (scope->module || scope->parent == NULL) {
+ if (scope->parent == NULL) {
/* A global scope. */
vr->scope = scope;

diff -r aaf68d999559 -r 81303df0fd67 njs/test/module/normal.js
--- a/njs/test/module/normal.js Sat Mar 23 14:57:52 2019 +0300
+++ b/njs/test/module/normal.js Sat Mar 23 16:39:40 2019 +0300
@@ -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!");
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed accesing global function and objects in modules.

Dmitry Volyntsev 249 March 23, 2019 11:48AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 266
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready