test(parser): move over the validator tests and some misc tests to parser
This commit is contained in:
@@ -1,20 +1,4 @@
|
||||
use crate::{assert_module, ast, parser};
|
||||
|
||||
#[test]
|
||||
fn windows_newline() {
|
||||
assert_module!("use aiken/list\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_handle_comments_at_end_of_file() {
|
||||
assert_module!(
|
||||
r#"
|
||||
use aiken
|
||||
|
||||
// some comment
|
||||
// more comments"#
|
||||
);
|
||||
}
|
||||
use crate::assert_module;
|
||||
|
||||
#[test]
|
||||
fn type_annotation_with_module_prefix() {
|
||||
@@ -42,45 +26,6 @@ fn test_fail() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validator() {
|
||||
assert_module!(
|
||||
r#"
|
||||
validator {
|
||||
fn foo(datum, rdmr, ctx) {
|
||||
True
|
||||
}
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn double_validator() {
|
||||
assert_module!(
|
||||
r#"
|
||||
validator {
|
||||
fn foo(datum, rdmr, ctx) {
|
||||
True
|
||||
}
|
||||
|
||||
fn bar(rdmr, ctx) {
|
||||
True
|
||||
}
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import_alias() {
|
||||
assert_module!(
|
||||
r#"
|
||||
use std/tx as t
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_type() {
|
||||
assert_module!(
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nuse aiken\n\n// some comment\n// more comments"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Use(
|
||||
Use {
|
||||
as_name: None,
|
||||
location: 0..9,
|
||||
module: [
|
||||
"aiken",
|
||||
],
|
||||
package: (),
|
||||
unqualified: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
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: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Validator(
|
||||
Validator {
|
||||
doc: None,
|
||||
end_position: 90,
|
||||
fun: Function {
|
||||
arguments: [
|
||||
Arg {
|
||||
arg_name: Named {
|
||||
name: "datum",
|
||||
label: "datum",
|
||||
location: 21..26,
|
||||
is_validator_param: false,
|
||||
},
|
||||
location: 21..26,
|
||||
annotation: None,
|
||||
tipo: (),
|
||||
},
|
||||
Arg {
|
||||
arg_name: Named {
|
||||
name: "rdmr",
|
||||
label: "rdmr",
|
||||
location: 28..32,
|
||||
is_validator_param: false,
|
||||
},
|
||||
location: 28..32,
|
||||
annotation: None,
|
||||
tipo: (),
|
||||
},
|
||||
Arg {
|
||||
arg_name: Named {
|
||||
name: "ctx",
|
||||
label: "ctx",
|
||||
location: 34..37,
|
||||
is_validator_param: false,
|
||||
},
|
||||
location: 34..37,
|
||||
annotation: None,
|
||||
tipo: (),
|
||||
},
|
||||
],
|
||||
body: Var {
|
||||
location: 45..49,
|
||||
name: "True",
|
||||
},
|
||||
doc: None,
|
||||
location: 14..38,
|
||||
name: "foo",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 52,
|
||||
can_error: true,
|
||||
},
|
||||
other_fun: Some(
|
||||
Function {
|
||||
arguments: [
|
||||
Arg {
|
||||
arg_name: Named {
|
||||
name: "rdmr",
|
||||
label: "rdmr",
|
||||
location: 64..68,
|
||||
is_validator_param: false,
|
||||
},
|
||||
location: 64..68,
|
||||
annotation: None,
|
||||
tipo: (),
|
||||
},
|
||||
Arg {
|
||||
arg_name: Named {
|
||||
name: "ctx",
|
||||
label: "ctx",
|
||||
location: 70..73,
|
||||
is_validator_param: false,
|
||||
},
|
||||
location: 70..73,
|
||||
annotation: None,
|
||||
tipo: (),
|
||||
},
|
||||
],
|
||||
body: Var {
|
||||
location: 81..85,
|
||||
name: "True",
|
||||
},
|
||||
doc: None,
|
||||
location: 57..74,
|
||||
name: "bar",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 88,
|
||||
can_error: true,
|
||||
},
|
||||
),
|
||||
location: 0..9,
|
||||
params: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nuse std/tx as t\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Use(
|
||||
Use {
|
||||
as_name: Some(
|
||||
"t",
|
||||
),
|
||||
location: 0..15,
|
||||
module: [
|
||||
"std",
|
||||
"tx",
|
||||
],
|
||||
package: (),
|
||||
unqualified: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nvalidator {\n fn foo(datum, rdmr, ctx) {\n True\n }\n}\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Validator(
|
||||
Validator {
|
||||
doc: None,
|
||||
end_position: 54,
|
||||
fun: Function {
|
||||
arguments: [
|
||||
Arg {
|
||||
arg_name: Named {
|
||||
name: "datum",
|
||||
label: "datum",
|
||||
location: 21..26,
|
||||
is_validator_param: false,
|
||||
},
|
||||
location: 21..26,
|
||||
annotation: None,
|
||||
tipo: (),
|
||||
},
|
||||
Arg {
|
||||
arg_name: Named {
|
||||
name: "rdmr",
|
||||
label: "rdmr",
|
||||
location: 28..32,
|
||||
is_validator_param: false,
|
||||
},
|
||||
location: 28..32,
|
||||
annotation: None,
|
||||
tipo: (),
|
||||
},
|
||||
Arg {
|
||||
arg_name: Named {
|
||||
name: "ctx",
|
||||
label: "ctx",
|
||||
location: 34..37,
|
||||
is_validator_param: false,
|
||||
},
|
||||
location: 34..37,
|
||||
annotation: None,
|
||||
tipo: (),
|
||||
},
|
||||
],
|
||||
body: Var {
|
||||
location: 45..49,
|
||||
name: "True",
|
||||
},
|
||||
doc: None,
|
||||
location: 14..38,
|
||||
name: "foo",
|
||||
public: false,
|
||||
return_annotation: None,
|
||||
return_type: (),
|
||||
end_position: 52,
|
||||
can_error: true,
|
||||
},
|
||||
other_fun: None,
|
||||
location: 0..9,
|
||||
params: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
description: "Code:\n\nuse aiken/list\r\n"
|
||||
---
|
||||
Module {
|
||||
name: "",
|
||||
docs: [],
|
||||
type_info: (),
|
||||
definitions: [
|
||||
Use(
|
||||
Use {
|
||||
as_name: None,
|
||||
location: 0..14,
|
||||
module: [
|
||||
"aiken",
|
||||
"list",
|
||||
],
|
||||
package: (),
|
||||
unqualified: [],
|
||||
},
|
||||
),
|
||||
],
|
||||
kind: Validator,
|
||||
}
|
||||
Reference in New Issue
Block a user