diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-04-13 10:39:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-13 08:39:45 +0000 |
| commit | 020294fca9a7065d4b9cf4e677f606ebaaa29b00 (patch) | |
| tree | c0027ad22046e2726c22298461327823d6b88d53 /tests/suite/scripting/field.typ | |
| parent | 72dd79210602ecc799726fc096b078afbb47f299 (diff) | |
Better test runner (#3922)
Diffstat (limited to 'tests/suite/scripting/field.typ')
| -rw-r--r-- | tests/suite/scripting/field.typ | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/suite/scripting/field.typ b/tests/suite/scripting/field.typ new file mode 100644 index 00000000..7b2427e3 --- /dev/null +++ b/tests/suite/scripting/field.typ @@ -0,0 +1,76 @@ +// Test field access. + +--- field-function --- +// Test fields on function scopes. +#enum.item +#assert.eq +#assert.ne + +--- field-normal-function-invalid --- +// Error: 9-16 function `assert` does not contain field `invalid` +#assert.invalid + +--- field-elem-function-invalid --- +// Error: 7-14 function `enum` does not contain field `invalid` +#enum.invalid + +--- field-elem-function-invalid-call --- +// Error: 7-14 function `enum` does not contain field `invalid` +#enum.invalid() + +--- field-closure-invalid --- +// Closures cannot have fields. +#let f(x) = x +// Error: 4-11 cannot access fields on user-defined functions +#f.invalid + +--- field-bool-invalid --- +// Error: 8-10 cannot access fields on type boolean +#false.ok + +--- field-bool-keyword-invalid --- +// Error: 9-13 cannot access fields on type boolean +#{false.true} + +--- field-invalid-none --- +#{ + let object = none + // Error: 3-9 none does not have accessible fields + object.property = "value" +} + +--- field-invalid-int --- +#{ + let object = 10 + // Error: 3-9 integer does not have accessible fields + object.property = "value" +} + +--- field-mutable-invalid-symbol --- +#{ + let object = sym.eq.not + // Error: 3-9 cannot mutate fields on symbol + object.property = "value" +} + +--- field-mutable-invalid-module --- +#{ + let object = calc + // Error: 3-9 cannot mutate fields on module + object.property = "value" +} + +--- field-mutable-invalid-function --- +#{ + let object = calc.sin + // Error: 3-9 cannot mutate fields on function + object.property = "value" +} + +--- field-mutable-invalid-stroke --- +#{ + let s = 1pt + red + // Error: 3-4 fields on stroke are not yet mutable + // Hint: 3-4 try creating a new stroke with the updated field value instead + s.thickness = 5pt +} |
