[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:
John Doty 2024-01-21 08:14:42 -08:00
parent d0b74db715
commit 5f0a0b3268
20 changed files with 186 additions and 118 deletions

View file

@ -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

View 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'?)

View file

@ -3,6 +3,5 @@ class Foo {
x: f64;
}
// @ignore
// @expect-errors:
// asdfadsf
// | 3:2: duplicate definition of field 'x'

View file

@ -1,5 +1,4 @@
fun something(x: f64, x: f64) {}
// @ignore
// @expect-errors:
// asdfadsf
// | 1:22: duplicate definition of parameter 'x'

View 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'

View file

@ -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')

View file

@ -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 ('()')

View 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

View file

@ -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'

View file

@ -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'