Skip to content

Commit f28c8c1

Browse files
committed
test: additional functions parameters tests
1 parent 959daec commit f28c8c1

3 files changed

+78
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
source: src/syntax_analysis/tests.rs
3+
expression: returned_abstract_syntax_tree
4+
---
5+
{
6+
"abstract_syntax_tree": [
7+
{
8+
"EXPRESSION": {
9+
"expression": {
10+
"FUNCTION": {
11+
"parameters": [],
12+
"block": {
13+
"BLOCK": {
14+
"blocks": []
15+
}
16+
}
17+
}
18+
}
19+
}
20+
}
21+
],
22+
"syntax_parsing_errors": []
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
source: src/syntax_analysis/tests.rs
3+
expression: returned_abstract_syntax_tree
4+
---
5+
{
6+
"abstract_syntax_tree": [
7+
{
8+
"EXPRESSION": {
9+
"expression": {
10+
"FUNCTION": {
11+
"parameters": [
12+
{
13+
"IDENTIFIER": {
14+
"identifier_token": {
15+
"token_type": "IDENTIFIER",
16+
"literal": "x"
17+
}
18+
}
19+
}
20+
],
21+
"block": {
22+
"BLOCK": {
23+
"blocks": []
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
],
31+
"syntax_parsing_errors": []
32+
}

src/syntax_analysis/tests.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ use rstest::rstest;
2525
],
2626
"test_syntax_analysis_for_function_expression_case1"
2727
),
28+
case(
29+
vec![
30+
Token{token_type: TokenType::FUNCTION, literal: "fn".to_string()},
31+
Token{token_type: TokenType::OPENING_ROUND_BRACKET, literal: "(".to_string()},
32+
Token{token_type: TokenType::CLOSING_ROUND_BRACKET, literal: ")".to_string()},
33+
Token{token_type: TokenType::OPENING_CURLY_BRACKET, literal: "{".to_string()},
34+
Token{token_type: TokenType::CLOSING_CURLY_BRACKET, literal: "}".to_string()},
35+
Token{token_type: TokenType::EOF, literal: "".to_string()},
36+
],
37+
"test_syntax_analysis_for_function_expression_case2"
38+
),
39+
case(
40+
vec![
41+
Token{token_type: TokenType::FUNCTION, literal: "fn".to_string()},
42+
Token{token_type: TokenType::OPENING_ROUND_BRACKET, literal: "(".to_string()},
43+
Token{token_type: TokenType::IDENTIFIER, literal: "x".to_string()},
44+
Token{token_type: TokenType::CLOSING_ROUND_BRACKET, literal: ")".to_string()},
45+
Token{token_type: TokenType::OPENING_CURLY_BRACKET, literal: "{".to_string()},
46+
Token{token_type: TokenType::CLOSING_CURLY_BRACKET, literal: "}".to_string()},
47+
Token{token_type: TokenType::EOF, literal: "".to_string()},
48+
],
49+
"test_syntax_analysis_for_function_expression_case3"
50+
),
2851
)]
2952
fn test_syntax_analysis_for_function_expression(tokens: Vec<Token>, snapshot_name: &str) {
3053
assert_expected_returned_abstract_syntax_tree(tokens, snapshot_name);

0 commit comments

Comments
 (0)