[fine] Many test improvements, error improvements
- Check for more error conditions - Move to more definitive error assertions - Simpler error messages in some cases - Test more conditions more thoroughly, revisit old tests
This commit is contained in:
parent
d0b74db715
commit
5f0a0b3268
20 changed files with 186 additions and 118 deletions
|
|
@ -14,7 +14,7 @@ fun wrong() {
|
|||
}
|
||||
|
||||
// @expect-errors:
|
||||
// | 7:4: cannot assign a value of type `string` to type `f64`
|
||||
// | 8:4: cannot assign a value of type `f64` to type `string`
|
||||
// | 11:4: cannot assign a value of type `f64` to type `string`
|
||||
// | 7:4: cannot assign a value of type 'string' to type 'f64'
|
||||
// | 8:4: cannot assign a value of type 'f64' to type 'string'
|
||||
// | 11:4: cannot assign a value of type 'f64' to type 'string'
|
||||
// | 13:2: cannot assign a new value to a function declaration
|
||||
|
|
|
|||
8
fine/tests/expression/errors/class_as_a_variable.fine
Normal file
8
fine/tests/expression/errors/class_as_a_variable.fine
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class Foo {}
|
||||
|
||||
fun test() -> f64 {
|
||||
Foo + 23
|
||||
}
|
||||
|
||||
// @expect-errors:
|
||||
// | 4:2: Foo is a class, not a value (did you mean to create a new instance with 'new'?)
|
||||
|
|
@ -3,6 +3,5 @@ class Foo {
|
|||
x: f64;
|
||||
}
|
||||
|
||||
// @ignore
|
||||
// @expect-errors:
|
||||
// asdfadsf
|
||||
// | 3:2: duplicate definition of field 'x'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
fun something(x: f64, x: f64) {}
|
||||
|
||||
// @ignore
|
||||
// @expect-errors:
|
||||
// asdfadsf
|
||||
// | 1:22: duplicate definition of parameter 'x'
|
||||
|
|
|
|||
16
fine/tests/expression/errors/duplicates.fine
Normal file
16
fine/tests/expression/errors/duplicates.fine
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
fun nested() {
|
||||
fun foo() {}
|
||||
fun foo() {}
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
fun nested() {}
|
||||
|
||||
class Bar {}
|
||||
class Bar {}
|
||||
|
||||
// @expect-errors:
|
||||
// | 3:2: duplicate definition of function 'foo'
|
||||
// | 8:0: duplicate definition of function 'nested'
|
||||
// | 11:0: duplicate definition of class 'Bar'
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
if true { "blarg" } else { 23 }
|
||||
// @type-error: 0 the type of the `then` branch (string) must match the type of the `else` branch (f64)
|
||||
|
||||
// @expect-errors:
|
||||
// | 1:0: the type of the 'then' branch ('string') must match the type of the 'else' branch ('f64')
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
if (if false { true }) { 32 } else { 23 }
|
||||
// @type-error: 4 the type of the `then` branch (bool) must match the type of the `else` branch (())
|
||||
|
||||
// @expect-errors:
|
||||
// | 1:4: the type of the 'then' branch ('bool') must match the type of the 'else' branch ('()')
|
||||
|
|
|
|||
12
fine/tests/expression/errors/locals_in_globals.fine
Normal file
12
fine/tests/expression/errors/locals_in_globals.fine
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
// This is a block-local declaration; it should *not* appear in the global
|
||||
// environment.
|
||||
let y = 23;
|
||||
}
|
||||
|
||||
fun foo() -> f64 {
|
||||
y + 3
|
||||
}
|
||||
|
||||
// @expect-errors:
|
||||
// | 8:2: cannot find value y here
|
||||
|
|
@ -5,4 +5,5 @@ fun test() -> f64 {
|
|||
23.0
|
||||
}
|
||||
|
||||
// @check-error: callers of this function expect a value of type `f64` but this statement returns a value of type `string`
|
||||
// @expect-errors:
|
||||
// | 3:4: callers of this function expect a value of type 'f64' but this statement returns a value of type 'string'
|
||||
|
|
@ -2,4 +2,4 @@ fun test() -> bool {
|
|||
32
|
||||
}
|
||||
|
||||
// @check-error: the body of this function yields a value of type `f64`, but callers expect this function to produce a `bool`
|
||||
// @check-error: the body of this function yields a value of type 'f64', but callers expect this function to produce a 'bool'
|
||||
Loading…
Add table
Add a link
Reference in a new issue