From 01de41b69539b164a574fef7e88ed2d8b95dbf79 Mon Sep 17 00:00:00 2001 From: peefy Date: Wed, 17 Jan 2024 13:59:09 +0800 Subject: [PATCH] fix: parser and ast crate test cases Signed-off-by: peefy --- kclvm/ast/src/ast.rs | 2 +- kclvm/ast/src/tests.rs | 2 +- ...kclvm_parser__tests__ast__schema_stmt.snap | 12 ++++---- ...vm_parser__tests__file__config_expr_4.snap | 10 +++---- .../kclvm_parser__tests__file__hello_win.snap | 2 +- .../kclvm_parser__tests__file__type_1.snap | 28 +++++++++---------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/kclvm/ast/src/ast.rs b/kclvm/ast/src/ast.rs index fb9a8eb1f..8b628761f 100644 --- a/kclvm/ast/src/ast.rs +++ b/kclvm/ast/src/ast.rs @@ -1583,7 +1583,7 @@ pub enum ExprContext { /// A expression #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] +#[serde(tag = "type", content = "value")] pub enum Type { Any, Named(Identifier), diff --git a/kclvm/ast/src/tests.rs b/kclvm/ast/src/tests.rs index c01922d1f..ebaa19797 100644 --- a/kclvm/ast/src/tests.rs +++ b/kclvm/ast/src/tests.rs @@ -81,7 +81,7 @@ fn get_dummy_assign_binary_ast() -> ast::Node { ))], value: Box::new(ast::Node::new( ast::Expr::Binary(ast::BinaryExpr { - op: ast::BinOrCmpOp::Bin(ast::BinOp::Add), + op: ast::BinOp::Add, left: Box::new(ast::Node::new( ast::Expr::Identifier(ast::Identifier { names: vec![Node::dummy_node(String::from("a"))], diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__schema_stmt.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__schema_stmt.snap index 9d988c366..fe180f810 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__schema_stmt.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__schema_stmt.snap @@ -70,7 +70,7 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "ty": { "node": { "type": "Basic", - "data": "Int" + "value": "Int" }, "filename": "hello.k", "line": 8, @@ -104,7 +104,7 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "ty": { "node": { "type": "Basic", - "data": "Str" + "value": "Str" }, "filename": "hello.k", "line": 9, @@ -152,7 +152,7 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "ty": { "node": { "type": "Basic", - "data": "Int" + "value": "Int" }, "filename": "hello.k", "line": 10, @@ -198,7 +198,7 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "ty": { "node": { "type": "Basic", - "data": "Str" + "value": "Str" }, "filename": "hello.k", "line": 11, @@ -877,7 +877,7 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "key_ty": { "node": { "type": "Basic", - "data": "Str" + "value": "Str" }, "filename": "hello.k", "line": 7, @@ -888,7 +888,7 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "value_ty": { "node": { "type": "Basic", - "data": "Int" + "value": "Int" }, "filename": "hello.k", "line": 7, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_4.snap index ac40f33f7..1f4a8ab74 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_4.snap @@ -46,7 +46,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" "ty": { "node": { "type": "Basic", - "data": "Str" + "value": "Str" }, "filename": "config_expr-04.k", "line": 4, @@ -80,7 +80,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" "ty": { "node": { "type": "Basic", - "data": "Str" + "value": "Str" }, "filename": "config_expr-04.k", "line": 5, @@ -144,11 +144,11 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" "ty": { "node": { "type": "List", - "data": { + "value": { "inner_type": { "node": { "type": "Named", - "data": { + "value": { "names": [ { "node": "Env", @@ -233,7 +233,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" "ty": { "node": { "type": "Named", - "data": { + "value": { "names": [ { "node": "Main", diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__hello_win.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__hello_win.snap index 7cf74c85f..760a592b0 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__hello_win.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__hello_win.snap @@ -58,7 +58,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/hello_win.k\")" "ty": { "node": { "type": "Basic", - "data": "Str" + "value": "Str" }, "filename": "hello_win.k", "line": 3, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__type_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__type_1.snap index d230d3380..91ac6fa3a 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__type_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__type_1.snap @@ -92,7 +92,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" "ty": { "node": { "type": "Basic", - "data": "Bool" + "value": "Bool" }, "filename": "type-01.k", "line": 3, @@ -142,7 +142,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" "ty": { "node": { "type": "Basic", - "data": "Int" + "value": "Int" }, "filename": "type-01.k", "line": 4, @@ -192,7 +192,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" "ty": { "node": { "type": "Basic", - "data": "Float" + "value": "Float" }, "filename": "type-01.k", "line": 5, @@ -242,7 +242,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" "ty": { "node": { "type": "Basic", - "data": "Str" + "value": "Str" }, "filename": "type-01.k", "line": 6, @@ -292,7 +292,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" "ty": { "node": { "type": "List", - "data": { + "value": { "inner_type": null } }, @@ -344,11 +344,11 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" "ty": { "node": { "type": "List", - "data": { + "value": { "inner_type": { "node": { "type": "List", - "data": { + "value": { "inner_type": null } }, @@ -408,11 +408,11 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" "ty": { "node": { "type": "List", - "data": { + "value": { "inner_type": { "node": { "type": "Basic", - "data": "Int" + "value": "Int" }, "filename": "type-01.k", "line": 10, @@ -470,12 +470,12 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" "ty": { "node": { "type": "Union", - "data": { + "value": { "type_elements": [ { "node": { "type": "Basic", - "data": "Int" + "value": "Int" }, "filename": "type-01.k", "line": 12, @@ -486,7 +486,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "Basic", - "data": "Str" + "value": "Str" }, "filename": "type-01.k", "line": 12, @@ -497,7 +497,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "List", - "data": { + "value": { "inner_type": null } }, @@ -510,7 +510,7 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "Dict", - "data": { + "value": { "key_type": null, "value_type": null }