diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-16 15:08:03 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-16 15:08:03 +0100 |
| commit | 51efb0f4d69943e290d977673970cd3c8ada306f (patch) | |
| tree | 6478ba698749eec120755e283adf7932a6a98d2f /tests/typ | |
| parent | d763f0f5a6a700352ee8926c15c8e58624f705c9 (diff) | |
Port remaining parser tests 🚚
Diffstat (limited to 'tests/typ')
| -rw-r--r-- | tests/typ/lang/blocks.typ | 21 | ||||
| -rw-r--r-- | tests/typ/lang/bracket-call.typ | 15 | ||||
| -rw-r--r-- | tests/typ/lang/expressions.typ | 37 | ||||
| -rw-r--r-- | tests/typ/lang/raw.typ | 23 |
4 files changed, 96 insertions, 0 deletions
diff --git a/tests/typ/lang/blocks.typ b/tests/typ/lang/blocks.typ new file mode 100644 index 00000000..cadd30dd --- /dev/null +++ b/tests/typ/lang/blocks.typ @@ -0,0 +1,21 @@ +{1} + +// Function calls. +{f(1)} +{[[f 1]]} + +// Error: 1:2-1:2 expected expression +{} + +// Error: 1:2-1:4 expected expression, found invalid token +{1u} + +// Error: 1:5-1:5 expected closing brace +{({1) + 2} + +// Error: 1:12-1:12 expected closing bracket +{[*] + [ok*} + +// Error: 2:4-2:5 unexpected hex value +// Error: 1:5-1:6 unexpected opening brace +{1 #{} _end_ diff --git a/tests/typ/lang/bracket-call.typ b/tests/typ/lang/bracket-call.typ index 642d6426..79667e61 100644 --- a/tests/typ/lang/bracket-call.typ +++ b/tests/typ/lang/bracket-call.typ @@ -41,6 +41,10 @@ // Error: 1:6-1:6 expected function name [f 1|] +// Error: 2:5-2:5 expected closing paren +// Error: 1:8-1:9 expected expression, found closing paren +[f (|f )] + // With actual functions. [box width: 1cm | image "res/rhino.png"] @@ -65,6 +69,7 @@ [f (x):1] --- +// Ref: false // Error: 2:2-2:3 a value of type string is not callable #let x = "string"; [x] @@ -77,6 +82,16 @@ [ --- +// Ref: false +// Error: 2:2-2:3 expected function name, found closing paren +// Error: 3:1-3:1 expected closing bracket +[) + +--- +// Error: 3:1-3:1 expected closing bracket +[f [*] + +--- // Error: 3:1-3:1 expected closing bracket [f][`a]` diff --git a/tests/typ/lang/expressions.typ b/tests/typ/lang/expressions.typ new file mode 100644 index 00000000..01725289 --- /dev/null +++ b/tests/typ/lang/expressions.typ @@ -0,0 +1,37 @@ +#let a = 2; +#let b = 4; + +// Unary operations. +{+1} +{-1} +{--1} + +// Binary operations. +{"a"+"b"} +{1-2} +{a * b} +{12pt/.4} + +// Associativity. +{1+2+3} +{1/2*3} + +// Precedence. +{1+2*-3} + +// Parentheses. +{(a)} +{(2)} +{(1+2)*3} + +// Confusion with floating-point literal. +{1e+2-1e-2} + +// Error: 1:3-1:3 expected expression +{-} + +// Error: 1:4-1:4 expected expression +{1+} + +// Error: 1:4-1:4 expected expression +{2*} diff --git a/tests/typ/lang/raw.typ b/tests/typ/lang/raw.typ new file mode 100644 index 00000000..22eda139 --- /dev/null +++ b/tests/typ/lang/raw.typ @@ -0,0 +1,23 @@ +The keyword ``rust let``. + +`#let x = 1` +`[f 1]` + +--- +[font 6pt] + +``py +import this + +def say_hi(): + print("Hello World!") +`` + +--- +```` +```backticks``` +```` + +--- +// Error: 2:1-2:1 expected backtick(s) +`endless |
