test(parser): finish moving tests to their correct modules

This commit is contained in:
rvcas 2023-07-04 17:48:48 -04:00
parent 47567c5e6f
commit 5e8edcb340
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
42 changed files with 974 additions and 1388 deletions

View File

@ -84,4 +84,28 @@ mod tests {
"#
);
}
#[test]
fn parse_unicode_offset_1() {
assert_module!(
r#"
fn foo() {
let x = ""
x
}
"#
);
}
#[test]
fn parse_unicode_offset_2() {
assert_module!(
r#"
fn foo() {
let x = "*"
x
}
"#
);
}
}

View File

@ -92,3 +92,32 @@ fn labeled_constructor_type_args(
.allow_trailing()
.delimited_by(just(Token::LeftBrace), just(Token::RightBrace))
}
#[cfg(test)]
mod tests {
use crate::assert_definition;
#[test]
fn custom_type() {
assert_definition!(
r#"
type Option<a> {
Some(a, Int)
None
Wow { name: Int, age: Int }
}
"#
);
}
#[test]
fn opaque_type() {
assert_definition!(
r#"
pub opaque type User {
name: _w
}
"#
);
}
}

View File

@ -0,0 +1,92 @@
---
source: crates/aiken-lang/src/parser/definition/data_type.rs
description: "Code:\n\ntype Option<a> {\n Some(a, Int)\n None\n Wow { name: Int, age: Int }\n}\n"
---
DataType(
DataType {
constructors: [
RecordConstructor {
location: 19..31,
name: "Some",
arguments: [
RecordConstructorArg {
label: None,
annotation: Var {
location: 24..25,
name: "a",
},
location: 24..25,
tipo: (),
doc: None,
},
RecordConstructorArg {
label: None,
annotation: Constructor {
location: 27..30,
module: None,
name: "Int",
arguments: [],
},
location: 27..30,
tipo: (),
doc: None,
},
],
doc: None,
sugar: false,
},
RecordConstructor {
location: 34..38,
name: "None",
arguments: [],
doc: None,
sugar: false,
},
RecordConstructor {
location: 41..68,
name: "Wow",
arguments: [
RecordConstructorArg {
label: Some(
"name",
),
annotation: Constructor {
location: 53..56,
module: None,
name: "Int",
arguments: [],
},
location: 47..56,
tipo: (),
doc: None,
},
RecordConstructorArg {
label: Some(
"age",
),
annotation: Constructor {
location: 63..66,
module: None,
name: "Int",
arguments: [],
},
location: 58..66,
tipo: (),
doc: None,
},
],
doc: None,
sugar: false,
},
],
doc: None,
location: 0..70,
name: "Option",
opaque: false,
parameters: [
"a",
],
public: false,
typed_parameters: [],
},
)

View File

@ -0,0 +1,37 @@
---
source: crates/aiken-lang/src/parser/definition/data_type.rs
description: "Code:\n\npub opaque type User {\n name: _w\n}\n"
---
DataType(
DataType {
constructors: [
RecordConstructor {
location: 21..35,
name: "User",
arguments: [
RecordConstructorArg {
label: Some(
"name",
),
annotation: Hole {
location: 31..33,
name: "_w",
},
location: 25..33,
tipo: (),
doc: None,
},
],
doc: None,
sugar: true,
},
],
doc: None,
location: 0..35,
name: "User",
opaque: true,
parameters: [],
public: true,
typed_parameters: [],
},
)

View File

@ -50,6 +50,11 @@ mod tests {
#[test]
fn let_bindings() {
assert_expr!(r#"let thing = [ 1, 2, a ]"#);
assert_expr!("let thing = [ 1, 2, a ]");
}
#[test]
fn expect() {
assert_expr!("expect Some(x) = something.field");
}
}

View File

@ -18,3 +18,21 @@ pub fn parser(
),
))
}
#[cfg(test)]
mod tests {
use crate::assert_expr;
#[test]
fn block_basic() {
assert_expr!(
r#"
let b = {
let x = 4
x + 5
}
"#
);
}
}

View File

@ -12,3 +12,23 @@ pub fn parser() -> impl Parser<Token, UntypedExpr, Error = ParseError> {
preferred_format,
})
}
#[cfg(test)]
mod tests {
use crate::assert_expr;
#[test]
fn bytearray_basic() {
assert_expr!("#[0, 170, 255]");
}
#[test]
fn bytearray_base16() {
assert_expr!("#\"00aaff\"");
}
#[test]
fn bytearray_utf8_encoded() {
assert_expr!("\"aiken\"");
}
}

