summaryrefslogtreecommitdiffhomepage
path: root/tests/custom
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-08-06 09:28:37 +0200
committerGitHub <noreply@github.com>2022-08-06 09:28:37 +0200
commitf1e393873a17571ada80c189fbedef020d89cdad (patch)
tree935044691733689fbae18879a8bb70bf15672d75 /tests/custom
parente55965a3d170f60776ffa2d82b2711d9ea3a0211 (diff)
parentb4a3f6828478f1d831ae11ee4d3dcd82b93407c8 (diff)
Merge pull request #97 from jow-/module-import-export-fixes
Diffstat (limited to 'tests/custom')
-rw-r--r--tests/custom/04_modules/06_export_errors26
-rw-r--r--tests/custom/04_modules/07_import_default2
-rw-r--r--tests/custom/04_modules/08_import_list2
-rw-r--r--tests/custom/04_modules/12_import_immutability2
-rw-r--r--tests/custom/04_modules/14_circular_imports43
-rw-r--r--tests/custom/04_modules/15_complex_imports151
6 files changed, 209 insertions, 17 deletions
diff --git a/tests/custom/04_modules/06_export_errors b/tests/custom/04_modules/06_export_errors
index c02a547..5c9f676 100644
--- a/tests/custom/04_modules/06_export_errors
+++ b/tests/custom/04_modules/06_export_errors
@@ -36,15 +36,14 @@ import "./files/test.uc";
-- Expect stderr --
Syntax error: Unable to compile module './files/test.uc':
-Syntax error: Exports may only appear at top level of a module
-In line 2, byte 2:
-
- ` export let x = 1;`
- ^-- Near here
-
+ | Syntax error: Exports may only appear at top level of a module
+ | In ./files/test.uc, line 2, byte 2:
+ |
+ | ` export let x = 1;`
+ | ^-- Near here
-In line 1, byte 25:
+In [stdin], line 1, byte 25:
`import "./files/test.uc";`
Near here --------------^
@@ -72,15 +71,14 @@ export { y as x };
-- Expect stderr --
Syntax error: Unable to compile module './files/test-duplicate.uc':
-Syntax error: Duplicate export 'x' for module './files/test-duplicate.uc'
-In line 4, byte 15:
-
- `export { y as x };`
- Near here ----^
-
+ | Syntax error: Duplicate export 'x' for module './files/test-duplicate.uc'
+ | In ./files/test-duplicate.uc, line 4, byte 15:
+ |
+ | `export { y as x };`
+ | Near here ----^
-In line 1, byte 35:
+In [stdin], line 1, byte 35:
`import "./files/test-duplicate.uc";`
Near here ------------------------^
diff --git a/tests/custom/04_modules/07_import_default b/tests/custom/04_modules/07_import_default
index 7190a22..d9d08b5 100644
--- a/tests/custom/04_modules/07_import_default
+++ b/tests/custom/04_modules/07_import_default
@@ -39,7 +39,7 @@ export const x = "This is a non-default export";
-- Expect stderr --
Syntax error: Module ./files/test2.uc has no default export
-In line 1, byte 20:
+In [stdin], line 1, byte 20:
`import defVal from "./files/test2.uc";`
Near here ---------^
diff --git a/tests/custom/04_modules/08_import_list b/tests/custom/04_modules/08_import_list
index 1a4f116..b55ddec 100644
--- a/tests/custom/04_modules/08_import_list
+++ b/tests/custom/04_modules/08_import_list
@@ -38,7 +38,7 @@ export const x = "This is a test";
-- Expect stderr --
Syntax error: Module ./files/test2.uc has no default export
-In line 1, byte 15:
+In [stdin], line 1, byte 15:
`import y from "./files/test2.uc";`
Near here ----^
diff --git a/tests/custom/04_modules/12_import_immutability b/tests/custom/04_modules/12_import_immutability
index 37c0bc6..48a7fe2 100644
--- a/tests/custom/04_modules/12_import_immutability
+++ b/tests/custom/04_modules/12_import_immutability
@@ -16,7 +16,7 @@ export let a = 1;
-- Expect stderr --
Syntax error: Invalid assignment to constant 'a'
-In line 3, byte 5:
+In [stdin], line 3, byte 5:
`a = 2;`
^-- Near here
diff --git a/tests/custom/04_modules/14_circular_imports b/tests/custom/04_modules/14_circular_imports
new file mode 100644
index 0000000..0b6070a
--- /dev/null
+++ b/tests/custom/04_modules/14_circular_imports
@@ -0,0 +1,43 @@
+Circular imports are not possible and will lead to a compilation error.
+
+-- Testcase --
+import a_val from "./files/a.uc";
+-- End --
+
+-- File a.uc --
+import b_val from "./b.uc";
+export default "a";
+-- End --
+
+-- File b.uc --
+import a_val from "./a.uc";
+export default "b";
+-- End --
+
+-- Args --
+-R
+-- End --
+
+-- Expect stderr --
+Syntax error: Unable to compile module './files/a.uc':
+
+ | Syntax error: Unable to compile module './files/b.uc':
+ |
+ | | Syntax error: Circular dependency
+ | | In ./files/b.uc, line 1, byte 19:
+ | |
+ | | `import a_val from "./a.uc";`
+ | | Near here --------^
+ |
+ | In ./files/a.uc, line 1, byte 27:
+ |
+ | `import b_val from "./b.uc";`
+ | Near here ----------------^
+
+In [stdin], line 1, byte 33:
+
+ `import a_val from "./files/a.uc";`
+ Near here ----------------------^
+
+
+-- End --
diff --git a/tests/custom/04_modules/15_complex_imports b/tests/custom/04_modules/15_complex_imports
new file mode 100644
index 0000000..f4dd588
--- /dev/null
+++ b/tests/custom/04_modules/15_complex_imports
@@ -0,0 +1,151 @@
+This testcase implements a somewhat complex dependency chain to stress
+test the compiler module resolving.
+
+The dependency tree is:
+
+root
+ + mod1
+ + mod4
+ + mod8
+ + mod2
+ + mod4
+ + mod6
+ + mod8
+ + mod9
+ + mod3
+ + mod4
+ + mod6
+ + mod4
+ + mod5
+ + mod1
+ + mod4
+ + mod8
+ + mod2
+ + mod4
+ + mod6
+ + mod8
+ + mod9
+ + mod4
+ + mod6
+ + mod8
+ + mod9
+ + mod4
+ + mod6
+ + mod6
+ + mod7
+ + mod5
+ + mod1
+ + mod4
+ + mod8
+ + mod2
+ + mod4
+ + mod6
+ + mod8
+ + mod9
+ + mod4
+ + mod6
+ + mod8
+ + mod9
+ + mod4
+ + mod6
+ + mod6
+ + mod8
+
+-- Testcase --
+import mod1 from 'mod1';
+import mod2 from 'mod2';
+import mod3 from 'mod3';
+import mod4 from 'mod4';
+import mod5 from 'mod5';
+import mod6 from 'mod6';
+import mod7 from 'mod7';
+import mod8 from 'mod8';
+
+print("root: ", [ mod1, mod2, mod3, mod4, mod5, mod6, mod7, mod8 ], "\n");
+-- End --
+
+-- File mod1.uc --
+import mod4 from 'mod4';
+import mod8 from 'mod8';
+
+print("mod1: ", [ mod4, mod8 ], "\n");
+
+export default 'mod1';
+-- End --
+
+-- File mod2.uc --
+import mod9 from 'mod9';
+import mod4 from 'mod4';
+import mod8 from 'mod8';
+import mod6 from 'mod6';
+
+print("mod2: ", [ mod4, mod6, mod8, mod9 ], "\n");
+
+export default 'mod2';
+-- End --
+
+-- File mod3.uc --
+import mod4 from 'mod4';
+import mod6 from 'mod6';
+
+print("mod3: ", [ mod4, mod6 ], "\n");
+
+export default 'mod3';
+-- End --
+
+-- File mod4.uc --
+export default 'mod4';
+-- End --
+
+-- File mod5.uc --
+import mod1 from 'mod1';
+import mod4 from 'mod4';
+import mod2 from 'mod2';
+import mod9 from 'mod9';
+import mod8 from 'mod8';
+import mod6 from 'mod6';
+
+print("mod5: ", [ mod1, mod2, mod4, mod6, mod8, mod9 ], "\n");
+
+export default 'mod5';
+-- End --
+
+-- File mod6.uc --
+export default 'mod6';
+-- End --
+
+-- File mod7.uc --
+import mod6 from 'mod6';
+import mod5 from 'mod5';
+
+print("mod7: ", [ mod5, mod6 ], "\n");
+
+export default 'mod7';
+-- End --
+
+-- File mod8.uc --
+export default 'mod8';
+-- End --
+
+-- File mod9.uc --
+import mod4 from 'mod4';
+import mod6 from 'mod6';
+
+print("mod9: ", [ mod4, mod6 ], "\n");
+
+export default 'mod9';
+-- End --
+
+-- Args --
+-R -L files/
+-- End --
+
+-- Expect stdout --
+mod1: [ "mod4", "mod8" ]
+mod9: [ "mod4", "mod6" ]
+mod2: [ "mod4", "mod6", "mod8", "mod9" ]
+mod3: [ "mod4", "mod6" ]
+mod5: [ "mod1", "mod2", "mod4", "mod6", "mod8", "mod9" ]
+mod7: [ "mod5", "mod6" ]
+root: [ "mod1", "mod2", "mod3", "mod4", "mod5", "mod6", "mod7", "mod8" ]
+-- End --