---
source: kcl/src/simulation_tests.rs
description: Result of parsing if_else.kcl
---
{
  "Ok": {
    "body": [
      {
        "declaration": {
          "end": 101,
          "id": {
            "end": 49,
            "name": "a",
            "start": 48,
            "type": "Identifier"
          },
          "init": {
            "cond": {
              "end": 59,
              "raw": "true",
              "start": 55,
              "type": "Literal",
              "type": "Literal",
              "value": true
            },
            "digest": null,
            "else_ifs": [
              {
                "cond": {
                  "end": 80,
                  "raw": "true",
                  "start": 76,
                  "type": "Literal",
                  "type": "Literal",
                  "value": true
                },
                "digest": null,
                "end": 88,
                "start": 68,
                "then_val": {
                  "body": [
                    {
                      "end": 86,
                      "expression": {
                        "end": 86,
                        "raw": "4",
                        "start": 85,
                        "type": "Literal",
                        "type": "Literal",
                        "value": {
                          "value": 4.0,
                          "suffix": "None"
                        }
                      },
                      "start": 85,
                      "type": "ExpressionStatement",
                      "type": "ExpressionStatement"
                    }
                  ],
                  "end": 87,
                  "start": 81
                },
                "type": "ElseIf"
              }
            ],
            "end": 101,
            "final_else": {
              "body": [
                {
                  "end": 99,
                  "expression": {
                    "end": 99,
                    "raw": "5",
                    "start": 98,
                    "type": "Literal",
                    "type": "Literal",
                    "value": {
                      "value": 5.0,
                      "suffix": "None"
                    }
                  },
                  "start": 98,
                  "type": "ExpressionStatement",
                  "type": "ExpressionStatement"
                }
              ],
              "end": 100,
              "start": 98
            },
            "start": 52,
            "then_val": {
              "body": [
                {
                  "end": 65,
                  "expression": {
                    "end": 65,
                    "raw": "3",
                    "start": 64,
                    "type": "Literal",
                    "type": "Literal",
                    "value": {
                      "value": 3.0,
                      "suffix": "None"
                    }
                  },
                  "start": 64,
                  "type": "ExpressionStatement",
                  "type": "ExpressionStatement"
                }
              ],
              "end": 66,
              "start": 64
            },
            "type": "IfExpression",
            "type": "IfExpression"
          },
          "start": 48,
          "type": "VariableDeclarator"
        },
        "end": 101,
        "kind": "const",
        "start": 48,
        "type": "VariableDeclaration",
        "type": "VariableDeclaration"
      },
      {
        "end": 159,
        "expression": {
          "arguments": [
            {
              "end": 115,
              "name": "a",
              "start": 114,
              "type": "Identifier",
              "type": "Identifier"
            },
            {
              "end": 118,
              "raw": "3",
              "start": 117,
              "type": "Literal",
              "type": "Literal",
              "value": {
                "value": 3.0,
                "suffix": "None"
              }
            },
            {
              "end": 125,
              "raw": "0.001",
              "start": 120,
              "type": "Literal",
              "type": "Literal",
              "value": {
                "value": 0.001,
                "suffix": "None"
              }
            },
            {
              "end": 158,
              "raw": "\"the 'if' branch gets returned\"",
              "start": 127,
              "type": "Literal",
              "type": "Literal",
              "value": "the 'if' branch gets returned"
            }
          ],
          "callee": {
            "end": 113,
            "name": "assertEqual",
            "start": 102,
            "type": "Identifier"
          },
          "end": 159,
          "start": 102,
          "type": "CallExpression",
          "type": "CallExpression"
        },
        "start": 102,
        "type": "ExpressionStatement",
        "type": "ExpressionStatement"
      },
      {
        "declaration": {
          "end": 215,
          "id": {
            "end": 162,
            "name": "b",
            "start": 161,
            "type": "Identifier"
          },
          "init": {
            "cond": {
              "end": 173,
              "raw": "false",
              "start": 168,
              "type": "Literal",
              "type": "Literal",
              "value": false
            },
            "digest": null,
            "else_ifs": [
              {
                "cond": {
                  "end": 194,
                  "raw": "true",
                  "start": 190,
                  "type": "Literal",
                  "type": "Literal",
                  "value": true
                },
                "digest": null,
                "end": 202,
                "start": 182,
                "then_val": {
                  "body": [
                    {
                      "end": 200,
                      "expression": {
                        "end": 200,
                        "raw": "4",
                        "start": 199,
                        "type": "Literal",
                        "type": "Literal",
                        "value": {
                          "value": 4.0,
                          "suffix": "None"
                        }
                      },
                      "start": 199,
                      "type": "ExpressionStatement",
                      "type": "ExpressionStatement"
                    }
                  ],
                  "end": 201,
                  "start": 195
                },
                "type": "ElseIf"
              }
            ],
            "end": 215,
            "final_else": {
              "body": [
                {
                  "end": 213,
                  "expression": {
                    "end": 213,
                    "raw": "5",
                    "start": 212,
                    "type": "Literal",
                    "type": "Literal",
                    "value": {
                      "value": 5.0,
                      "suffix": "None"
                    }
                  },
                  "start": 212,
                  "type": "ExpressionStatement",
                  "type": "ExpressionStatement"
                }
              ],
              "end": 214,
              "start": 212
            },
            "start": 165,
            "then_val": {
              "body": [
                {
                  "end": 179,
                  "expression": {
                    "end": 179,
                    "raw": "3",
                    "start": 178,
                    "type": "Literal",
                    "type": "Literal",
                    "value": {
                      "value": 3.0,
                      "suffix": "None"
                    }
                  },
                  "start": 178,
                  "type": "ExpressionStatement",
                  "type": "ExpressionStatement"
                }
              ],
              "end": 180,
              "start": 178
            },
            "type": "IfExpression",
            "type": "IfExpression"
          },
          "start": 161,
          "type": "VariableDeclarator"
        },
        "end": 215,
        "kind": "const",
        "start": 161,
        "type": "VariableDeclaration",
        "type": "VariableDeclaration"
      },
      {
        "end": 278,
        "expression": {
          "arguments": [
            {
              "end": 229,
              "name": "b",
              "start": 228,
              "type": "Identifier",
              "type": "Identifier"
            },
            {
              "end": 232,
              "raw": "4",
              "start": 231,
              "type": "Literal",
              "type": "Literal",
              "value": {
                "value": 4.0,
                "suffix": "None"
              }
            },
            {
              "end": 239,
              "raw": "0.001",
              "start": 234,
              "type": "Literal",
              "type": "Literal",
              "value": {
                "value": 0.001,
                "suffix": "None"
              }
            },
            {
              "end": 277,
              "raw": "\"the 'else if' branch gets returned\"",
              "start": 241,
              "type": "Literal",
              "type": "Literal",
              "value": "the 'else if' branch gets returned"
            }
          ],
          "callee": {
            "end": 227,
            "name": "assertEqual",
            "start": 216,
            "type": "Identifier"
          },
          "end": 278,
          "start": 216,
          "type": "CallExpression",
          "type": "CallExpression"
        },
        "start": 216,
        "type": "ExpressionStatement",
        "type": "ExpressionStatement"
      },
      {
        "declaration": {
          "end": 335,
          "id": {
            "end": 281,
            "name": "c",
            "start": 280,
            "type": "Identifier"
          },
          "init": {
            "cond": {
              "end": 292,
              "raw": "false",
              "start": 287,
              "type": "Literal",
              "type": "Literal",
              "value": false
            },
            "digest": null,
            "else_ifs": [
              {
                "cond": {
                  "end": 314,
                  "raw": "false",
                  "start": 309,
                  "type": "Literal",
                  "type": "Literal",
                  "value": false
                },
                "digest": null,
                "end": 322,
                "start": 301,
                "then_val": {
                  "body": [
                    {
                      "end": 320,
                      "expression": {
                        "end": 320,
                        "raw": "4",
                        "start": 319,
                        "type": "Literal",
                        "type": "Literal",
                        "value": {
                          "value": 4.0,
                          "suffix": "None"
                        }
                      },
                      "start": 319,
                      "type": "ExpressionStatement",
                      "type": "ExpressionStatement"
                    }
                  ],
                  "end": 321,
                  "start": 315
                },
                "type": "ElseIf"
              }
            ],
            "end": 335,
            "final_else": {
              "body": [
                {
                  "end": 333,
                  "expression": {
                    "end": 333,
                    "raw": "5",
                    "start": 332,
                    "type": "Literal",
                    "type": "Literal",
                    "value": {
                      "value": 5.0,
                      "suffix": "None"
                    }
                  },
                  "start": 332,
                  "type": "ExpressionStatement",
                  "type": "ExpressionStatement"
                }
              ],
              "end": 334,
              "start": 332
            },
            "start": 284,
            "then_val": {
              "body": [
                {
                  "end": 298,
                  "expression": {
                    "end": 298,
                    "raw": "3",
                    "start": 297,
                    "type": "Literal",
                    "type": "Literal",
                    "value": {
                      "value": 3.0,
                      "suffix": "None"
                    }
                  },
                  "start": 297,
                  "type": "ExpressionStatement",
                  "type": "ExpressionStatement"
                }
              ],
              "end": 299,
              "start": 297
            },
            "type": "IfExpression",
            "type": "IfExpression"
          },
          "start": 280,
          "type": "VariableDeclarator"
        },
        "end": 335,
        "kind": "const",
        "start": 280,
        "type": "VariableDeclaration",
        "type": "VariableDeclaration"
      },
      {
        "end": 395,
        "expression": {
          "arguments": [
            {
              "end": 349,
              "name": "c",
              "start": 348,
              "type": "Identifier",
              "type": "Identifier"
            },
            {
              "end": 352,
              "raw": "5",
              "start": 351,
              "type": "Literal",
              "type": "Literal",
              "value": {
                "value": 5.0,
                "suffix": "None"
              }
            },
            {
              "end": 359,
              "raw": "0.001",
              "start": 354,
              "type": "Literal",
              "type": "Literal",
              "value": {
                "value": 0.001,
                "suffix": "None"
              }
            },
            {
              "end": 394,
              "raw": "\"the 'else' branch gets returned\"",
              "start": 361,
              "type": "Literal",
              "type": "Literal",
              "value": "the 'else' branch gets returned"
            }
          ],
          "callee": {
            "end": 347,
            "name": "assertEqual",
            "start": 336,
            "type": "Identifier"
          },
          "end": 395,
          "start": 336,
          "type": "CallExpression",
          "type": "CallExpression"
        },
        "start": 336,
        "type": "ExpressionStatement",
        "type": "ExpressionStatement"
      }
    ],
    "end": 396,
    "nonCodeMeta": {
      "nonCodeNodes": {
        "1": [
          {
            "end": 161,
            "start": 159,
            "type": "NonCodeNode",
            "value": {
              "type": "newLine"
            }
          }
        ],
        "3": [
          {
            "end": 280,
            "start": 278,
            "type": "NonCodeNode",
            "value": {
              "type": "newLine"
            }
          }
        ]
      },
      "startNodes": [
        {
          "end": 45,
          "start": 0,
          "type": "NonCodeNode",
          "value": {
            "type": "blockComment",
            "value": "This tests evaluating if-else expressions.",
            "style": "line"
          }
        },
        {
          "end": 48,
          "start": 45,
          "type": "NonCodeNode",
          "value": {
            "type": "newLine"
          }
        }
      ]
    },
    "start": 0
  }
}
