diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-07-30 14:02:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-30 14:02:03 +0200 |
commit | e55965a3d170f60776ffa2d82b2711d9ea3a0211 (patch) | |
tree | b73977b8e71445de9e5947d2db3bf941cc174f42 /tests/custom/04_modules/06_export_errors | |
parent | 1219d7efa170bf38fb1bf6a10fa0d1f96e62f091 (diff) | |
parent | 156d584e4d0af46c39234ee68a98a16ab4cbe225 (diff) |
Merge pull request #96 from jow-/module-import-export-support
Module import export support
Diffstat (limited to 'tests/custom/04_modules/06_export_errors')
-rw-r--r-- | tests/custom/04_modules/06_export_errors | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/custom/04_modules/06_export_errors b/tests/custom/04_modules/06_export_errors new file mode 100644 index 0000000..c02a547 --- /dev/null +++ b/tests/custom/04_modules/06_export_errors @@ -0,0 +1,89 @@ +Export statements are only allowed at the toplevel of a module. + +-- Testcase -- +export let x = 1; +-- End -- + +-- Args -- +-R +-- End -- + +-- Expect stderr -- +Syntax error: Exports may only appear at top level of a module + + `export let x = 1;` + ^-- Near here + + +-- End -- + + +Export statements are not allowed within functions or nested blocks. + +-- Testcase -- +import "./files/test.uc"; +-- End -- + +-- File test.uc -- +{ + export let x = 1; +} +-- End -- + +-- Args -- +-R +-- End -- + +-- 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 + + + +In line 1, byte 25: + + `import "./files/test.uc";` + Near here --------------^ + + +-- End -- + + +Duplicate export names should result in an error. + +-- Testcase -- +import "./files/test-duplicate.uc"; +-- End -- + +-- File test-duplicate.uc -- +let x = 1, y = 2; + +export { x }; +export { y as x }; +-- End -- + +-- Args -- +-R +-- End -- + +-- 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 ----^ + + + +In line 1, byte 35: + + `import "./files/test-duplicate.uc";` + Near here ------------------------^ + + +-- End -- |