add failing compiler test
This commit is contained in:
parent
5ac8b6f0ec
commit
1bc5d90d22
3 changed files with 282 additions and 0 deletions
|
|
@ -1378,6 +1378,21 @@ x -> y: {
|
|||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "nil_scope_obj_regression",
|
||||
|
||||
text: `a
|
||||
b: {
|
||||
_.a
|
||||
}
|
||||
`,
|
||||
assertions: func(t *testing.T, g *d2graph.Graph) {
|
||||
tassert.Equal(t, "a", g.Objects[0].ID)
|
||||
for _, ref := range g.Objects[0].References {
|
||||
tassert.NotNil(t, ref.ScopeObj)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "path_link",
|
||||
|
||||
|
|
|
|||
|
|
@ -3309,6 +3309,23 @@ d
|
|||
exp: `a: {
|
||||
_.b -> c -> _.b
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "container_multiple_refs_with_underscore",
|
||||
|
||||
text: `a
|
||||
b: {
|
||||
_.a
|
||||
}
|
||||
`,
|
||||
key: `a`,
|
||||
newKey: `b.a`,
|
||||
|
||||
exp: `b.a
|
||||
b: {
|
||||
a
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
250
testdata/d2compiler/TestCompile/nil_scope_obj_regression.exp.json
generated
vendored
Normal file
250
testdata/d2compiler/TestCompile/nil_scope_obj_regression.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,0:0:0-4:0:15",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,0:0:0-0:1:1",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,0:0:0-0:1:1",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,1:0:2-3:1:14",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,1:0:2-1:1:3",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,1:0:2-1:1:3",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,1:3:5-3:0:13",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,2:2:9-2:5:12",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,2:2:9-2:5:12",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,2:2:9-2:3:10",
|
||||
"value": [
|
||||
{
|
||||
"string": "_",
|
||||
"raw_string": "_"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,2:4:11-2:5:12",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"root": {
|
||||
"id": "",
|
||||
"id_val": "",
|
||||
"label_dimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": ""
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": {
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
"edges": null,
|
||||
"objects": [
|
||||
{
|
||||
"id": "a",
|
||||
"id_val": "a",
|
||||
"label_dimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,0:0:0-0:1:1",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,2:2:9-2:5:12",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,2:2:9-2:3:10",
|
||||
"value": [
|
||||
{
|
||||
"string": "_",
|
||||
"raw_string": "_"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,2:4:11-2:5:12",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 1,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "a"
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": {
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
{
|
||||
"id": "b",
|
||||
"id_val": "b",
|
||||
"label_dimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,1:0:2-1:1:3",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/nil_scope_obj_regression.d2,1:0:2-1:1:3",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "b"
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": {
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": null
|
||||
}
|
||||
Loading…
Reference in a new issue