diff options
| author | Tulio Martins <113527485+tulio240@users.noreply.github.com> | 2024-05-30 04:56:40 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-30 07:56:40 +0000 |
| commit | 06a925a0ee0e1e7b93428d8b4952512a2e48ed79 (patch) | |
| tree | 02725b8b534eff798ba96949073edc6766f45fa6 /tests/suite | |
| parent | 5f6d942519b36eb839a0a11e4ef3f1ea4013a8b5 (diff) | |
Add nested import syntax (#4228)
Co-authored-by: LuizAugustoPapa <luiz.papa@aluno.puc-rio.br>
Co-authored-by: PepinhoJp <pepinho.jp@gmail.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Diffstat (limited to 'tests/suite')
| -rw-r--r-- | tests/suite/scripting/import.typ | 45 | ||||
| -rw-r--r-- | tests/suite/scripting/module.typ | 1 | ||||
| -rw-r--r-- | tests/suite/scripting/modules/chap2.typ | 1 |
3 files changed, 47 insertions, 0 deletions
diff --git a/tests/suite/scripting/import.typ b/tests/suite/scripting/import.typ index 820f81d6..8bfa8ca6 100644 --- a/tests/suite/scripting/import.typ +++ b/tests/suite/scripting/import.typ @@ -45,6 +45,16 @@ #test(val, 1) #test(other(1, 2), 3) +--- import-nested-item --- +// Nested item imports. +#import "modules/chap1.typ" as orig-chap1 +#import "modules/chap2.typ" as orig-chap2 +#import "module.typ": chap2, chap2.name, chap2.chap1, chap2.chap1.name as othername +#test(chap2, orig-chap2) +#test(chap1, orig-chap1) +#test(name, "Klaus") +#test(othername, "Klaus") + --- import-from-function-scope --- // Test importing from function scopes. @@ -63,6 +73,28 @@ #import assert: eq as aseq #aseq(10, 10) +--- import-from-function-scope-nested-import --- +// Test importing items from function scopes via nested import. +#import std: grid.cell, table.cell as tcell +#test(cell, grid.cell) +#test(tcell, table.cell) + +--- import-from-type-scope --- +// Test importing from a type's scope. +#import array: zip +#test(zip((1, 2), (3, 4)), ((1, 3), (2, 4))) + +--- import-from-type-scope-item-renamed --- +// Test importing from a type's scope with renaming. +#import array: pop as renamed-pop +#test(renamed-pop((1, 2)), 2) + +--- import-from-type-scope-nested-import --- +// Test importing from a type's scope with nested import. +#import std: array.zip, array.pop as renamed-pop +#test(zip((1, 2), (3, 4)), ((1, 3), (2, 4))) +#test(renamed-pop((1, 2)), 2) + --- import-from-file-bare --- // A module import without items. #import "module.typ" @@ -225,6 +257,10 @@ This is never reached. // Error: 7-12 unknown variable: chap1 #test(chap1.b, "Klaus") +--- import-nested-invalid-type --- +// Error: 19-21 expected module, function, or type, found float +#import std: calc.pi.something + --- import-incomplete --- // Error: 8 expected expression #import @@ -262,6 +298,15 @@ This is never reached. // Error: 16-17 unexpected integer #import "": a: 1 +--- import-incomplete-nested --- +// Error: 15 expected identifier +#import "": a. + +--- import-wildcard-in-nested --- +// Error: 15 expected identifier +// Error: 15-16 unexpected star +#import "": a.* + --- import-missing-comma --- // Error: 14 expected comma #import "": a b diff --git a/tests/suite/scripting/module.typ b/tests/suite/scripting/module.typ index 8a67d225..8e388bfb 100644 --- a/tests/suite/scripting/module.typ +++ b/tests/suite/scripting/module.typ @@ -1,5 +1,6 @@ // SKIP // A file to import in import / include tests. +#import "modules/chap2.typ" #let a #let b = 1 diff --git a/tests/suite/scripting/modules/chap2.typ b/tests/suite/scripting/modules/chap2.typ index 9c9d12d7..f1a886d6 100644 --- a/tests/suite/scripting/modules/chap2.typ +++ b/tests/suite/scripting/modules/chap2.typ @@ -1,4 +1,5 @@ // SKIP +#import "chap1.typ" #let name = "Klaus" == Chapter 2 |
