[njs] Tests: refactored modules tests using test262 test suite.
Dmitry Volyntsev
xeioex at nginx.com
Thu Jan 27 13:03:29 UTC 2022
details: https://hg.nginx.org/njs/rev/4d38ea471228
branches:
changeset: 1822:4d38ea471228
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Thu Jan 27 13:01:55 2022 +0000
description:
Tests: refactored modules tests using test262 test suite.
diffstat:
auto/expect | 6 +-
auto/make | 2 +-
test/js/import_declaration_exception.t.js | 9 +
test/js/import_exception.t.js | 11 +
test/js/import_export_comma_expression.t.js | 9 +
test/js/import_export_empty.t.js | 9 +
test/js/import_export_expression.t.js | 9 +
test/js/import_export_multi_default.t.js | 9 +
test/js/import_export_non_assignment.t.js | 9 +
test/js/import_export_non_default.t.js | 9 +
test/js/import_export_object.t.js | 9 +
test/js/import_export_ref_exception.t.js | 9 +
test/js/import_export_return.t.js | 9 +
test/js/import_loading_exception.t.js | 9 +
test/js/import_normal.t.js | 31 +
test/js/import_not_enough.t.js | 10 +
test/js/import_not_found.t.js | 9 +
test/js/import_recursive.t.js | 9 +
test/js/module/declaration_exception.js | 10 +
test/js/module/exception.js | 4 +
test/js/module/export.js | 4 +
test/js/module/export_comma_expression.js | 5 +
test/js/module/export_expression.js | 10 +
test/js/module/export_name.js | 6 +
test/js/module/export_non_assignment.js | 1 +
test/js/module/export_non_default.js | 3 +
test/js/module/lib1.js | 26 +
test/js/module/lib2.js | 7 +
test/js/module/lib3.js | 11 +
test/js/module/libs/hash.js | 10 +
test/js/module/libs/name.js | 1 +
test/js/module/loading_exception.js | 3 +
test/js/module/name.js | 1 +
test/js/module/ref_exception.js | 1 +
test/js/module/return.js | 1 +
test/js/module/sub/sub1.js | 12 +
test/js/module/sub/sub2.js | 7 +
test/module/declaration_exception.js | 10 -
test/module/exception.js | 4 -
test/module/export.js | 4 -
test/module/export_expression.js | 10 -
test/module/export_expression2.js | 5 -
test/module/export_name.js | 6 -
test/module/export_non_assignment.js | 1 -
test/module/export_non_default.js | 3 -
test/module/lib1.js | 26 -
test/module/lib2.js | 7 -
test/module/lib3.js | 11 -
test/module/libs/hash.js | 10 -
test/module/libs/name.js | 1 -
test/module/loading_exception.js | 3 -
test/module/name.js | 1 -
test/module/normal.js | 51 --
test/module/recursive.js | 1 -
test/module/ref_exception.js | 1 -
test/module/return.js | 1 -
test/module/sub/sub1.js | 12 -
test/module/sub/sub2.js | 7 -
test/njs_expect_test.exp | 650 ----------------------------
test/shell_test.exp | 598 +++++++++++++++++++++++++
60 files changed, 894 insertions(+), 829 deletions(-)
diffs (truncated from 1983 to 1000 lines):
diff -r b4998a4f82dc -r 4d38ea471228 auto/expect
--- a/auto/expect Wed Jan 26 17:24:58 2022 +0000
+++ b/auto/expect Thu Jan 27 13:01:55 2022 +0000
@@ -20,9 +20,9 @@ fi
if [ $njs_found = yes -a $NJS_HAVE_READLINE = YES ]; then
cat << END >> $NJS_MAKEFILE
-expect_test: njs test/njs_expect_test.exp
+shell_test: njs test/shell_test.exp
INPUTRC=test/inputrc PATH=$NJS_BUILD_DIR:\$(PATH) \
- expect -f test/njs_expect_test.exp
+ expect -f test/shell_test.exp
END
else
@@ -30,7 +30,7 @@ else
cat << END >> $NJS_MAKEFILE
-expect_test:
+shell_test:
@echo "Skipping expect tests"
END
diff -r b4998a4f82dc -r 4d38ea471228 auto/make
--- a/auto/make Wed Jan 26 17:24:58 2022 +0000
+++ b/auto/make Thu Jan 27 13:01:55 2022 +0000
@@ -249,7 +249,7 @@ unit_test: $NJS_BUILD_DIR/njs_auto_confi
$NJS_BUILD_DIR/njs_unit_test
-test: expect_test unit_test test262
+test: shell_test unit_test test262
benchmark: $NJS_BUILD_DIR/njs_auto_config.h \\
$NJS_BUILD_DIR/njs_benchmark
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_declaration_exception.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_declaration_exception.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'declaration_exception.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_exception.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_exception.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,11 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import lib from 'lib3.js';
+
+lib.exception();
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_comma_expression.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_comma_expression.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module]
+---*/
+
+import m from 'export_comma_expression.js';
+
+assert.sameValue(m.prod(3,5), 15);
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_empty.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_empty.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'empty.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_expression.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_expression.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module]
+---*/
+
+import m from 'export_expression.js';
+
+assert.sameValue(m.sum(3,4), 7);
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_multi_default.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_multi_default.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'export.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_non_assignment.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_non_assignment.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'export_non_assignment.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_non_default.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_non_default.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'export_non_default.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_object.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_object.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module]
+---*/
+
+import m from 'export_name.js';
+
+assert.sameValue(m.prod(3,4), 12);
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_ref_exception.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_ref_exception.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'ref_exception.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_export_return.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_export_return.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'return.js'
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_loading_exception.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_loading_exception.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'loading_exception.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_normal.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_normal.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,31 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/, test/js/module/libs/]
+---*/
+
+import name from 'name.js';
+import lib1 from 'lib1.js';
+import lib2 from 'lib2.js';
+import lib1_2 from 'lib1.js';
+
+import crypto from 'crypto';
+var h = crypto.createHash('md5');
+var hash = h.update('AB').digest('hex');
+
+assert.sameValue(name, "name");
+
+assert.sameValue(lib1.name, "libs.name");
+
+assert.sameValue(lib1.hash(), hash);
+assert.sameValue(lib2.hash(), hash);
+
+assert.sameValue(lib1.get(), 0);
+
+assert.sameValue(lib1_2.get(), 0);
+
+lib1.inc();
+
+assert.sameValue(lib1.get(), 1);
+
+assert.sameValue(lib1_2.get(), 1);
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_not_enough.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_not_enough.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,10 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module]
+negative:
+ phase: runtime
+---*/
+
+import name from 'name.js';
+import lib1 from 'lib1.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_not_found.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_not_found.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+njs_cmd_args: []
+negative:
+ phase: runtime
+---*/
+
+import name from 'name.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/import_recursive.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_recursive.t.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/]
+negative:
+ phase: runtime
+---*/
+
+import lib from 'import_recursive.t.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/declaration_exception.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/declaration_exception.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,10 @@
+
+function f() {
+ return 1;
+}
+
+function f() {
+ return 2;
+}
+
+export default f;
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/exception.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/exception.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,4 @@
+import lib from 'lib3.js';
+
+lib.exception();
+
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/export.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/export.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,4 @@
+var a = 1;
+
+export default {a}
+export default {a}
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/export_comma_expression.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/export_comma_expression.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,5 @@
+var _export = {};
+
+export default (_export.sum = function(a, b) { return a + b; },
+ _export.prod = function(a, b) { return a * b; },
+ _export);
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/export_expression.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/export_expression.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,10 @@
+function gen_export() {
+ var _export = {};
+
+ _export.sum = function(a, b) { return a + b; }
+ _export.prod = function(a, b) { return a * b; }
+
+ return _export;
+}
+
+export default gen_export();
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/export_name.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/export_name.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,6 @@
+var _export = {};
+
+_export.sum = function(a, b) { return a + b; }
+_export.prod = function(a, b) { return a * b; }
+
+export default _export;
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/export_non_assignment.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/export_non_assignment.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,1 @@
+export default 10, 11;
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/export_non_default.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/export_non_default.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,3 @@
+var a = 1;
+
+export a {a}
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/lib1.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/lib1.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,26 @@
+var foo = (function(){
+ return (function f() {})
+});
+
+foo()({1:[]})
+
+function hash() {
+ var h = crypto.createHash('md5');
+ var v = h.update('AB').digest('hex');
+ return v;
+}
+
+import hashlib from 'hash.js';
+import crypto from 'crypto';
+
+var state = {count:0}
+
+function inc() {
+ state.count++;
+}
+
+function get() {
+ return state.count;
+}
+
+export default {hash, inc, get, name: hashlib.name}
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/lib2.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/lib2.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,7 @@
+import lib3 from 'lib3.js';
+
+function hash() {
+ return lib3.hash();
+}
+
+export default {hash};
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/lib3.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/lib3.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,11 @@
+function hash() {
+ return sub.hash();
+}
+
+function exception() {
+ return sub.error();
+}
+
+import sub from './sub/sub1.js';
+
+export default {hash, exception};
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/libs/hash.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/libs/hash.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,10 @@
+function hash() {
+ var h = crypto.createHash('md5');
+ var v = h.update('AB').digest('hex');
+ return v;
+}
+
+import name from 'name.js';
+import crypto from 'crypto';
+
+export default {hash, name};
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/libs/name.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/libs/name.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,1 @@
+export default 'libs.name';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/loading_exception.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/loading_exception.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,3 @@
+throw Error('loading exception');
+
+export default {};
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/name.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/name.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,1 @@
+export default 'name';
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/ref_exception.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/ref_exception.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,1 @@
+export default {type:typeof undeclared, undeclared};
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/return.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/return.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,1 @@
+return 1;
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/sub/sub1.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/sub/sub1.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,12 @@
+function hash() {
+ return sub2.hash(crypto);
+}
+
+function error() {
+ return {}.a.a;
+}
+
+import sub2 from 'sub2.js';
+import crypto from 'crypto';
+
+export default {hash, error};
diff -r b4998a4f82dc -r 4d38ea471228 test/js/module/sub/sub2.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/sub/sub2.js Thu Jan 27 13:01:55 2022 +0000
@@ -0,0 +1,7 @@
+function hash(crypto) {
+ return hashlib.hash();
+}
+
+import hashlib from 'hash.js';
+
+export default {hash};
diff -r b4998a4f82dc -r 4d38ea471228 test/module/declaration_exception.js
--- a/test/module/declaration_exception.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-
-function f() {
- return 1;
-}
-
-function f() {
- return 2;
-}
-
-export default f;
diff -r b4998a4f82dc -r 4d38ea471228 test/module/exception.js
--- a/test/module/exception.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-import lib from 'lib3.js';
-
-lib.exception();
-
diff -r b4998a4f82dc -r 4d38ea471228 test/module/export.js
--- a/test/module/export.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-var a = 1;
-
-export default {a}
-export default {a}
diff -r b4998a4f82dc -r 4d38ea471228 test/module/export_expression.js
--- a/test/module/export_expression.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-function gen_export() {
- var _export = {};
-
- _export.sum = function(a, b) { return a + b; }
- _export.prod = function(a, b) { return a * b; }
-
- return _export;
-}
-
-export default gen_export();
diff -r b4998a4f82dc -r 4d38ea471228 test/module/export_expression2.js
--- a/test/module/export_expression2.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-var _export = {};
-
-export default (_export.sum = function(a, b) { return a + b; },
- _export.prod = function(a, b) { return a * b; },
- _export);
diff -r b4998a4f82dc -r 4d38ea471228 test/module/export_name.js
--- a/test/module/export_name.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-var _export = {};
-
-_export.sum = function(a, b) { return a + b; }
-_export.prod = function(a, b) { return a * b; }
-
-export default _export;
diff -r b4998a4f82dc -r 4d38ea471228 test/module/export_non_assignment.js
--- a/test/module/export_non_assignment.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-export default 10, 11;
diff -r b4998a4f82dc -r 4d38ea471228 test/module/export_non_default.js
--- a/test/module/export_non_default.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-var a = 1;
-
-export a {a}
diff -r b4998a4f82dc -r 4d38ea471228 test/module/lib1.js
--- a/test/module/lib1.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-var foo = (function(){
- return (function f() {})
-});
-
-foo()({1:[]})
-
-function hash() {
- var h = crypto.createHash('md5');
- var v = h.update('AB').digest('hex');
- return v;
-}
-
-import hashlib from 'hash.js';
-import crypto from 'crypto';
-
-var state = {count:0}
-
-function inc() {
- state.count++;
-}
-
-function get() {
- return state.count;
-}
-
-export default {hash, inc, get, name: hashlib.name}
diff -r b4998a4f82dc -r 4d38ea471228 test/module/lib2.js
--- a/test/module/lib2.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-import lib3 from 'lib3.js';
-
-function hash() {
- return lib3.hash();
-}
-
-export default {hash};
diff -r b4998a4f82dc -r 4d38ea471228 test/module/lib3.js
--- a/test/module/lib3.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-function hash() {
- return sub.hash();
-}
-
-function exception() {
- return sub.error();
-}
-
-import sub from './sub/sub1.js';
-
-export default {hash, exception};
diff -r b4998a4f82dc -r 4d38ea471228 test/module/libs/hash.js
--- a/test/module/libs/hash.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-function hash() {
- var h = crypto.createHash('md5');
- var v = h.update('AB').digest('hex');
- return v;
-}
-
-import name from 'name.js';
-import crypto from 'crypto';
-
-export default {hash, name};
diff -r b4998a4f82dc -r 4d38ea471228 test/module/libs/name.js
--- a/test/module/libs/name.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-export default 'libs.name';
diff -r b4998a4f82dc -r 4d38ea471228 test/module/loading_exception.js
--- a/test/module/loading_exception.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-throw Error('loading exception');
-
-export default {};
diff -r b4998a4f82dc -r 4d38ea471228 test/module/name.js
--- a/test/module/name.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-export default 'name';
diff -r b4998a4f82dc -r 4d38ea471228 test/module/normal.js
--- a/test/module/normal.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-import name from 'name.js';
-import lib1 from 'lib1.js';
-import lib2 from 'lib2.js';
-import lib1_2 from 'lib1.js';
-
-import crypto from 'crypto';
-var h = crypto.createHash('md5');
-var hash = h.update('AB').digest('hex');
-
-var fails = 0;
-
-if (name != 'name') {
- fails++;
-}
-
-if (lib1.name != 'libs.name') {
- fails++;
-}
-
-if (lib1.hash() != hash) {
- fails++;
-}
-
-if (lib2.hash() != hash) {
- fails++;
-}
-
-if (lib1.get() != 0) {
- fails++;
-}
-
-if (lib1_2.get() != 0) {
- fails++;
-}
-
-lib1.inc();
-
-if (lib1.get() != 1) {
- fails++;
-}
-
-if (lib1_2.get() != 1) {
- fails++;
-}
-
-if (JSON.stringify({}) != "{}") {
- fails++;
-}
-
-setImmediate(console.log,
- fails ? "failed: " + fails : "passed!");
diff -r b4998a4f82dc -r 4d38ea471228 test/module/recursive.js
--- a/test/module/recursive.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-import lib from 'recursive.js';
diff -r b4998a4f82dc -r 4d38ea471228 test/module/ref_exception.js
--- a/test/module/ref_exception.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-export default {type:typeof undeclared, undeclared};
diff -r b4998a4f82dc -r 4d38ea471228 test/module/return.js
--- a/test/module/return.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-return 1;
diff -r b4998a4f82dc -r 4d38ea471228 test/module/sub/sub1.js
--- a/test/module/sub/sub1.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-function hash() {
- return sub2.hash(crypto);
-}
-
-function error() {
- return {}.a.a;
-}
-
-import sub2 from 'sub2.js';
-import crypto from 'crypto';
-
-export default {hash, error};
diff -r b4998a4f82dc -r 4d38ea471228 test/module/sub/sub2.js
--- a/test/module/sub/sub2.js Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-function hash(crypto) {
- return hashlib.hash();
-}
-
-import hashlib from 'hash.js';
-
-export default {hash};
diff -r b4998a4f82dc -r 4d38ea471228 test/njs_expect_test.exp
--- a/test/njs_expect_test.exp Wed Jan 26 17:24:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,650 +0,0 @@
-#
-# Copyright (C) Dmitry Volyntsev
-# Copyright (C) NGINX, Inc.
-#
-
-proc njs_test {body {opts ""}} {
-
- if {$opts eq ""} {
- spawn -nottycopy njs
-
- } else {
- eval spawn -nottycopy njs $opts
- }
-
- # TODO:
- # SIGINT handling race condition
- # deb9-amd64-generic-njs-try
- # ub1404-armv7-generic-njs-try
- # ub1804-arm64-generic-njs-try
- # UTF8 terminal support issue
- # sol11-amd64-sunpro-njs-try
- # ub1604-arm64-generic-njs-try
-
- # set timeout 30
- # expect_before timeout { exit 1 }
-
- expect -re "interactive njs \\d+\.\\d+\.\\d+\r\n\r"
- expect "v.<Tab> -> the properties and prototype methods of v.\r
-\r
->> "
-
- set len [llength $body]
- for {set i 0} {$i < $len} {incr i} {
- set pair [lindex $body $i]
- send [lindex $pair 0]
- expect [lindex $pair 1]
- }
-
- # Ctrl-C
- send \x03
- expect eof
-}
-
-proc njs_run {opts expected_re} {
- catch {exec njs {*}$opts} out
- if {[regexp $expected_re $out match] == 0} {
- return -code error "njs_run: unexpected output '$out' vs '$expected_re'"
- }
-}
-
-njs_test {
- {"njs.version\r\n"
- "njs.version\r\n\*\.\*\.\*"}
-}
-
-# simple multi line interaction
-njs_test {
- {"var a = 1\r\n"
- "var a = 1\r\nundefined\r\n>> "}
- {"a *= 2\r\n"
- "a *= 2\r\n2\r\n>> "}
-}
-
-# Global completions, no
-njs_test {
- {"\t\tn"
- "\a\r\nDisplay all*possibilities? (y or n)*>> "}
-}
-
-# Global completions, yes
-njs_test {
- {"\t\ty"
- "\a\r\nDisplay all*possibilities? (y or n)*Array"}
-}
-
-# Global completions, single partial match
-
-# \a* is WORKAROUND for libedit-20170329.3.1-r3
-# which inserts '\rESC[6G' after '\a'.
-njs_test {
- {"O\t"
- "O\a*bject"}
-}
-
-njs_test {
- {"Ma\t"
- "Ma\a*th"}
-}
-
-# FIXME: completions for external objects
-# are not supported
-
-# njs_test {
-# {"conso\t"
-# "conso\a*le"}
-# }
-
-# Global completions, multiple partial match
-njs_test {
- {"cons\t\t"
- "console*const"}
-}
-
-njs_test {
- {"O\t"
- "O\a*bject"}
- {"\t\t"
- "Object.create*Object.isSealed"}
-}
-
-njs_test {
- {"Object.\t\t"
- "Object.create*Object.isSealed"}
-}
-
-njs_test {
- {"Object.g\t"
- "Object.g\a*et"}
- {"\t\t"
- "Object.getOwnPropertyDescriptor*Object.getPrototypeOf"}
-}
-
-njs_test {
- {"JS\t"
- "JS\a*ON"}
- {"\t\t"
- "JSON.parse*JSON.stringify"}
-}
-
-# Global completions, no matches
-njs_test {
- {"1.\t\t"
- "1."}
-}
-
-njs_test {
- {"1..\t\t"
- "1.."}
-}
-
-njs_test {
- {"'abc'.\t\t"
- "'abc'."}
-}
-
-# Global completions, global vars
-njs_test {
- {"var a = 1; var aa = 2\r\n"
- "var a = 1; var aa = 2\r\nundefined\r\n>> "}
- {"a\t\t"
- "a*aa*arguments*await"}
-}
-
-# z*z is WORKAROUND for libedit-20170329.3.1-r3
-# which inserts bogus '\a' between 'z'
-njs_test {
- {"var zz = 1\r\n"
- "var zz = 1\r\nundefined\r\n>> "}
- {"1 + z\t\r\n"
- "1 + z*z*\r\n2"}
-}
-
-njs_test {
- {"unknown_var\t\t"
- "unknown_var"}
-}
-
-njs_test {
- {"unknown_var.\t\t"
- "unknown_var."}
-}
-
-# An object's level completions
-njs_test {
- {"var o = {zz:1, zb:2}\r\n"
- "var o = {zz:1, zb:2}\r\nundefined\r\n>> "}
- {"o.z\t\t"
- "o.zb*o.zz"}
-}
-
-njs_test {
- {"var d = new Date()\r\n"
- "var d = new Date()\r\nundefined\r\n>> "}
- {"d.to\t\t"
- "d.toDateString*d.toLocaleDateString*d.toString"}
-}
-
-njs_test {
- {"var o = {a:new Date()}\r\n"
- "var o = {a:new Date()}\r\nundefined\r\n>> "}
- {"o.a.to\t\t"
- "o.a.toDateString*o.a.toLocaleDateString*o.a.toString"}
-}
-
-njs_test {
- {"var o = {a:1,b:2,333:'t'}\r\n"
- "var o = {a:1,b:2,333:'t'}\r\nundefined\r\n>> "}
- {"o.3\t\t"
- "o.3"}
-}
-
-njs_test {
- {"var a = Array(5000000); a.aab = 1; a.aac = 2\r\n"
- "var a = Array(5000000); a.aab = 1; a.aac = 2\r\n2\r\n>> "}
- {"a.\t\t"
- "a.aab*"}
-}
-
-njs_test {
- {"var a = new Uint8Array([5,6,7,8,8]); a.aab = 1; a.aac = 2\r\n"
- "var a = new Uint8Array(\\\[5,6,7,8,8]); a.aab = 1; a.aac = 2\r\n2\r\n>> "}
- {"a.\t\t"
- "a.aab*"}
-}
-
-# function declarations in interactive mode
-njs_test {
- {"function a() { return 1; }\r\n"
- "undefined\r\n>> "}
- {"a();\r\n"
- "1\r\n>> "}
- {"function a() { return 2; }\r\n"
- "undefined\r\n>> "}
- {"a();\r\n"
- "2\r\n>> "}
-}
-
-# console object
-njs_test {
- {"console[Symbol.toStringTag]\r\n"
- "console\\\[Symbol.toStringTag]\r\n'Console'\r\n>> "}
- {"Object.prototype.toString.call(console)\r\n"
- "Object.prototype.toString.call(console)\r\n'\\\[object Console]'\r\n>> "}
- {"console.toString()\r\n"
- "console.toString()\r\n'\\\[object Console]'\r\n>> "}
- {"console\r\n"
- "console\r\nConsole *>> "}
- {"delete console.log\r\n"
- "delete console.log\r\ntrue\r\n>>"}
- {"console\r\n"
- "console\r\nConsole *>> "}
-}
-
-# console log functions
-njs_test {
- {"console[Symbol.toStringTag]\r\n"
- "console\\\[Symbol.toStringTag]\r\n'Console'\r\n>> "}
- {"console\r\n"
- "console\r\nConsole *>> "}
- {"console.log()\r\n"
- "console.log()\r\nundefined\r\n>> "}
- {"console.log('')\r\n"
- "console.log('')\r\n\r\nundefined\r\n>> "}
- {"console.log(1)\r\n"
- "console.log(1)\r\n1\r\nundefined\r\n>> "}
- {"console.log(1, 'a')\r\n"
- "console.log(1, 'a')\r\n1 a\r\nundefined\r\n>> "}
- {"print(1, 'a')\r\n"
- "print(1, 'a')\r\n1 a\r\nundefined\r\n>> "}
- {"console.log('\\tабв\\nгд')\r\n"
- "console.log('\\\\tабв\\\\nгд')\r\n\tабв\r\nгд\r\nundefined\r\n>> "}
- {"console.dump()\r\n"
- "console.dump()\r\nundefined\r\n>> "}
- {"console.dump(1)\r\n"
- "console.dump(1)\r\n1\r\nundefined\r\n>> "}
- {"console.dump(1, 'a')\r\n"
- "console.dump(1, 'a')\r\n1 a\r\nundefined\r\n>> "}
-}
-
More information about the nginx-devel
mailing list