This commit is contained in:
Alexander Wang 2024-07-25 18:36:25 -06:00
parent 4ff04cd94b
commit a7b55fc830
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
2 changed files with 710 additions and 0 deletions

View file

@ -4699,6 +4699,29 @@ z.link: https://yahoo.com
assert.Equal(t, (*d2graph.Scalar)(nil), g.Objects[2].Attributes.Style.Underline) assert.Equal(t, (*d2graph.Scalar)(nil), g.Objects[2].Attributes.Style.Underline)
}, },
}, },
{
name: "double-glob-second-scenario",
run: func(t *testing.T) {
g, _ := assertCompile(t, `
**.b*.shape: circle
scenarios: {
k: {
x: {
b
}
}
z: {
x: {
b
}
}
}
`, ``)
assert.Equal(t, "circle", g.Scenarios[0].Objects[1].Attributes.Shape.Value)
assert.Equal(t, "circle", g.Scenarios[1].Objects[1].Attributes.Shape.Value)
},
},
} }
for _, tc := range tca { for _, tc := range tca {

View file

@ -0,0 +1,687 @@
{
"graph": {
"name": "",
"isFolderOnly": true,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,0:0:0-15:0:105",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,1:0:1-1:19:20",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,1:0:1-1:11:12",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,1:3:4-1:5:6",
"value": [
{
"string": "b*",
"raw_string": "b*"
}
],
"pattern": [
"b",
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,1:6:7-1:11:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,1:13:14-1:19:20",
"value": [
{
"string": "circle",
"raw_string": "circle"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,3:0:22-14:1:104",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,3:0:22-3:9:31",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,3:0:22-3:9:31",
"value": [
{
"string": "scenarios",
"raw_string": "scenarios"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,3:11:33-14:1:104",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,4:2:37-8:3:68",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,4:2:37-4:3:38",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,4:2:37-4:3:38",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,4:5:40-8:3:68",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,5:4:46-7:5:64",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,5:4:46-5:5:47",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,5:4:46-5:5:47",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,5:7:49-7:5:64",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,6:6:57-6:7:58",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,6:6:57-6:7:58",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,6:6:57-6:7:58",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,9:2:71-13:3:102",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,9:2:71-9:3:72",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,9:2:71-9:3:72",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,9:5:74-13:3:102",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,10:4:80-12:5:98",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,10:4:80-10:5:81",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,10:4:80-10:5:81",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,10:7:83-12:5:98",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,11:6:91-11:7:92",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,11:6:91-11:7:92",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,11:6:91-11:7:92",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": null,
"objects": null,
"scenarios": [
{
"name": "k",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "b"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "shape"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,1:13:14-1:19:20",
"value": [
{
"string": "circle",
"raw_string": "circle"
}
]
}
},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "x",
"id_val": "x",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,5:4:46-5:5:47",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,5:4:46-5:5:47",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "x"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,6:6:57-6:7:58",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,6:6:57-6:7:58",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "circle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
{
"name": "z",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "b"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1:0:0",
"nodes": null
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "x",
"id_val": "x",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,10:4:80-10:5:81",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,10:4:80-10:5:81",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "x"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,11:6:91-11:7:92",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/double-glob-second-scenario.d2,11:6:91-11:7:92",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}