Files
modeling-app/rust/kcl-lib/tests/if_else/ast.snap

582 lines
15 KiB
Plaintext
Raw Normal View History

---
source: kcl-lib/src/simulation_tests.rs
description: Result of parsing if_else.kcl
---
{
"Ok": {
"body": [
{
"declaration": {
"end": 0,
"id": {
"end": 0,
"name": "a",
"start": 0,
"type": "Identifier"
},
"init": {
"cond": {
"end": 0,
"raw": "true",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": true
},
"digest": null,
"else_ifs": [
{
"cond": {
"end": 0,
"raw": "true",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": true
},
"digest": null,
"end": 0,
"start": 0,
"then_val": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "4",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 4.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"type": "ElseIf"
}
],
"end": 0,
"final_else": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 5.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"start": 0,
"then_val": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "3",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"type": "IfExpression",
"type": "IfExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 0,
"expression": {
"arguments": [
{
"end": 0,
"name": "a",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 0,
"raw": "3",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
{
"end": 0,
"raw": "0.001",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.001,
"suffix": "None"
}
},
{
"end": 0,
"raw": "\"the 'if' branch gets returned\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "the 'if' branch gets returned"
}
],
"callee": {
"end": 0,
"name": "assertEqual",
"start": 0,
"type": "Identifier"
},
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"declaration": {
"end": 0,
"id": {
"end": 0,
"name": "b",
"start": 0,
"type": "Identifier"
},
"init": {
"cond": {
"end": 0,
"raw": "false",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": false
},
"digest": null,
"else_ifs": [
{
"cond": {
"end": 0,
"raw": "true",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": true
},
"digest": null,
"end": 0,
"start": 0,
"then_val": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "4",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 4.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"type": "ElseIf"
}
],
"end": 0,
"final_else": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 5.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"start": 0,
"then_val": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "3",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"type": "IfExpression",
"type": "IfExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 0,
"expression": {
"arguments": [
{
"end": 0,
"name": "b",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 0,
"raw": "4",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 4.0,
"suffix": "None"
}
},
{
"end": 0,
"raw": "0.001",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.001,
"suffix": "None"
}
},
{
"end": 0,
"raw": "\"the 'else if' branch gets returned\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "the 'else if' branch gets returned"
}
],
"callee": {
"end": 0,
"name": "assertEqual",
"start": 0,
"type": "Identifier"
},
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"declaration": {
"end": 0,
"id": {
"end": 0,
"name": "c",
"start": 0,
"type": "Identifier"
},
"init": {
"cond": {
"end": 0,
"raw": "false",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": false
},
"digest": null,
"else_ifs": [
{
"cond": {
"end": 0,
"raw": "false",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": false
},
"digest": null,
"end": 0,
"start": 0,
"then_val": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "4",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 4.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"type": "ElseIf"
}
],
"end": 0,
"final_else": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 5.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"start": 0,
"then_val": {
"body": [
{
"end": 0,
"expression": {
"end": 0,
"raw": "3",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"start": 0
},
"type": "IfExpression",
"type": "IfExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 0,
"expression": {
"arguments": [
{
"end": 0,
"name": "c",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 0,
"raw": "5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 5.0,
"suffix": "None"
}
},
{
"end": 0,
"raw": "0.001",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.001,
"suffix": "None"
}
},
{
"end": 0,
"raw": "\"the 'else' branch gets returned\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "the 'else' branch gets returned"
}
],
"callee": {
"end": 0,
"name": "assertEqual",
"start": 0,
"type": "Identifier"
},
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 0,
"nonCodeMeta": {
"nonCodeNodes": {
"1": [
{
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"3": [
{
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": [
{
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
"value": "This tests evaluating if-else expressions.",
"style": "line"
}
},
{
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"start": 0
}
}