summaryrefslogtreecommitdiff
path: root/tests/specs/run/single_compile_with_reload
diff options
context:
space:
mode:
authorhaturau <135221985+haturatu@users.noreply.github.com>2024-11-20 01:20:47 +0900
committerGitHub <noreply@github.com>2024-11-20 01:20:47 +0900
commit85719a67e59c7aa45bead26e4942d7df8b1b42d4 (patch)
treeface0aecaac53e93ce2f23b53c48859bcf1a36ec /tests/specs/run/single_compile_with_reload
parent67697bc2e4a62a9670699fd18ad0dd8efc5bd955 (diff)
parent186b52731c6bb326c4d32905c5e732d082e83465 (diff)
Merge branch 'denoland:main' into main
Diffstat (limited to 'tests/specs/run/single_compile_with_reload')
-rw-r--r--tests/specs/run/single_compile_with_reload/__test__.jsonc4
-rw-r--r--tests/specs/run/single_compile_with_reload/mod1.ts17
-rw-r--r--tests/specs/run/single_compile_with_reload/print_hello.ts3
-rw-r--r--tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts18
-rw-r--r--tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts.out7
-rw-r--r--tests/specs/run/single_compile_with_reload/single_compile_with_reload_dyn.ts11
-rw-r--r--tests/specs/run/single_compile_with_reload/single_compile_with_reload_worker.ts3
-rw-r--r--tests/specs/run/single_compile_with_reload/subdir2/dynamic_import.ts4
-rw-r--r--tests/specs/run/single_compile_with_reload/subdir2/mod2.ts9
9 files changed, 76 insertions, 0 deletions
diff --git a/tests/specs/run/single_compile_with_reload/__test__.jsonc b/tests/specs/run/single_compile_with_reload/__test__.jsonc
new file mode 100644
index 000000000..3e2e04379
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/__test__.jsonc
@@ -0,0 +1,4 @@
+{
+ "args": "run --reload --allow-read single_compile_with_reload.ts",
+ "output": "single_compile_with_reload.ts.out"
+}
diff --git a/tests/specs/run/single_compile_with_reload/mod1.ts b/tests/specs/run/single_compile_with_reload/mod1.ts
new file mode 100644
index 000000000..5e58f432e
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/mod1.ts
@@ -0,0 +1,17 @@
+import { printHello2, returnsFoo } from "./subdir2/mod2.ts";
+
+export function returnsHi(): string {
+ return "Hi";
+}
+
+export function returnsFoo2(): string {
+ return returnsFoo();
+}
+
+export function printHello3() {
+ printHello2();
+}
+
+export function throwsError() {
+ throw Error("exception from mod1");
+}
diff --git a/tests/specs/run/single_compile_with_reload/print_hello.ts b/tests/specs/run/single_compile_with_reload/print_hello.ts
new file mode 100644
index 000000000..b9c0ad527
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/print_hello.ts
@@ -0,0 +1,3 @@
+export function printHello() {
+ console.log("Hello");
+}
diff --git a/tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts b/tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts
new file mode 100644
index 000000000..9478ad523
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts
@@ -0,0 +1,18 @@
+await import("./single_compile_with_reload_dyn.ts");
+console.log("1");
+await import("./single_compile_with_reload_dyn.ts");
+console.log("2");
+await new Promise((r) =>
+ new Worker(
+ import.meta.resolve("./single_compile_with_reload_worker.ts"),
+ { type: "module" },
+ ).onmessage = r
+);
+console.log("3");
+await new Promise((r) =>
+ new Worker(
+ import.meta.resolve("./single_compile_with_reload_worker.ts"),
+ { type: "module" },
+ ).onmessage = r
+);
+console.log("4");
diff --git a/tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts.out b/tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts.out
new file mode 100644
index 000000000..a3986e3af
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts.out
@@ -0,0 +1,7 @@
+Hello
+1
+2
+Hello from worker
+3
+Hello from worker
+4
diff --git a/tests/specs/run/single_compile_with_reload/single_compile_with_reload_dyn.ts b/tests/specs/run/single_compile_with_reload/single_compile_with_reload_dyn.ts
new file mode 100644
index 000000000..c69556be1
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/single_compile_with_reload_dyn.ts
@@ -0,0 +1,11 @@
+import { printHello3, returnsFoo2, returnsHi } from "./mod1.ts";
+
+printHello3();
+
+if (returnsHi() !== "Hi") {
+ throw Error("Unexpected");
+}
+
+if (returnsFoo2() !== "Foo") {
+ throw Error("Unexpected");
+}
diff --git a/tests/specs/run/single_compile_with_reload/single_compile_with_reload_worker.ts b/tests/specs/run/single_compile_with_reload/single_compile_with_reload_worker.ts
new file mode 100644
index 000000000..103cafe20
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/single_compile_with_reload_worker.ts
@@ -0,0 +1,3 @@
+console.log("Hello from worker");
+postMessage(null);
+close();
diff --git a/tests/specs/run/single_compile_with_reload/subdir2/dynamic_import.ts b/tests/specs/run/single_compile_with_reload/subdir2/dynamic_import.ts
new file mode 100644
index 000000000..59beb64c3
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/subdir2/dynamic_import.ts
@@ -0,0 +1,4 @@
+(async () => {
+ const { printHello } = await import("../mod2.ts");
+ printHello();
+})();
diff --git a/tests/specs/run/single_compile_with_reload/subdir2/mod2.ts b/tests/specs/run/single_compile_with_reload/subdir2/mod2.ts
new file mode 100644
index 000000000..9071d0aeb
--- /dev/null
+++ b/tests/specs/run/single_compile_with_reload/subdir2/mod2.ts
@@ -0,0 +1,9 @@
+import { printHello } from "../print_hello.ts";
+
+export function returnsFoo(): string {
+ return "Foo";
+}
+
+export function printHello2() {
+ printHello();
+}