Skip to content

Commit c873b23

Browse files
committed
feat: add test case to astsexplorer
close #48
1 parent 89faebe commit c873b23

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

parser/ast_tree_test.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,74 +13,84 @@ mod tests {
1313
assert_snapshot!(name, ast, input);
1414
}
1515

16+
// https://astexplorer.net/#/gist/3a8ce5192e08ab973d255db5295671b1/831267b339e5562244c88f88587744153fbcfb6b
1617
#[test]
1718
fn test_let() {
1819
let input = "let a = 3";
1920
test_ast_tree("test_let", input)
2021
}
2122

23+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/f462e81e4940309f2c6a694a3bdedd283e7b035d
2224
#[test]
2325
fn test_string() {
2426
let input = r#""jw""#;
2527
test_ast_tree("test_string", input)
2628
}
2729

30+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/e74ab41b095abe19f2dd0c0398ffae94674d0a8c
2831
#[test]
2932
fn test_array() {
3033
let input = "[1, true]";
3134
test_ast_tree("test_array", input)
3235
}
3336

37+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/9263c8a45953e56d209597e90299547a733622a9
3438
#[test]
3539
fn test_hash() {
3640
let input = r#"{"a": 1}"#;
3741
test_ast_tree("test_hash", input)
3842
}
3943

44+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/ebbaf31807ccdcec6605aaa2d3a222258cac7f28
4045
#[test]
4146
fn test_return() {
4247
let input = "return 3";
4348
test_ast_tree("test_return", input)
4449
}
4550

51+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/5bf612e5f406bc59076f54371671af05022a74d0
4652
#[test]
4753
fn test_unary() {
4854
let input = "-3";
4955
test_ast_tree("test_unary", input)
5056
}
5157

58+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/7a2707a45fffc15d322807ffa2738b16b2690a67
5259
#[test]
5360
fn test_binary() {
5461
let input = "1 + 2 * 3";
5562
test_ast_tree("test_binary", input)
5663
}
5764

65+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/ab013f6feb719e8bece669b375c8b2d43f2231d0
5866
#[test]
5967
fn test_binary_nested() {
6068
let input = "1+2+3";
6169
test_ast_tree("test_binary_nested", input)
6270
}
6371

72+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/25ae0e103e732ace3d443a4bf0c620a44bedcd55
6473
#[test]
6574
fn test_if() {
6675
let input = "if (x < y) { x } else { y }";
6776
test_ast_tree("test_if", input)
6877
}
6978

79+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/9f5b73a95afba5c5300f67ac69f837048da77750
7080
#[test]
7181
fn test_func_declaration() {
7282
let input = "fn(x) { x };";
7383
test_ast_tree("test_func_declaration", input)
7484
}
7585

76-
// JS: https://astexplorer.net/#/gist/b263eabba126aba94f1ad1c00ccce45e/2eb24376e622e07cf04915ee7eea1bc1c49d6122
86+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/3213bab3987673584c55b2f5ff4d723369aecd8d
7787
#[test]
7888
fn test_func_call() {
7989
let input = "add(1, 2)";
8090
test_ast_tree("test_func_call", input)
8191
}
8292

83-
// JS: https://astexplorer.net/#/gist/785eba71d71896939d5e91e0d445d357/a7bc3d915da84c16313da691a42b4a410fc3eef0
93+
// https://astexplorer.net/#/gist/0911a07ddb31d261074d1d59f6291a7c/3d5d8bfe7ec5b192674f46211408a07d88d14c65
8494
#[test]
8595
fn test_index() {
8696
let input = "a[1]";

0 commit comments

Comments
 (0)