Welcome! Log In Create A New Profile

Advanced

[njs] Tests: splitting large import tests into several simple ones.

Dmitry Volyntsev
February 16, 2022 10:28AM
details: https://hg.nginx.org/njs/rev/7a08ed3e9cb8
branches:
changeset: 1827:7a08ed3e9cb8
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Feb 15 13:17:52 2022 +0000
description:
Tests: splitting large import tests into several simple ones.

diffstat:

test/js/import_chain.t.js | 13 ++++++++++++
test/js/import_comma_expression.t.js | 9 ++++++++
test/js/import_empty.t.js | 9 ++++++++
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_expression.t.js | 9 ++++++++
test/js/import_function_expression.t.js | 7 ++++++
test/js/import_multi_default.t.js | 9 ++++++++
test/js/import_non_assignment.t.js | 9 ++++++++
test/js/import_non_default.t.js | 9 ++++++++
test/js/import_normal.t.js | 31 -----------------------------
test/js/import_not_enough.t.js | 3 +-
test/js/import_object.t.js | 9 ++++++++
test/js/import_ref_exception.t.js | 9 ++++++++
test/js/import_relative_path.t.js | 10 +++++++++
test/js/import_return.t.js | 9 ++++++++
test/js/import_scalar.t.js | 9 ++++++++
test/js/import_singleton.t.js | 16 ++++++++++++++
test/js/module/function_expression.js | 7 ++++++
test/js/module/lib1.js | 17 +--------------
test/js/module/lib3.js | 2 +-
test/shell_test.exp | 2 +-
29 files changed, 147 insertions(+), 132 deletions(-)

diffs (421 lines):

diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_chain.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_chain.t.js Tue Feb 15 13:17:52 2022 +0000
@@ -0,0 +1,13 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/, test/js/module/libs/]
+---*/
+
+import lib2 from 'lib2.js';
+
+import crypto from 'crypto';
+var h = crypto.createHash('md5');
+var hash = h.update('AB').digest('hex');
+
+assert.sameValue(lib2.hash(), hash);
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_comma_expression.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_comma_expression.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_empty.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_empty.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_comma_expression.t.js
--- a/test/js/import_export_comma_expression.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module]
----*/
-
-import m from 'export_comma_expression.js';
-
-assert.sameValue(m.prod(3,5), 15);
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_empty.t.js
--- a/test/js/import_export_empty.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module, test/js/module/libs]
-negative:
- phase: runtime
----*/
-
-import m from 'empty.js';
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_expression.t.js
--- a/test/js/import_export_expression.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module]
----*/
-
-import m from 'export_expression.js';
-
-assert.sameValue(m.sum(3,4), 7);
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_multi_default.t.js
--- a/test/js/import_export_multi_default.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module, test/js/module/libs]
-negative:
- phase: runtime
----*/
-
-import m from 'export.js';
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_non_assignment.t.js
--- a/test/js/import_export_non_assignment.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module, test/js/module/libs]
-negative:
- phase: runtime
----*/
-
-import m from 'export_non_assignment.js';
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_non_default.t.js
--- a/test/js/import_export_non_default.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module, test/js/module/libs]
-negative:
- phase: runtime
----*/
-
-import m from 'export_non_default.js';
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_object.t.js
--- a/test/js/import_export_object.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module]
----*/
-
-import m from 'export_name.js';
-
-assert.sameValue(m.prod(3,4), 12);
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_ref_exception.t.js
--- a/test/js/import_export_ref_exception.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module, test/js/module/libs]
-negative:
- phase: runtime
----*/
-
-import m from 'ref_exception.js';
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_export_return.t.js
--- a/test/js/import_export_return.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-/*---
-includes: []
-flags: []
-paths: [test/js/module, test/js/module/libs]
-negative:
- phase: runtime
----*/
-
-import m from 'return.js'
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_expression.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_expression.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_function_expression.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_function_expression.t.js Tue Feb 15 13:17:52 2022 +0000
@@ -0,0 +1,7 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/]
+---*/
+
+import _ from 'function_expression.js';
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_multi_default.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_multi_default.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_non_assignment.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_non_assignment.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_non_default.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_non_default.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_normal.t.js
--- a/test/js/import_normal.t.js Mon Feb 14 14:10:59 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*---
-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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_not_enough.t.js
--- a/test/js/import_not_enough.t.js Mon Feb 14 14:10:59 2022 +0000
+++ b/test/js/import_not_enough.t.js Tue Feb 15 13:17:52 2022 +0000
@@ -1,10 +1,9 @@
/*---
includes: []
flags: []
-paths: [test/js/module]
+paths: []
negative:
phase: runtime
---*/

import name from 'name.js';
-import lib1 from 'lib1.js';
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_object.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_object.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_ref_exception.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_ref_exception.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_relative_path.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_relative_path.t.js Tue Feb 15 13:17:52 2022 +0000
@@ -0,0 +1,10 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/]
+---*/
+
+import name from 'name.js';
+import hash from 'libs/hash.js';
+
+assert.sameValue(hash.name, "libs.name");
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_return.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_return.t.js Tue Feb 15 13:17:52 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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_scalar.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_scalar.t.js Tue Feb 15 13:17:52 2022 +0000
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/]
+---*/
+
+import name from 'name.js';
+
+assert.sameValue(name, "name");
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/import_singleton.t.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/import_singleton.t.js Tue Feb 15 13:17:52 2022 +0000
@@ -0,0 +1,16 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/, test/js/module/libs/]
+---*/
+
+import lib1 from 'lib1.js';
+import lib1_2 from 'lib1.js';
+
+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 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/module/function_expression.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/js/module/function_expression.js Tue Feb 15 13:17:52 2022 +0000
@@ -0,0 +1,7 @@
+var foo = (function(){
+ return (function f() {})
+});
+
+foo()({1:[]})
+
+export default {foo};
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/module/lib1.js
--- a/test/js/module/lib1.js Mon Feb 14 14:10:59 2022 +0000
+++ b/test/js/module/lib1.js Tue Feb 15 13:17:52 2022 +0000
@@ -1,18 +1,3 @@
-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() {
@@ -23,4 +8,4 @@ function get() {
return state.count;
}

-export default {hash, inc, get, name: hashlib.name}
+export default {inc, get}
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/js/module/lib3.js
--- a/test/js/module/lib3.js Mon Feb 14 14:10:59 2022 +0000
+++ b/test/js/module/lib3.js Tue Feb 15 13:17:52 2022 +0000
@@ -6,6 +6,6 @@ function exception() {
return sub.error();
}

-import sub from './sub/sub1.js';
+import sub from 'sub/sub1.js';

export default {hash, exception};
diff -r 26fd49ea3f72 -r 7a08ed3e9cb8 test/shell_test.exp
--- a/test/shell_test.exp Mon Feb 14 14:10:59 2022 +0000
+++ b/test/shell_test.exp Tue Feb 15 13:17:52 2022 +0000
@@ -548,7 +548,7 @@ njs_test {

# quiet mode

-njs_run {"-q" "test/js/import_normal.t.js"} \
+njs_run {"-q" "test/js/import_relative_path.t.js"} \
"SyntaxError: Cannot find module \"name.js\" in 7"

# sandboxing
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] Tests: splitting large import tests into several simple ones.

Dmitry Volyntsev 451 February 16, 2022 10:28AM



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

Online Users

Guests: 61
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready