From a346542465c09285f317875b63326e8e4b83b1de Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 22 Feb 2023 12:15:59 -0800 Subject: [PATCH 01/15] add error for dagre container-child edge --- d2graph/d2graph.go | 10 ++++++++++ d2plugin/plugin_elk.go | 1 + d2plugin/plugin_features.go | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 385a6b2ed..d1a06cf52 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1586,3 +1586,13 @@ func (g *Graph) SortEdgesByAST() { }) g.Edges = edges } + +func (obj *Object) IsDescendantOf(ancestor *Object) bool { + if obj == ancestor { + return true + } + if obj.Parent == nil { + return false + } + return obj.Parent.IsDescendantOf(ancestor) +} diff --git a/d2plugin/plugin_elk.go b/d2plugin/plugin_elk.go index 3b2113c6d..d28fba3cb 100644 --- a/d2plugin/plugin_elk.go +++ b/d2plugin/plugin_elk.go @@ -89,6 +89,7 @@ func (p elkPlugin) Info(ctx context.Context) (*PluginInfo, error) { Type: "bundled", Features: []PluginFeature{ CONTAINER_DIMENSIONS, + DESCENDANT_EDGES, }, ShortHelp: "Eclipse Layout Kernel (ELK) with the Layered algorithm.", LongHelp: fmt.Sprintf(`ELK is a layout engine offered by Eclipse. diff --git a/d2plugin/plugin_features.go b/d2plugin/plugin_features.go index f41462b37..20bdb4d95 100644 --- a/d2plugin/plugin_features.go +++ b/d2plugin/plugin_features.go @@ -18,6 +18,9 @@ const CONTAINER_DIMENSIONS PluginFeature = "container_dimensions" // When this is true, objects can specify their `top` and `left` keywords const TOP_LEFT PluginFeature = "top_left" +// When this is true, containers can have connections to descendants +const DESCENDANT_EDGES PluginFeature = "descendant_edges" + func FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error { // Older version of plugin. Skip checking. if info.Features == nil { @@ -50,5 +53,12 @@ func FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error { } } } + if _, ok := featureMap[DESCENDANT_EDGES]; !ok { + for _, e := range g.Edges { + if e.Src.IsDescendantOf(e.Dst) || e.Dst.IsDescendantOf(e.Src) { + return fmt.Errorf(`Connection "%s" goes from a container to a descendant, but layout engine "%s" does not support this.`, e.AbsID(), info.Name) + } + } + } return nil } From c8ad0dc0d52e75555c549996808a259e2ae1b3fa Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 22 Feb 2023 12:31:41 -0800 Subject: [PATCH 02/15] check for plugin feature errors in e2e tests --- d2plugin/plugin_features.go | 10 +++++++++ e2etests/e2e_test.go | 41 ++++++++++++++++++++++++++++++------- e2etests/stable_test.go | 2 ++ e2etests/todo_test.go | 3 +++ 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/d2plugin/plugin_features.go b/d2plugin/plugin_features.go index 20bdb4d95..76e1825b4 100644 --- a/d2plugin/plugin_features.go +++ b/d2plugin/plugin_features.go @@ -55,6 +55,16 @@ func FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error { } if _, ok := featureMap[DESCENDANT_EDGES]; !ok { for _, e := range g.Edges { + // descendant edges are ok in sequence diagrams + if e.Src.OuterSequenceDiagram() != nil || e.Dst.OuterSequenceDiagram() != nil { + continue + } + if !e.Src.IsContainer() && !e.Dst.IsContainer() { + continue + } + if e.Src == e.Dst { + return fmt.Errorf(`Connection "%s" is a self loop on a container, but layout engine "%s" does not support this.`, e.AbsID(), info.Name) + } if e.Src.IsDescendantOf(e.Dst) || e.Dst.IsDescendantOf(e.Src) { return fmt.Errorf(`Connection "%s" goes from a container to a descendant, but layout engine "%s" does not support this.`, e.AbsID(), info.Name) } diff --git a/e2etests/e2e_test.go b/e2etests/e2e_test.go index ab4059cd4..0f3ba0ac8 100644 --- a/e2etests/e2e_test.go +++ b/e2etests/e2e_test.go @@ -24,6 +24,7 @@ import ( "oss.terrastruct.com/d2/d2layouts/d2near" "oss.terrastruct.com/d2/d2layouts/d2sequence" "oss.terrastruct.com/d2/d2lib" + "oss.terrastruct.com/d2/d2plugin" "oss.terrastruct.com/d2/d2renderers/d2svg" "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/lib/log" @@ -73,12 +74,14 @@ a -> c } type testCase struct { - name string - script string - mtexts []*d2target.MText - assertions func(t *testing.T, diagram *d2target.Diagram) - skip bool - expErr string + name string + script string + mtexts []*d2target.MText + assertions func(t *testing.T, diagram *d2target.Diagram) + skip bool + dagreFeatureError string + elkFeatureError string + expErr string } func runa(t *testing.T, tcs []testCase) { @@ -136,16 +139,20 @@ func run(t *testing.T, tc testCase) { for _, layoutName := range layoutsTested { var layout func(context.Context, *d2graph.Graph) error + var plugin d2plugin.Plugin if layoutName == "dagre" { layout = d2dagrelayout.DefaultLayout + plugin = &d2plugin.DagrePlugin } else if layoutName == "elk" { // If measured texts exists, we are specifically exercising text measurements, no need to run on both layouts if tc.mtexts != nil { continue } layout = d2elklayout.DefaultLayout + plugin = &d2plugin.ELKPlugin } - diagram, _, err := d2lib.Compile(ctx, tc.script, &d2lib.CompileOptions{ + + diagram, g, err := d2lib.Compile(ctx, tc.script, &d2lib.CompileOptions{ Ruler: ruler, MeasuredTexts: tc.mtexts, ThemeID: 0, @@ -160,6 +167,26 @@ func run(t *testing.T, tc testCase) { assert.Success(t, err) } + pluginInfo, err := plugin.Info(ctx) + assert.Success(t, err) + + err = d2plugin.FeatureSupportCheck(pluginInfo, g) + switch layoutName { + case "dagre": + if tc.dagreFeatureError != "" { + assert.Error(t, err) + assert.ErrorString(t, err, tc.dagreFeatureError) + return + } + case "elk": + if tc.elkFeatureError != "" { + assert.Error(t, err) + assert.ErrorString(t, err, tc.elkFeatureError) + return + } + } + assert.Success(t, err) + if tc.assertions != nil { t.Run("assertions", func(t *testing.T) { tc.assertions(t, diagram) diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index 169d1ad1e..615dff3ec 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -448,6 +448,7 @@ eee.shape: document eee <- aaa.ccc (eee <- aaa.ccc)[0]: '222' `, + dagreFeatureError: `Connection "(aaa.ccc -- aaa)[0]" goes from a container to a descendant, but layout engine "dagre" does not support this.`, }, { name: "chaos2", @@ -1792,6 +1793,7 @@ c: { a } `, + dagreFeatureError: `Object "a" has attribute "width" and/or "height" set, but layout engine "dagre" does not support dimensions set on containers.`, }, { name: "crow_foot_arrowhead", diff --git a/e2etests/todo_test.go b/e2etests/todo_test.go index 5d5953cdd..17903edbd 100644 --- a/e2etests/todo_test.go +++ b/e2etests/todo_test.go @@ -14,12 +14,14 @@ func testTodo(t *testing.T) { container.first -> container.second: 1->2 container -> container.second: c->2 `, + dagreFeatureError: `Connection "(container -> container.second)[0]" goes from a container to a descendant, but layout engine "dagre" does not support this.`, }, { name: "child_parent_edges", script: `a.b -> a a.b -> a.b.c a.b.c.d -> a.b`, + dagreFeatureError: `Connection "(a.b -> a)[0]" goes from a container to a descendant, but layout engine "dagre" does not support this.`, }, { name: "container_label_loop", @@ -27,6 +29,7 @@ a.b.c.d -> a.b`, b -> c } a -> a`, + dagreFeatureError: `Connection "(a -> a)[0]" is a self loop on a container, but layout engine "dagre" does not support this.`, }, { // as nesting gets deeper, the groups advance towards `c` and may overlap its lifeline From 0608dfdc14820915c30b9f97f66bc3094bb9d1d0 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 22 Feb 2023 12:51:27 -0800 Subject: [PATCH 03/15] cleanup --- .../stable/chaos1/dagre/board.exp.json | 309 ------------ .../stable/chaos1/dagre/sketch.exp.svg | 67 --- .../container_dimensions/dagre/board.exp.json | 473 ------------------ .../container_dimensions/dagre/sketch.exp.svg | 59 --- .../child_parent_edges/dagre/board.exp.json | 379 -------------- .../child_parent_edges/dagre/sketch.exp.svg | 59 --- .../container_child_edge/dagre/board.exp.json | 227 --------- .../container_child_edge/dagre/sketch.exp.svg | 67 --- .../container_label_loop/dagre/board.exp.json | 263 ---------- .../container_label_loop/dagre/sketch.exp.svg | 59 --- 10 files changed, 1962 deletions(-) delete mode 100644 e2etests/testdata/stable/chaos1/dagre/board.exp.json delete mode 100644 e2etests/testdata/stable/chaos1/dagre/sketch.exp.svg delete mode 100644 e2etests/testdata/stable/container_dimensions/dagre/board.exp.json delete mode 100644 e2etests/testdata/stable/container_dimensions/dagre/sketch.exp.svg delete mode 100644 e2etests/testdata/todo/child_parent_edges/dagre/board.exp.json delete mode 100644 e2etests/testdata/todo/child_parent_edges/dagre/sketch.exp.svg delete mode 100644 e2etests/testdata/todo/container_child_edge/dagre/board.exp.json delete mode 100644 e2etests/testdata/todo/container_child_edge/dagre/sketch.exp.svg delete mode 100644 e2etests/testdata/todo/container_label_loop/dagre/board.exp.json delete mode 100644 e2etests/testdata/todo/container_label_loop/dagre/sketch.exp.svg diff --git a/e2etests/testdata/stable/chaos1/dagre/board.exp.json b/e2etests/testdata/stable/chaos1/dagre/board.exp.json deleted file mode 100644 index 79f84598b..000000000 --- a/e2etests/testdata/stable/chaos1/dagre/board.exp.json +++ /dev/null @@ -1,309 +0,0 @@ -{ - "name": "", - "fontFamily": "SourceSansPro", - "shapes": [ - { - "id": "aaa", - "type": "rectangle", - "pos": { - "x": 0, - "y": 41 - }, - "width": 173, - "height": 389, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#E3E9FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "aaa", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 41, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "aaa.bbb", - "type": "callout", - "pos": { - "x": 40, - "y": 309 - }, - "width": 72, - "height": 91, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "bbb", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 27, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "aaa.ccc", - "type": "rectangle", - "pos": { - "x": 64, - "y": 96 - }, - "width": 68, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "ccc", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 23, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "ddd", - "type": "cylinder", - "pos": { - "x": 213, - "y": 50 - }, - "width": 73, - "height": 118, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "ddd", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 28, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "eee", - "type": "document", - "pos": { - "x": 213, - "y": 297 - }, - "width": 70, - "height": 76, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "eee", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 25, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 - } - ], - "connections": [ - { - "id": "(aaa.ccc -- aaa)[0]", - "src": "aaa.ccc", - "srcArrow": "none", - "srcLabel": "", - "dst": "aaa", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "111", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 23, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "labelPercentage": 0, - "route": [ - { - "x": 91.92468619246861, - "y": 162.5 - }, - { - "x": 79.18493723849372, - "y": 231.7 - }, - { - "x": 76, - "y": 261.1 - }, - { - "x": 76, - "y": 309.5 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - }, - { - "id": "(eee <- aaa.ccc)[0]", - "src": "eee", - "srcArrow": "triangle", - "srcLabel": "", - "dst": "aaa.ccc", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "222", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 25, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "labelPercentage": 0, - "route": [ - { - "x": 213, - "y": 305 - }, - { - "x": 138.6, - "y": 243.8 - }, - { - "x": 116.8, - "y": 215.2 - }, - { - "x": 104, - "y": 162 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - } - ] -} diff --git a/e2etests/testdata/stable/chaos1/dagre/sketch.exp.svg b/e2etests/testdata/stable/chaos1/dagre/sketch.exp.svg deleted file mode 100644 index d2fcaff3c..000000000 --- a/e2etests/testdata/stable/chaos1/dagre/sketch.exp.svg +++ /dev/null @@ -1,67 +0,0 @@ - -aaadddeeebbbccc111 222 - - - - \ No newline at end of file diff --git a/e2etests/testdata/stable/container_dimensions/dagre/board.exp.json b/e2etests/testdata/stable/container_dimensions/dagre/board.exp.json deleted file mode 100644 index 317bd2d40..000000000 --- a/e2etests/testdata/stable/container_dimensions/dagre/board.exp.json +++ /dev/null @@ -1,473 +0,0 @@ -{ - "name": "", - "fontFamily": "SourceSansPro", - "shapes": [ - { - "id": "a", - "type": "rectangle", - "pos": { - "x": 0, - "y": 41 - }, - "width": 680, - "height": 575, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#E3E9FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "a", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 12, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "a.b", - "type": "rectangle", - "pos": { - "x": 140, - "y": 73 - }, - "width": 400, - "height": 61, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "b", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 8, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "a.c", - "type": "rectangle", - "pos": { - "x": 40, - "y": 406 - }, - "width": 600, - "height": 61, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "c", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 8, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "b", - "type": "rectangle", - "pos": { - "x": 853, - "y": 41 - }, - "width": 241, - "height": 575, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#E3E9FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "b", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 13, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "b.b", - "type": "rectangle", - "pos": { - "x": 893, - "y": 70 - }, - "width": 53, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "b", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 8, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "b.c", - "type": "rectangle", - "pos": { - "x": 893, - "y": 403 - }, - "width": 53, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "c", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 8, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "b.e", - "type": "rectangle", - "pos": { - "x": 1006, - "y": 286 - }, - "width": 48, - "height": 300, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "e", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 8, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "c", - "type": "rectangle", - "pos": { - "x": 700, - "y": 41 - }, - "width": 133, - "height": 125, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#E3E9FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "c", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 12, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "c.a", - "type": "rectangle", - "pos": { - "x": 740, - "y": 70 - }, - "width": 53, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "a", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 8, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - } - ], - "connections": [ - { - "id": "a.(b -> c)[0]", - "src": "a.b", - "srcArrow": "none", - "srcLabel": "", - "dst": "a.c", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 340, - "y": 135 - }, - { - "x": 340, - "y": 176.2 - }, - { - "x": 340, - "y": 270.4 - }, - { - "x": 340, - "y": 406 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - }, - { - "id": "b.(b -> c)[0]", - "src": "b.b", - "srcArrow": "none", - "srcLabel": "", - "dst": "b.c", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 919.5, - "y": 136.5 - }, - { - "x": 919.5, - "y": 176.5 - }, - { - "x": 919.5, - "y": 269.9 - }, - { - "x": 919.5, - "y": 403.5 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - } - ] -} diff --git a/e2etests/testdata/stable/container_dimensions/dagre/sketch.exp.svg b/e2etests/testdata/stable/container_dimensions/dagre/sketch.exp.svg deleted file mode 100644 index eb78ff58d..000000000 --- a/e2etests/testdata/stable/container_dimensions/dagre/sketch.exp.svg +++ /dev/null @@ -1,59 +0,0 @@ - -abcbcbcea - - - \ No newline at end of file diff --git a/e2etests/testdata/todo/child_parent_edges/dagre/board.exp.json b/e2etests/testdata/todo/child_parent_edges/dagre/board.exp.json deleted file mode 100644 index d0ff5aa83..000000000 --- a/e2etests/testdata/todo/child_parent_edges/dagre/board.exp.json +++ /dev/null @@ -1,379 +0,0 @@ -{ - "name": "", - "fontFamily": "SourceSansPro", - "shapes": [ - { - "id": "a", - "type": "rectangle", - "pos": { - "x": 0, - "y": 41 - }, - "width": 274, - "height": 325, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#E3E9FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "a", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 12, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "a.b", - "type": "rectangle", - "pos": { - "x": 20, - "y": 106 - }, - "width": 234, - "height": 230, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "b", - "fontSize": 24, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 12, - "labelHeight": 31, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "a.b.c", - "type": "rectangle", - "pos": { - "x": 40, - "y": 169 - }, - "width": 194, - "height": 135, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#F7F8FE", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "c", - "fontSize": 20, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 9, - "labelHeight": 26, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 3 - }, - { - "id": "a.b.c.d", - "type": "rectangle", - "pos": { - "x": 80, - "y": 204 - }, - "width": 54, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "d", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 9, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 4 - } - ], - "connections": [ - { - "id": "(a.b -> a)[0]", - "src": "a.b", - "srcArrow": "none", - "srcLabel": "", - "dst": "a", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 134, - "y": 222.8975155279503 - }, - { - "x": 155.33333333333331, - "y": 180.97950310559006 - }, - { - "x": 162, - "y": 170.5 - }, - { - "x": 164, - "y": 170.5 - }, - { - "x": 166, - "y": 170.5 - }, - { - "x": 168.66666666666669, - "y": 177.1 - }, - { - "x": 170.66666666666669, - "y": 187 - }, - { - "x": 172.66666666666666, - "y": 196.9 - }, - { - "x": 172.66666666666666, - "y": 210.1 - }, - { - "x": 170.66666666666669, - "y": 220 - }, - { - "x": 168.66666666666669, - "y": 229.9 - }, - { - "x": 155.33333333333331, - "y": 233.22049689440993 - }, - { - "x": 134, - "y": 220.1024844720497 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - }, - { - "id": "a.(b -> b.c)[0]", - "src": "a.b", - "srcArrow": "none", - "srcLabel": "", - "dst": "a.b.c", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 134, - "y": 208.20149253731344 - }, - { - "x": 166, - "y": 192.4402985074627 - }, - { - "x": 176, - "y": 188.5 - }, - { - "x": 179, - "y": 188.5 - }, - { - "x": 182, - "y": 188.5 - }, - { - "x": 186, - "y": 195.1 - }, - { - "x": 189, - "y": 205 - }, - { - "x": 192, - "y": 214.9 - }, - { - "x": 192, - "y": 228.1 - }, - { - "x": 189, - "y": 238 - }, - { - "x": 186, - "y": 247.9 - }, - { - "x": 166, - "y": 256.7597014925373 - }, - { - "x": 134, - "y": 265.79850746268653 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - }, - { - "id": "a.(b.c.d -> b)[0]", - "src": "a.b.c.d", - "srcArrow": "none", - "srcLabel": "", - "dst": "a.b", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 134.33333333333334, - "y": 248 - }, - { - "x": 134, - "y": 232.59128630705393 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - } - ] -} diff --git a/e2etests/testdata/todo/child_parent_edges/dagre/sketch.exp.svg b/e2etests/testdata/todo/child_parent_edges/dagre/sketch.exp.svg deleted file mode 100644 index 6ee251f44..000000000 --- a/e2etests/testdata/todo/child_parent_edges/dagre/sketch.exp.svg +++ /dev/null @@ -1,59 +0,0 @@ - -abcd - - - \ No newline at end of file diff --git a/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json b/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json deleted file mode 100644 index 3957f8df7..000000000 --- a/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json +++ /dev/null @@ -1,227 +0,0 @@ -{ - "name": "", - "fontFamily": "SourceSansPro", - "shapes": [ - { - "id": "container", - "type": "rectangle", - "pos": { - "x": 0, - "y": 41 - }, - "width": 175, - "height": 312, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#E3E9FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "container", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 112, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "container.first", - "type": "rectangle", - "pos": { - "x": 50, - "y": 70 - }, - "width": 75, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "first", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 30, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "container.second", - "type": "rectangle", - "pos": { - "x": 40, - "y": 257 - }, - "width": 95, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "second", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 50, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - } - ], - "connections": [ - { - "id": "container.(first -> second)[0]", - "src": "container.first", - "srcArrow": "none", - "srcLabel": "", - "dst": "container.second", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "1->2", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 29, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "labelPercentage": 0, - "route": [ - { - "x": 78.1470588235294, - "y": 136.5 - }, - { - "x": 64.42941176470588, - "y": 184.9 - }, - { - "x": 64.4, - "y": 209.2 - }, - { - "x": 78, - "y": 258 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - }, - { - "id": "(container -> container.second)[0]", - "src": "container", - "srcArrow": "none", - "srcLabel": "", - "dst": "container.second", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "c->2", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 28, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "labelPercentage": 0, - "route": [ - { - "x": 96.94117647058823, - "y": 136.5 - }, - { - "x": 110.78823529411764, - "y": 184.9 - }, - { - "x": 110.85, - "y": 209.2 - }, - { - "x": 97.25, - "y": 258 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - } - ] -} diff --git a/e2etests/testdata/todo/container_child_edge/dagre/sketch.exp.svg b/e2etests/testdata/todo/container_child_edge/dagre/sketch.exp.svg deleted file mode 100644 index b4fe3bc2b..000000000 --- a/e2etests/testdata/todo/container_child_edge/dagre/sketch.exp.svg +++ /dev/null @@ -1,67 +0,0 @@ - -containerfirstsecond 1->2c->2 - - - - \ No newline at end of file diff --git a/e2etests/testdata/todo/container_label_loop/dagre/board.exp.json b/e2etests/testdata/todo/container_label_loop/dagre/board.exp.json deleted file mode 100644 index 35ff0b882..000000000 --- a/e2etests/testdata/todo/container_label_loop/dagre/board.exp.json +++ /dev/null @@ -1,263 +0,0 @@ -{ - "name": "", - "fontFamily": "SourceSansPro", - "shapes": [ - { - "id": "a", - "type": "rectangle", - "pos": { - "x": 0, - "y": 41 - }, - "width": 153, - "height": 291, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#E3E9FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "If we were meant to fly, we wouldn't keep losing our luggage", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 702, - "labelHeight": 36, - "labelPosition": "OUTSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "a.b", - "type": "rectangle", - "pos": { - "x": 40, - "y": 70 - }, - "width": 53, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "b", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 8, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "a.c", - "type": "rectangle", - "pos": { - "x": 40, - "y": 236 - }, - "width": 53, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "c", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 8, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - } - ], - "connections": [ - { - "id": "a.(b -> c)[0]", - "src": "a.b", - "srcArrow": "none", - "srcLabel": "", - "dst": "a.c", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 66.5, - "y": 136.5 - }, - { - "x": 66.5, - "y": 176.5 - }, - { - "x": 66.5, - "y": 196.5 - }, - { - "x": 66.5, - "y": 236.5 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - }, - { - "id": "(a -> a)[0]", - "src": "a", - "srcArrow": "none", - "srcLabel": "", - "dst": "a", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 93, - "y": 107.55172413793103 - }, - { - "x": 114.33333333333334, - "y": 94.3103448275862 - }, - { - "x": 121, - "y": 91 - }, - { - "x": 123, - "y": 91 - }, - { - "x": 125.00000000000001, - "y": 91 - }, - { - "x": 127.66666666666667, - "y": 97.6 - }, - { - "x": 129.66666666666669, - "y": 107.5 - }, - { - "x": 131.66666666666666, - "y": 117.4 - }, - { - "x": 131.66666666666666, - "y": 130.6 - }, - { - "x": 129.66666666666669, - "y": 140.5 - }, - { - "x": 127.66666666666667, - "y": 150.4 - }, - { - "x": 114.33333333333334, - "y": 153.68965517241378 - }, - { - "x": 93, - "y": 140.44827586206895 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - } - ] -} diff --git a/e2etests/testdata/todo/container_label_loop/dagre/sketch.exp.svg b/e2etests/testdata/todo/container_label_loop/dagre/sketch.exp.svg deleted file mode 100644 index a7cf0d257..000000000 --- a/e2etests/testdata/todo/container_label_loop/dagre/sketch.exp.svg +++ /dev/null @@ -1,59 +0,0 @@ - -If we were meant to fly, we wouldn't keep losing our luggagebc - - - \ No newline at end of file From 389f4cb9d330226c04086464124cd2079a57f83a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 13:21:29 -0800 Subject: [PATCH 04/15] failing test --- d2compiler/compile_test.go | 27 + e2etests/regression_test.go | 14 + .../dagre/board.exp.json | 368 +++++++++++ .../dagre/sketch.exp.svg | 52 ++ .../elk/board.exp.json | 368 +++++++++++ .../elk/sketch.exp.svg | 52 ++ .../TestCompile/sequence-timestamp.exp.json | 608 ++++++++++++++++++ 7 files changed, 1489 insertions(+) create mode 100644 e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/sequence-note-escape-group/elk/board.exp.json create mode 100644 e2etests/testdata/regression/sequence-note-escape-group/elk/sketch.exp.svg create mode 100644 testdata/d2compiler/TestCompile/sequence-timestamp.exp.json diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 3b6f2ac6a..8a8bb33c3 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -1774,6 +1774,33 @@ dst.id <-> src.dst_id assert.String(t, "sequence_diagram", g.Objects[0].Attributes.Shape.Value) }, }, + { + name: "sequence-timestamp", + + text: `shape: sequence_diagram +a +b + +"04:20,11:20": { + "loop through each table": { + a."start_time = datetime.datetime.now" + a -> b + } +} +`, + assertions: func(t *testing.T, g *d2graph.Graph) { + tassert.Equal(t, 1, len(g.Edges)) + tassert.Equal(t, 5, len(g.Objects)) + tassert.Equal(t, "a", g.Objects[0].ID) + tassert.Equal(t, "b", g.Objects[1].ID) + tassert.Equal(t, `"04:20,11:20"`, g.Objects[2].ID) + tassert.Equal(t, `loop through each table`, g.Objects[3].ID) + tassert.Equal(t, 1, len(g.Objects[0].ChildrenArray)) + tassert.Equal(t, 0, len(g.Objects[1].ChildrenArray)) + tassert.Equal(t, 1, len(g.Objects[2].ChildrenArray)) + tassert.True(t, g.Edges[0].ContainedBy(g.Objects[3])) + }, + }, { name: "root_sequence", diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index 17a7e6e18..8b977c988 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -515,6 +515,20 @@ s: { s.n -> y.r: {style.stroke-width: 8; style.stroke: red} y.r -> a.g.i: 1\n2\n3\n4 +`, + }, + { + name: "sequence-note-escape-group", + script: `shape: sequence_diagram +a +b + +"04:20,11:20": { + "loop through each table": { + a."start_time = datetime.datetime.now" + a -> b + } +} `, }, } diff --git a/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json b/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json new file mode 100644 index 000000000..4d4584b8a --- /dev/null +++ b/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json @@ -0,0 +1,368 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "a", + "type": "rectangle", + "pos": { + "x": 12, + "y": 52 + }, + "width": 100, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 7, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "rectangle", + "pos": { + "x": 197, + "y": 52 + }, + "width": 100, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"04:20,11:20\"", + "type": "rectangle", + "pos": { + "x": 337, + "y": 52 + }, + "width": 121, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "04:20,11:20", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 76, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"04:20,11:20\".loop through each table", + "type": "rectangle", + "pos": { + "x": 391, + "y": 9223372036854775807 + }, + "width": 12, + "height": 30, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 160, + "labelHeight": 21, + "zIndex": 2, + "level": 2 + }, + { + "id": "a.\"start_time = datetime.datetime.now\"", + "type": "page", + "pos": { + "x": -82, + "y": 188 + }, + "width": 289, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "start_time = datetime.datetime.now", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 244, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 5, + "level": 2 + } + ], + "connections": [ + { + "id": "(a -> b)[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "b", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 62, + "y": 324 + }, + { + "x": 247, + "y": 324 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(a -- )[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 62, + "y": 118 + }, + { + "x": 62, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(b -- )[0]", + "src": "b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 247, + "y": 118 + }, + { + "x": 247, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(\"04:20,11:20\" -- )[0]", + "src": "\"04:20,11:20\"", + "srcArrow": "none", + "srcLabel": "", + "dst": "\"04:20,11:20\"-lifeline-end-548673492", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 397.5, + "y": 118 + }, + { + "x": 397.5, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg new file mode 100644 index 000000000..ce6398a9f --- /dev/null +++ b/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg @@ -0,0 +1,52 @@ + +ab04:20,11:20 start_time = datetime.datetime.now + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/sequence-note-escape-group/elk/board.exp.json b/e2etests/testdata/regression/sequence-note-escape-group/elk/board.exp.json new file mode 100644 index 000000000..4d4584b8a --- /dev/null +++ b/e2etests/testdata/regression/sequence-note-escape-group/elk/board.exp.json @@ -0,0 +1,368 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "a", + "type": "rectangle", + "pos": { + "x": 12, + "y": 52 + }, + "width": 100, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 7, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "rectangle", + "pos": { + "x": 197, + "y": 52 + }, + "width": 100, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"04:20,11:20\"", + "type": "rectangle", + "pos": { + "x": 337, + "y": 52 + }, + "width": 121, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "04:20,11:20", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 76, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"04:20,11:20\".loop through each table", + "type": "rectangle", + "pos": { + "x": 391, + "y": 9223372036854775807 + }, + "width": 12, + "height": 30, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 160, + "labelHeight": 21, + "zIndex": 2, + "level": 2 + }, + { + "id": "a.\"start_time = datetime.datetime.now\"", + "type": "page", + "pos": { + "x": -82, + "y": 188 + }, + "width": 289, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "start_time = datetime.datetime.now", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 244, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 5, + "level": 2 + } + ], + "connections": [ + { + "id": "(a -> b)[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "b", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 62, + "y": 324 + }, + { + "x": 247, + "y": 324 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(a -- )[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 62, + "y": 118 + }, + { + "x": 62, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(b -- )[0]", + "src": "b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 247, + "y": 118 + }, + { + "x": 247, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(\"04:20,11:20\" -- )[0]", + "src": "\"04:20,11:20\"", + "srcArrow": "none", + "srcLabel": "", + "dst": "\"04:20,11:20\"-lifeline-end-548673492", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 397.5, + "y": 118 + }, + { + "x": 397.5, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence-note-escape-group/elk/sketch.exp.svg b/e2etests/testdata/regression/sequence-note-escape-group/elk/sketch.exp.svg new file mode 100644 index 000000000..ce6398a9f --- /dev/null +++ b/e2etests/testdata/regression/sequence-note-escape-group/elk/sketch.exp.svg @@ -0,0 +1,52 @@ + +ab04:20,11:20 start_time = datetime.datetime.now + + + \ No newline at end of file diff --git a/testdata/d2compiler/TestCompile/sequence-timestamp.exp.json b/testdata/d2compiler/TestCompile/sequence-timestamp.exp.json new file mode 100644 index 000000000..c41a4f00b --- /dev/null +++ b/testdata/d2compiler/TestCompile/sequence-timestamp.exp.json @@ -0,0 +1,608 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:0:0-10:0:137", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:0:0-0:23:23", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:0:0-0:5:5", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:7:7-0:23:23", + "value": [ + { + "string": "sequence_diagram", + "raw_string": "sequence_diagram" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-9:1:136", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-4:13:42", + "path": [ + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-4:13:42", + "value": [ + { + "string": "04:20,11:20", + "raw_string": "04:20,11:20" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:15:44-9:0:135", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-8:3:134", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-5:27:73", + "path": [ + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-5:27:73", + "value": [ + { + "string": "loop through each table", + "raw_string": "loop through each table" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:29:75-8:2:133", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:42:119", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:42:119", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:5:82", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:6:83-6:42:119", + "value": [ + { + "string": "start_time = datetime.datetime.now", + "raw_string": "start_time = datetime.datetime.now" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:10:130", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:10:130", + "src": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:6:126", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:5:125", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:8:128-7:10:130", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:9:129-7:10:130", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "sequence_diagram" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:42:119", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:5:82", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:6:83-6:42:119", + "value": [ + { + "string": "start_time = datetime.datetime.now", + "raw_string": "start_time = datetime.datetime.now" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:6:126", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:5:125", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "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/sequence-timestamp.d2,2:0:26-2:1:27", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:8:128-7:10:130", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:9:129-7:10:130", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "\"04:20,11:20\"", + "id_val": "04:20,11:20", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-4:13:42", + "path": [ + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-4:13:42", + "value": [ + { + "string": "04:20,11:20", + "raw_string": "04:20,11:20" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "04:20,11:20" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "loop through each table", + "id_val": "loop through each table", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-5:27:73", + "path": [ + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-5:27:73", + "value": [ + { + "string": "loop through each table", + "raw_string": "loop through each table" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "loop through each table" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "\"start_time = datetime.datetime.now\"", + "id_val": "start_time = datetime.datetime.now", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:42:119", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:5:82", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:6:83-6:42:119", + "value": [ + { + "string": "start_time = datetime.datetime.now", + "raw_string": "start_time = datetime.datetime.now" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "start_time = datetime.datetime.now" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": null +} From d64e1ddbb12982f9212ac62a2a5ec9c6ae6a6336 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Thu, 9 Feb 2023 15:06:33 -0800 Subject: [PATCH 05/15] add test --- e2etests/todo_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2etests/todo_test.go b/e2etests/todo_test.go index 5d5953cdd..907cd750a 100644 --- a/e2etests/todo_test.go +++ b/e2etests/todo_test.go @@ -159,6 +159,15 @@ small code: |go width: 4 height: 3 } +`, + }, + { + skip: true, + name: "steps_panic", + script: `steps: { + shape: sql_table + id: {type: int, constraint: primary_key} +} `, }, { From a0f8dbee22c696438a795b8a897aa96358a63b6c Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 13:43:24 -0800 Subject: [PATCH 06/15] fix steps panic --- d2ir/compile.go | 3 ++ .../todo/steps_panic/dagre/board.exp.json | 22 +++++++++ .../todo/steps_panic/dagre/sketch.exp.svg | 45 +++++++++++++++++++ .../todo/steps_panic/elk/board.exp.json | 22 +++++++++ .../todo/steps_panic/elk/sketch.exp.svg | 45 +++++++++++++++++++ e2etests/todo_test.go | 7 ++- 6 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 e2etests/testdata/todo/steps_panic/dagre/board.exp.json create mode 100644 e2etests/testdata/todo/steps_panic/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/todo/steps_panic/elk/board.exp.json create mode 100644 e2etests/testdata/todo/steps_panic/elk/sketch.exp.svg diff --git a/d2ir/compile.go b/d2ir/compile.go index 03cc04b85..e59cb51be 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -66,6 +66,9 @@ func (c *compiler) compileSteps(m *Map) { if i == 0 { base = m.CopyBase(sf) } else { + if steps.Fields[i-1].Map() == nil { + continue + } base = steps.Fields[i-1].Map().CopyBase(sf) } OverlayMap(base, sf.Map()) diff --git a/e2etests/testdata/todo/steps_panic/dagre/board.exp.json b/e2etests/testdata/todo/steps_panic/dagre/board.exp.json new file mode 100644 index 000000000..b230f4a99 --- /dev/null +++ b/e2etests/testdata/todo/steps_panic/dagre/board.exp.json @@ -0,0 +1,22 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [], + "connections": [], + "scenarios": [ + { + "name": "hey", + "fontFamily": "SourceSansPro", + "shapes": [], + "connections": [] + } + ], + "steps": [ + { + "name": "id", + "fontFamily": "SourceSansPro", + "shapes": [], + "connections": [] + } + ] +} diff --git a/e2etests/testdata/todo/steps_panic/dagre/sketch.exp.svg b/e2etests/testdata/todo/steps_panic/dagre/sketch.exp.svg new file mode 100644 index 000000000..5169c50f1 --- /dev/null +++ b/e2etests/testdata/todo/steps_panic/dagre/sketch.exp.svg @@ -0,0 +1,45 @@ + + + + + \ No newline at end of file diff --git a/e2etests/testdata/todo/steps_panic/elk/board.exp.json b/e2etests/testdata/todo/steps_panic/elk/board.exp.json new file mode 100644 index 000000000..b230f4a99 --- /dev/null +++ b/e2etests/testdata/todo/steps_panic/elk/board.exp.json @@ -0,0 +1,22 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [], + "connections": [], + "scenarios": [ + { + "name": "hey", + "fontFamily": "SourceSansPro", + "shapes": [], + "connections": [] + } + ], + "steps": [ + { + "name": "id", + "fontFamily": "SourceSansPro", + "shapes": [], + "connections": [] + } + ] +} diff --git a/e2etests/testdata/todo/steps_panic/elk/sketch.exp.svg b/e2etests/testdata/todo/steps_panic/elk/sketch.exp.svg new file mode 100644 index 000000000..5169c50f1 --- /dev/null +++ b/e2etests/testdata/todo/steps_panic/elk/sketch.exp.svg @@ -0,0 +1,45 @@ + + + + + \ No newline at end of file diff --git a/e2etests/todo_test.go b/e2etests/todo_test.go index 907cd750a..bd2aeded0 100644 --- a/e2etests/todo_test.go +++ b/e2etests/todo_test.go @@ -162,11 +162,14 @@ small code: |go `, }, { - skip: true, name: "steps_panic", script: `steps: { shape: sql_table - id: {type: int, constraint: primary_key} + id: int {constraint: primary_key} +} +scenarios: { + shape: sql_table + hey: int {constraint: primary_key} } `, }, From 9c99212762abf053150caf8334fbcbe17711cc53 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 13:45:00 -0800 Subject: [PATCH 07/15] 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 6dbef495b..557bf32a1 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -18,3 +18,4 @@ - Fixes rare possibility of rendered connections being hidden or cut off. [#828](https://github.com/terrastruct/d2/pull/828) - Creating nested children within `sql_table` and `class` shapes are now prevented (caused confusion when accidentally done). [#834](https://github.com/terrastruct/d2/pull/834) - Fixes graph deserialization bug. [#837](https://github.com/terrastruct/d2/pull/837) +- `steps` with non-map fields could cause panics. [#783](https://github.com/terrastruct/d2/pull/783) From 691b45733db3b80dd5cfe42f315804a94902b3af Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 14:59:05 -0800 Subject: [PATCH 08/15] update --- d2ir/compile.go | 9 ++-- d2ir/compile_test.go | 17 +++++++ .../todo/steps_panic/dagre/board.exp.json | 22 --------- .../todo/steps_panic/dagre/sketch.exp.svg | 45 ------------------- .../todo/steps_panic/elk/board.exp.json | 22 --------- .../todo/steps_panic/elk/sketch.exp.svg | 45 ------------------- e2etests/todo_test.go | 12 ----- 7 files changed, 23 insertions(+), 149 deletions(-) delete mode 100644 e2etests/testdata/todo/steps_panic/dagre/board.exp.json delete mode 100644 e2etests/testdata/todo/steps_panic/dagre/sketch.exp.svg delete mode 100644 e2etests/testdata/todo/steps_panic/elk/board.exp.json delete mode 100644 e2etests/testdata/todo/steps_panic/elk/sketch.exp.svg diff --git a/d2ir/compile.go b/d2ir/compile.go index e59cb51be..182ebafb4 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -38,7 +38,8 @@ func (c *compiler) compileScenarios(m *Map) { } for _, sf := range scenarios.Fields { - if sf.Map() == nil { + if sf.Map() == nil || sf.Primary() != nil { + c.errorf(sf.References[0].Context.Key, "invalid scenario") continue } base := m.CopyBase(sf) @@ -59,14 +60,16 @@ func (c *compiler) compileSteps(m *Map) { return } for i, sf := range steps.Fields { - if sf.Map() == nil { + if sf.Map() == nil || sf.Primary() != nil { + c.errorf(sf.References[0].Context.Key, "invalid step") continue } var base *Map if i == 0 { base = m.CopyBase(sf) } else { - if steps.Fields[i-1].Map() == nil { + if steps.Fields[i-1].Map() == nil || steps.Fields[i-1].Primary() != nil { + c.errorf(steps.Fields[i-1].References[0].Context.Key, "invalid step") continue } base = steps.Fields[i-1].Map().CopyBase(sf) diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index bd21d9ae2..1a25e7b8f 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -420,6 +420,23 @@ steps: { assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche") }, }, + { + name: "steps_panic", + run: func(t testing.TB) { + _, err := compile(t, `steps: { + shape: sql_table + id: int {constraint: primary_key} +} +scenarios: { + shape: sql_table + hey: int {constraint: primary_key} +}`) + assert.ErrorString(t, err, `TestCompile/steps/steps_panic.d2:6:3: invalid scenario +TestCompile/steps/steps_panic.d2:7:3: invalid scenario +TestCompile/steps/steps_panic.d2:2:3: invalid step +TestCompile/steps/steps_panic.d2:3:3: invalid step`) + }, + }, { name: "recursive", run: func(t testing.TB) { diff --git a/e2etests/testdata/todo/steps_panic/dagre/board.exp.json b/e2etests/testdata/todo/steps_panic/dagre/board.exp.json deleted file mode 100644 index b230f4a99..000000000 --- a/e2etests/testdata/todo/steps_panic/dagre/board.exp.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "", - "fontFamily": "SourceSansPro", - "shapes": [], - "connections": [], - "scenarios": [ - { - "name": "hey", - "fontFamily": "SourceSansPro", - "shapes": [], - "connections": [] - } - ], - "steps": [ - { - "name": "id", - "fontFamily": "SourceSansPro", - "shapes": [], - "connections": [] - } - ] -} diff --git a/e2etests/testdata/todo/steps_panic/dagre/sketch.exp.svg b/e2etests/testdata/todo/steps_panic/dagre/sketch.exp.svg deleted file mode 100644 index 5169c50f1..000000000 --- a/e2etests/testdata/todo/steps_panic/dagre/sketch.exp.svg +++ /dev/null @@ -1,45 +0,0 @@ - - - - - \ No newline at end of file diff --git a/e2etests/testdata/todo/steps_panic/elk/board.exp.json b/e2etests/testdata/todo/steps_panic/elk/board.exp.json deleted file mode 100644 index b230f4a99..000000000 --- a/e2etests/testdata/todo/steps_panic/elk/board.exp.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "", - "fontFamily": "SourceSansPro", - "shapes": [], - "connections": [], - "scenarios": [ - { - "name": "hey", - "fontFamily": "SourceSansPro", - "shapes": [], - "connections": [] - } - ], - "steps": [ - { - "name": "id", - "fontFamily": "SourceSansPro", - "shapes": [], - "connections": [] - } - ] -} diff --git a/e2etests/testdata/todo/steps_panic/elk/sketch.exp.svg b/e2etests/testdata/todo/steps_panic/elk/sketch.exp.svg deleted file mode 100644 index 5169c50f1..000000000 --- a/e2etests/testdata/todo/steps_panic/elk/sketch.exp.svg +++ /dev/null @@ -1,45 +0,0 @@ - - - - - \ No newline at end of file diff --git a/e2etests/todo_test.go b/e2etests/todo_test.go index bd2aeded0..5d5953cdd 100644 --- a/e2etests/todo_test.go +++ b/e2etests/todo_test.go @@ -159,18 +159,6 @@ small code: |go width: 4 height: 3 } -`, - }, - { - name: "steps_panic", - script: `steps: { - shape: sql_table - id: int {constraint: primary_key} -} -scenarios: { - shape: sql_table - hey: int {constraint: primary_key} -} `, }, { From f40350609abf647e2046681a0d3a3733b687a684 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 15:34:41 -0800 Subject: [PATCH 09/15] fix near updating when not first path --- d2oracle/edit.go | 2 +- d2oracle/edit_test.go | 31 + .../delete_container_of_near.exp.json | 1504 +++++++++++++++++ 3 files changed, 1536 insertions(+), 1 deletion(-) create mode 100644 testdata/d2oracle/TestDelete/delete_container_of_near.exp.json diff --git a/d2oracle/edit.go b/d2oracle/edit.go index 8905450a7..dd2c882c9 100644 --- a/d2oracle/edit.go +++ b/d2oracle/edit.go @@ -1538,7 +1538,7 @@ func updateNear(prevG, g *d2graph.Graph, from, to *string) error { if len(n.MapKey.Key.Path) == 0 { continue } - if n.MapKey.Key.Path[0].Unbox().ScalarString() == "near" { + if n.MapKey.Key.Path[len(n.MapKey.Key.Path)-1].Unbox().ScalarString() == "near" { k := n.MapKey.Value.ScalarBox().Unbox().ScalarString() if strings.EqualFold(k, *from) && to == nil { deleteFromMap(obj.Map, n.MapKey) diff --git a/d2oracle/edit_test.go b/d2oracle/edit_test.go index 7cd1ef697..0fc9f7892 100644 --- a/d2oracle/edit_test.go +++ b/d2oracle/edit_test.go @@ -3824,6 +3824,37 @@ y exp: `x y +`, + }, + { + name: "delete_container_of_near", + + text: `direction: down +first input -> start game -> game loop + +game loop: { + direction: down + input -> increase bird top velocity + + move bird -> move pipes -> render + + render -> no collision -> wait 16 milliseconds -> move bird + render -> collision detected -> game over + no collision.near: game loop.collision detected +} +`, + key: `game loop`, + + exp: `direction: down +first input -> start game + +input -> increase bird top velocity + +move bird -> move pipes -> render + +render -> no collision -> wait 16 milliseconds -> move bird +render -> collision detected -> game over +no collision.near: collision detected `, }, { diff --git a/testdata/d2oracle/TestDelete/delete_container_of_near.exp.json b/testdata/d2oracle/TestDelete/delete_container_of_near.exp.json new file mode 100644 index 000000000..9dcbd5845 --- /dev/null +++ b/testdata/d2oracle/TestDelete/delete_container_of_near.exp.json @@ -0,0 +1,1504 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,0:0:0-10:0:255", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,0:0:0-0:15:15", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,0:0:0-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,0:0:0-0:9:9", + "value": [ + { + "string": "direction", + "raw_string": "direction" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,0:11:11-0:15:15", + "value": [ + { + "string": "down", + "raw_string": "down" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:0:16-1:25:41", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:0:16-1:25:41", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:0:16-1:12:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:0:16-1:11:27", + "value": [ + { + "string": "first input", + "raw_string": "first input" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:14:30-1:25:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:15:31-1:25:41", + "value": [ + { + "string": "start game", + "raw_string": "start game" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:0:43-3:35:78", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:0:43-3:35:78", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:0:43-3:6:49", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:0:43-3:5:48", + "value": [ + { + "string": "input", + "raw_string": "input" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:8:51-3:35:78", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:9:52-3:35:78", + "value": [ + { + "string": "increase bird top velocity", + "raw_string": "increase bird top velocity" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:0:80-5:33:113", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:0:80-5:24:104", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:0:80-5:10:90", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:0:80-5:9:89", + "value": [ + { + "string": "move bird", + "raw_string": "move bird" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:12:92-5:24:104", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:13:93-5:23:103", + "value": [ + { + "string": "move pipes", + "raw_string": "move pipes" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:12:92-5:33:113", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:12:92-5:24:104", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:13:93-5:23:103", + "value": [ + { + "string": "move pipes", + "raw_string": "move pipes" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:26:106-5:33:113", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:27:107-5:33:113", + "value": [ + { + "string": "render", + "raw_string": "render" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:0:115-7:59:174", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:0:115-7:23:138", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:0:115-7:7:122", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:0:115-7:6:121", + "value": [ + { + "string": "render", + "raw_string": "render" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:9:124-7:23:138", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:10:125-7:22:137", + "value": [ + { + "string": "no collision", + "raw_string": "no collision" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:9:124-7:47:162", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:9:124-7:23:138", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:10:125-7:22:137", + "value": [ + { + "string": "no collision", + "raw_string": "no collision" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:25:140-7:47:162", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:26:141-7:46:161", + "value": [ + { + "string": "wait 16 milliseconds", + "raw_string": "wait 16 milliseconds" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:25:140-7:59:174", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:25:140-7:47:162", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:26:141-7:46:161", + "value": [ + { + "string": "wait 16 milliseconds", + "raw_string": "wait 16 milliseconds" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:49:164-7:59:174", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:50:165-7:59:174", + "value": [ + { + "string": "move bird", + "raw_string": "move bird" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:0:175-8:41:216", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:0:175-8:29:204", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:0:175-8:7:182", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:0:175-8:6:181", + "value": [ + { + "string": "render", + "raw_string": "render" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:9:184-8:29:204", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:10:185-8:28:203", + "value": [ + { + "string": "collision detected", + "raw_string": "collision detected" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:9:184-8:41:216", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:9:184-8:29:204", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:10:185-8:28:203", + "value": [ + { + "string": "collision detected", + "raw_string": "collision detected" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:31:206-8:41:216", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:32:207-8:41:216", + "value": [ + { + "string": "game over", + "raw_string": "game over" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:0:217-9:37:254", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:0:217-9:17:234", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:0:217-9:12:229", + "value": [ + { + "string": "no collision", + "raw_string": "no collision" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:13:230-9:17:234", + "value": [ + { + "string": "near", + "raw_string": "near" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:19:236-9:37:254", + "value": [ + { + "string": "collision detected", + "raw_string": "collision detected" + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "down" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 2 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "first input", + "id_val": "first input", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:0:16-1:12:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:0:16-1:11:27", + "value": [ + { + "string": "first input", + "raw_string": "first input" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "first input" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "start game", + "id_val": "start game", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:14:30-1:25:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,1:15:31-1:25:41", + "value": [ + { + "string": "start game", + "raw_string": "start game" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "start game" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "input", + "id_val": "input", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:0:43-3:6:49", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:0:43-3:5:48", + "value": [ + { + "string": "input", + "raw_string": "input" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "input" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "increase bird top velocity", + "id_val": "increase bird top velocity", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:8:51-3:35:78", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,3:9:52-3:35:78", + "value": [ + { + "string": "increase bird top velocity", + "raw_string": "increase bird top velocity" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "increase bird top velocity" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "move bird", + "id_val": "move bird", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:0:80-5:10:90", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:0:80-5:9:89", + "value": [ + { + "string": "move bird", + "raw_string": "move bird" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:49:164-7:59:174", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:50:165-7:59:174", + "value": [ + { + "string": "move bird", + "raw_string": "move bird" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 2 + } + ], + "attributes": { + "label": { + "value": "move bird" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "move pipes", + "id_val": "move pipes", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:12:92-5:24:104", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:13:93-5:23:103", + "value": [ + { + "string": "move pipes", + "raw_string": "move pipes" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:12:92-5:24:104", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:13:93-5:23:103", + "value": [ + { + "string": "move pipes", + "raw_string": "move pipes" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "move pipes" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "render", + "id_val": "render", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:26:106-5:33:113", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,5:27:107-5:33:113", + "value": [ + { + "string": "render", + "raw_string": "render" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:0:115-7:7:122", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:0:115-7:6:121", + "value": [ + { + "string": "render", + "raw_string": "render" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:0:175-8:7:182", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:0:175-8:6:181", + "value": [ + { + "string": "render", + "raw_string": "render" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "render" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "no collision", + "id_val": "no collision", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:9:124-7:23:138", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:10:125-7:22:137", + "value": [ + { + "string": "no collision", + "raw_string": "no collision" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:9:124-7:23:138", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:10:125-7:22:137", + "value": [ + { + "string": "no collision", + "raw_string": "no collision" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:0:217-9:17:234", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:0:217-9:12:229", + "value": [ + { + "string": "no collision", + "raw_string": "no collision" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:13:230-9:17:234", + "value": [ + { + "string": "near", + "raw_string": "near" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "no collision" + }, + "style": {}, + "near_key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,9:19:236-9:37:254", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:18:18", + "value": [ + { + "string": "collision detected", + "raw_string": "collision detected" + } + ] + } + } + ] + }, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "wait 16 milliseconds", + "id_val": "wait 16 milliseconds", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:25:140-7:47:162", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:26:141-7:46:161", + "value": [ + { + "string": "wait 16 milliseconds", + "raw_string": "wait 16 milliseconds" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:25:140-7:47:162", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,7:26:141-7:46:161", + "value": [ + { + "string": "wait 16 milliseconds", + "raw_string": "wait 16 milliseconds" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 2 + } + ], + "attributes": { + "label": { + "value": "wait 16 milliseconds" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "collision detected", + "id_val": "collision detected", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:9:184-8:29:204", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:10:185-8:28:203", + "value": [ + { + "string": "collision detected", + "raw_string": "collision detected" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:9:184-8:29:204", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:10:185-8:28:203", + "value": [ + { + "string": "collision detected", + "raw_string": "collision detected" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "collision detected" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "game over", + "id_val": "game over", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:31:206-8:41:216", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/delete_container_of_near.d2,8:32:207-8:41:216", + "value": [ + { + "string": "game over", + "raw_string": "game over" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "game over" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} From f0eba7dda775d3756d910d2ad01a1a76c8b99bc7 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 22 Feb 2023 16:07:24 -0800 Subject: [PATCH 10/15] d2compiler: Fix sequence-timestamp test --- d2compiler/compile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 3d4a55a7f..8cc6452a7 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -427,7 +427,7 @@ func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { edge.Attributes.Label.MapKey = e.LastPrimaryKey() for _, er := range e.References { scopeObjIDA := d2ir.IDA(er.Context.ScopeMap) - scopeObj, _ := edge.Src.Graph.Root.HasChildIDVal(d2graphIDA(scopeObjIDA)) + scopeObj, _ := edge.Src.Graph.Root.HasChildIDVal(scopeObjIDA) edge.References = append(edge.References, d2graph.EdgeReference{ Edge: er.Context.Edge, MapKey: er.Context.Key, From a027564100ec08db60c8f55aeb09c9f69a2c359e Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 16:21:16 -0800 Subject: [PATCH 11/15] update --- d2ir/compile.go | 6 +----- d2ir/compile_test.go | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/d2ir/compile.go b/d2ir/compile.go index 182ebafb4..167fd0972 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -62,16 +62,12 @@ func (c *compiler) compileSteps(m *Map) { for i, sf := range steps.Fields { if sf.Map() == nil || sf.Primary() != nil { c.errorf(sf.References[0].Context.Key, "invalid step") - continue + break } var base *Map if i == 0 { base = m.CopyBase(sf) } else { - if steps.Fields[i-1].Map() == nil || steps.Fields[i-1].Primary() != nil { - c.errorf(steps.Fields[i-1].References[0].Context.Key, "invalid step") - continue - } base = steps.Fields[i-1].Map().CopyBase(sf) } OverlayMap(base, sf.Map()) diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 1a25e7b8f..71d46c924 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -433,8 +433,7 @@ scenarios: { }`) assert.ErrorString(t, err, `TestCompile/steps/steps_panic.d2:6:3: invalid scenario TestCompile/steps/steps_panic.d2:7:3: invalid scenario -TestCompile/steps/steps_panic.d2:2:3: invalid step -TestCompile/steps/steps_panic.d2:3:3: invalid step`) +TestCompile/steps/steps_panic.d2:2:3: invalid step`) }, }, { From a733c6ec2fc2b687ca98255bb7effb4ad608d65d Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 16:22:28 -0800 Subject: [PATCH 12/15] regen test --- .../dagre/board.exp.json | 146 +++++++----------- .../dagre/sketch.exp.svg | 9 +- .../elk/board.exp.json | 146 +++++++----------- .../elk/sketch.exp.svg | 9 +- 4 files changed, 120 insertions(+), 190 deletions(-) diff --git a/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json b/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json index 4d4584b8a..1bb1391e5 100644 --- a/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json @@ -88,52 +88,11 @@ "id": "\"04:20,11:20\"", "type": "rectangle", "pos": { - "x": 337, - "y": 52 + "x": -134, + "y": 161 }, - "width": 121, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "04:20,11:20", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 76, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "\"04:20,11:20\".loop through each table", - "type": "rectangle", - "pos": { - "x": 391, - "y": 9223372036854775807 - }, - "width": 12, - "height": 30, + "width": 433, + "height": 248, "opacity": 1, "strokeDash": 0, "strokeWidth": 0, @@ -152,7 +111,49 @@ "fields": null, "methods": null, "columns": null, - "label": "", + "label": "04:20,11:20", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 76, + "labelHeight": 21, + "labelFill": "#DEE1EB", + "labelPosition": "INSIDE_TOP_LEFT", + "zIndex": 3, + "level": 1 + }, + { + "id": "\"04:20,11:20\".loop through each table", + "type": "rectangle", + "pos": { + "x": -122, + "y": 202 + }, + "width": 409, + "height": 195, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "loop through each table", "fontSize": 16, "fontFamily": "DEFAULT", "language": "", @@ -162,7 +163,9 @@ "underline": false, "labelWidth": 160, "labelHeight": 21, - "zIndex": 2, + "labelFill": "#DEE1EB", + "labelPosition": "INSIDE_TOP_LEFT", + "zIndex": 3, "level": 2 }, { @@ -170,7 +173,7 @@ "type": "page", "pos": { "x": -82, - "y": 188 + "y": 246 }, "width": 289, "height": 66, @@ -235,11 +238,11 @@ "route": [ { "x": 62, - "y": 324 + "y": 382 }, { "x": 247, - "y": 324 + "y": 382 } ], "animated": false, @@ -278,7 +281,7 @@ }, { "x": 62, - "y": 394 + "y": 452 } ], "animated": false, @@ -317,46 +320,7 @@ }, { "x": 247, - "y": 394 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 1 - }, - { - "id": "(\"04:20,11:20\" -- )[0]", - "src": "\"04:20,11:20\"", - "srcArrow": "none", - "srcLabel": "", - "dst": "\"04:20,11:20\"-lifeline-end-548673492", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 6, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 397.5, - "y": 118 - }, - { - "x": 397.5, - "y": 394 + "y": 452 } ], "animated": false, diff --git a/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg index ce6398a9f..a8fe48516 100644 --- a/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="744" height="544" viewBox="-184 -50 744 544">