test(parser): rename definitions to definition and more tests
This commit is contained in:
@@ -72,24 +72,6 @@ fn double_validator() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import() {
|
||||
assert_module!(
|
||||
r#"
|
||||
use std/list
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unqualified_imports() {
|
||||
assert_module!(
|
||||
r#"
|
||||
use std/address.{Address as A, thing as w}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import_alias() {
|
||||
assert_module!(
|
||||
@@ -186,25 +168,6 @@ fn pipeline() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn if_expression() {
|
||||
assert_module!(
|
||||
r#"
|
||||
fn ifs() {
|
||||
if True {
|
||||
1 + 1
|
||||
} else if a < 4 {
|
||||
5
|
||||
} else if a || b {
|
||||
6
|
||||
} else {
|
||||
3
|
||||
}
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn let_bindings() {
|
||||
assert_module!(
|
||||
@@ -445,30 +408,6 @@ fn tuple_type_alias() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn int_parsing_hex_bytes() {
|
||||
assert_module!(
|
||||
r#"
|
||||
fn foo() {
|
||||
#[ 0x01, 0xa2, 0x03 ]
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parsing_numeric_underscore() {
|
||||
assert_module!(
|
||||
r#"
|
||||
fn foo() {
|
||||
let i = 1_234_567
|
||||
let j = 1_000_000
|
||||
let k = -10_000
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn first_class_binop() {
|
||||
assert_module!(
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nfn ifs() {\n if True {\n 1 + 1\n } else if a < 4 {\n 5\n } else if a || b {\n 6\n } else {\n 3\n }\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Fn(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: If {
|
||||
location: 13..106,
|
||||
branches: [
|
||||
IfBranch {
|
||||
condition: Var {
|
||||
location: 16..20,
|
||||
name: "True",
|
||||
},
|
||||
body: BinOp {
|
||||
location: 27..32,
|
||||
name: AddInt,
|
||||
left: Int {
|
||||
location: 27..28,
|
||||
value: "1",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
right: Int {
|
||||
location: 31..32,
|
||||
value: "1",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
location: 16..36,
|
||||
},
|
||||
IfBranch {
|
||||
condition: BinOp {
|
||||
location: 45..50,
|
||||
name: LtInt,
|
||||
left: Var {
|
||||
location: 45..46,
|
||||
name: "a",
|
||||
},
|
||||
right: Int {
|
||||
location: 49..50,
|
||||
value: "4",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
body: Int {
|
||||
location: 57..58,
|
||||
value: "5",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
location: 45..62,
|
||||
},
|
||||
IfBranch {
|
||||
condition: BinOp {
|
||||
location: 71..77,
|
||||
name: Or,
|
||||
left: Var {
|
||||
location: 71..72,
|
||||
name: "a",
|
||||
},
|
||||
right: Var {
|
||||
location: 76..77,
|
||||
name: "b",
|
||||
},
|
||||
},
|
||||
body: Int {
|
||||
location: 84..85,
|
||||
value: "6",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
location: 71..89,
|
||||
},
|
||||
],
|
||||
final_else: Int {
|
||||
location: 101..102,
|
||||
value: "3",
|
||||
base: Decimal {
|
||||
numeric_underscore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
doc: None,
|
||||
location: 0..8,
|
||||
name: "ifs",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 107,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nuse std/list\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Use(
|
||||
Use {
|
||||
as_name: None,
|
||||
location: 0..12,
|
||||
module: [
|
||||
"std",
|
||||
"list",
|
||||
],
|
||||
package: (),
|
||||
unqualified: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nfn foo() {\n #[ 0x01, 0xa2, 0x03 ]\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Fn(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: ByteArray {
|
||||
location: 13..34,
|
||||
bytes: [
|
||||
1,
|
||||
162,
|
||||
3,
|
||||
],
|
||||
preferred_format: ArrayOfBytes(
|
||||
Hexadecimal,
|
||||
),
|
||||
},
|
||||
doc: None,
|
||||
location: 0..8,
|
||||
name: "foo",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 35,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nfn foo() {\n let i = 1_234_567\n let j = 1_000_000\n let k = -10_000\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Fn(
|
||||
Function {
|
||||
arguments: [],
|
||||
body: Sequence {
|
||||
location: 13..68,
|
||||
expressions: [
|
||||
Assignment {
|
||||
location: 13..30,
|
||||
value: Int {
|
||||
location: 21..30,
|
||||
value: "1234567",
|
||||
base: Decimal {
|
||||
numeric_underscore: true,
|
||||
},
|
||||
},
|
||||
pattern: Var {
|
||||
location: 17..18,
|
||||
name: "i",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
Assignment {
|
||||
location: 33..50,
|
||||
value: Int {
|
||||
location: 41..50,
|
||||
value: "1000000",
|
||||
base: Decimal {
|
||||
numeric_underscore: true,
|
||||
},
|
||||
},
|
||||
pattern: Var {
|
||||
location: 37..38,
|
||||
name: "j",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
Assignment {
|
||||
location: 53..68,
|
||||
value: UnOp {
|
||||
op: Negate,
|
||||
location: 61..68,
|
||||
value: Int {
|
||||
location: 62..68,
|
||||
value: "10000",
|
||||
base: Decimal {
|
||||
numeric_underscore: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
pattern: Var {
|
||||
location: 57..58,
|
||||
name: "k",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
],
|
||||
},
|
||||
doc: None,
|
||||
location: 0..8,
|
||||
name: "foo",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 69,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nuse std/address.{Address as A, thing as w}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Use(
|
||||
Use {
|
||||
as_name: None,
|
||||
location: 0..42,
|
||||
module: [
|
||||
"std",
|
||||
"address",
|
||||
],
|
||||
package: (),
|
||||
unqualified: [
|
||||
UnqualifiedImport {
|
||||
location: 17..29,
|
||||
name: "Address",
|
||||
as_name: Some(
|
||||
"A",
|
||||
),
|
||||
layer: Value,
|
||||
},
|
||||
UnqualifiedImport {
|
||||
location: 31..41,
|
||||
name: "thing",
|
||||
as_name: Some(
|
||||
"w",
|
||||
),
|
||||
layer: Value,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
Reference in New Issue
Block a user