View File

@ -364,3 +364,42 @@ pub fn parser(
})
})
}
#[cfg(test)]
mod tests {
use crate::assert_expr;
#[test]
fn plus_binop() {
assert_expr!("a + 1");
}
#[test]
fn pipeline() {
assert_expr!(
r#"
a + 2
|> add_one
|> add_one
"#
);
}
#[test]
fn field_access() {
assert_expr!("user.name");
}
#[test]
fn function_invoke() {
assert_expr!(
r#"
let x = add_one(3)
let map_add_x = list.map(_, fn (y) { x + y })
map_add_x([ 1, 2, 3 ])
"#
);
}
}

View File

@ -0,0 +1,49 @@
---
source: crates/aiken-lang/src/parser/expr/block.rs
description: "Code:\n\nlet b = {\n let x = 4\n\n x + 5\n}\n"
---
Assignment {
location: 0..32,
value: Sequence {
location: 12..30,
expressions: [
Assignment {
location: 12..21,
value: Int {
location: 20..21,
value: "4",
base: Decimal {
numeric_underscore: false,
},
},
pattern: Var {
location: 16..17,
name: "x",
},
kind: Let,
annotation: None,
},
BinOp {
location: 25..30,
name: AddInt,
left: Var {
location: 25..26,
name: "x",
},
right: Int {
location: 29..30,
value: "5",
base: Decimal {
numeric_underscore: false,
},
},
},
],
},
pattern: Var {
location: 4..5,
name: "b",
},
kind: Let,
annotation: None,
}

View File

@ -0,0 +1,13 @@
---
source: crates/aiken-lang/src/parser/expr/bytearray.rs
description: "Code:\n\n#\"00aaff\""
---
ByteArray {
location: 0..9,
bytes: [
0,
170,
255,
],
preferred_format: HexadecimalString,
}

View File

@ -0,0 +1,17 @@
---
source: crates/aiken-lang/src/parser/expr/bytearray.rs
description: "Code:\n\n#[0, 170, 255]"
---
ByteArray {
location: 0..14,
bytes: [
0,
170,
255,
],
preferred_format: ArrayOfBytes(
Decimal {
numeric_underscore: false,
},
),
}

View File

@ -0,0 +1,15 @@
---
source: crates/aiken-lang/src/parser/expr/bytearray.rs
description: "Code:\n\n\"aiken\""
---
ByteArray {
location: 0..7,
bytes: [
97,
105,
107,
101,
110,
],
preferred_format: Utf8String,
}

View File

@ -0,0 +1,36 @@
---
source: crates/aiken-lang/src/parser/expr/assignment.rs
description: "Code:\n\nexpect Some(x) = something.field"
---
Assignment {
location: 0..32,
value: FieldAccess {
location: 17..32,
label: "field",
container: Var {
location: 17..26,
name: "something",
},
},
pattern: Constructor {
is_record: false,
location: 7..14,
name: "Some",
arguments: [
CallArg {
label: None,
location: 12..13,
value: Var {
location: 12..13,
name: "x",
},
},
],
module: None,
constructor: (),
with_spread: false,
tipo: (),
},
kind: Expect,
annotation: None,
}

View File

@ -0,0 +1,12 @@
---
source: crates/aiken-lang/src/parser/expr/mod.rs
description: "Code:\n\nuser.name"
---
FieldAccess {
location: 0..9,
label: "name",
container: Var {
location: 0..4,
name: "user",
},
}

View File

