[fine] Tests for type errors
WHEEEEEEE!
This commit is contained in:
parent
618e0028d3
commit
a9c1b04920
8 changed files with 123 additions and 47 deletions
4
fine/tests/expression/errors/binary_mismatch.fine
Normal file
4
fine/tests/expression/errors/binary_mismatch.fine
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
112 - "twenty five";
|
||||
"twenty five" - 112;
|
||||
// type-error: 4 cannot apply binary operator '-' to expressions of type 'f64' (on the left) and 'string' (on the right)
|
||||
// type-error: 35 cannot apply binary operator '-' to expressions of type 'string' (on the left) and 'f64' (on the right)
|
||||
2
fine/tests/expression/errors/if_mismatched_arms.fine
Normal file
2
fine/tests/expression/errors/if_mismatched_arms.fine
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if true { "blarg" } else { 23 }
|
||||
// type-error: 0 the type of the `then` branch (string) must match the type of the `else` branch (f64)
|
||||
2
fine/tests/expression/errors/if_not_bool.fine
Normal file
2
fine/tests/expression/errors/if_not_bool.fine
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if 23 { "what" } else { "the" }
|
||||
// type-error: 0 conditions must yield a boolean
|
||||
2
fine/tests/expression/errors/if_requires_else.fine
Normal file
2
fine/tests/expression/errors/if_requires_else.fine
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if (if false { true }) { 32 } else { 23 }
|
||||
// type-error: 4 this conditional expression needs an else arm to produce a value
|
||||
2
fine/tests/expression/errors/unary_mismatch.fine
Normal file
2
fine/tests/expression/errors/unary_mismatch.fine
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
- "twenty five";
|
||||
// type-error: 0 cannot apply unary operator '-' to value of type string
|
||||
Loading…
Add table
Add a link
Reference in a new issue