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

635 lines
15 KiB
Plaintext
Raw Normal View History

---
source: kcl/src/simulation_tests.rs
description: Result of parsing computed_var.kcl
---
{
"Ok": {
"body": [
{
"declaration": {
"end": 56,
"id": {
"end": 40,
"name": "arr",
"start": 37,
"type": "Identifier"
},
"init": {
"elements": [
{
"end": 45,
"raw": "0",
"start": 44,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 48,
"raw": "0",
"start": 47,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 51,
"raw": "0",
"start": 50,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 55,
"raw": "10",
"start": 53,
"type": "Literal",
"type": "Literal",
"value": {
"value": 10.0,
"suffix": "None"
}
}
],
"end": 56,
"start": 43,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 37,
"type": "VariableDeclarator"
},
"end": 56,
"kind": "const",
"start": 37,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 62,
"id": {
"end": 58,
"name": "i",
"start": 57,
"type": "Identifier"
},
"init": {
"end": 62,
"raw": "3",
"start": 61,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
"start": 57,
"type": "VariableDeclarator"
},
"end": 62,
"kind": "const",
"start": 57,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 75,
"id": {
"end": 66,
"name": "ten",
"start": 63,
"type": "Identifier"
},
"init": {
"computed": true,
"end": 75,
"object": {
"end": 72,
"name": "arr",
"start": 69,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 74,
"name": "i",
"start": 73,
"type": "Identifier",
"type": "Identifier"
},
"start": 69,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 63,
"type": "VariableDeclarator"
},
"end": 75,
"kind": "const",
"start": 63,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 115,
"expression": {
"arguments": [
{
"end": 92,
"name": "ten",
"start": 89,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 96,
"raw": "10",
"start": 94,
"type": "Literal",
"type": "Literal",
"value": {
"value": 10.0,
"suffix": "None"
}
},
{
"end": 106,
"raw": "0.000001",
"start": 98,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.000001,
"suffix": "None"
}
},
{
"end": 114,
"raw": "\"oops\"",
"start": 108,
"type": "Literal",
"type": "Literal",
"value": "oops"
}
],
"callee": {
"end": 88,
"name": "assertEqual",
"start": 77,
"type": "Identifier"
},
"end": 115,
"start": 77,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 77,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"declaration": {
"end": 126,
"id": {
"end": 118,
"name": "p",
"start": 117,
"type": "Identifier"
},
"init": {
"end": 126,
"raw": "\"foo\"",
"start": 121,
"type": "Literal",
"type": "Literal",
"value": "foo"
},
"start": 117,
"type": "VariableDeclarator"
},
"end": 126,
"kind": "const",
"start": 117,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 153,
"id": {
"end": 130,
"name": "obj",
"start": 127,
"type": "Identifier"
},
"init": {
"end": 153,
"properties": [
{
"end": 142,
"key": {
"end": 138,
"name": "foo",
"start": 135,
"type": "Identifier"
},
"start": 135,
"type": "ObjectProperty",
"value": {
"end": 142,
"raw": "1",
"start": 141,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
},
{
"end": 151,
"key": {
"end": 147,
"name": "bar",
"start": 144,
"type": "Identifier"
},
"start": 144,
"type": "ObjectProperty",
"value": {
"end": 151,
"raw": "0",
"start": 150,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
}
],
"start": 133,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
"start": 127,
"type": "VariableDeclarator"
},
"end": 153,
"kind": "const",
"start": 127,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 166,
"id": {
"end": 157,
"name": "one",
"start": 154,
"type": "Identifier"
},
"init": {
"computed": true,
"end": 166,
"object": {
"end": 163,
"name": "obj",
"start": 160,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 165,
"name": "p",
"start": 164,
"type": "Identifier",
"type": "Identifier"
},
"start": 160,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 154,
"type": "VariableDeclarator"
},
"end": 166,
"kind": "const",
"start": 154,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 206,
"expression": {
"arguments": [
{
"end": 183,
"name": "one",
"start": 180,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 186,
"raw": "1",
"start": 185,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 197,
"raw": "0.0000001",
"start": 188,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0000001,
"suffix": "None"
}
},
{
"end": 205,
"raw": "\"oops\"",
"start": 199,
"type": "Literal",
"type": "Literal",
"value": "oops"
}
],
"callee": {
"end": 179,
"name": "assertEqual",
"start": 168,
"type": "Identifier"
},
"end": 206,
"start": 168,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 168,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"end": 242,
"expression": {
"arguments": [
{
"end": 222,
"name": "PI",
"start": 220,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 225,
"raw": "3",
"start": 224,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "None"
}
},
{
"end": 230,
"raw": "0.2",
"start": 227,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.2,
"suffix": "None"
}
},
{
"end": 241,
"raw": "\"oops pi\"",
"start": 232,
"type": "Literal",
"type": "Literal",
"value": "oops pi"
}
],
"callee": {
"end": 219,
"name": "assertEqual",
"start": 208,
"type": "Identifier"
},
"end": 242,
"start": 208,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 208,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"declaration": {
"end": 258,
"id": {
"end": 244,
"name": "x",
"start": 243,
"type": "Identifier"
},
"init": {
"arguments": [
{
"end": 257,
"left": {
"end": 252,
"raw": "2",
"start": 251,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"operator": "*",
"right": {
"end": 257,
"name": "PI",
"start": 255,
"type": "Identifier",
"type": "Identifier"
},
"start": 251,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"end": 250,
"name": "cos",
"start": 247,
"type": "Identifier"
},
"end": 258,
"start": 247,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 243,
"type": "VariableDeclarator"
},
"end": 258,
"kind": "const",
"start": 243,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 298,
"expression": {
"arguments": [
{
"end": 272,
"name": "x",
"start": 271,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 275,
"raw": "1",
"start": 274,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 285,
"raw": "0.000001",
"start": 277,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.000001,
"suffix": "None"
}
},
{
"end": 297,
"raw": "\"oops cos\"",
"start": 287,
"type": "Literal",
"type": "Literal",
"value": "oops cos"
}
],
"callee": {
"end": 270,
"name": "assertEqual",
"start": 259,
"type": "Identifier"
},
"end": 298,
"start": 259,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 259,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 299,
"nonCodeMeta": {
"nonCodeNodes": {
"2": [
{
"end": 77,
"start": 75,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"3": [
{
"end": 117,
"start": 115,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"6": [
{
"end": 168,
"start": 166,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"7": [
{
"end": 208,
"start": 206,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": [
{
"end": 34,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
"value": "This tests computed properties.",
"style": "line"
}
},
{
"end": 37,
"start": 34,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"start": 0
}
}