@ -0,0 +1,160 @@
---
source: crates/aiken-lang/src/parser/expr/mod.rs
description: "Code:\n\nlet x = add_one(3)\n\nlet map_add_x = list.map(_, fn (y) { x + y })\n\nmap_add_x([ 1, 2, 3 ])\n"
---
Sequence {
location: 0..89,
expressions: [
Assignment {
location: 0..18,
value: Call {
arguments: [
CallArg {
label: None,
location: 16..17,
value: Int {
location: 16..17,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
},
],
fun: Var {
location: 8..15,
name: "add_one",
},
location: 8..18,
},
pattern: Var {
location: 4..5,
name: "x",
},
kind: Let,
annotation: None,
},
Assignment {
location: 20..65,
value: Fn {
location: 36..65,
fn_style: Capture,
arguments: [
Arg {
arg_name: Named {
name: "_capture__0",
label: "_capture__0",
location: 0..0,
is_validator_param: false,
},
location: 0..0,
annotation: None,
tipo: (),
},
],
body: Call {
arguments: [
CallArg {
label: None,
location: 45..46,
value: Var {
location: 45..46,
name: "_capture__0",
},
},
CallArg {
label: None,
location: 48..64,
value: Fn {
location: 48..64,
fn_style: Plain,
arguments: [
Arg {
arg_name: Named {
name: "y",
label: "y",
location: 52..53,
is_validator_param: false,
},
location: 52..53,
annotation: None,
tipo: (),
},
],
body: BinOp {
location: 57..62,
name: AddInt,
left: Var {
location: 57..58,
name: "x",
},
right: Var {
location: 61..62,
name: "y",
},
},
return_annotation: None,
},
},
],
fun: FieldAccess {
location: 36..44,
label: "map",
container: Var {
location: 36..40,
name: "list",
},
},
location: 36..65,
},
return_annotation: None,
},
pattern: Var {
location: 24..33,
name: "map_add_x",
},
kind: Let,
annotation: None,
},
Call {
arguments: [
CallArg {
label: None,
location: 77..88,
value: List {
location: 77..88,
elements: [
Int {
location: 79..80,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 82..83,
value: "2",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 85..86,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
],
tail: None,
},
},
],
fun: Var {
location: 67..76,
name: "map_add_x",
},
location: 67..89,
},
],
}

View File

@ -0,0 +1,95 @@
---
source: crates/aiken-lang/src/parser/expr/tuple.rs
description: "Code:\n\nlet tuple = (1, 2, 3, 4)\ntuple.1st + tuple.2nd + tuple.3rd + tuple.4th\n"
---
Sequence {
location: 0..70,
expressions: [
Assignment {
location: 0..24,
value: Tuple {
location: 12..24,
elems: [
Int {
location: 13..14,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 16..17,
value: "2",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 19..20,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 22..23,
value: "4",
base: Decimal {
numeric_underscore: false,
},
},
],
},
pattern: Var {
location: 4..9,
name: "tuple",
},
kind: Let,
annotation: None,
},
BinOp {
location: 25..70,
name: AddInt,
left: BinOp {
location: 25..58,
name: AddInt,
left: BinOp {
location: 25..46,
name: AddInt,
left: TupleIndex {
location: 25..34,
index: 0,
tuple: Var {
location: 25..30,
name: "tuple",
},
},
right: TupleIndex {
location: 37..46,
index: 1,
tuple: Var {
location: 37..42,
name: "tuple",
},
},
},
right: TupleIndex {
location: 49..58,
index: 2,
tuple: Var {
location: 49..54,
name: "tuple",
},
},
},
right: TupleIndex {
location: 61..70,
index: 3,
tuple: Var {
location: 61..66,
name: "tuple",
},
},
},
],
}

View File

@ -0,0 +1,54 @@
---
source: crates/aiken-lang/src/parser/expr/tuple.rs
description: "Code:\n\nlet a = foo(14)\n(a, 42)\n"
---
Sequence {
location: 0..23,
expressions: [
Assignment {
location: 0..15,
value: Call {
arguments: [
CallArg {
label: None,
location: 12..14,
value: Int {
location: 12..14,
value: "14",
base: Decimal {
numeric_underscore: false,
},
},
},
],
fun: Var {
location: 8..11,
name: "foo",
},
location: 8..15,
},
pattern: Var {
location: 4..5,
name: "a",
},
kind: Let,
annotation: None,
},
Tuple {
location: 16..23,
elems: [
Var {
location: 17..18,
name: "a",
},
Int {
location: 20..22,
value: "42",
base: Decimal {
numeric_underscore: false,
},
},
],
},
],
}

View File

@ -0,0 +1,32 @@
---
source: crates/aiken-lang/src/parser/expr/mod.rs
description: "Code:\n\na + 2\n|> add_one\n|> add_one\n"
---
PipeLine {
expressions: [
BinOp {
location: 0..5,
name: AddInt,
left: Var {
location: 0..1,
name: "a",
},
right: Int {
location: 4..5,
value: "2",
base: Decimal {
numeric_underscore: false,
},
},
},
Var {
location: 9..16,
name: "add_one",
},
Var {
location: 20..27,
name: "add_one",
},
],
one_liner: false,
}

View File

@ -0,0 +1,19 @@
---
source: crates/aiken-lang/src/parser/expr/mod.rs
description: "Code:\n\na + 1"
---
BinOp {
location: 0..5,
name: AddInt,
left: Var {
location: 0..1,
name: "a",
},
right: Int {
location: 4..5,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
}

View File

@ -0,0 +1,8 @@
---
source: crates/aiken-lang/src/parser/expr/string.rs
description: "Code:\n\n@\"aiken\""
---
String {
location: 0..8,
value: "aiken",
}

View File

@ -31,3 +31,13 @@ pub fn flexible(expr: UntypedExpr) -> UntypedExpr {
_ => expr,
}
}
#[cfg(test)]
mod tests {
use crate::assert_expr;
#[test]
fn string_basic() {
assert_expr!("@\"aiken\"");
}
}

View File

@ -21,3 +21,28 @@ pub fn parser(
elems,
})
}
#[cfg(test)]
mod tests {
use crate::assert_expr;
#[test]
fn parse_tuple() {
assert_expr!(
r#"
let tuple = (1, 2, 3, 4)
tuple.1st + tuple.2nd + tuple.3rd + tuple.4th
"#
);
}
#[test]
fn parse_tuple2() {
assert_expr!(
r#"
let a = foo(14)
(a, 42)
"#
);
}
}

