From 8d6dc9b19a59055b8995eb11778967e7dcecc031 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 5 Oct 2023 11:09:39 -0700 Subject: [PATCH 1/7] add var_in_glob test --- e2etests/regression_test.go | 1 + e2etests/testdata/files/var_in_glob.d2 | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 e2etests/testdata/files/var_in_glob.d2 diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index 2bbea307d..f8cb1be7e 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -1047,6 +1047,7 @@ cf many required: { loadFromFile(t, "empty_nested_grid"), loadFromFile(t, "code_font_size"), loadFromFile(t, "disclaimer"), + loadFromFile(t, "var_in_glob"), } runa(t, tcs) diff --git a/e2etests/testdata/files/var_in_glob.d2 b/e2etests/testdata/files/var_in_glob.d2 new file mode 100644 index 000000000..45c7d6734 --- /dev/null +++ b/e2etests/testdata/files/var_in_glob.d2 @@ -0,0 +1,11 @@ +vars: { + v: { + ok + } +} + +x1 -> x2 + +x*: { + ...${v} +} From 2fb7058ab6a0210d9872802e5a74aa1e77787746 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 5 Oct 2023 11:11:25 -0700 Subject: [PATCH 2/7] handle nil Keys in Equals --- d2ast/d2ast.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 87b0921f6..201d8eb3f 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -724,6 +724,12 @@ func (mk1 *Key) D2OracleEquals(mk2 *Key) bool { } func (mk1 *Key) Equals(mk2 *Key) bool { + if mk1 == nil && mk2 == nil { + return true + } + if (mk1 == nil) || (mk2 == nil) { + return false + } if mk1.Ampersand != mk2.Ampersand { return false } From 8a4f970c5f7ef5d926a975c2382af10d05832ac5 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 5 Oct 2023 11:11:50 -0700 Subject: [PATCH 3/7] test success --- .../var_in_glob/dagre/board.exp.json | 260 ++++++++++++++++++ .../var_in_glob/dagre/sketch.exp.svg | 105 +++++++ .../regression/var_in_glob/elk/board.exp.json | 251 +++++++++++++++++ .../regression/var_in_glob/elk/sketch.exp.svg | 105 +++++++ 4 files changed, 721 insertions(+) create mode 100644 e2etests/testdata/regression/var_in_glob/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/var_in_glob/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/var_in_glob/elk/board.exp.json create mode 100644 e2etests/testdata/regression/var_in_glob/elk/sketch.exp.svg diff --git a/e2etests/testdata/regression/var_in_glob/dagre/board.exp.json b/e2etests/testdata/regression/var_in_glob/dagre/board.exp.json new file mode 100644 index 000000000..5590e99c2 --- /dev/null +++ b/e2etests/testdata/regression/var_in_glob/dagre/board.exp.json @@ -0,0 +1,260 @@ +{ + "name": "", + "isFolderOnly": false, + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x1.ok", + "type": "rectangle", + "pos": { + "x": 40, + "y": 50 + }, + "width": 63, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "ok", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 18, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "x2.ok", + "type": "rectangle", + "pos": { + "x": 40, + "y": 316 + }, + "width": 63, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "ok", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 18, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "x1", + "type": "rectangle", + "pos": { + "x": 10, + "y": 20 + }, + "width": 123, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "x1", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 26, + "labelHeight": 36, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "x2", + "type": "rectangle", + "pos": { + "x": 10, + "y": 286 + }, + "width": 123, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "x2", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 26, + "labelHeight": 36, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(x1 -> x2)[0]", + "src": "x1", + "srcArrow": "none", + "dst": "x2", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 71.5, + "y": 146 + }, + { + "x": 71.5, + "y": 202 + }, + { + "x": 71.5, + "y": 221.8000030517578 + }, + { + "x": 71.5, + "y": 245 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "root": { + "id": "", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 0, + "height": 0, + "opacity": 0, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "N7", + "stroke": "", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 0 + } +} diff --git a/e2etests/testdata/regression/var_in_glob/dagre/sketch.exp.svg b/e2etests/testdata/regression/var_in_glob/dagre/sketch.exp.svg new file mode 100644 index 000000000..d4fb2880e --- /dev/null +++ b/e2etests/testdata/regression/var_in_glob/dagre/sketch.exp.svg @@ -0,0 +1,105 @@ +x1x2okok + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/var_in_glob/elk/board.exp.json b/e2etests/testdata/regression/var_in_glob/elk/board.exp.json new file mode 100644 index 000000000..6d4d405d2 --- /dev/null +++ b/e2etests/testdata/regression/var_in_glob/elk/board.exp.json @@ -0,0 +1,251 @@ +{ + "name": "", + "isFolderOnly": false, + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x1.ok", + "type": "rectangle", + "pos": { + "x": 62, + "y": 62 + }, + "width": 63, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "ok", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 18, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "x2.ok", + "type": "rectangle", + "pos": { + "x": 62, + "y": 298 + }, + "width": 63, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "ok", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 18, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "x1", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 163, + "height": 166, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "x1", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 26, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "x2", + "type": "rectangle", + "pos": { + "x": 12, + "y": 248 + }, + "width": 163, + "height": 166, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "stroke": "B1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "x2", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 26, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(x1 -> x2)[0]", + "src": "x1", + "srcArrow": "none", + "dst": "x2", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "borderRadius": 10, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 93.5, + "y": 178 + }, + { + "x": 93.5, + "y": 248 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "root": { + "id": "", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 0, + "height": 0, + "opacity": 0, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "N7", + "stroke": "", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 0 + } +} diff --git a/e2etests/testdata/regression/var_in_glob/elk/sketch.exp.svg b/e2etests/testdata/regression/var_in_glob/elk/sketch.exp.svg new file mode 100644 index 000000000..6ac36d93a --- /dev/null +++ b/e2etests/testdata/regression/var_in_glob/elk/sketch.exp.svg @@ -0,0 +1,105 @@ +x1x2okok + + + + + + \ No newline at end of file From 47251006ae2c458cec47f1af02d1a9ba27228f58 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 5 Oct 2023 12:18:38 -0700 Subject: [PATCH 4/7] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index d0c8a972a..870bdaaac 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -8,3 +8,4 @@ #### Bugfixes ⛑️ - Grid layout now accounts for each cell's outside labels and icons [#1624](https://github.com/terrastruct/d2/pull/1624) +- Fixes a panic with a spread substitution in a glob map [#1643](https://github.com/terrastruct/d2/pull/1643) From 142f637b6a1906a03f8e336a3c2237be69ae96ea Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 5 Oct 2023 13:10:56 -0700 Subject: [PATCH 5/7] add compile test --- d2compiler/compile_test.go | 22 + .../TestCompile/var_in_glob.exp.json | 428 ++++++++++++++++++ 2 files changed, 450 insertions(+) create mode 100644 testdata/d2compiler/TestCompile/var_in_glob.exp.json diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 5bd130eca..836922aae 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -2684,6 +2684,28 @@ a -> b: { class: [association; one target] } tassert.Equal(t, "arrow", g.Edges[1].DstArrowhead.Shape.Value) }, }, + { + name: "var_in_glob", + text: `vars: { + v: { + ok + } +} + +x1 -> x2 + +x*: { + ...${v} +} +`, + assertions: func(t *testing.T, g *d2graph.Graph) { + tassert.Equal(t, 4, len(g.Objects)) + tassert.Equal(t, "x1.ok", g.Objects[0].AbsID()) + tassert.Equal(t, "x2.ok", g.Objects[1].AbsID()) + tassert.Equal(t, "x1", g.Objects[2].AbsID()) + tassert.Equal(t, "x2", g.Objects[3].AbsID()) + }, + }, { name: "class-shape-class", text: `classes: { diff --git a/testdata/d2compiler/TestCompile/var_in_glob.exp.json b/testdata/d2compiler/TestCompile/var_in_glob.exp.json new file mode 100644 index 000000000..1ac428dc9 --- /dev/null +++ b/testdata/d2compiler/TestCompile/var_in_glob.exp.json @@ -0,0 +1,428 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,0:0:0-11:0:57", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,0:0:0-4:1:27", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,0:0:0-0:4:4", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,0:6:6-4:1:27", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,1:2:10-3:3:25", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,1:2:10-1:3:11", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,1:2:10-1:3:11", + "value": [ + { + "string": "v", + "raw_string": "v" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,1:5:13-3:3:25", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,2:4:19-2:6:21", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,2:4:19-2:6:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,2:4:19-2:6:21", + "value": [ + { + "string": "ok", + "raw_string": "ok" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:0:29-6:8:37", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:0:29-6:8:37", + "src": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:0:29-6:2:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:0:29-6:2:31", + "value": [ + { + "string": "x1", + "raw_string": "x1" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:6:35-6:8:37", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:6:35-6:8:37", + "value": [ + { + "string": "x2", + "raw_string": "x2" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,8:0:39-10:1:56", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,8:0:39-8:2:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,8:0:39-8:2:41", + "value": [ + { + "string": "x*", + "raw_string": "x*" + } + ], + "pattern": [ + "x", + "*" + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,8:4:43-10:1:56", + "nodes": [ + { + "substitution": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,9:2:47-9:9:54", + "spread": true, + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,9:7:52-9:8:53", + "value": [ + { + "string": "v", + "raw_string": "v" + } + ] + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "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": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "ok", + "id_val": "ok", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,2:4:19-2:6:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,2:4:19-2:6:21", + "value": [ + { + "string": "ok", + "raw_string": "ok" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "ok" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "ok", + "id_val": "ok", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,2:4:19-2:6:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,2:4:19-2:6:21", + "value": [ + { + "string": "ok", + "raw_string": "ok" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "ok" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "x1", + "id_val": "x1", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:0:29-6:2:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:0:29-6:2:31", + "value": [ + { + "string": "x1", + "raw_string": "x1" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x1" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "x2", + "id_val": "x2", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:6:35-6:8:37", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/var_in_glob.d2,6:6:35-6:8:37", + "value": [ + { + "string": "x2", + "raw_string": "x2" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x2" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} From 1a4001d56e960e15d5543569ab2cfb1147454c53 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 5 Oct 2023 13:13:19 -0700 Subject: [PATCH 6/7] remove e2e test --- e2etests/regression_test.go | 1 - e2etests/testdata/files/var_in_glob.d2 | 11 - .../var_in_glob/dagre/board.exp.json | 260 ------------------ .../var_in_glob/dagre/sketch.exp.svg | 105 ------- .../regression/var_in_glob/elk/board.exp.json | 251 ----------------- .../regression/var_in_glob/elk/sketch.exp.svg | 105 ------- 6 files changed, 733 deletions(-) delete mode 100644 e2etests/testdata/files/var_in_glob.d2 delete mode 100644 e2etests/testdata/regression/var_in_glob/dagre/board.exp.json delete mode 100644 e2etests/testdata/regression/var_in_glob/dagre/sketch.exp.svg delete mode 100644 e2etests/testdata/regression/var_in_glob/elk/board.exp.json delete mode 100644 e2etests/testdata/regression/var_in_glob/elk/sketch.exp.svg diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index f8cb1be7e..2bbea307d 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -1047,7 +1047,6 @@ cf many required: { loadFromFile(t, "empty_nested_grid"), loadFromFile(t, "code_font_size"), loadFromFile(t, "disclaimer"), - loadFromFile(t, "var_in_glob"), } runa(t, tcs) diff --git a/e2etests/testdata/files/var_in_glob.d2 b/e2etests/testdata/files/var_in_glob.d2 deleted file mode 100644 index 45c7d6734..000000000 --- a/e2etests/testdata/files/var_in_glob.d2 +++ /dev/null @@ -1,11 +0,0 @@ -vars: { - v: { - ok - } -} - -x1 -> x2 - -x*: { - ...${v} -} diff --git a/e2etests/testdata/regression/var_in_glob/dagre/board.exp.json b/e2etests/testdata/regression/var_in_glob/dagre/board.exp.json deleted file mode 100644 index 5590e99c2..000000000 --- a/e2etests/testdata/regression/var_in_glob/dagre/board.exp.json +++ /dev/null @@ -1,260 +0,0 @@ -{ - "name": "", - "isFolderOnly": false, - "fontFamily": "SourceSansPro", - "shapes": [ - { - "id": "x1.ok", - "type": "rectangle", - "pos": { - "x": 40, - "y": 50 - }, - "width": 63, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B5", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "ok", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 18, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "x2.ok", - "type": "rectangle", - "pos": { - "x": 40, - "y": 316 - }, - "width": 63, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B5", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "ok", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 18, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "x1", - "type": "rectangle", - "pos": { - "x": 10, - "y": 20 - }, - "width": 123, - "height": 126, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B4", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "x1", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 26, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "x2", - "type": "rectangle", - "pos": { - "x": 10, - "y": 286 - }, - "width": 123, - "height": 126, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B4", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "x2", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 26, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - } - ], - "connections": [ - { - "id": "(x1 -> x2)[0]", - "src": "x1", - "srcArrow": "none", - "dst": "x2", - "dstArrow": "triangle", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "B1", - "borderRadius": 10, - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N2", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 71.5, - "y": 146 - }, - { - "x": 71.5, - "y": 202 - }, - { - "x": 71.5, - "y": 221.8000030517578 - }, - { - "x": 71.5, - "y": 245 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - } - ], - "root": { - "id": "", - "type": "", - "pos": { - "x": 0, - "y": 0 - }, - "width": 0, - "height": 0, - "opacity": 0, - "strokeDash": 0, - "strokeWidth": 0, - "borderRadius": 0, - "fill": "N7", - "stroke": "", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "", - "fontSize": 0, - "fontFamily": "", - "language": "", - "color": "", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "zIndex": 0, - "level": 0 - } -} diff --git a/e2etests/testdata/regression/var_in_glob/dagre/sketch.exp.svg b/e2etests/testdata/regression/var_in_glob/dagre/sketch.exp.svg deleted file mode 100644 index d4fb2880e..000000000 --- a/e2etests/testdata/regression/var_in_glob/dagre/sketch.exp.svg +++ /dev/null @@ -1,105 +0,0 @@ -x1x2okok - - - - - - \ No newline at end of file diff --git a/e2etests/testdata/regression/var_in_glob/elk/board.exp.json b/e2etests/testdata/regression/var_in_glob/elk/board.exp.json deleted file mode 100644 index 6d4d405d2..000000000 --- a/e2etests/testdata/regression/var_in_glob/elk/board.exp.json +++ /dev/null @@ -1,251 +0,0 @@ -{ - "name": "", - "isFolderOnly": false, - "fontFamily": "SourceSansPro", - "shapes": [ - { - "id": "x1.ok", - "type": "rectangle", - "pos": { - "x": 62, - "y": 62 - }, - "width": 63, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B5", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "ok", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 18, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "x2.ok", - "type": "rectangle", - "pos": { - "x": 62, - "y": 298 - }, - "width": 63, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B5", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "ok", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 18, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "x1", - "type": "rectangle", - "pos": { - "x": 12, - "y": 12 - }, - "width": 163, - "height": 166, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B4", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "x1", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 26, - "labelHeight": 36, - "labelPosition": "INSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "x2", - "type": "rectangle", - "pos": { - "x": 12, - "y": 248 - }, - "width": 163, - "height": 166, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B4", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "x2", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 26, - "labelHeight": 36, - "labelPosition": "INSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - } - ], - "connections": [ - { - "id": "(x1 -> x2)[0]", - "src": "x1", - "srcArrow": "none", - "dst": "x2", - "dstArrow": "triangle", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "B1", - "borderRadius": 10, - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N2", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 93.5, - "y": 178 - }, - { - "x": 93.5, - "y": 248 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - } - ], - "root": { - "id": "", - "type": "", - "pos": { - "x": 0, - "y": 0 - }, - "width": 0, - "height": 0, - "opacity": 0, - "strokeDash": 0, - "strokeWidth": 0, - "borderRadius": 0, - "fill": "N7", - "stroke": "", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "", - "fontSize": 0, - "fontFamily": "", - "language": "", - "color": "", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "zIndex": 0, - "level": 0 - } -} diff --git a/e2etests/testdata/regression/var_in_glob/elk/sketch.exp.svg b/e2etests/testdata/regression/var_in_glob/elk/sketch.exp.svg deleted file mode 100644 index 6ac36d93a..000000000 --- a/e2etests/testdata/regression/var_in_glob/elk/sketch.exp.svg +++ /dev/null @@ -1,105 +0,0 @@ -x1x2okok - - - - - - \ No newline at end of file From f200c19e3118efa2185ea81d2e2e32fbd3f66cd5 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 6 Oct 2023 15:48:19 -0700 Subject: [PATCH 7/7] d2oracle Equals --- d2ast/d2ast.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 201d8eb3f..85a530c88 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -651,6 +651,12 @@ type Key struct { } func (mk1 *Key) D2OracleEquals(mk2 *Key) bool { + if mk1 == nil && mk2 == nil { + return true + } + if (mk1 == nil) || (mk2 == nil) { + return false + } if mk1.Ampersand != mk2.Ampersand { return false }