Revise desugaring following feedback

- We now consistently desugar an expect in the last position as
    `Void`. Regardless of the pattern. Desugaring to a boolean value is
    deemed too confusing.

  - This commit also removes the desugaring for let-binding. It's only
    ever allowed for _expect_ which then behaves like a side effect.

  - We also now allow tests to return either `Bool` or `Void`. A test
    that returns `Void` is treated the same as a test returning `True`.
This commit is contained in:
KtorZ
2024-08-21 14:31:57 +02:00
parent fbe6f02fd1
commit 9aa9070f56
13 changed files with 196 additions and 128 deletions

View File

@@ -52,14 +52,7 @@ Test(
location: 0..26,
name: "foo",
public: false,
return_annotation: Some(
Constructor {
location: 0..39,
module: None,
name: "Bool",
arguments: [],
},
),
return_annotation: None,
return_type: (),
end_position: 38,
on_test_failure: FailImmediately,

View File

@@ -37,14 +37,7 @@ Test(
location: 0..28,
name: "foo",
public: false,
return_annotation: Some(
Constructor {
location: 0..41,
module: None,
name: "Bool",
arguments: [],
},
),
return_annotation: None,
return_type: (),
end_position: 40,
on_test_failure: FailImmediately,

View File

@@ -44,14 +44,7 @@ Test(
location: 0..26,
name: "foo",
public: false,
return_annotation: Some(
Constructor {
location: 0..39,
module: None,
name: "Bool",
arguments: [],
},
),
return_annotation: None,
return_type: (),
end_position: 38,
on_test_failure: FailImmediately,

View File

@@ -13,14 +13,7 @@ Test(
location: 0..10,
name: "foo",
public: false,
return_annotation: Some(
Constructor {
location: 0..23,
module: None,
name: "Bool",
arguments: [],
},
),
return_annotation: None,
return_type: (),
end_position: 22,
on_test_failure: FailImmediately,

View File

@@ -44,14 +44,7 @@ Test(
location: 0..26,
name: "invalid_inputs",
public: false,
return_annotation: Some(
Constructor {
location: 0..61,
module: None,
name: "Bool",
arguments: [],
},
),
return_annotation: None,
return_type: (),
end_position: 60,
on_test_failure: SucceedEventually,

View File

@@ -45,7 +45,7 @@ pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError
end_position: span.end - 1,
name,
public: false,
return_annotation: Some(ast::Annotation::boolean(span)),
return_annotation: None,
return_type: (),
on_test_failure: fail.unwrap_or(OnTestFailure::FailImmediately),
})