test(parser): anon binop and ambiguous sequence
This commit is contained in:
parent
8a6c81493c
commit
b25db429be
|
@ -58,4 +58,30 @@ mod tests {
|
|||
// more comments"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_ambiguous_sequence() {
|
||||
assert_module!(
|
||||
r#"
|
||||
fn foo_1() {
|
||||
let a = bar
|
||||
(40)
|
||||
}
|
||||
|
||||
fn foo_2() {
|
||||
let a = bar
|
||||
{40}
|
||||
}
|
||||
|
||||
fn foo_3() {
|
||||
let a = (40+2)
|
||||
}
|
||||
|
||||
fn foo_4() {
|
||||
let a = bar(42)
|
||||
(a + 14) * 42
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,3 +87,28 @@ pub fn parser() -> impl Parser<Token, UntypedExpr, Error = ParseError> {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::assert_expr;
|
||||
|
||||
#[test]
|
||||
fn first_class_binop() {
|
||||
assert_expr!(
|
||||
r#"
|
||||
compare_with(a, >, b)
|
||||
compare_with(a, >=, b)
|
||||
compare_with(a, <, b)
|
||||
compare_with(a, <=, b)
|
||||
compare_with(a, ==, b)
|
||||
compare_with(a, !=, b)
|
||||
combine_with(a, &&, b)
|
||||
combine_with(a, ||, b)
|
||||
compute_with(a, +, b)
|
||||
compute_with(a, -, b)
|
||||
compute_with(a, /, b)
|
||||
compute_with(a, *, b)
|
||||
compute_with(a, %, b)"#
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
source: crates/aiken-lang/src/parser.rs
|
||||
description: "Code:\n\nfn foo_1() {\n let a = bar\n (40)\n}\n\nfn foo_2() {\n let a = bar\n {40}\n}\n\nfn foo_3() {\n let a = (40+2)\n}\n\nfn foo_4() {\n let a = bar(42)\n (a + 14) * 42\n}\n"
|
||||
---
|
||||
Module {
|
|
@ -168,15 +168,6 @@ fn base16_bytearray_literals() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_def() {
|
||||
assert_module!(
|
||||
r#"
|
||||
fn foo() {}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_invoke() {
|
||||
assert_module!(
|
||||
|
@ -188,55 +179,6 @@ fn function_invoke() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_ambiguous_sequence() {
|
||||
assert_module!(
|
||||
r#"
|
||||
fn foo_1() {
|
||||
let a = bar
|
||||
(40)
|
||||
}
|
||||
|
||||
fn foo_2() {
|
||||
let a = bar
|
||||
{40}
|
||||
}
|
||||
|
||||
fn foo_3() {
|
||||
let a = (40+2)
|
||||
}
|
||||
|
||||
fn foo_4() {
|
||||
let a = bar(42)
|
||||
(a + 14) * 42
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn first_class_binop() {
|
||||
assert_module!(
|
||||
r#"
|
||||
fn foo() {
|
||||
compare_with(a, >, b)
|
||||
compare_with(a, >=, b)
|
||||
compare_with(a, <, b)
|
||||
compare_with(a, <=, b)
|
||||
compare_with(a, ==, b)
|
||||
compare_with(a, !=, b)
|
||||
combine_with(a, &&, b)
|
||||
combine_with(a, ||, b)
|
||||
compute_with(a, +, b)
|
||||
compute_with(a, -, b)
|
||||
compute_with(a, /, b)
|
||||
compute_with(a, *, b)
|
||||
compute_with(a, %, b)
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_unicode_offset_1() {
|
||||
assert_module!(
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nfn foo() {}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Fn(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: Trace {
|
||||
kind: Todo,
|
||||
location: 0..11,
|
||||
then: ErrorTerm {
|
||||
location: 0..11,
|
||||
},
|
||||
text: String {
|
||||
location: 0..11,
|
||||
value: "aiken::todo",
|
||||
},
|
||||
},
|
||||
doc: None,
|
||||
location: 0..8,
|
||||
name: "foo",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 10,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
Loading…
Reference in New Issue