test: adjust snapshots
This commit is contained in:
parent
8a7df7f66b
commit
da0b969865
|
@ -1,34 +1,39 @@
|
|||
use crate::{ast, parser};
|
||||
|
||||
macro_rules! assert_parse {
|
||||
($name:ident, $code:expr) => {
|
||||
#[test]
|
||||
fn $name() {
|
||||
($code:expr) => {
|
||||
let (module, _) =
|
||||
parser::module(indoc::indoc!{ $code }, ast::ModuleKind::Validator).expect("Failed to parse code");
|
||||
|
||||
insta::with_settings!({
|
||||
info => &stringify!($name),
|
||||
description => $code,
|
||||
description => concat!("Code:\n\n", indoc::indoc! { $code }),
|
||||
prepend_module_to_snapshot => false,
|
||||
omit_expression => true
|
||||
}, {
|
||||
insta::assert_debug_snapshot!(module);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
assert_parse!(windows_newline, "use aiken/list\r\n");
|
||||
#[test]
|
||||
fn windows_newline() {
|
||||
assert_parse!("use aiken/list\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_handle_comments_at_end_of_file() {
|
||||
assert_parse!(
|
||||
can_handle_comments_at_end_of_file,
|
||||
r#"
|
||||
use aiken
|
||||
|
||||
// some comment
|
||||
// more comments"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_annotation_with_module_prefix() {
|
||||
assert_parse!(
|
||||
type_annotation_with_module_prefix,
|
||||
r#"
|
||||
use aiken
|
||||
|
||||
|
@ -37,8 +42,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fail() {
|
||||
assert_parse!(
|
||||
test_fail,
|
||||
r#"
|
||||
!test invalid_inputs() {
|
||||
expect True = False
|
||||
|
@ -47,8 +55,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validator() {
|
||||
assert_parse!(
|
||||
validator,
|
||||
r#"
|
||||
validator {
|
||||
fn foo(datum, rdmr, ctx) {
|
||||
|
@ -57,8 +68,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn double_validator() {
|
||||
assert_parse!(
|
||||
double_validator,
|
||||
r#"
|
||||
validator {
|
||||
fn foo(datum, rdmr, ctx) {
|
||||
|
@ -71,26 +85,38 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import() {
|
||||
assert_parse!(
|
||||
import,
|
||||
r#"
|
||||
use std/list
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unqualified_imports() {
|
||||
assert_parse!(
|
||||
unqualified_imports,
|
||||
r#"
|
||||
use std/address.{Address as A, thing as w}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import_alias() {
|
||||
assert_parse!(
|
||||
import_alias,
|
||||
r#"
|
||||
use std/tx as t
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_type() {
|
||||
assert_parse!(
|
||||
custom_type,
|
||||
r#"
|
||||
type Option<a> {
|
||||
Some(a, Int)
|
||||
|
@ -99,34 +125,49 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opaque_type() {
|
||||
assert_parse!(
|
||||
opaque_type,
|
||||
r#"
|
||||
pub opaque type User {
|
||||
name: _w
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_alias() {
|
||||
assert_parse!(
|
||||
type_alias,
|
||||
r#"
|
||||
type Thing = Option<Int>
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pub_type_alias() {
|
||||
assert_parse!(
|
||||
pub_type_alias,
|
||||
r#"
|
||||
pub type Me = Option<String>
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_function() {
|
||||
assert_parse!(
|
||||
empty_function,
|
||||
r#"
|
||||
pub fn run() {}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expect() {
|
||||
assert_parse!(
|
||||
expect,
|
||||
r#"
|
||||
pub fn run() {
|
||||
expect Some(x) = something.field
|
||||
|
@ -134,16 +175,22 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plus_binop() {
|
||||
assert_parse!(
|
||||
plus_binop,
|
||||
r#"
|
||||
pub fn add_one(a) -> Int {
|
||||
a + 1
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pipeline() {
|
||||
assert_parse!(
|
||||
pipeline,
|
||||
r#"
|
||||
pub fn thing(thing a: Int) {
|
||||
a + 2
|
||||
|
@ -152,8 +199,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn if_expression() {
|
||||
assert_parse!(
|
||||
if_expression,
|
||||
r#"
|
||||
fn ifs() {
|
||||
if True {
|
||||
|
@ -168,8 +218,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn let_bindings() {
|
||||
assert_parse!(
|
||||
let_bindings,
|
||||
r#"
|
||||
pub fn wow(a: Int) {
|
||||
let x =
|
||||
|
@ -185,8 +238,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn block() {
|
||||
assert_parse!(
|
||||
block,
|
||||
r#"
|
||||
pub fn wow2(a: Int){
|
||||
let b = {
|
||||
|
@ -199,8 +255,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn when() {
|
||||
assert_parse!(
|
||||
when,
|
||||
r#"
|
||||
pub fn wow2(a: Int){
|
||||
when a is {
|
||||
|
@ -215,8 +274,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn anonymous_function() {
|
||||
assert_parse!(
|
||||
anonymous_function,
|
||||
r#"
|
||||
pub fn such() -> Int {
|
||||
let add_one = fn (a: Int) -> Int { a + 1 }
|
||||
|
@ -225,16 +287,22 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn field_access() {
|
||||
assert_parse!(
|
||||
field_access,
|
||||
r#"
|
||||
fn name(user: User) {
|
||||
user.name
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call() {
|
||||
assert_parse!(
|
||||
call,
|
||||
r#"
|
||||
fn calls() {
|
||||
let x = add_one(3)
|
||||
|
@ -245,40 +313,55 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn record_update() {
|
||||
assert_parse!(
|
||||
record_update,
|
||||
r#"
|
||||
fn update_name(user: User, name: ByteArray) -> User {
|
||||
User { ..user, name: "Aiken", age }
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn record_create_labeled() {
|
||||
assert_parse!(
|
||||
record_create_labeled,
|
||||
r#"
|
||||
fn create() {
|
||||
User { name: "Aiken", age, thing: 2 }
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn record_create_labeled_with_field_access() {
|
||||
assert_parse!(
|
||||
record_create_labeled_with_field_access,
|
||||
r#"
|
||||
fn create() {
|
||||
some_module.User { name: "Aiken", age, thing: 2 }
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cargo_create_unlabeled() {
|
||||
assert_parse!(
|
||||
cargo_create_unlabeled,
|
||||
r#"
|
||||
fn create() {
|
||||
some_module.Thing(1, a)
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_tuple() {
|
||||
assert_parse!(
|
||||
parse_tuple,
|
||||
r#"
|
||||
fn foo() {
|
||||
let tuple = (1, 2, 3, 4)
|
||||
|
@ -286,8 +369,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_tuple2() {
|
||||
assert_parse!(
|
||||
parse_tuple2,
|
||||
r#"
|
||||
fn foo() {
|
||||
let a = foo(14)
|
||||
|
@ -295,14 +381,20 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plain_bytearray_literals() {
|
||||
assert_parse!(
|
||||
plain_bytearray_literals,
|
||||
r#"
|
||||
pub const my_policy_id = #[0, 170, 255]
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn base16_bytearray_literals() {
|
||||
assert_parse!(
|
||||
base16_bytearray_literals,
|
||||
r#"
|
||||
pub const my_policy_id = #"00aaff"
|
||||
|
||||
|
@ -311,22 +403,31 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_def() {
|
||||
assert_parse!(
|
||||
function_def,
|
||||
r#"
|
||||
fn foo() {}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_invoke() {
|
||||
assert_parse!(
|
||||
function_invoke,
|
||||
r#"
|
||||
fn foo() {
|
||||
let a = bar(42)
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_ambiguous_sequence() {
|
||||
assert_parse!(
|
||||
function_ambiguous_sequence,
|
||||
r#"
|
||||
fn foo_1() {
|
||||
let a = bar
|
||||
|
@ -348,22 +449,31 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuple_type_alias() {
|
||||
assert_parse!(
|
||||
tuple_type_alias,
|
||||
r#"
|
||||
type RoyaltyToken = (PolicyId, AssetName)
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn int_parsing_hex_bytes() {
|
||||
assert_parse!(
|
||||
int_parsing_hex_bytes,
|
||||
r#"
|
||||
fn foo() {
|
||||
#[ 0x01, 0xa2, 0x03 ]
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parsing_numeric_underscore() {
|
||||
assert_parse!(
|
||||
test_parsing_numeric_underscore,
|
||||
r#"
|
||||
fn foo() {
|
||||
let i = 1_234_567
|
||||
|
@ -372,8 +482,11 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn first_class_binop() {
|
||||
assert_parse!(
|
||||
first_class_binop,
|
||||
r#"
|
||||
fn foo() {
|
||||
compare_with(a, >, b)
|
||||
|
@ -392,6 +505,7 @@ assert_parse!(
|
|||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_unicode_offset_1() {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub fn such() -> Int {\n let add_one = fn (a: Int) -> Int { a + 1 }\n\n 2 |> add_one\n }\n "
|
||||
info: anonymous_function
|
||||
description: "Code:\n\npub fn such() -> Int {\n let add_one = fn (a: Int) -> Int { a + 1 }\n\n 2 |> add_one\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub const my_policy_id = #\"00aaff\"\n\n pub fn foo() {\n my_policy_id == #\"00aaff\"\n }\n "
|
||||
info: base16_bytearray_literals
|
||||
description: "Code:\n\npub const my_policy_id = #\"00aaff\"\n\npub fn foo() {\n my_policy_id == #\"00aaff\"\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub fn wow2(a: Int){\n let b = {\n let x = 4\n\n x + 5\n }\n\n b\n }\n "
|
||||
info: block
|
||||
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: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn 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 "
|
||||
info: call
|
||||
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: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n use aiken\n\n // some comment\n // more comments"
|
||||
info: can_handle_comments_at_end_of_file
|
||||
description: "Code:\n\nuse aiken\n\n// some comment\n// more comments"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn create() {\n some_module.Thing(1, a)\n }\n "
|
||||
info: cargo_create_unlabeled
|
||||
description: "Code:\n\nfn create() {\n some_module.Thing(1, a)\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n type Option<a> {\n Some(a, Int)\n None\n Wow { name: Int, age: Int }\n }\n "
|
||||
info: custom_type
|
||||
description: "Code:\n\ntype Option<a> {\n Some(a, Int)\n None\n Wow { name: Int, age: Int }\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n validator {\n fn foo(datum, rdmr, ctx) {\n True\n }\n\n fn bar(rdmr, ctx) {\n True\n }\n }\n "
|
||||
info: double_validator
|
||||
description: "Code:\n\nvalidator {\n fn foo(datum, rdmr, ctx) {\n True\n }\n\n fn bar(rdmr, ctx) {\n True\n }\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub fn run() {}\n "
|
||||
info: empty_function
|
||||
description: "Code:\n\npub fn run() {}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub fn run() {\n expect Some(x) = something.field\n x.other_field\n }\n "
|
||||
info: expect
|
||||
description: "Code:\n\npub fn run() {\n expect Some(x) = something.field\n x.other_field\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n !test invalid_inputs() {\n expect True = False\n\n False\n }\n "
|
||||
info: test_fail
|
||||
description: "Code:\n\n!test invalid_inputs() {\n expect True = False\n\n False\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn name(user: User) {\n user.name\n }\n "
|
||||
info: field_access
|
||||
description: "Code:\n\nfn name(user: User) {\n user.name\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn foo() {\n compare_with(a, >, b)\n compare_with(a, >=, b)\n compare_with(a, <, b)\n compare_with(a, <=, b)\n compare_with(a, ==, b)\n compare_with(a, !=, b)\n combine_with(a, &&, b)\n combine_with(a, ||, b)\n compute_with(a, +, b)\n compute_with(a, -, b)\n compute_with(a, /, b)\n compute_with(a, *, b)\n compute_with(a, %, b)\n }\n "
|
||||
info: first_class_binop
|
||||
description: "Code:\n\nfn foo() {\n compare_with(a, >, b)\n compare_with(a, >=, b)\n compare_with(a, <, b)\n compare_with(a, <=, b)\n compare_with(a, ==, b)\n compare_with(a, !=, b)\n combine_with(a, &&, b)\n combine_with(a, ||, b)\n compute_with(a, +, b)\n compute_with(a, -, b)\n compute_with(a, /, b)\n compute_with(a, *, b)\n compute_with(a, %, b)\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn foo_1() {\n let a = bar\n (40)\n }\n\n fn foo_2() {\n let a = bar\n {40}\n }\n\n fn foo_3() {\n let a = (40+2)\n }\n\n fn foo_4() {\n let a = bar(42)\n (a + 14) * 42\n }\n "
|
||||
info: function_ambiguous_sequence
|
||||
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: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn foo() {}\n "
|
||||
info: function_def
|
||||
description: "Code:\n\nfn foo() {}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn foo() {\n let a = bar(42)\n }\n "
|
||||
info: function_invoke
|
||||
description: "Code:\n\nfn foo() {\n let a = bar(42)\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn 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 "
|
||||
info: if_expression
|
||||
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: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n use std/list\n "
|
||||
info: import
|
||||
description: "Code:\n\nuse std/list\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n use std/tx as t\n "
|
||||
info: import_alias
|
||||
description: "Code:\n\nuse std/tx as t\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn foo() {\n #[ 0x01, 0xa2, 0x03 ]\n }\n "
|
||||
info: int_parsing_hex_bytes
|
||||
description: "Code:\n\nfn foo() {\n #[ 0x01, 0xa2, 0x03 ]\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub fn wow(a: Int) {\n let x =\n a + 2\n |> add_one\n |> add_one\n\n let thing = [ 1, 2, a ]\n\n let idk = thing\n\n y\n }\n "
|
||||
info: let_bindings
|
||||
description: "Code:\n\npub fn wow(a: Int) {\n let x =\n a + 2\n |> add_one\n |> add_one\n\n let thing = [ 1, 2, a ]\n\n let idk = thing\n\n y\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub opaque type User {\n name: _w\n }\n "
|
||||
info: opaque_type
|
||||
description: "Code:\n\npub opaque type User {\n name: _w\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn foo() {\n let tuple = (1, 2, 3, 4)\n tuple.1st + tuple.2nd + tuple.3rd + tuple.4th\n }\n "
|
||||
info: parse_tuple
|
||||
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: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn foo() {\n let a = foo(14)\n (a, 42)\n }\n "
|
||||
info: parse_tuple2
|
||||
description: "Code:\n\nfn foo() {\n let a = foo(14)\n (a, 42)\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn foo() {\n let i = 1_234_567\n let j = 1_000_000\n let k = -10_000\n }\n "
|
||||
info: test_parsing_numeric_underscore
|
||||
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: "",
|
||||
|
@ -12,47 +11,47 @@ Module {
|
|||
Function {
|
||||
arguments: [],
|
||||
body: Sequence {
|
||||
location: 17..76,
|
||||
location: 13..68,
|
||||
expressions: [
|
||||
Assignment {
|
||||
location: 17..34,
|
||||
location: 13..30,
|
||||
value: Int {
|
||||
location: 25..34,
|
||||
location: 21..30,
|
||||
value: "1234567",
|
||||
base: Decimal {
|
||||
numeric_underscore: true,
|
||||
},
|
||||
},
|
||||
pattern: Var {
|
||||
location: 21..22,
|
||||
location: 17..18,
|
||||
name: "i",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
Assignment {
|
||||
location: 39..56,
|
||||
location: 33..50,
|
||||
value: Int {
|
||||
location: 47..56,
|
||||
location: 41..50,
|
||||
value: "1000000",
|
||||
base: Decimal {
|
||||
numeric_underscore: true,
|
||||
},
|
||||
},
|
||||
pattern: Var {
|
||||
location: 43..44,
|
||||
location: 37..38,
|
||||
name: "j",
|
||||
},
|
||||
kind: Let,
|
||||
annotation: None,
|
||||
},
|
||||
Assignment {
|
||||
location: 61..76,
|
||||
location: 53..68,
|
||||
value: UnOp {
|
||||
op: Negate,
|
||||
location: 69..76,
|
||||
location: 61..68,
|
||||
value: Int {
|
||||
location: 70..76,
|
||||
location: 62..68,
|
||||
value: "10000",
|
||||
base: Decimal {
|
||||
numeric_underscore: true,
|
||||
|
@ -60,7 +59,7 @@ Module {
|
|||
},
|
||||
},
|
||||
pattern: Var {
|
||||
location: 65..66,
|
||||
location: 57..58,
|
||||
name: "k",
|
||||
},
|
||||
kind: Let,
|
||||
|
@ -69,12 +68,12 @@ Module {
|
|||
],
|
||||
},
|
||||
doc: None,
|
||||
location: 2..10,
|
||||
location: 0..8,
|
||||
name: "foo",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 77,
|
||||
end_position: 69,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub fn thing(thing a: Int) {\n a + 2\n |> add_one\n |> add_one\n }\n "
|
||||
info: pipeline
|
||||
description: "Code:\n\npub fn thing(thing a: Int) {\n a + 2\n |> add_one\n |> add_one\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub const my_policy_id = #[0, 170, 255]\n "
|
||||
info: plain_bytearray_literals
|
||||
description: "Code:\n\npub const my_policy_id = #[0, 170, 255]\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub fn add_one(a) -> Int {\n a + 1\n }\n "
|
||||
info: plus_binop
|
||||
description: "Code:\n\npub fn add_one(a) -> Int {\n a + 1\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub type Me = Option<String>\n "
|
||||
info: pub_type_alias
|
||||
description: "Code:\n\npub type Me = Option<String>\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn create() {\n User { name: \"Aiken\", age, thing: 2 }\n }\n "
|
||||
info: record_create_labeled
|
||||
description: "Code:\n\nfn create() {\n User { name: \"Aiken\", age, thing: 2 }\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn create() {\n some_module.User { name: \"Aiken\", age, thing: 2 }\n }\n "
|
||||
info: record_create_labeled_with_field_access
|
||||
description: "Code:\n\nfn create() {\n some_module.User { name: \"Aiken\", age, thing: 2 }\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n fn update_name(user: User, name: ByteArray) -> User {\n User { ..user, name: \"Aiken\", age }\n }\n "
|
||||
info: record_update
|
||||
description: "Code:\n\nfn update_name(user: User, name: ByteArray) -> User {\n User { ..user, name: \"Aiken\", age }\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n type RoyaltyToken = (PolicyId, AssetName)\n "
|
||||
info: tuple_type_alias
|
||||
description: "Code:\n\ntype RoyaltyToken = (PolicyId, AssetName)\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n type Thing = Option<Int>\n "
|
||||
info: type_alias
|
||||
description: "Code:\n\ntype Thing = Option<Int>\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n use aiken\n\n pub fn go() -> aiken.Option<Int> {\n False\n }\n "
|
||||
info: type_annotation_with_module_prefix
|
||||
description: "Code:\n\nuse aiken\n\npub fn go() -> aiken.Option<Int> {\n False\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n use std/address.{Address as A, thing as w}\n "
|
||||
info: unqualified_imports
|
||||
description: "Code:\n\nuse std/address.{Address as A, thing as w}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n validator {\n fn foo(datum, rdmr, ctx) {\n True\n }\n }\n "
|
||||
info: validator
|
||||
description: "Code:\n\nvalidator {\n fn foo(datum, rdmr, ctx) {\n True\n }\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "\n pub 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 "
|
||||
info: when
|
||||
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: "",
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "use aiken/list\r\n"
|
||||
info: windows_newline
|
||||
description: "Code:\n\nuse aiken/list\r\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
Loading…
Reference in New Issue