View File

@ -28,3 +28,25 @@ pub fn parser(
clauses,
})
}
#[cfg(test)]
mod tests {
use crate::assert_expr;
#[test]
fn when_basic() {
assert_expr!(
r#"
when a is {
2 if x > 1 -> 3
1 | 4 | 5 -> {
let amazing = 5
amazing
}
3 -> 9
_ -> 4
}
"#
);
}
}

View File

@ -0,0 +1,140 @@
---
source: crates/aiken-lang/src/parser/expr/when/mod.rs
description: "Code:\n\nwhen a is {\n 2 if x > 1 -> 3\n 1 | 4 | 5 -> {\n let amazing = 5\n amazing\n }\n 3 -> 9\n _ -> 4\n}\n"
---
When {
location: 0..102,
subject: Var {
location: 5..6,
name: "a",
},
clauses: [
UntypedClause {
location: 14..29,
patterns: [
Int {
location: 14..15,
value: "2",
base: Decimal {
numeric_underscore: false,
},
},
],
guard: Some(
GtInt {
location: 19..24,
left: Var {
location: 19..20,
tipo: (),
name: "x",
},
right: Constant(
Int {
location: 23..24,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
),
},
),
then: Int {
location: 28..29,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
},
UntypedClause {
location: 32..82,
patterns: [
Int {
location: 32..33,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 36..37,
value: "4",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 40..41,
value: "5",
base: Decimal {
numeric_underscore: false,
},
},
],
guard: None,
then: Sequence {
location: 51..78,
expressions: [
Assignment {
location: 51..66,
value: Int {
location: 65..66,
value: "5",
base: Decimal {
numeric_underscore: false,
},
},
pattern: Var {
location: 55..62,
name: "amazing",
},
kind: Let,
annotation: None,
},
Var {
location: 71..78,
name: "amazing",
},
],
},
},
UntypedClause {
location: 85..91,
patterns: [
Int {
location: 85..86,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
],
guard: None,
then: Int {
location: 90..91,
value: "9",
base: Decimal {
numeric_underscore: false,
},
},
},
UntypedClause {
location: 94..100,
patterns: [
Discard {
name: "_",
location: 94..95,
},
],
guard: None,
then: Int {
location: 99..100,
value: "4",
base: Decimal {
numeric_underscore: false,
},
},
},
],
}

View File

@ -1,5 +1,5 @@
---
source: crates/aiken-lang/src/tests/parser.rs
source: crates/aiken-lang/src/parser.rs
description: "Code:\n\nfn foo() {\n let x = \"★\"\n x\n}\n"
---
Module {

View File

@ -1,5 +1,5 @@
---
source: crates/aiken-lang/src/tests/parser.rs
source: crates/aiken-lang/src/parser.rs
description: "Code:\n\nfn foo() {\n let x = \"*\"\n x\n}\n"
---
Module {

View File

@ -1,4 +1,3 @@
mod check;
mod format;
mod lexer;
mod parser;

View File

@ -1,204 +0,0 @@
use crate::assert_module;
#[test]
fn custom_type() {
assert_module!(
r#"
type Option<a> {
Some(a, Int)
None
Wow { name: Int, age: Int }
}
"#
);
}
#[test]
fn opaque_type() {
assert_module!(
r#"
pub opaque type User {
name: _w
}
"#
);
}
#[test]
fn expect() {
assert_module!(
r#"
pub fn run() {
expect Some(x) = something.field
x.other_field
}
"#
);
}
#[test]
fn plus_binop() {
assert_module!(
r#"
pub fn add_one(a) -> Int {
a + 1
}
"#
);
}
#[test]
fn pipeline() {
assert_module!(
r#"
pub fn thing(thing a: Int) {
a + 2
|> add_one
|> add_one
}
"#
);
}
#[test]
fn block() {
assert_module!(
r#"
pub fn wow2(a: Int){
let b = {
let x = 4
x + 5
}
b
}
"#
);
}
#[test]
fn when() {
assert_module!(
r#"
pub fn wow2(a: Int){
when a is {
2 -> 3
1 | 4 | 5 -> {
let amazing = 5
amazing
}
3 -> 9
_ -> 4
}
}
"#
);
}
#[test]
fn field_access() {
assert_module!(
r#"
fn name(user: User) {
user.name
}
"#
);
}
#[test]
fn call() {
assert_module!(
r#"
fn calls() {
let x = add_one(3)
let map_add_x = list.map(_, fn (y) { x + y })
map_add_x([ 1, 2, 3 ])
}
"#
);
}
#[test]
fn parse_tuple() {
assert_module!(
r#"
fn foo() {
let tuple = (1, 2, 3, 4)
tuple.1st + tuple.2nd + tuple.3rd + tuple.4th
}
"#
);
}
#[test]
fn parse_tuple2() {
assert_module!(
r#"
fn foo() {
let a = foo(14)
(a, 42)
}
"#
);
}
#[test]
fn plain_bytearray_literals() {
assert_module!(
r#"
pub const my_policy_id = #[0, 170, 255]
"#
);
}
#[test]
fn base16_bytearray_literals() {
assert_module!(
r#"
pub const my_policy_id = #"00aaff"
pub fn foo() {
my_policy_id == #"00aaff"
}
"#
);
}
#[test]
fn function_invoke() {
assert_module!(
r#"
fn foo() {
let a = bar(42)
}
"#
);
}
#[test]
fn parse_unicode_offset_1() {
assert_module!(
r#"
fn foo() {
let x = ""
x
}
"#
);
}
#[test]
fn parse_unicode_offset_2() {
assert_module!(
r#"
fn foo() {
let x = "*"
x
}
"#
);
}

View File

@ -1,61 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\npub const my_policy_id = #\"00aaff\"\n\npub fn foo() {\n my_policy_id == #\"00aaff\"\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
ModuleConstant(
ModuleConstant {
doc: None,
location: 0..34,
public: true,
name: "my_policy_id",
annotation: None,
value: ByteArray {
location: 25..34,
bytes: [
0,
170,
255,
],
preferred_format: HexadecimalString,
},
tipo: (),
},
),
Fn(
Function {
arguments: [],
body: BinOp {
location: 55..80,
name: Eq,
left: Var {
location: 55..67,
name: "my_policy_id",
},
right: ByteArray {
location: 71..80,
bytes: [
0,
170,
255,
],
preferred_format: HexadecimalString,
},
},
doc: None,
location: 36..48,
name: "foo",
public: true,
return_annotation: None,
return_type: (),
end_position: 81,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,98 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\npub fn wow2(a: Int){\n let b = {\n let x = 4\n\n x + 5\n }\n\n b\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [
Arg {
arg_name: Named {
name: "a",
label: "a",
location: 12..13,
is_validator_param: false,
},
location: 12..18,
annotation: Some(
Constructor {
location: 15..18,
module: None,
name: "Int",
arguments: [],
},
),
tipo: (),
},
],
body: Sequence {
location: 23..66,
expressions: [
Assignment {
location: 23..61,
value: Sequence {
location: 37..57,
expressions: [
Assignment {
location: 37..46,
value: Int {
location: 45..46,
value: "4",
base: Decimal {
numeric_underscore: false,
},
},
pattern: Var {
location: 41..42,
name: "x",
},
kind: Let,
annotation: None,
},
BinOp {
location: 52..57,
name: AddInt,
left: Var {
location: 52..53,
name: "x",
},
right: Int {
location: 56..57,
value: "5",
base: Decimal {
numeric_underscore: false,
},
},
},
],
},
pattern: Var {
location: 27..28,
name: "b",
},
kind: Let,
annotation: None,
},
Var {
location: 65..66,
name: "b",
},
],
},
doc: None,
location: 0..19,
name: "wow2",
public: true,
return_annotation: None,
return_type: (),
end_position: 67,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,181 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\nfn calls() {\n let x = add_one(3)\n\n let map_add_x = list.map(_, fn (y) { x + y })\n\n map_add_x([ 1, 2, 3 ])\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [],
body: Sequence {
location: 15..108,
expressions: [
Assignment {
location: 15..33,
value: Call {
arguments: [
CallArg {
label: None,
location: 31..32,
value: Int {
location: 31..32,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
},
],
fun: Var {
location: 23..30,
name: "add_one",
},
location: 23..33,
},
pattern: Var {
location: 19..20,
name: "x",
},
kind: Let,
annotation: None,
},
Assignment {
location: 37..82,
value: Fn {
location: 53..82,
fn_style: Capture,
arguments: [
Arg {
arg_name: Named {
name: "_capture__0",
label: "_capture__0",
location: 0..0,
is_validator_param: false,
},
location: 0..0,
annotation: None,
tipo: (),
},
],
body: Call {
arguments: [
CallArg {
label: None,
location: 62..63,
value: Var {
location: 62..63,
name: "_capture__0",
},
},
CallArg {
label: None,
location: 65..81,
value: Fn {
location: 65..81,
fn_style: Plain,
arguments: [
Arg {
arg_name: Named {
name: "y",
label: "y",
location: 69..70,
is_validator_param: false,
},
location: 69..70,
annotation: None,
tipo: (),
},
],
body: BinOp {
location: 74..79,
name: AddInt,
left: Var {
location: 74..75,
name: "x",
},
right: Var {
location: 78..79,
name: "y",
},
},
return_annotation: None,
},
},
],
fun: FieldAccess {
location: 53..61,
label: "map",
container: Var {
location: 53..57,
name: "list",
},
},
location: 53..82,
},
return_annotation: None,
},
pattern: Var {
location: 41..50,
name: "map_add_x",
},
kind: Let,
annotation: None,
},
Call {
arguments: [
CallArg {
label: None,
location: 96..107,
value: List {
location: 96..107,
elements: [
Int {
location: 98..99,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 101..102,
value: "2",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 104..105,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
],
tail: None,
},
},
],
fun: Var {
location: 86..95,
name: "map_add_x",
},
location: 86..108,
},
],
},
doc: None,
location: 0..10,
name: "calls",
public: false,
return_annotation: None,
return_type: (),
end_position: 109,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,100 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\ntype Option<a> {\n Some(a, Int)\n None\n Wow { name: Int, age: Int }\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
DataType(
DataType {
constructors: [
RecordConstructor {
location: 19..31,
name: "Some",
arguments: [
RecordConstructorArg {
label: None,
annotation: Var {
location: 24..25,
name: "a",
},
location: 24..25,
tipo: (),
doc: None,
},
RecordConstructorArg {
label: None,
annotation: Constructor {
location: 27..30,
module: None,
name: "Int",
arguments: [],
},
location: 27..30,
tipo: (),
doc: None,
},
],
doc: None,
sugar: false,
},
RecordConstructor {
location: 34..38,
name: "None",
arguments: [],
doc: None,
sugar: false,
},
RecordConstructor {
location: 41..68,
name: "Wow",
arguments: [
RecordConstructorArg {
label: Some(
"name",
),
annotation: Constructor {
location: 53..56,
module: None,
name: "Int",
arguments: [],
},
location: 47..56,
tipo: (),
doc: None,
},
RecordConstructorArg {
label: Some(
"age",
),
annotation: Constructor {
location: 63..66,
module: None,
name: "Int",
arguments: [],
},
location: 58..66,
tipo: (),
doc: None,
},
],
doc: None,
sugar: false,
},
],
doc: None,
location: 0..70,
name: "Option",
opaque: false,
parameters: [
"a",
],
public: false,
typed_parameters: [],
},
),
],
kind: Validator,
}

View File

@ -1,70 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\npub fn run() {\n expect Some(x) = something.field\n x.other_field\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [],
body: Sequence {
location: 19..69,
expressions: [
Assignment {
location: 19..51,
value: FieldAccess {
location: 36..51,
label: "field",
container: Var {
location: 36..45,
name: "something",
},
},
pattern: Constructor {
is_record: false,
location: 26..33,
name: "Some",
arguments: [
CallArg {
label: None,
location: 31..32,
value: Var {
location: 31..32,
name: "x",
},
},
],
module: None,
constructor: (),
with_spread: false,
tipo: (),
},
kind: Expect,
annotation: None,
},
FieldAccess {
location: 56..69,
label: "other_field",
container: Var {
location: 56..57,
name: "x",
},
},
],
},
doc: None,
location: 0..12,
name: "run",
public: true,
return_annotation: None,
return_type: (),
end_position: 70,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,52 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\nfn name(user: User) {\n user.name\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [
Arg {
arg_name: Named {
name: "user",
label: "user",
location: 8..12,
is_validator_param: false,
},
location: 8..18,
annotation: Some(
Constructor {
location: 14..18,
module: None,
name: "User",
arguments: [],
},
),
tipo: (),
},
],
body: FieldAccess {
location: 24..33,
label: "name",
container: Var {
location: 24..28,
name: "user",
},
},
doc: None,
location: 0..19,
name: "name",
public: false,
return_annotation: None,
return_type: (),
end_position: 34,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,54 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\nfn foo() {\n let a = bar(42)\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [],
body: Assignment {
location: 15..30,
value: Call {
arguments: [
CallArg {
label: None,
location: 27..29,
value: Int {
location: 27..29,
value: "42",
base: Decimal {
numeric_underscore: false,
},
},
},
],
fun: Var {
location: 23..26,
name: "bar",
},
location: 23..30,
},
pattern: Var {
location: 19..20,
name: "a",
},
kind: Let,
annotation: None,
},
doc: None,
location: 0..8,
name: "foo",
public: false,
return_annotation: None,
return_type: (),
end_position: 31,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,45 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\npub opaque type User {\n name: _w\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
DataType(
DataType {
constructors: [
RecordConstructor {
location: 21..35,
name: "User",
arguments: [
RecordConstructorArg {
label: Some(
"name",
),
annotation: Hole {
location: 31..33,
name: "_w",
},
location: 25..33,
tipo: (),
doc: None,
},
],
doc: None,
sugar: true,
},
],
doc: None,
location: 0..35,
name: "User",
opaque: true,
parameters: [],
public: true,
typed_parameters: [],
},
),
],
kind: Validator,
}

View File

@ -1,116 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\nfn foo() {\n let tuple = (1, 2, 3, 4)\n tuple.1st + tuple.2nd + tuple.3rd + tuple.4th\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [],
body: Sequence {
location: 13..85,
expressions: [
Assignment {
location: 13..37,
value: Tuple {
location: 25..37,
elems: [
Int {
location: 26..27,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 29..30,
value: "2",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 32..33,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 35..36,
value: "4",
base: Decimal {
numeric_underscore: false,
},
},
],
},
pattern: Var {
location: 17..22,
name: "tuple",
},
kind: Let,
annotation: None,
},
BinOp {
location: 40..85,
name: AddInt,
left: BinOp {
location: 40..73,
name: AddInt,
left: BinOp {
location: 40..61,
name: AddInt,
left: TupleIndex {
location: 40..49,
index: 0,
tuple: Var {
location: 40..45,
name: "tuple",
},
},
right: TupleIndex {
location: 52..61,
index: 1,
tuple: Var {
location: 52..57,
name: "tuple",
},
},
},
right: TupleIndex {
location: 64..73,
index: 2,
tuple: Var {
location: 64..69,
name: "tuple",
},
},
},
right: TupleIndex {
location: 76..85,
index: 3,
tuple: Var {
location: 76..81,
name: "tuple",
},
},
},
],
},
doc: None,
location: 0..8,
name: "foo",
public: false,
return_annotation: None,
return_type: (),
end_position: 86,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,75 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\nfn foo() {\n let a = foo(14)\n (a, 42)\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [],
body: Sequence {
location: 13..38,
expressions: [
Assignment {
location: 13..28,
value: Call {
arguments: [
CallArg {
label: None,
location: 25..27,
value: Int {
location: 25..27,
value: "14",
base: Decimal {
numeric_underscore: false,
},
},
},
],
fun: Var {
location: 21..24,
name: "foo",
},
location: 21..28,
},
pattern: Var {
location: 17..18,
name: "a",
},
kind: Let,
annotation: None,
},
Tuple {
location: 31..38,
elems: [
Var {
location: 32..33,
name: "a",
},
Int {
location: 35..37,
value: "42",
base: Decimal {
numeric_underscore: false,
},
},
],
},
],
},
doc: None,
location: 0..8,
name: "foo",
public: false,
return_annotation: None,
return_type: (),
end_position: 39,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,72 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\npub fn thing(thing a: Int) {\n a + 2\n |> add_one\n |> add_one\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [
Arg {
arg_name: Named {
name: "a",
label: "thing",
location: 13..20,
is_validator_param: false,
},
location: 13..25,
annotation: Some(
Constructor {
location: 22..25,
module: None,
name: "Int",
arguments: [],
},
),
tipo: (),
},
],
body: PipeLine {
expressions: [
BinOp {
location: 31..36,
name: AddInt,
left: Var {
location: 31..32,
name: "a",
},
right: Int {
location: 35..36,
value: "2",
base: Decimal {
numeric_underscore: false,
},
},
},
Var {
location: 42..49,
name: "add_one",
},
Var {
location: 55..62,
name: "add_one",
},
],
one_liner: false,
},
doc: None,
location: 0..26,
name: "thing",
public: true,
return_annotation: None,
return_type: (),
end_position: 63,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,35 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\npub const my_policy_id = #[0, 170, 255]\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
ModuleConstant(
ModuleConstant {
doc: None,
location: 0..39,
public: true,
name: "my_policy_id",
annotation: None,
value: ByteArray {
location: 25..39,
bytes: [
0,
170,
255,
],
preferred_format: ArrayOfBytes(
Decimal {
numeric_underscore: false,
},
),
},
tipo: (),
},
),
],
kind: Validator,
}

View File

@ -1,59 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\npub fn add_one(a) -> Int {\n a + 1\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [
Arg {
arg_name: Named {
name: "a",
label: "a",
location: 15..16,
is_validator_param: false,
},
location: 15..16,
annotation: None,
tipo: (),
},
],
body: BinOp {
location: 29..34,
name: AddInt,
left: Var {
location: 29..30,
name: "a",
},
right: Int {
location: 33..34,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
},
doc: None,
location: 0..24,
name: "add_one",
public: true,
return_annotation: Some(
Constructor {
location: 21..24,
module: None,
name: "Int",
arguments: [],
},
),
return_type: (),
end_position: 35,
can_error: true,
},
),
],
kind: Validator,
}

View File

@ -1,162 +0,0 @@
---
source: crates/aiken-lang/src/tests/parser.rs
description: "Code:\n\npub fn wow2(a: Int){\n when a is {\n 2 -> 3\n 1 | 4 | 5 -> {\n let amazing = 5\n amazing\n }\n 3 -> 9\n _ -> 4\n }\n}\n"
---
Module {
name: "",
docs: [],
type_info: (),
definitions: [
Fn(
Function {
arguments: [
Arg {
arg_name: Named {
name: "a",
label: "a",
location: 12..13,
is_validator_param: false,
},
location: 12..18,
annotation: Some(
Constructor {
location: 15..18,
module: None,
name: "Int",
arguments: [],
},
),
tipo: (),
},
],
body: When {
location: 23..132,
subject: Var {
location: 28..29,
name: "a",
},
clauses: [
UntypedClause {
location: 39..45,
patterns: [
Int {
location: 39..40,
value: "2",
base: Decimal {
numeric_underscore: false,
},
},
],
guard: None,
then: Int {
location: 44..45,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
},
UntypedClause {
location: 50..106,
patterns: [
Int {
location: 50..51,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 54..55,
value: "4",
base: Decimal {
numeric_underscore: false,
},
},
Int {
location: 58..59,
value: "5",
base: Decimal {
numeric_underscore: false,
},
},
],
guard: None,
then: Sequence {
location: 71..100,
expressions: [
Assignment {
location: 71..86,
value: Int {
location: 85..86,
value: "5",
base: Decimal {
numeric_underscore: false,
},
},
pattern: Var {
location: 75..82,
name: "amazing",
},
kind: Let,
annotation: None,
},
Var {
location: 93..100,
name: "amazing",
},
],
},
},
UntypedClause {
location: 111..117,
patterns: [
Int {
location: 111..112,
value: "3",
base: Decimal {
numeric_underscore: false,
},
},
],
guard: None,
then: Int {
location: 116..117,
value: "9",
base: Decimal {
numeric_underscore: false,
},
},
},
UntypedClause {
location: 122..128,
patterns: [
Discard {
name: "_",
location: 122..123,
},
],
guard: None,
then: Int {
location: 127..128,
value: "4",
base: Decimal {
numeric_underscore: false,
},
},
},
],
},
doc: None,
location: 0..19,
name: "wow2",
public: true,
return_annotation: None,
return_type: (),
end_position: 133,
can_error: true,
},
),
],
kind: Validator,
}