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
cat << END >> $NJS_MAKEFILE
-expect_test:
+shell_test:
@echo "Skipping expect tests"
END
$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
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'declaration_exception.js';
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import lib from 'lib3.js';
+
+lib.exception();
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module]
+---*/
+
+import m from 'export_comma_expression.js';
+
+assert.sameValue(m.prod(3,5), 15);
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'empty.js';
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module]
+---*/
+
+import m from 'export_expression.js';
+
+assert.sameValue(m.sum(3,4), 7);
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'export.js';
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'export_non_assignment.js';
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'export_non_default.js';
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module]
+---*/
+
+import m from 'export_name.js';
+
+assert.sameValue(m.prod(3,4), 12);
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'ref_exception.js';
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'return.js'
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module, test/js/module/libs]
+negative:
+ phase: runtime
+---*/
+
+import m from 'loading_exception.js';
--- /dev/null
+/*---
+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);
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module]
+negative:
+ phase: runtime
+---*/
+
+import name from 'name.js';
+import lib1 from 'lib1.js';
--- /dev/null
+/*---
+includes: []
+flags: []
+njs_cmd_args: []
+negative:
+ phase: runtime
+---*/
+
+import name from 'name.js';
--- /dev/null
+/*---
+includes: []
+flags: []
+paths: [test/js/module/]
+negative:
+ phase: runtime
+---*/
+
+import lib from 'import_recursive.t.js';
+++ /dev/null
-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!");
+++ /dev/null
-import lib from 'recursive.js';
at anonymous \\\(string:1\\\)
at main \\\(string:1\\\)\n$"
-# Modules
-
-njs_run {"-p" "test/module/libs" "./test/module/normal.js"} \
- "passed!"
-
-njs_run {"-p" "test/module/libs/" "./test/module/normal.js"} \
- "passed!"
-
-njs_run {"-p" "test/module" "-p" "test/module/libs" "./test/module/normal.js"} \
- "passed!"
-
-njs_run {"./test/module/normal.js"} \
- "SyntaxError: Cannot find module \"hash.js\" in lib1.js:13"
-
-njs_run {"-p" "test/module/libs" "./test/module/exception.js"} \
- "at error \\(sub1.js:6\\)"
-
-njs_run {"-p" "test/module" "./test/module/recursive.js"} \
- "SyntaxError: Cannot import itself \"./test/module/recursive.js\" in recursive.js:1"
-
# CLI OPTIONS
# help
"undefined\r\n"}
{"lib1.get()\r\n"
"1\r\n"}
- {"import m from 'return.js'\r\n"
- "Illegal return statement in return.js:1\r\n"}
- {"import m from 'empty.js'\r\n"
- "export statement is required in empty.js:1\r\n"}
- {"import m from 'export.js'\r\n"
- "Identifier \"default\" has already been declared in export.js:5\r\n"}
- {"import m from 'export_non_default.js'\r\n"
- "Non-default export is not supported in export_non_default.js:3\r\n"}
- {"import m from 'export_non_assignment.js'\r\n"
- "Unexpected token \",\" in export_non_assignment.js:1\r\n"}
{"import ref from 'ref_exception.js'\r\n"
"ReferenceError: \"undeclared\" is not defined"}
{"var ref\r\n"
"undefined\r\n"}
{"import ref from 'ref_exception.js'\r\n"
"ReferenceError: \"undeclared\" is not defined"}
- {"import m from 'declaration_exception.js'\r\n"
- "SyntaxError: \"f\" has already been declared in declaration_exception.js:6"}
- {"import m from 'loading_exception.js'\r\n"
- "Error: loading exception\r\n at module \\(loading_exception.js:1\\)"}
- {"import lib3 from 'lib1.js'\r\n"
- "undefined\r\n"}
-} "-p test/module/ -p test/module/libs/"
-
-njs_test {
- {"import m from 'export_name.js'\r\n"
- "undefined\r\n"}
- {"m.prod(3,4)\r\n"
- "12\r\n"}
- {"import m from 'export_expression.js'\r\n"
- "undefined\r\n"}
- {"m.sum(3,4)\r\n"
- "7\r\n"}
- {"import m from 'export_expression2.js'\r\n"
- "undefined\r\n"}
- {"m.prod(3,4)\r\n"
- "12\r\n"}
-} "-p test/module/"
+} "-p test/js/module/ -p test/js/module/libs/"
-njs_run {"-q" "./test/module/normal.js"} \
- "SyntaxError: Cannot find module \"hash.js\" in 13"
+# quiet mode
-njs_run {"-p" "test/module/libs/" "-d" "./test/module/normal.js"} \
- "passed!"
+njs_run {"-q" "test/js/import_normal.t.js"} \
+ "SyntaxError: Cannot find module \"name.js\" in 7"
# sandboxing