--- source: kcl-lib/src/simulation_tests.rs description: Result of parsing if_else.kcl --- { "Ok": { "body": [ { "commentStart": 0, "declaration": { "commentStart": 48, "end": 0, "id": { "commentStart": 48, "end": 0, "name": "a", "start": 0, "type": "Identifier" }, "init": { "commentStart": 52, "cond": { "commentStart": 55, "end": 0, "raw": "true", "start": 0, "type": "Literal", "type": "Literal", "value": true }, "digest": null, "else_ifs": [ { "commentStart": 68, "cond": { "commentStart": 76, "end": 0, "raw": "true", "start": 0, "type": "Literal", "type": "Literal", "value": true }, "digest": null, "end": 0, "start": 0, "then_val": { "body": [ { "commentStart": 85, "end": 0, "expression": { "commentStart": 85, "end": 0, "raw": "4", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 4.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 81, "end": 0, "start": 0 }, "type": "ElseIf" } ], "end": 0, "final_else": { "body": [ { "commentStart": 98, "end": 0, "expression": { "commentStart": 98, "end": 0, "raw": "5", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 5.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 98, "end": 0, "start": 0 }, "start": 0, "then_val": { "body": [ { "commentStart": 64, "end": 0, "expression": { "commentStart": 64, "end": 0, "raw": "3", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 3.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 64, "end": 0, "start": 0 }, "type": "IfExpression", "type": "IfExpression" }, "start": 0, "type": "VariableDeclarator" }, "end": 0, "kind": "const", "start": 0, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "commentStart": 102, "end": 0, "expression": { "arguments": [ { "abs_path": false, "commentStart": 114, "end": 0, "name": { "commentStart": 114, "end": 0, "name": "a", "start": 0, "type": "Identifier" }, "path": [], "start": 0, "type": "Name", "type": "Name" }, { "commentStart": 117, "end": 0, "raw": "3", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 3.0, "suffix": "None" } }, { "commentStart": 120, "end": 0, "raw": "0.001", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 0.001, "suffix": "None" } }, { "commentStart": 127, "end": 0, "raw": "\"the 'if' branch gets returned\"", "start": 0, "type": "Literal", "type": "Literal", "value": "the 'if' branch gets returned" } ], "callee": { "abs_path": false, "commentStart": 102, "end": 0, "name": { "commentStart": 102, "end": 0, "name": "assertEqual", "start": 0, "type": "Identifier" }, "path": [], "start": 0, "type": "Name" }, "commentStart": 102, "end": 0, "start": 0, "type": "CallExpression", "type": "CallExpression" }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" }, { "commentStart": 159, "declaration": { "commentStart": 161, "end": 0, "id": { "commentStart": 161, "end": 0, "name": "b", "start": 0, "type": "Identifier" }, "init": { "commentStart": 165, "cond": { "commentStart": 168, "end": 0, "raw": "false", "start": 0, "type": "Literal", "type": "Literal", "value": false }, "digest": null, "else_ifs": [ { "commentStart": 182, "cond": { "commentStart": 190, "end": 0, "raw": "true", "start": 0, "type": "Literal", "type": "Literal", "value": true }, "digest": null, "end": 0, "start": 0, "then_val": { "body": [ { "commentStart": 199, "end": 0, "expression": { "commentStart": 199, "end": 0, "raw": "4", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 4.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 195, "end": 0, "start": 0 }, "type": "ElseIf" } ], "end": 0, "final_else": { "body": [ { "commentStart": 212, "end": 0, "expression": { "commentStart": 212, "end": 0, "raw": "5", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 5.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 212, "end": 0, "start": 0 }, "start": 0, "then_val": { "body": [ { "commentStart": 178, "end": 0, "expression": { "commentStart": 178, "end": 0, "raw": "3", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 3.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 178, "end": 0, "start": 0 }, "type": "IfExpression", "type": "IfExpression" }, "start": 0, "type": "VariableDeclarator" }, "end": 0, "kind": "const", "start": 0, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "commentStart": 216, "end": 0, "expression": { "arguments": [ { "abs_path": false, "commentStart": 228, "end": 0, "name": { "commentStart": 228, "end": 0, "name": "b", "start": 0, "type": "Identifier" }, "path": [], "start": 0, "type": "Name", "type": "Name" }, { "commentStart": 231, "end": 0, "raw": "4", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 4.0, "suffix": "None" } }, { "commentStart": 234, "end": 0, "raw": "0.001", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 0.001, "suffix": "None" } }, { "commentStart": 241, "end": 0, "raw": "\"the 'else if' branch gets returned\"", "start": 0, "type": "Literal", "type": "Literal", "value": "the 'else if' branch gets returned" } ], "callee": { "abs_path": false, "commentStart": 216, "end": 0, "name": { "commentStart": 216, "end": 0, "name": "assertEqual", "start": 0, "type": "Identifier" }, "path": [], "start": 0, "type": "Name" }, "commentStart": 216, "end": 0, "start": 0, "type": "CallExpression", "type": "CallExpression" }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" }, { "commentStart": 278, "declaration": { "commentStart": 280, "end": 0, "id": { "commentStart": 280, "end": 0, "name": "c", "start": 0, "type": "Identifier" }, "init": { "commentStart": 284, "cond": { "commentStart": 287, "end": 0, "raw": "false", "start": 0, "type": "Literal", "type": "Literal", "value": false }, "digest": null, "else_ifs": [ { "commentStart": 301, "cond": { "commentStart": 309, "end": 0, "raw": "false", "start": 0, "type": "Literal", "type": "Literal", "value": false }, "digest": null, "end": 0, "start": 0, "then_val": { "body": [ { "commentStart": 319, "end": 0, "expression": { "commentStart": 319, "end": 0, "raw": "4", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 4.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 315, "end": 0, "start": 0 }, "type": "ElseIf" } ], "end": 0, "final_else": { "body": [ { "commentStart": 332, "end": 0, "expression": { "commentStart": 332, "end": 0, "raw": "5", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 5.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 332, "end": 0, "start": 0 }, "start": 0, "then_val": { "body": [ { "commentStart": 297, "end": 0, "expression": { "commentStart": 297, "end": 0, "raw": "3", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 3.0, "suffix": "None" } }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 297, "end": 0, "start": 0 }, "type": "IfExpression", "type": "IfExpression" }, "start": 0, "type": "VariableDeclarator" }, "end": 0, "kind": "const", "start": 0, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "commentStart": 336, "end": 0, "expression": { "arguments": [ { "abs_path": false, "commentStart": 348, "end": 0, "name": { "commentStart": 348, "end": 0, "name": "c", "start": 0, "type": "Identifier" }, "path": [], "start": 0, "type": "Name", "type": "Name" }, { "commentStart": 351, "end": 0, "raw": "5", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 5.0, "suffix": "None" } }, { "commentStart": 354, "end": 0, "raw": "0.001", "start": 0, "type": "Literal", "type": "Literal", "value": { "value": 0.001, "suffix": "None" } }, { "commentStart": 361, "end": 0, "raw": "\"the 'else' branch gets returned\"", "start": 0, "type": "Literal", "type": "Literal", "value": "the 'else' branch gets returned" } ], "callee": { "abs_path": false, "commentStart": 336, "end": 0, "name": { "commentStart": 336, "end": 0, "name": "assertEqual", "start": 0, "type": "Identifier" }, "path": [], "start": 0, "type": "Name" }, "commentStart": 336, "end": 0, "start": 0, "type": "CallExpression", "type": "CallExpression" }, "start": 0, "type": "ExpressionStatement", "type": "ExpressionStatement" } ], "commentStart": 0, "end": 0, "nonCodeMeta": { "nonCodeNodes": { "1": [ { "commentStart": 159, "end": 0, "start": 0, "type": "NonCodeNode", "value": { "type": "newLine" } } ], "3": [ { "commentStart": 278, "end": 0, "start": 0, "type": "NonCodeNode", "value": { "type": "newLine" } } ] }, "startNodes": [ { "commentStart": 0, "end": 0, "start": 0, "type": "NonCodeNode", "value": { "type": "blockComment", "value": "This tests evaluating if-else expressions.", "style": "line" } }, { "commentStart": 45, "end": 0, "start": 0, "type": "NonCodeNode", "value": { "type": "newLine" } } ] }, "start": 0 } }