feat: update syntax for failing test to be more consistent
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/parser/definition/test.rs
|
||||
description: "Code:\n\n!test invalid_inputs() {\n expect True = False\n\n False\n}\n"
|
||||
description: "Code:\n\ntest invalid_inputs() fail {\n expect True = False\n\n False\n}\n"
|
||||
---
|
||||
Test(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: Sequence {
|
||||
location: 27..55,
|
||||
location: 31..59,
|
||||
expressions: [
|
||||
Assignment {
|
||||
location: 27..46,
|
||||
location: 31..50,
|
||||
value: Var {
|
||||
location: 41..46,
|
||||
location: 45..50,
|
||||
name: "False",
|
||||
},
|
||||
pattern: Constructor {
|
||||
is_record: false,
|
||||
location: 34..38,
|
||||
location: 38..42,
|
||||
name: "True",
|
||||
arguments: [],
|
||||
module: None,
|
||||
@@ -28,18 +28,18 @@ Test(
|
||||
annotation: None,
|
||||
},
|
||||
Var {
|
||||
location: 50..55,
|
||||
location: 54..59,
|
||||
name: "False",
|
||||
},
|
||||
],
|
||||
},
|
||||
doc: None,
|
||||
location: 0..22,
|
||||
location: 0..26,
|
||||
name: "invalid_inputs",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 56,
|
||||
end_position: 60,
|
||||
can_error: true,
|
||||
},
|
||||
)
|
||||
@@ -7,20 +7,18 @@ use crate::{
|
||||
};
|
||||
|
||||
pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError> {
|
||||
just(Token::Bang)
|
||||
.ignored()
|
||||
.or_not()
|
||||
.then_ignore(just(Token::Test))
|
||||
.then(select! {Token::Name {name} => name})
|
||||
just(Token::Test)
|
||||
.ignore_then(select! {Token::Name {name} => name})
|
||||
.then_ignore(just(Token::LeftParen))
|
||||
.then_ignore(just(Token::RightParen))
|
||||
.then(just(Token::Fail).ignored().or_not())
|
||||
.map_with_span(|name, span| (name, span))
|
||||
.then(
|
||||
expr::sequence()
|
||||
.or_not()
|
||||
.delimited_by(just(Token::LeftBrace), just(Token::RightBrace)),
|
||||
)
|
||||
.map_with_span(|(((fail, name), span_end), body), span| {
|
||||
.map_with_span(|(((name, fail), span_end), body), span| {
|
||||
ast::UntypedDefinition::Test(ast::Function {
|
||||
arguments: vec![],
|
||||
body: body.unwrap_or_else(|| UntypedExpr::todo(None, span)),
|
||||
@@ -41,10 +39,10 @@ mod tests {
|
||||
use crate::assert_definition;
|
||||
|
||||
#[test]
|
||||
fn test_fail() {
|
||||
fn def_test_fail() {
|
||||
assert_definition!(
|
||||
r#"
|
||||
!test invalid_inputs() {
|
||||
test invalid_inputs() fail {
|
||||
expect True = False
|
||||
|
||||
False
|
||||
|
||||
Reference in New Issue
Block a user