mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Add number-syntax edge case tests (#5560)
This commit is contained in:
parent
ef4fc040b2
commit
5e0e58d26e
BIN
tests/ref/double-percent.png
Normal file
BIN
tests/ref/double-percent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 496 B |
@ -95,3 +95,23 @@
|
||||
#float.inf \
|
||||
#(-float.inf) \
|
||||
#float.nan
|
||||
|
||||
--- float-syntax-edge-cases ---
|
||||
// Test float syntax edge cases and which spans of text are highlighted. Valid
|
||||
// items are those not annotated with an error comment since syntax is handled
|
||||
// at parse time.
|
||||
|
||||
#123.456e+789
|
||||
#000.000E-000
|
||||
#.9e0
|
||||
#123.E // this is a field access, so is fine syntactically
|
||||
#0.e
|
||||
#1.E+020
|
||||
// Error: 2-10 invalid number: 123.456e
|
||||
#123.456e
|
||||
// Error: 2-11 invalid number: 123.456e+
|
||||
#123.456e+
|
||||
// Error: 2-6 invalid number: .1E-
|
||||
#.1E-
|
||||
// Error: 2-4 invalid number: 0e
|
||||
#0e
|
||||
|
@ -79,3 +79,30 @@
|
||||
// Error: 2-9 invalid base-2 prefix
|
||||
// Hint: 2-9 numbers with a unit cannot have a base prefix
|
||||
#0b100pt
|
||||
|
||||
--- number-syntax-edge-cases ---
|
||||
// Test numeric syntax edge cases with suffixes and which spans of text are
|
||||
// highlighted. Valid items are those not annotated with an error comment since
|
||||
// syntax is handled at parse time.
|
||||
|
||||
// All fine
|
||||
#2em
|
||||
#6.3e5em
|
||||
#.5pt
|
||||
#1.2E+0%
|
||||
#1.2e-0%
|
||||
#0.0e0deg
|
||||
#5in%
|
||||
#0.%
|
||||
// Error: 2-8 invalid number suffix: hello
|
||||
#1hello
|
||||
// Error: 2-7 invalid number suffix: infr
|
||||
#1infr
|
||||
// Error: 2-5 invalid number: 2E
|
||||
#2EM
|
||||
// Error: 2-8 invalid number: .1E-
|
||||
#.1E-fr
|
||||
// Error: 2-16 invalid number: 0.1E+
|
||||
#0.1E+fr123e456
|
||||
// Error: 2-11 invalid number: .1e-
|
||||
#.1e-fr123.456
|
||||
|
@ -5,3 +5,11 @@
|
||||
#test((100% + 2pt).length, 2pt)
|
||||
#test((100% + 2pt - 2pt).length, 0pt)
|
||||
#test((56% + 2pt - 56%).ratio, 0%)
|
||||
|
||||
--- double-percent ---
|
||||
// Test for two percent signs in a row.
|
||||
#3.1%%
|
||||
|
||||
--- double-percent-error ---
|
||||
// Error: 7-8 the character `%` is not valid in code
|
||||
#(3.1%%)
|
||||
|
Loading…
x
Reference in New Issue
Block a user