diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/bundle.test.out | 26 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 34 | ||||
-rw-r--r-- | cli/tests/subdir/circular1.ts | 7 | ||||
-rw-r--r-- | cli/tests/subdir/circular2.ts | 7 |
4 files changed, 62 insertions, 12 deletions
diff --git a/cli/tests/bundle.test.out b/cli/tests/bundle.test.out index 23b7de35e..1379eb7e5 100644 --- a/cli/tests/bundle.test.out +++ b/cli/tests/bundle.test.out @@ -1,22 +1,24 @@ [WILDCARD] -let define; +let System; +let __inst; [WILDCARD] -let instantiate; -[WILDCARD] -(function() { +(() => { [WILDCARD] })(); -define("print_hello", ["require", "exports"], function (require, exports) { +System.register("print_hello", [], function (exports_1, context_1) { [WILDCARD] }); -define("mod1", ["require", "exports", "subdir2/mod2"], function (require, exports, mod2_ts_1) { +System.register("subdir2/mod2", ["print_hello"], function (exports_2, context_2) { +[WILDCARD] +}); +System.register("mod1", ["subdir2/mod2"], function (exports_3, context_3) { [WILDCARD] }); -const __rootExports = instantiate("mod1"); -export const returnsHi = __rootExports["returnsHi"]; -export const returnsFoo2 = __rootExports["returnsFoo2"]; -export const printHello3 = __rootExports["printHello3"]; -export const throwsError = __rootExports["throwsError"]; - +const __exp = await __inst("mod1"); +export const returnsHi = __exp["returnsHi"]; +export const returnsFoo2 = __exp["returnsFoo2"]; +export const printHello3 = __exp["printHello3"]; +export const throwsError = __exp["throwsError"]; +[WILDCARD] diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 013e4c41b..a41fdd032 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -252,6 +252,40 @@ fn bundle_exports() { assert_eq!(output.stderr, b""); } +#[test] +fn bundle_circular() { + use tempfile::TempDir; + + // First we have to generate a bundle of some module that has exports. + let circular1 = util::root_path().join("cli/tests/subdir/circular1.ts"); + assert!(circular1.is_file()); + let t = TempDir::new().expect("tempdir fail"); + let bundle = t.path().join("circular1.bundle.js"); + let mut deno = util::deno_cmd() + .current_dir(util::root_path()) + .arg("bundle") + .arg(circular1) + .arg(&bundle) + .spawn() + .expect("failed to spawn script"); + let status = deno.wait().expect("failed to wait for the child process"); + assert!(status.success()); + assert!(bundle.is_file()); + + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg(&bundle) + .output() + .expect("failed to spawn script"); + // check the output of the the bundle program. + assert!(std::str::from_utf8(&output.stdout) + .unwrap() + .trim() + .ends_with("f1\nf2")); + assert_eq!(output.stderr, b""); +} + // TODO(#2933): Rewrite this test in rust. #[test] fn repl_test() { diff --git a/cli/tests/subdir/circular1.ts b/cli/tests/subdir/circular1.ts new file mode 100644 index 000000000..f9054338f --- /dev/null +++ b/cli/tests/subdir/circular1.ts @@ -0,0 +1,7 @@ +import * as circular2 from "./circular2.ts"; + +export function f1(): void { + console.log("f1"); +} + +circular2.f2(); diff --git a/cli/tests/subdir/circular2.ts b/cli/tests/subdir/circular2.ts new file mode 100644 index 000000000..a96ffb13d --- /dev/null +++ b/cli/tests/subdir/circular2.ts @@ -0,0 +1,7 @@ +import * as circular1 from "./circular1.ts"; + +export function f2(): void { + console.log("f2"); +} + +circular1.f1(); |