]> git.kaiwu.me - njs.git/commitdiff
Tests: splitting large import tests into several simple ones.
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 15 Feb 2022 13:17:52 +0000 (13:17 +0000)
committerDmitry Volyntsev <xeioex@nginx.com>
Tue, 15 Feb 2022 13:17:52 +0000 (13:17 +0000)
20 files changed:
test/js/import_chain.t.js [new file with mode: 0644]
test/js/import_comma_expression.t.js [moved from test/js/import_export_comma_expression.t.js with 100% similarity]
test/js/import_empty.t.js [moved from test/js/import_export_empty.t.js with 100% similarity]
test/js/import_expression.t.js [moved from test/js/import_export_expression.t.js with 100% similarity]
test/js/import_function_expression.t.js [new file with mode: 0644]
test/js/import_multi_default.t.js [moved from test/js/import_export_multi_default.t.js with 100% similarity]
test/js/import_non_assignment.t.js [moved from test/js/import_export_non_assignment.t.js with 100% similarity]
test/js/import_non_default.t.js [moved from test/js/import_export_non_default.t.js with 100% similarity]
test/js/import_normal.t.js [deleted file]
test/js/import_not_enough.t.js
test/js/import_object.t.js [moved from test/js/import_export_object.t.js with 100% similarity]
test/js/import_ref_exception.t.js [moved from test/js/import_export_ref_exception.t.js with 100% similarity]
test/js/import_relative_path.t.js [new file with mode: 0644]
test/js/import_return.t.js [moved from test/js/import_export_return.t.js with 100% similarity]
test/js/import_scalar.t.js [new file with mode: 0644]
test/js/import_singleton.t.js [new file with mode: 0644]
test/js/module/function_expression.js [new file with mode: 0644]
test/js/module/lib1.js
test/js/module/lib3.js
test/shell_test.exp

diff --git a/test/js/import_chain.t.js b/test/js/import_chain.t.js
new file mode 100644 (file)
index 0000000..70d8c26
--- /dev/null
@@ -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_function_expression.t.js b/test/js/import_function_expression.t.js
new file mode 100644 (file)
index 0000000..0fc4d07
--- /dev/null
@@ -0,0 +1,7 @@
+/*---
+includes: []
+flags: []
+paths: [test/js/module/]
+---*/
+
+import _ from 'function_expression.js';
diff --git a/test/js/import_normal.t.js b/test/js/import_normal.t.js
deleted file mode 100644 (file)
index 85ced08..0000000
+++ /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);
index fae5ec606372db5cfc85d1185d5af395aee4532a..26b8d61724357c8203420e9941cdf03c91f4ded7 100644 (file)
@@ -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_relative_path.t.js b/test/js/import_relative_path.t.js
new file mode 100644 (file)
index 0000000..6a9f3cc
--- /dev/null
@@ -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_scalar.t.js b/test/js/import_scalar.t.js
new file mode 100644 (file)
index 0000000..92b3899
--- /dev/null
@@ -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 (file)
index 0000000..6188212
--- /dev/null
@@ -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 (file)
index 0000000..45cd865
--- /dev/null
@@ -0,0 +1,7 @@
+var foo = (function(){
+    return (function f() {})
+});
+
+foo()({1:[]})
+
+export default {foo};
index a5778173c36243d79cfef1e97dfbb0a148eb0b44..4b249b739cca6d232f7e1ea6774fd582a6b1212f 100644 (file)
@@ -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}
index c3f192972f114b53ae7c95e77f096501a61294b2..384bda823b5d9b60ea33d1fec2e37d086fd9cbc3 100644 (file)
@@ -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};
index bb9b8c10a80f2e553c2cc82e5025c6f113fb1afc..c320fa57403c1b4035947e6de0f7751fa5479501 100644 (file)
@@ -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