From: Dmitry Volyntsev Date: Tue, 15 Feb 2022 13:17:52 +0000 (+0000) Subject: Tests: splitting large import tests into several simple ones. X-Git-Tag: 0.7.3~8 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=2ce56247844c0964b0db927b64234fdc0fb9aa38;p=njs.git Tests: splitting large import tests into several simple ones. --- 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 similarity index 100% rename from test/js/import_export_comma_expression.t.js rename to test/js/import_comma_expression.t.js diff --git a/test/js/import_export_empty.t.js b/test/js/import_empty.t.js similarity index 100% rename from test/js/import_export_empty.t.js rename to test/js/import_empty.t.js diff --git a/test/js/import_export_expression.t.js b/test/js/import_expression.t.js similarity index 100% rename from test/js/import_export_expression.t.js rename to 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 similarity index 100% rename from test/js/import_export_multi_default.t.js rename to 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 similarity index 100% rename from test/js/import_export_non_assignment.t.js rename to 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 similarity index 100% rename from test/js/import_export_non_default.t.js rename to 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 similarity index 100% rename from test/js/import_export_object.t.js rename to 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 similarity index 100% rename from test/js/import_export_ref_exception.t.js rename to 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 similarity index 100% rename from test/js/import_export_return.t.js rename to 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