diff --git a/crates/aiken-lang/src/parser/expr/when/clause.rs b/crates/aiken-lang/src/parser/expr/when/clause.rs index fc2df9df..50a64114 100644 --- a/crates/aiken-lang/src/parser/expr/when/clause.rs +++ b/crates/aiken-lang/src/parser/expr/when/clause.rs @@ -47,7 +47,7 @@ mod tests { use crate::assert_expr; #[test] - fn todo_clause() { + fn when_clause_todo() { assert_expr!( r#" when val is { @@ -59,7 +59,7 @@ mod tests { } #[test] - fn error_single_clause_no_message() { + fn when_clause_solo_error() { assert_expr!( r#" when val is { @@ -70,7 +70,7 @@ mod tests { } #[test] - fn todo_double_clause_no_message() { + fn when_clause_double_todo() { assert_expr!( r#" when val is { diff --git a/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_double_todo.snap b/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_double_todo.snap new file mode 100644 index 00000000..b708e48a --- /dev/null +++ b/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_double_todo.snap @@ -0,0 +1,67 @@ +--- +source: crates/aiken-lang/src/parser/expr/when/clause.rs +description: "Code:\n\nwhen val is {\n Bar1{..} -> todo\n Bar2{..} -> todo\n}\n" +--- +When { + location: 0..53, + subject: Var { + location: 5..8, + name: "val", + }, + clauses: [ + UntypedClause { + location: 16..32, + patterns: [ + Constructor { + is_record: true, + location: 16..24, + name: "Bar1", + arguments: [], + module: None, + constructor: (), + with_spread: true, + tipo: (), + }, + ], + guard: None, + then: Trace { + kind: Todo, + location: 28..32, + then: ErrorTerm { + location: 28..32, + }, + text: String { + location: 28..32, + value: "aiken::todo", + }, + }, + }, + UntypedClause { + location: 35..51, + patterns: [ + Constructor { + is_record: true, + location: 35..43, + name: "Bar2", + arguments: [], + module: None, + constructor: (), + with_spread: true, + tipo: (), + }, + ], + guard: None, + then: Trace { + kind: Todo, + location: 47..51, + then: ErrorTerm { + location: 47..51, + }, + text: String { + location: 47..51, + value: "aiken::todo", + }, + }, + }, + ], +} diff --git a/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_solo_error.snap b/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_solo_error.snap new file mode 100644 index 00000000..92b6171f --- /dev/null +++ b/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_solo_error.snap @@ -0,0 +1,40 @@ +--- +source: crates/aiken-lang/src/parser/expr/when/clause.rs +description: "Code:\n\nwhen val is {\n Bar1{..} -> error\n}\n" +--- +When { + location: 0..35, + subject: Var { + location: 5..8, + name: "val", + }, + clauses: [ + UntypedClause { + location: 16..33, + patterns: [ + Constructor { + is_record: true, + location: 16..24, + name: "Bar1", + arguments: [], + module: None, + constructor: (), + with_spread: true, + tipo: (), + }, + ], + guard: None, + then: Trace { + kind: Error, + location: 28..33, + then: ErrorTerm { + location: 28..33, + }, + text: String { + location: 28..33, + value: "aiken::error", + }, + }, + }, + ], +} diff --git a/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_todo.snap b/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_todo.snap new file mode 100644 index 00000000..26c65eea --- /dev/null +++ b/crates/aiken-lang/src/parser/expr/when/snapshots/when_clause_todo.snap @@ -0,0 +1,60 @@ +--- +source: crates/aiken-lang/src/parser/expr/when/clause.rs +description: "Code:\n\nwhen val is {\n Bar1{..} -> True\n Bar2{..} -> todo @\"unimplemented\"\n}\n" +--- +When { + location: 0..70, + subject: Var { + location: 5..8, + name: "val", + }, + clauses: [ + UntypedClause { + location: 16..32, + patterns: [ + Constructor { + is_record: true, + location: 16..24, + name: "Bar1", + arguments: [], + module: None, + constructor: (), + with_spread: true, + tipo: (), + }, + ], + guard: None, + then: Var { + location: 28..32, + name: "True", + }, + }, + UntypedClause { + location: 35..68, + patterns: [ + Constructor { + is_record: true, + location: 35..43, + name: "Bar2", + arguments: [], + module: None, + constructor: (), + with_spread: true, + tipo: (), + }, + ], + guard: None, + then: Trace { + kind: Todo, + location: 47..68, + then: ErrorTerm { + location: 47..68, + }, + text: String { + location: 52..68, + value: "unimplemented", + }, + }, + }, + ], +}