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

871 lines
22 KiB
Plaintext
Raw Normal View History

---
source: kcl/src/simulation_tests.rs
description: Result of parsing property_of_object.kcl
---
{
"Ok": {
"body": [
{
"declaration": {
"end": 76,
"id": {
"end": 53,
"name": "obj",
"start": 50,
"type": "Identifier"
},
"init": {
"end": 76,
"properties": [
{
"end": 65,
"key": {
"end": 61,
"name": "foo",
"start": 58,
"type": "Identifier"
},
"start": 58,
"type": "ObjectProperty",
"value": {
"end": 65,
"raw": "1",
"start": 64,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
},
{
"end": 74,
"key": {
"end": 70,
"name": "bar",
"start": 67,
"type": "Identifier"
},
"start": 67,
"type": "ObjectProperty",
"value": {
"end": 74,
"raw": "0",
"start": 73,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
}
],
"start": 56,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
"start": 50,
"type": "VariableDeclarator"
},
"end": 76,
"kind": "const",
"start": 50,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 134,
"id": {
"end": 121,
"name": "one_a",
"start": 116,
"type": "Identifier"
},
"init": {
"computed": false,
"end": 134,
"object": {
"end": 127,
"name": "obj",
"start": 124,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 133,
"raw": "\"foo\"",
"start": 128,
"type": "Literal",
"type": "Literal",
"value": "foo"
},
"start": 124,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 116,
"type": "VariableDeclarator"
},
"end": 134,
"kind": "const",
"start": 116,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 191,
"expression": {
"arguments": [
{
"end": 160,
"name": "one_a",
"start": 155,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 163,
"raw": "1",
"start": 162,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 190,
"raw": "\"Literal property lookup\"",
"start": 165,
"type": "Literal",
"type": "Literal",
"value": "Literal property lookup"
}
],
"callee": {
"end": 154,
"name": "assertLessThanOrEq",
"start": 136,
"type": "Identifier"
},
"end": 191,
"start": 136,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 136,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"end": 250,
"expression": {
"arguments": [
{
"end": 219,
"name": "one_a",
"start": 214,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 222,
"raw": "1",
"start": 221,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 249,
"raw": "\"Literal property lookup\"",
"start": 224,
"type": "Literal",
"type": "Literal",
"value": "Literal property lookup"
}
],
"callee": {
"end": 213,
"name": "assertGreaterThanOrEq",
"start": 192,
"type": "Identifier"
},
"end": 250,
"start": 192,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 192,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"declaration": {
"end": 349,
"id": {
"end": 341,
"name": "p",
"start": 340,
"type": "Identifier"
},
"init": {
"end": 349,
"raw": "\"foo\"",
"start": 344,
"type": "Literal",
"type": "Literal",
"value": "foo"
},
"start": 340,
"type": "VariableDeclarator"
},
"end": 349,
"kind": "const",
"start": 340,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 364,
"id": {
"end": 355,
"name": "one_b",
"start": 350,
"type": "Identifier"
},
"init": {
"computed": true,
"end": 364,
"object": {
"end": 361,
"name": "obj",
"start": 358,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 363,
"name": "p",
"start": 362,
"type": "Identifier",
"type": "Identifier"
},
"start": 358,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 350,
"type": "VariableDeclarator"
},
"end": 364,
"kind": "const",
"start": 350,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 422,
"expression": {
"arguments": [
{
"end": 390,
"name": "one_b",
"start": 385,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 393,
"raw": "1",
"start": 392,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 421,
"raw": "\"Computed property lookup\"",
"start": 395,
"type": "Literal",
"type": "Literal",
"value": "Computed property lookup"
}
],
"callee": {
"end": 384,
"name": "assertLessThanOrEq",
"start": 366,
"type": "Identifier"
},
"end": 422,
"start": 366,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 366,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"end": 482,
"expression": {
"arguments": [
{
"end": 450,
"name": "one_b",
"start": 445,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 453,
"raw": "1",
"start": 452,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 481,
"raw": "\"Computed property lookup\"",
"start": 455,
"type": "Literal",
"type": "Literal",
"value": "Computed property lookup"
}
],
"callee": {
"end": 444,
"name": "assertGreaterThanOrEq",
"start": 423,
"type": "Identifier"
},
"end": 482,
"start": 423,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 423,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"declaration": {
"end": 546,
"id": {
"end": 528,
"name": "obj2",
"start": 524,
"type": "Identifier"
},
"init": {
"end": 546,
"properties": [
{
"end": 544,
"key": {
"end": 538,
"name": "inner",
"start": 533,
"type": "Identifier"
},
"start": 533,
"type": "ObjectProperty",
"value": {
"end": 544,
"name": "obj",
"start": 541,
"type": "Identifier",
"type": "Identifier"
}
}
],
"start": 531,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
"start": 524,
"type": "VariableDeclarator"
},
"end": 546,
"kind": "const",
"start": 524,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 573,
"id": {
"end": 553,
"name": "one_c",
"start": 548,
"type": "Identifier"
},
"init": {
"computed": false,
"end": 573,
"object": {
"computed": false,
"end": 566,
"object": {
"end": 560,
"name": "obj2",
"start": 556,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 566,
"name": "inner",
"start": 561,
"type": "Identifier",
"type": "Identifier"
},
"start": 556,
"type": "MemberExpression",
"type": "MemberExpression"
},
"property": {
"end": 572,
"raw": "\"foo\"",
"start": 567,
"type": "Literal",
"type": "Literal",
"value": "foo"
},
"start": 556,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 548,
"type": "VariableDeclarator"
},
"end": 573,
"kind": "const",
"start": 548,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 630,
"expression": {
"arguments": [
{
"end": 599,
"name": "one_c",
"start": 594,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 602,
"raw": "1",
"start": 601,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 629,
"raw": "\"Literal property lookup\"",
"start": 604,
"type": "Literal",
"type": "Literal",
"value": "Literal property lookup"
}
],
"callee": {
"end": 593,
"name": "assertLessThanOrEq",
"start": 575,
"type": "Identifier"
},
"end": 630,
"start": 575,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 575,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"end": 689,
"expression": {
"arguments": [
{
"end": 658,
"name": "one_c",
"start": 653,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 661,
"raw": "1",
"start": 660,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 688,
"raw": "\"Literal property lookup\"",
"start": 663,
"type": "Literal",
"type": "Literal",
"value": "Literal property lookup"
}
],
"callee": {
"end": 652,
"name": "assertGreaterThanOrEq",
"start": 631,
"type": "Identifier"
},
"end": 689,
"start": 631,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 631,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"declaration": {
"end": 773,
"id": {
"end": 757,
"name": "one_d",
"start": 752,
"type": "Identifier"
},
"init": {
"computed": true,
"end": 773,
"object": {
"computed": false,
"end": 770,
"object": {
"end": 764,
"name": "obj2",
"start": 760,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 770,
"name": "inner",
"start": 765,
"type": "Identifier",
"type": "Identifier"
},
"start": 760,
"type": "MemberExpression",
"type": "MemberExpression"
},
"property": {
"end": 772,
"name": "p",
"start": 771,
"type": "Identifier",
"type": "Identifier"
},
"start": 760,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 752,
"type": "VariableDeclarator"
},
"end": 773,
"kind": "const",
"start": 752,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 831,
"expression": {
"arguments": [
{
"end": 799,
"name": "one_d",
"start": 794,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 802,
"raw": "1",
"start": 801,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 830,
"raw": "\"Computed property lookup\"",
"start": 804,
"type": "Literal",
"type": "Literal",
"value": "Computed property lookup"
}
],
"callee": {
"end": 793,
"name": "assertLessThanOrEq",
"start": 775,
"type": "Identifier"
},
"end": 831,
"start": 775,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 775,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"end": 891,
"expression": {
"arguments": [
{
"end": 859,
"name": "one_d",
"start": 854,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 862,
"raw": "1",
"start": 861,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 890,
"raw": "\"Computed property lookup\"",
"start": 864,
"type": "Literal",
"type": "Literal",
"value": "Computed property lookup"
}
],
"callee": {
"end": 853,
"name": "assertGreaterThanOrEq",
"start": 832,
"type": "Identifier"
},
"end": 891,
"start": 832,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 832,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 892,
"nonCodeMeta": {
"nonCodeNodes": {
"0": [
{
"end": 113,
"start": 76,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "Test: the property is a literal.",
"style": "line"
}
},
{
"end": 116,
"start": 113,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"1": [
{
"end": 136,
"start": 134,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"3": [
{
"end": 288,
"start": 250,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "Test: the property is a variable,",
"style": "line"
}
},
{
"end": 337,
"start": 289,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
"value": "which must be evaluated before looking it up.",
"style": "line"
}
},
{
"end": 340,
"start": 337,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"5": [
{
"end": 366,
"start": 364,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"7": [
{
"end": 521,
"start": 482,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "Test: multiple literal properties.",
"style": "line"
}
},
{
"end": 524,
"start": 521,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"8": [
{
"end": 548,
"start": 546,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"9": [
{
"end": 575,
"start": 573,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"11": [
{
"end": 749,
"start": 689,
"type": "NonCodeNode",
"value": {
"type": "newLineBlockComment",
"value": "Test: multiple properties, mix of literal and computed.",
"style": "line"
}
},
{
"end": 752,
"start": 749,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"12": [
{
"end": 775,
"start": 773,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": [
{
"end": 47,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
"value": "This tests evaluating properties of objects.",
"style": "line"
}
},
{
"end": 50,
"start": 47,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"start": 0
}
}