test(parser): anon binop and ambiguous sequence
This commit is contained in:
@@ -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,201 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/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 {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Fn(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: Sequence {
|
||||
location: 15..32,
|
||||
expressions: [
|
||||
Assignment {
|
||||
location: 15..26,
|
||||
value: Var {
|
||||
location: 23..26,
|
||||
name: "bar",
|
||||
},
|
||||
pattern: Var {
|
||||
location: 19..20,
|
||||
name: "a",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
Int {
|
||||
location: 30..32,
|
||||
value: "40",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
doc: None,
|
||||
location: 0..10,
|
||||
name: "foo_1",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 34,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
Fn(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: Sequence {
|
||||
location: 52..69,
|
||||
expressions: [
|
||||
Assignment {
|
||||
location: 52..63,
|
||||
value: Var {
|
||||
location: 60..63,
|
||||
name: "bar",
|
||||
},
|
||||
pattern: Var {
|
||||
location: 56..57,
|
||||
name: "a",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
Int {
|
||||
location: 67..69,
|
||||
value: "40",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
doc: None,
|
||||
location: 37..47,
|
||||
name: "foo_2",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 71,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
Fn(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: Assignment {
|
||||
location: 89..103,
|
||||
value: BinOp {
|
||||
location: 98..102,
|
||||
name: AddInt,
|
||||
left: Int {
|
||||
location: 98..100,
|
||||
value: "40",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
right: Int {
|
||||
location: 101..102,
|
||||
value: "2",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
pattern: Var {
|
||||
location: 93..94,
|
||||
name: "a",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
doc: None,
|
||||
location: 74..84,
|
||||
name: "foo_3",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 104,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
Fn(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: Sequence {
|
||||
location: 122..153,
|
||||
expressions: [
|
||||
Assignment {
|
||||
location: 122..137,
|
||||
value: Call {
|
||||
arguments: [
|
||||
CallArg {
|
||||
label: None,
|
||||
location: 134..136,
|
||||
value: Int {
|
||||
location: 134..136,
|
||||
value: "42",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
fun: Var {
|
||||
location: 130..133,
|
||||
name: "bar",
|
||||
},
|
||||
location: 130..137,
|
||||
},
|
||||
pattern: Var {
|
||||
location: 126..127,
|
||||
name: "a",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
BinOp {
|
||||
location: 141..153,
|
||||
name: MultInt,
|
||||
left: BinOp {
|
||||
location: 141..147,
|
||||
name: AddInt,
|
||||
left: Var {
|
||||
location: 141..142,
|
||||
name: "a",
|
||||
},
|
||||
right: Int {
|
||||
location: 145..147,
|
||||
value: "14",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
right: Int {
|
||||
location: 151..153,
|
||||
value: "42",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
doc: None,
|
||||
location: 107..117,
|
||||
name: "foo_4",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 154,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
Reference in New Issue
Block a user