aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Volyntsev <xeioex@nginx.com>2022-02-15 13:17:52 +0000
committerDmitry Volyntsev <xeioex@nginx.com>2022-02-15 13:17:52 +0000
commit2ce56247844c0964b0db927b64234fdc0fb9aa38 (patch)
tree99b65e3d8f737357765dc3b3ee10d397120378a8
parent3efcecc9efd00cfacf9bc110f94f61ad416072e4 (diff)
downloadnjs-2ce56247844c0964b0db927b64234fdc0fb9aa38.tar.gz
njs-2ce56247844c0964b0db927b64234fdc0fb9aa38.zip
Tests: splitting large import tests into several simple ones.
-rw-r--r--test/js/import_chain.t.js13
-rw-r--r--test/js/import_comma_expression.t.js (renamed from test/js/import_export_comma_expression.t.js)0
-rw-r--r--test/js/import_empty.t.js (renamed from test/js/import_export_empty.t.js)0
-rw-r--r--test/js/import_expression.t.js (renamed from test/js/import_export_expression.t.js)0
-rw-r--r--test/js/import_function_expression.t.js7
-rw-r--r--test/js/import_multi_default.t.js (renamed from test/js/import_export_multi_default.t.js)0
-rw-r--r--test/js/import_non_assignment.t.js (renamed from test/js/import_export_non_assignment.t.js)0
-rw-r--r--test/js/import_non_default.t.js (renamed from test/js/import_export_non_default.t.js)0
-rw-r--r--test/js/import_normal.t.js31
-rw-r--r--test/js/import_not_enough.t.js3
-rw-r--r--test/js/import_object.t.js (renamed from test/js/import_export_object.t.js)0
-rw-r--r--test/js/import_ref_exception.t.js (renamed from test/js/import_export_ref_exception.t.js)0
-rw-r--r--test/js/import_relative_path.t.js10
-rw-r--r--test/js/import_return.t.js (renamed from test/js/import_export_return.t.js)0
-rw-r--r--test/js/import_scalar.t.js9
-rw-r--r--test/js/import_singleton.t.js16
-rw-r--r--test/js/module/function_expression.js7
-rw-r--r--test/js/module/lib1.js17
-rw-r--r--test/js/module/lib3.js2
-rw-r--r--test/shell_test.exp2
20 files changed, 66 insertions, 51 deletions
diff --git a/test/js/import_chain.t.js b/test/js/import_chain.t.js
new file mode 100644
index 00000000..70d8c26d
--- /dev/null
+++ b/test/js/import_chain.t.js
@@ -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 --git a/test/js/import_export_comma_expression.t.js b/test/js/import_comma_expression.t.js
index 185d3a6d..185d3a6d 100644
--- a/test/js/import_export_comma_expression.t.js
+++ b/test/js/import_comma_expression.t.js
diff --git a/test/js/import_export_empty.t.js b/test/js/import_empty.t.js
index cf6ec367..cf6ec367 100644
--- a/test/js/import_export_empty.t.js
+++ b/test/js/import_empty.t.js
diff --git a/test/js/import_export_expression.t.js b/test/js/import_expression.t.js
index bf6fd5fb..bf6fd5fb 100644
--- a/test/js/import_export_expression.t.js
+++ b/test/js/import_expression.t.js
diff --git a/test/js/import_function_expression.t.js b/test/js/import_function_expression.t.js
new file mode 100644
index 00000000..0fc4d079
--- /dev/null
+++ b/test/js/import_function_expression.t.js
@@ -0,0 +1,7 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/]
+---*/
+
+import _ from 'function_expression.js';
diff --git a/test/js/import_export_multi_default.t.js b/test/js/import_multi_default.t.js
index 1e4cf08a..1e4cf08a 100644
--- a/test/js/import_export_multi_default.t.js
+++ b/test/js/import_multi_default.t.js
diff --git a/test/js/import_export_non_assignment.t.js b/test/js/import_non_assignment.t.js
index f8d6361a..f8d6361a 100644
--- a/test/js/import_export_non_assignment.t.js
+++ b/test/js/import_non_assignment.t.js
diff --git a/test/js/import_export_non_default.t.js b/test/js/import_non_default.t.js
index 6b53010f..6b53010f 100644
--- a/test/js/import_export_non_default.t.js
+++ b/test/js/import_non_default.t.js
diff --git a/test/js/import_normal.t.js b/test/js/import_normal.t.js
deleted file mode 100644
index 85ced08f..00000000
--- a/test/js/import_normal.t.js
+++ /dev/null
@@ -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 --git a/test/js/import_not_enough.t.js b/test/js/import_not_enough.t.js
index fae5ec60..26b8d617 100644
--- a/test/js/import_not_enough.t.js
+++ b/test/js/import_not_enough.t.js
@@ -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 --git a/test/js/import_export_object.t.js b/test/js/import_object.t.js
index d430742d..d430742d 100644
--- a/test/js/import_export_object.t.js
+++ b/test/js/import_object.t.js
diff --git a/test/js/import_export_ref_exception.t.js b/test/js/import_ref_exception.t.js
index 654933a0..654933a0 100644
--- a/test/js/import_export_ref_exception.t.js
+++ b/test/js/import_ref_exception.t.js
diff --git a/test/js/import_relative_path.t.js b/test/js/import_relative_path.t.js
new file mode 100644
index 00000000..6a9f3cc4
--- /dev/null
+++ b/test/js/import_relative_path.t.js
@@ -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 --git a/test/js/import_export_return.t.js b/test/js/import_return.t.js
index 64fd5e21..64fd5e21 100644
--- a/test/js/import_export_return.t.js
+++ b/test/js/import_return.t.js
diff --git a/test/js/import_scalar.t.js b/test/js/import_scalar.t.js
new file mode 100644
index 00000000..92b3899b
--- /dev/null
+++ b/test/js/import_scalar.t.js
@@ -0,0 +1,9 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/]
+---*/
+
+import name from 'name.js';
+
+assert.sameValue(name, "name");
diff --git a/test/js/import_singleton.t.js b/test/js/import_singleton.t.js
new file mode 100644
index 00000000..61882121
--- /dev/null
+++ b/test/js/import_singleton.t.js
@@ -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 --git a/test/js/module/function_expression.js b/test/js/module/function_expression.js
new file mode 100644
index 00000000..45cd8655
--- /dev/null
+++ b/test/js/module/function_expression.js
@@ -0,0 +1,7 @@
+var foo = (function(){
+ return (function f() {})
+});
+
+foo()({1:[]})
+
+export default {foo};
diff --git a/test/js/module/lib1.js b/test/js/module/lib1.js
index a5778173..4b249b73 100644
--- a/test/js/module/lib1.js
+++ b/test/js/module/lib1.js
@@ -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 --git a/test/js/module/lib3.js b/test/js/module/lib3.js
index c3f19297..384bda82 100644
--- a/test/js/module/lib3.js
+++ b/test/js/module/lib3.js
@@ -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 --git a/test/shell_test.exp b/test/shell_test.exp
index bb9b8c10..c320fa57 100644
--- a/test/shell_test.exp
+++ b/test/shell_test.exp
@@ -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