From 60e5a33c8ad6dda0b2ca961dc90a69ca482758a0 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 29 Apr 2023 21:50:11 -0700 Subject: [PATCH] implement ReconnectEdge --- d2oracle/edit.go | 287 +++++++-- d2oracle/edit_test.go | 519 +++++++++++++++ .../d2oracle/TestReconnectEdge/basic.exp.json | 369 +++++++++++ .../d2oracle/TestReconnectEdge/both.exp.json | 369 +++++++++++ .../TestReconnectEdge/contained.exp.json | 565 +++++++++++++++++ .../TestReconnectEdge/in_chain_3.exp.json | 467 ++++++++++++++ .../TestReconnectEdge/in_chain_4.exp.json | 510 +++++++++++++++ .../TestReconnectEdge/indexed_ref.exp.json | 461 ++++++++++++++ .../d2oracle/TestReconnectEdge/loop.exp.json | 256 ++++++++ .../TestReconnectEdge/middle_chain.exp.json | 428 +++++++++++++ .../middle_chain_both.exp.json | 573 +++++++++++++++++ .../middle_chain_first.exp.json | 598 ++++++++++++++++++ .../middle_chain_last.exp.json | 598 ++++++++++++++++++ .../middle_chain_src.exp.json | 428 +++++++++++++ .../TestReconnectEdge/missing_params.exp.json | 4 + .../nonexistant_edge.exp.json | 4 + .../nonexistant_obj.exp.json | 4 + .../TestReconnectEdge/reverse.exp.json | 213 +++++++ .../TestReconnectEdge/scope_inner.exp.json | 531 ++++++++++++++++ .../TestReconnectEdge/scope_outer.exp.json | 424 +++++++++++++ .../TestReconnectEdge/second_index.exp.json | 509 +++++++++++++++ .../d2oracle/TestReconnectEdge/src.exp.json | 369 +++++++++++ 22 files changed, 8435 insertions(+), 51 deletions(-) create mode 100644 testdata/d2oracle/TestReconnectEdge/basic.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/both.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/contained.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/in_chain_3.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/in_chain_4.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/indexed_ref.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/loop.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/middle_chain.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/middle_chain_both.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/middle_chain_first.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/middle_chain_last.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/middle_chain_src.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/missing_params.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/nonexistant_edge.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/nonexistant_obj.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/reverse.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/scope_inner.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/scope_outer.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/second_index.exp.json create mode 100644 testdata/d2oracle/TestReconnectEdge/src.exp.json diff --git a/d2oracle/edit.go b/d2oracle/edit.go index bd0f2b48a..46a8f95e9 100644 --- a/d2oracle/edit.go +++ b/d2oracle/edit.go @@ -68,6 +68,146 @@ func Set(g *d2graph.Graph, key string, tag, value *string) (_ *d2graph.Graph, er return recompile(g) } +func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ *d2graph.Graph, err error) { + mk, err := d2parser.ParseMapKey(edgeKey) + if err != nil { + return nil, err + } + + if len(mk.Edges) == 0 { + return nil, errors.New("edgeKey must be an edge") + } + + if mk.EdgeIndex == nil { + return nil, errors.New("edgeKey must refer to an existing edge") + } + + if srcKey == nil && dstKey == nil { + return nil, errors.New("must provide at least one new endpoint") + } + + edge, ok := g.Root.HasEdge(mk) + if !ok { + return nil, errors.New("edge not found") + } + + var src *d2graph.Object + var dst *d2graph.Object + if srcKey != nil { + srcmk, err := d2parser.ParseMapKey(*srcKey) + if err != nil { + return nil, err + } + src, ok = g.Root.HasChild(d2graph.Key(srcmk.Key)) + if !ok { + return nil, errors.New("newSrc not found") + } + } + if dstKey != nil { + dstmk, err := d2parser.ParseMapKey(*dstKey) + if err != nil { + return nil, err + } + dst, ok = g.Root.HasChild(d2graph.Key(dstmk.Key)) + if !ok { + return nil, errors.New("newDst not found") + } + } + + ref := edge.References[0] + + // for loops where only one end is changing, node is always ensured + if edge.Src != edge.Dst && (srcKey == nil || dstKey == nil) { + var refEdges []*d2ast.Edge + for _, ref := range edge.References { + refEdges = append(refEdges, ref.Edge) + } + + if srcKey != nil { + ensureNode(g, refEdges, ref.ScopeObj, ref.Scope, ref.MapKey, ref.MapKey.Edges[ref.MapKeyEdgeIndex].Src, true) + } + if dstKey != nil { + ensureNode(g, refEdges, ref.ScopeObj, ref.Scope, ref.MapKey, ref.MapKey.Edges[ref.MapKeyEdgeIndex].Dst, false) + } + } + + for i := range edge.References { + ref := edge.References[i] + // it's a chain + if len(ref.MapKey.Edges) > 1 && ref.MapKey.EdgeIndex == nil { + splitChain := true + // Changing the start of a chain is okay + if ref.MapKeyEdgeIndex == 0 && dstKey == nil { + splitChain = false + } + // Changing the end of a chain is okay + if ref.MapKeyEdgeIndex == len(ref.MapKey.Edges)-1 && srcKey == nil { + splitChain = false + } + if splitChain { + tmp := *ref.MapKey + mk2 := &tmp + mk2.Edges = []*d2ast.Edge{ref.MapKey.Edges[ref.MapKeyEdgeIndex]} + ref.Scope.InsertAfter(ref.MapKey, mk2) + + if ref.MapKeyEdgeIndex < len(ref.MapKey.Edges)-1 { + tmp := *ref.MapKey + mk2 := &tmp + mk2.Edges = ref.MapKey.Edges[ref.MapKeyEdgeIndex+1:] + ref.Scope.InsertAfter(ref.MapKey, mk2) + } + ref.MapKey.Edges = ref.MapKey.Edges[:ref.MapKeyEdgeIndex] + } + } + + if src != nil { + srcmk, _ := d2parser.ParseMapKey(*srcKey) + ref.Edge.Src = srcmk.Key + newPath, err := pathFromScope(g, srcmk, ref.ScopeObj) + if err != nil { + return nil, err + } + ref.Edge.Src.Path = newPath + } + if dst != nil { + dstmk, _ := d2parser.ParseMapKey(*dstKey) + ref.Edge.Dst = dstmk.Key + newPath, err := pathFromScope(g, dstmk, ref.ScopeObj) + if err != nil { + return nil, err + } + ref.Edge.Dst.Path = newPath + } + } + + return recompile(g) +} + +func pathFromScope(g *d2graph.Graph, key *d2ast.Key, fromScope *d2graph.Object) ([]*d2ast.StringBox, error) { + ak2 := d2graph.Key(key.Key) + + // We don't want this to be underscore-resolved scope. We want to ignore underscores + var scopeak []string + if fromScope != g.Root { + scopek, err := d2parser.ParseKey(fromScope.AbsID()) + if err != nil { + return nil, err + } + scopeak = d2graph.Key(scopek) + } + commonPath := getCommonPath(scopeak, ak2) + + var newPath []*d2ast.StringBox + // Move out to most common scope + for i := len(commonPath); i < len(scopeak); i++ { + newPath = append(newPath, d2ast.MakeValueBox(d2ast.RawString("_", true)).StringBox()) + } + // From most common scope, target the toKey + newPath = append(newPath, key.Key.Path[len(commonPath):]...) + + return newPath, nil +} + func recompile(g *d2graph.Graph) (*d2graph.Graph, error) { s := d2format.Format(g.AST) g, err := d2compiler.Compile(g.AST.Range.Path, strings.NewReader(s), nil) @@ -1476,17 +1616,6 @@ func move(g *d2graph.Graph, key, newKey string) (*d2graph.Graph, error) { continue } - // We don't want this to be underscore-resolved scope. We want to ignore underscores - var scopeak []string - if ref.ScopeObj != g.Root { - scopek, err := d2parser.ParseKey(ref.ScopeObj.AbsID()) - if err != nil { - return nil, err - } - scopeak = d2graph.Key(scopek) - } - commonPath := getCommonPath(scopeak, ak2) - // When moving a node out of an edge, e.g. the `b` out of `a.b.c -> ...`, // The edge needs to continue targeting the same thing (c) if ref.KeyPathIndex != len(ref.Key.Path)-1 { @@ -1507,13 +1636,12 @@ func move(g *d2graph.Graph, key, newKey string) (*d2graph.Graph, error) { detachedK.Path = detachedK.Path[:len(detachedK.Path)-1] ensureNode(g, refEdges, ref.ScopeObj, ref.Scope, ref.MapKey, detachedK, false) } - // Move out to most common scope - ref.Key.Path = nil - for i := len(commonPath); i < len(scopeak); i++ { - ref.Key.Path = append(ref.Key.Path, d2ast.MakeValueBox(d2ast.RawString("_", true)).StringBox()) + + newPath, err := pathFromScope(g, mk2, ref.ScopeObj) + if err != nil { + return nil, err } - // From most common scope, target the toKey - ref.Key.Path = append(ref.Key.Path, mk2.Key.Path[len(commonPath):]...) + ref.Key.Path = newPath } } @@ -1691,55 +1819,112 @@ func ReparentIDDelta(g *d2graph.Graph, key, parentKey string) (string, error) { return id, nil } -func ReconnectEdgeIDDelta(g *d2graph.Graph, edgeID, srcID, dstID string) (string, error) { - mk, err := d2parser.ParseMapKey(edgeID) +func ReconnectEdgeIDDeltas(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (deltas map[string]string, err error) { + defer xdefer.Errorf(&err, "failed to get deltas for reconnect edge %#v", edgeKey) + deltas = make(map[string]string) + // Reconnection: nothing is created or destroyed, the edge just gets a new ID + // For deltas, it's indices that change: + // - old sibling edges may decrement index + // -- happens when the edge is not the last edge index + // - new sibling edges may increment index + // -- happens when the edge is not the last edge index + // - new edge of course always needs an entry + + // The change happens at the first ref, since that is what changes index + mk, err := d2parser.ParseMapKey(edgeKey) if err != nil { - return "", err + return nil, err } - edgeTrimCommon(mk) - obj := g.Root - if mk.Key != nil { - var ok bool - obj, ok = g.Root.HasChild(d2graph.Key(mk.Key)) - if !ok { - return "", errors.New("edge key not found") - } + + if len(mk.Edges) == 0 { + return nil, errors.New("edgeKey must be an edge") } - e, ok := obj.HasEdge(mk) + + if mk.EdgeIndex == nil { + return nil, errors.New("edgeKey must refer to an existing edge") + } + + if srcKey == nil && dstKey == nil { + return nil, errors.New("must provide at least one new endpoint") + } + + edge, ok := g.Root.HasEdge(mk) if !ok { - return "", fmt.Errorf("edge %v not found", edgeID) + return nil, errors.New("edge not found") } - if e.Src.AbsID() == srcID && e.Dst.AbsID() == dstID { - return edgeID, nil - } - oldSrc := e.Src - oldDst := e.Dst - if e.Src.AbsID() != srcID { - mk, err := d2parser.ParseMapKey(srcID) + + newSrc := edge.Src + newDst := edge.Dst + var src *d2graph.Object + var dst *d2graph.Object + if srcKey != nil { + srcmk, err := d2parser.ParseMapKey(*srcKey) if err != nil { - return "", err + return nil, err } - src, ok := g.Root.HasChild(d2graph.Key(mk.Key)) + src, ok = g.Root.HasChild(d2graph.Key(srcmk.Key)) if !ok { - return "", fmt.Errorf("src %v not found", srcID) + return nil, errors.New("newSrc not found") } - e.Src = src + newSrc = src } - if e.Dst.AbsID() != dstID { - mk, err := d2parser.ParseMapKey(dstID) + if dstKey != nil { + dstmk, err := d2parser.ParseMapKey(*dstKey) if err != nil { - return "", err + return nil, err } - dst, ok := g.Root.HasChild(d2graph.Key(mk.Key)) + dst, ok = g.Root.HasChild(d2graph.Key(dstmk.Key)) if !ok { - return "", fmt.Errorf("dst %v not found", dstID) + return nil, errors.New("newDst not found") } - e.Dst = dst + newDst = dst } - newID := fmt.Sprintf("%s %s %s", e.Src.AbsID(), e.ArrowString(), e.Dst.AbsID()) - e.Src = oldSrc - e.Dst = oldDst - return newID, nil + + // The first ref is always the definition + firstRef := edge.References[0] + line := firstRef.MapKey.Range.Start.Line + newIndex := 0 + + // For the edge's own delta, it just needs to know how many edges came before it with the same src and dst + for _, otherEdge := range g.Edges { + if otherEdge.Src == newSrc && otherEdge.Dst == newDst { + firstRef := otherEdge.References[0] + if firstRef.MapKey.Range.Start.Line <= line { + newIndex++ + } + } + if otherEdge.Src == edge.Src && otherEdge.Dst == edge.Dst && otherEdge.Index > edge.Index { + before := otherEdge.AbsID() + otherEdge.Index-- + after := otherEdge.AbsID() + deltas[before] = after + otherEdge.Index++ + } + } + + for _, otherEdge := range g.Edges { + if otherEdge.Src == newSrc && otherEdge.Dst == newDst { + if otherEdge.Index >= newIndex { + before := otherEdge.AbsID() + otherEdge.Index++ + after := otherEdge.AbsID() + deltas[before] = after + otherEdge.Index-- + } + } + } + + newEdge := &d2graph.Edge{ + Src: newSrc, + Dst: newDst, + SrcArrow: edge.SrcArrow, + DstArrow: edge.DstArrow, + Index: newIndex, + } + + deltas[edge.AbsID()] = newEdge.AbsID() + + return deltas, nil } // generateUniqueKey generates a unique key by appending a number after `prefix` such that it doesn't conflict with any IDs in `g` diff --git a/d2oracle/edit_test.go b/d2oracle/edit_test.go index eaa7d451a..6e138f321 100644 --- a/d2oracle/edit_test.go +++ b/d2oracle/edit_test.go @@ -1493,6 +1493,304 @@ six } } +func TestReconnectEdge(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + text string + edgeKey string + newSrc string + newDst string + + expErr string + exp string + assertions func(t *testing.T, g *d2graph.Graph) + }{ + { + name: "basic", + text: `a +b +c +a -> b +`, + edgeKey: `(a -> b)[0]`, + newDst: "c", + exp: `a +b +c +a -> c +`, + }, + { + name: "src", + text: `a +b +c +a -> b +`, + edgeKey: `(a -> b)[0]`, + newSrc: "c", + exp: `a +b +c +c -> b +`, + }, + { + name: "both", + text: `a +b +c +a -> b +`, + edgeKey: `(a -> b)[0]`, + newSrc: "b", + newDst: "a", + exp: `a +b +c +b -> a +`, + }, + { + name: "contained", + text: `a.x -> a.y +a.z`, + edgeKey: `(a.x -> a.y)[0]`, + newDst: "a.z", + exp: `a.x -> a.z +a.y +a.z +`, + }, + { + name: "scope_outer", + text: `a: { + x -> y +} +b`, + edgeKey: `(a.x -> a.y)[0]`, + newDst: "b", + exp: `a: { + x -> _.b + y +} +b +`, + }, + { + name: "scope_inner", + text: `a: { + x -> y + z: { + b + } +}`, + edgeKey: `(a.x -> a.y)[0]`, + newDst: "a.z.b", + exp: `a: { + x -> z.b + y + + z: { + b + } +} +`, + }, + { + name: "loop", + text: `a -> a +b`, + edgeKey: `(a -> a)[0]`, + newDst: "b", + exp: `a -> b +b +`, + }, + { + name: "middle_chain", + text: `a -> b -> c +x`, + edgeKey: `(a -> b)[0]`, + newDst: "x", + exp: `b -> c +a -> x +x +`, + }, + { + name: "middle_chain_src", + text: `a -> b -> c +x`, + edgeKey: `(b -> c)[0]`, + newSrc: "x", + exp: `a -> b +x -> c +x +`, + }, + { + name: "middle_chain_both", + text: `a -> b -> c -> d +x`, + edgeKey: `(b -> c)[0]`, + newSrc: "x", + newDst: "x", + exp: `a -> b +c -> d +x -> x +x +`, + }, + { + name: "middle_chain_first", + text: `a -> b -> c -> d +x`, + edgeKey: `(a -> b)[0]`, + newSrc: "x", + exp: `a +x -> b -> c -> d +x +`, + }, + { + name: "middle_chain_last", + text: `a -> b -> c -> d +x`, + edgeKey: `(c -> d)[0]`, + newDst: "x", + exp: `a -> b -> c -> x +d +x +`, + }, + // These _3 and _4 match the delta tests + { + name: "in_chain_3", + + text: `a -> b -> a -> c +`, + edgeKey: "(a -> b)[0]", + newDst: "c", + + exp: `b -> a -> c +a -> c +`, + }, + { + name: "in_chain_4", + + text: `a -> c -> a -> c +b +`, + edgeKey: "(a -> c)[0]", + newDst: "b", + + exp: `c -> a -> c +a -> b +b +`, + }, + { + name: "indexed_ref", + text: `a -> b +x +(a -> b)[0].style.stroke: red +`, + edgeKey: `(a -> b)[0]`, + newDst: "x", + exp: `a -> x +b +x +(a -> x)[0].style.stroke: red +`, + }, + { + name: "reverse", + text: `a -> b +`, + edgeKey: `(a -> b)[0]`, + newSrc: "b", + newDst: "a", + exp: `b -> a +`, + }, + { + name: "second_index", + text: `a -> b: { + style.stroke: blue +} +a -> b: { + style.stroke: red +} +x +`, + edgeKey: `(a -> b)[1]`, + newDst: "x", + exp: `a -> b: { + style.stroke: blue +} +a -> x: { + style.stroke: red +} +x +`, + }, + { + name: "nonexistant_edge", + text: `a -> b +`, + edgeKey: `(b -> a)[0]`, + newDst: "a", + expErr: "edge not found", + }, + { + name: "nonexistant_obj", + text: `a -> b +`, + edgeKey: `(a -> b)[0]`, + newDst: "x", + expErr: "newDst not found", + }, + { + name: "missing_params", + text: `a -> b +`, + edgeKey: `(a -> b)[0]`, + expErr: "must provide at least one new endpoint", + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + et := editTest{ + text: tc.text, + testFunc: func(g *d2graph.Graph) (*d2graph.Graph, error) { + var newSrc *string + var newDst *string + if tc.newSrc != "" { + newSrc = &tc.newSrc + } + if tc.newDst != "" { + newDst = &tc.newDst + } + return d2oracle.ReconnectEdge(g, tc.edgeKey, newSrc, newDst) + }, + + exp: tc.exp, + expErr: tc.expErr, + assertions: tc.assertions, + } + et.run(t) + }) + } +} + func TestRename(t *testing.T) { t.Parallel() @@ -5300,6 +5598,227 @@ func (tc editTest) run(t *testing.T) { assert.Success(t, err) } +func TestReconnectEdgeIDDeltas(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + + text string + edge string + newSrc string + newDst string + + exp string + expErr string + }{ + { + name: "basic", + + text: `a -> b +x +`, + edge: "(a -> b)[0]", + newDst: "x", + + exp: `{ + "(a -> b)[0]": "(a -> x)[0]" +}`, + }, + { + name: "both", + text: `a +b +c +a -> b +`, + edge: `(a -> b)[0]`, + newSrc: "b", + newDst: "a", + exp: `{ + "(a -> b)[0]": "(b -> a)[0]" +}`, + }, + { + name: "contained", + + text: `a.x -> a.y +a.z +`, + edge: "(a.x -> a.y)[0]", + newDst: "a.z", + + exp: `{ + "a.(x -> y)[0]": "a.(x -> z)[0]" +}`, + }, + { + name: "second_index", + + text: `a -> b +a -> b +c +`, + edge: "(a -> b)[1]", + newDst: "c", + + exp: `{ + "(a -> b)[1]": "(a -> c)[0]" +}`, + }, + { + name: "old_sibling_decrement", + + text: `a -> b +a -> b +c +`, + edge: "(a -> b)[0]", + newDst: "c", + + exp: `{ + "(a -> b)[0]": "(a -> c)[0]", + "(a -> b)[1]": "(a -> b)[0]" +}`, + }, + { + name: "new_sibling_increment", + + text: `a -> b +c -> b +a -> b +`, + edge: "(c -> b)[0]", + newSrc: "a", + + exp: `{ + "(a -> b)[1]": "(a -> b)[2]", + "(c -> b)[0]": "(a -> b)[1]" +}`, + }, + { + name: "increment_and_decrement", + + text: `a -> b +c -> b +c -> b +a -> b +`, + edge: "(c -> b)[0]", + newSrc: "a", + + exp: `{ + "(a -> b)[1]": "(a -> b)[2]", + "(c -> b)[0]": "(a -> b)[1]", + "(c -> b)[1]": "(c -> b)[0]" +}`, + }, + { + name: "in_chain", + + text: `a -> b -> a -> b +c +`, + edge: "(a -> b)[0]", + newDst: "c", + + exp: `{ + "(a -> b)[0]": "(a -> c)[0]", + "(a -> b)[1]": "(a -> b)[0]" +}`, + }, + { + name: "in_chain_2", + + text: `a -> b -> a -> b +c +`, + edge: "(a -> b)[1]", + newDst: "c", + + exp: `{ + "(a -> b)[1]": "(a -> c)[0]" +}`, + }, + { + name: "in_chain_3", + + text: `a -> b -> a -> c +`, + edge: "(a -> b)[0]", + newDst: "c", + + exp: `{ + "(a -> b)[0]": "(a -> c)[1]" +}`, + }, + { + name: "in_chain_4", + + text: `a -> c -> a -> c +b +`, + edge: "(a -> c)[0]", + newDst: "b", + + exp: `{ + "(a -> c)[0]": "(a -> b)[0]", + "(a -> c)[1]": "(a -> c)[0]" +}`, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + d2Path := fmt.Sprintf("d2/testdata/d2oracle/%v.d2", t.Name()) + g, err := d2compiler.Compile(d2Path, strings.NewReader(tc.text), nil) + if err != nil { + t.Fatal(err) + } + + var newSrc *string + var newDst *string + if tc.newSrc != "" { + newSrc = &tc.newSrc + } + if tc.newDst != "" { + newDst = &tc.newDst + } + + deltas, err := d2oracle.ReconnectEdgeIDDeltas(g, tc.edge, newSrc, newDst) + if tc.expErr != "" { + if err == nil { + t.Fatalf("expected error with: %q", tc.expErr) + } + ds, err := diff.Strings(tc.expErr, err.Error()) + if err != nil { + t.Fatal(err) + } + if ds != "" { + t.Fatalf("unexpected error: %s", ds) + } + } else if err != nil { + t.Fatal(err) + } + + if hasRepeatedValue(deltas) { + t.Fatalf("deltas set more than one value equal to another: %s", string(xjson.Marshal(deltas))) + } + + ds, err := diff.Strings(tc.exp, string(xjson.Marshal(deltas))) + if err != nil { + t.Fatal(err) + } + if ds != "" { + t.Fatalf("unexpected deltas: %s", ds) + } + }) + } +} + func TestMoveIDDeltas(t *testing.T) { t.Parallel() diff --git a/testdata/d2oracle/TestReconnectEdge/basic.exp.json b/testdata/d2oracle/TestReconnectEdge/basic.exp.json new file mode 100644 index 000000000..5ecabc316 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/basic.exp.json @@ -0,0 +1,369 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,0:0:0-4:0:13", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,1:0:2-1:1:3", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,2:0:4-2:1:5", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,2:0:4-2:1:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:0:6-3:6:12", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:0:6-3:6:12", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:0:6-3:2:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:0:6-3:1:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:4:10-3:6:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:5:11-3:6:12", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:0:6-3:2:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:0:6-3:1:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,2:0:4-2:1:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:4:10-3:6:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/basic.d2,3:5:11-3:6:12", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/both.exp.json b/testdata/d2oracle/TestReconnectEdge/both.exp.json new file mode 100644 index 000000000..f2a26f07d --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/both.exp.json @@ -0,0 +1,369 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,0:0:0-4:0:13", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,1:0:2-1:1:3", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,2:0:4-2:1:5", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,2:0:4-2:1:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:0:6-3:6:12", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:0:6-3:6:12", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:0:6-3:2:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:0:6-3:1:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:4:10-3:6:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:5:11-3:6:12", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:4:10-3:6:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:5:11-3:6:12", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:0:6-3:2:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,3:0:6-3:1:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,2:0:4-2:1:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/both.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/contained.exp.json b/testdata/d2oracle/TestReconnectEdge/contained.exp.json new file mode 100644 index 000000000..3a05ce263 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/contained.exp.json @@ -0,0 +1,565 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-3:0:19", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-0:10:10", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:2:2-0:3:3", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:7:7-0:8:8", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:9:9-0:10:10", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:0:11-1:3:14", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:0:11-1:3:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:0:11-1:1:12", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:2:13-1:3:14", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:0:15-2:3:18", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:0:15-2:3:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:0:15-2:1:16", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:2:17-2:3:18", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:2:2-0:3:3", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:7:7-0:8:8", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:9:9-0:10:10", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:0:11-1:3:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:0:11-1:1:12", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:2:13-1:3:14", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:0:15-2:3:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:0:15-2:1:16", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:2:17-2:3:18", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:2:2-0:3:3", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "z", + "id_val": "z", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:7:7-0:8:8", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,0:9:9-0:10:10", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:0:15-2:3:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:0:15-2:1:16", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,2:2:17-2:3:18", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "z" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:0:11-1:3:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:0:11-1:1:12", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/contained.d2,1:2:13-1:3:14", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/in_chain_3.exp.json b/testdata/d2oracle/TestReconnectEdge/in_chain_3.exp.json new file mode 100644 index 000000000..84a4f42f3 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/in_chain_3.exp.json @@ -0,0 +1,467 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,0:0:0-3:0:20", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:0:1-1:11:12", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:0:1-1:7:8", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:0:1-1:2:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:0:1-1:1:2", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:4:5-1:7:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:5:6-1:6:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:4:5-1:11:12", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:4:5-1:7:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:5:6-1:6:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:9:10-1:11:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:10:11-1:11:12", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:0:13-2:6:19", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:0:13-2:6:19", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:0:13-2:2:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:0:13-2:1:14", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:4:17-2:6:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:5:18-2:6:19", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 1, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:0:1-1:2:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:0:1-1:1:2", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:4:5-1:7:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:5:6-1:6:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:4:5-1:7:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:5:6-1:6:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:0:13-2:2:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:0:13-2:1:14", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:9:10-1:11:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,1:10:11-1:11:12", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:4:17-2:6:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_3.d2,2:5:18-2:6:19", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/in_chain_4.exp.json b/testdata/d2oracle/TestReconnectEdge/in_chain_4.exp.json new file mode 100644 index 000000000..c9881b7df --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/in_chain_4.exp.json @@ -0,0 +1,510 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,0:0:0-4:0:22", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:0:1-1:11:12", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:0:1-1:7:8", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:0:1-1:2:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:0:1-1:1:2", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:4:5-1:7:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:5:6-1:6:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:4:5-1:11:12", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:4:5-1:7:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:5:6-1:6:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:9:10-1:11:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:10:11-1:11:12", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:0:13-2:6:19", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:0:13-2:6:19", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:0:13-2:2:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:0:13-2:1:14", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:4:17-2:6:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:5:18-2:6:19", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,3:0:20-3:1:21", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,3:0:20-3:1:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,3:0:20-3:1:21", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:0:1-1:2:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:0:1-1:1:2", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:9:10-1:11:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:10:11-1:11:12", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:4:5-1:7:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:5:6-1:6:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:4:5-1:7:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,1:5:6-1:6:7", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:0:13-2:2:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:0:13-2:1:14", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:4:17-2:6:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,2:5:18-2:6:19", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,3:0:20-3:1:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/in_chain_4.d2,3:0:20-3:1:21", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/indexed_ref.exp.json b/testdata/d2oracle/TestReconnectEdge/indexed_ref.exp.json new file mode 100644 index 000000000..56f86712b --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/indexed_ref.exp.json @@ -0,0 +1,461 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:0:0-4:0:41", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:5:5-0:6:6", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,1:0:7-1:1:8", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,1:0:7-1:1:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,1:0:7-1:1:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,2:0:9-2:1:10", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,2:0:9-2:1:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,2:0:9-2:1:10", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:0:11-3:29:40", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:1:12-3:7:18", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:1:12-3:3:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:1:12-3:2:13", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:5:16-3:7:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:6:17-3:7:18", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:8:19-3:11:22", + "int": 0, + "glob": false + }, + "edge_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:12:23-3:24:35", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:12:23-3:17:28", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:18:29-3:24:35", + "value": [ + { + "string": "stroke", + "raw_string": "stroke" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:26:37-3:29:40", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + }, + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "stroke": { + "value": "red" + } + }, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:1:12-3:3:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:1:12-3:2:13", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,0:5:5-0:6:6", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,2:0:9-2:1:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,2:0:9-2:1:10", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:5:16-3:7:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,3:6:17-3:7:18", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,1:0:7-1:1:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/indexed_ref.d2,1:0:7-1:1:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/loop.exp.json b/testdata/d2oracle/TestReconnectEdge/loop.exp.json new file mode 100644 index 000000000..16231c290 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/loop.exp.json @@ -0,0 +1,256 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:0:0-2:0:9", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,1:0:7-1:1:8", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,1:0:7-1:1:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,1:0:7-1:1:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,1:0:7-1:1:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/loop.d2,1:0:7-1:1:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/middle_chain.exp.json b/testdata/d2oracle/TestReconnectEdge/middle_chain.exp.json new file mode 100644 index 000000000..a926f2f27 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/middle_chain.exp.json @@ -0,0 +1,428 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,0:0:0-4:0:17", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:0:1-1:6:7", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:0:1-1:6:7", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:0:1-1:2:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:0:1-1:1:2", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:4:5-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:5:6-1:6:7", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:0:8-2:6:14", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:0:8-2:6:14", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:0:8-2:2:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:0:8-2:1:9", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:4:12-2:6:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:5:13-2:6:14", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,3:0:15-3:1:16", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,3:0:15-3:1:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,3:0:15-3:1:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:0:1-1:2:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:0:1-1:1:2", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:4:5-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,1:5:6-1:6:7", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:0:8-2:2:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:0:8-2:1:9", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:4:12-2:6:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,2:5:13-2:6:14", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,3:0:15-3:1:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain.d2,3:0:15-3:1:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/middle_chain_both.exp.json b/testdata/d2oracle/TestReconnectEdge/middle_chain_both.exp.json new file mode 100644 index 000000000..e85957343 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/middle_chain_both.exp.json @@ -0,0 +1,573 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:0:0-4:0:23", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:0:7-1:6:13", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:0:7-1:6:13", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:0:7-1:2:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:0:7-1:1:8", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:4:11-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:5:12-1:6:13", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:0:14-2:6:20", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:0:14-2:6:20", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:0:14-2:2:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:0:14-2:1:15", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:4:18-2:6:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:5:19-2:6:20", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,3:0:21-3:1:22", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,3:0:21-3:1:22", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,3:0:21-3:1:22", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:0:7-1:2:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:0:7-1:1:8", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:4:11-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,1:5:12-1:6:13", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:0:14-2:2:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:0:14-2:1:15", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:4:18-2:6:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,2:5:19-2:6:20", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,3:0:21-3:1:22", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_both.d2,3:0:21-3:1:22", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/middle_chain_first.exp.json b/testdata/d2oracle/TestReconnectEdge/middle_chain_first.exp.json new file mode 100644 index 000000000..d271c4d14 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/middle_chain_first.exp.json @@ -0,0 +1,598 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,0:0:0-3:0:21", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:0:2-1:16:18", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:0:2-1:7:9", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:0:2-1:2:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:0:2-1:1:3", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:4:6-1:7:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:5:7-1:6:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:4:6-1:12:14", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:4:6-1:7:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:5:7-1:6:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:9:11-1:12:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:10:12-1:11:13", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:9:11-1:16:18", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:9:11-1:12:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:10:12-1:11:13", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:14:16-1:16:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:15:17-1:16:18", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,2:0:19-2:1:20", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,2:0:19-2:1:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,2:0:19-2:1:20", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 2 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:0:2-1:2:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:0:2-1:1:3", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,2:0:19-2:1:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,2:0:19-2:1:20", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:4:6-1:7:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:5:7-1:6:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:4:6-1:7:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:5:7-1:6:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:9:11-1:12:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:10:12-1:11:13", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:9:11-1:12:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:10:12-1:11:13", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 2 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:14:16-1:16:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_first.d2,1:15:17-1:16:18", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 2 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/middle_chain_last.exp.json b/testdata/d2oracle/TestReconnectEdge/middle_chain_last.exp.json new file mode 100644 index 000000000..0b1d4216b --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/middle_chain_last.exp.json @@ -0,0 +1,598 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:0:0-3:0:21", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:0:0-0:7:7", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:4:4-0:12:12", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:9:9-0:16:16", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:15:15-0:16:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,1:0:17-1:1:18", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,1:0:17-1:1:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,1:0:17-1:1:18", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,2:0:19-2:1:20", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,2:0:19-2:1:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,2:0:19-2:1:20", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 2 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 2 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,0:15:15-0:16:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 2 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,2:0:19-2:1:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,2:0:19-2:1:20", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,1:0:17-1:1:18", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_last.d2,1:0:17-1:1:18", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/middle_chain_src.exp.json b/testdata/d2oracle/TestReconnectEdge/middle_chain_src.exp.json new file mode 100644 index 000000000..9f9afb350 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/middle_chain_src.exp.json @@ -0,0 +1,428 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:0:0-3:0:16", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:0:7-1:6:13", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:0:7-1:6:13", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:0:7-1:2:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:0:7-1:1:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:4:11-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:5:12-1:6:13", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,2:0:14-2:1:15", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,2:0:14-2:1:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,2:0:14-2:1:15", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:0:7-1:2:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:0:7-1:1:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,2:0:14-2:1:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,2:0:14-2:1:15", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:4:11-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/middle_chain_src.d2,1:5:12-1:6:13", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/missing_params.exp.json b/testdata/d2oracle/TestReconnectEdge/missing_params.exp.json new file mode 100644 index 000000000..f933a6875 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/missing_params.exp.json @@ -0,0 +1,4 @@ +{ + "graph": null, + "err": "&errors.errorString{s:\"must provide at least one new endpoint\"}" +} diff --git a/testdata/d2oracle/TestReconnectEdge/nonexistant_edge.exp.json b/testdata/d2oracle/TestReconnectEdge/nonexistant_edge.exp.json new file mode 100644 index 000000000..712fb77dd --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/nonexistant_edge.exp.json @@ -0,0 +1,4 @@ +{ + "graph": null, + "err": "&errors.errorString{s:\"edge not found\"}" +} diff --git a/testdata/d2oracle/TestReconnectEdge/nonexistant_obj.exp.json b/testdata/d2oracle/TestReconnectEdge/nonexistant_obj.exp.json new file mode 100644 index 000000000..19755638e --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/nonexistant_obj.exp.json @@ -0,0 +1,4 @@ +{ + "graph": null, + "err": "&errors.errorString{s:\"newDst not found\"}" +} diff --git a/testdata/d2oracle/TestReconnectEdge/reverse.exp.json b/testdata/d2oracle/TestReconnectEdge/reverse.exp.json new file mode 100644 index 000000000..705a45c2b --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/reverse.exp.json @@ -0,0 +1,213 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:0:0-1:0:7", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:5:5-0:6:6", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/reverse.d2,0:5:5-0:6:6", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/scope_inner.exp.json b/testdata/d2oracle/TestReconnectEdge/scope_inner.exp.json new file mode 100644 index 000000000..64aa981c7 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/scope_inner.exp.json @@ -0,0 +1,531 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,0:0:0-8:0:40", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,0:0:0-7:1:39", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,0:3:3-7:0:38", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:2:7-1:10:15", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:2:7-1:10:15", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:2:7-1:4:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:2:7-1:3:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:6:11-1:10:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:7:12-1:8:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:9:14-1:10:15", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,2:2:18-2:3:19", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,2:2:18-2:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,2:2:18-2:3:19", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,4:2:23-6:3:37", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,4:2:23-4:3:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,4:2:23-4:3:24", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,4:5:26-6:2:36", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,5:4:32-5:5:33", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,5:4:32-5:5:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,5:4:32-5:5:33", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:2:7-1:4:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:2:7-1:3:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "z", + "id_val": "z", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:6:11-1:10:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:7:12-1:8:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:9:14-1:10:15", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,4:2:23-4:3:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,4:2:23-4:3:24", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "z" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:6:11-1:10:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:7:12-1:8:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,1:9:14-1:10:15", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,5:4:32-5:5:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,5:4:32-5:5:33", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,2:2:18-2:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_inner.d2,2:2:18-2:3:19", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/scope_outer.exp.json b/testdata/d2oracle/TestReconnectEdge/scope_outer.exp.json new file mode 100644 index 000000000..49329e84b --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/scope_outer.exp.json @@ -0,0 +1,424 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,0:0:0-5:0:24", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,0:0:0-3:1:21", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,0:3:3-3:0:20", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:2:7-1:10:15", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:2:7-1:10:15", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:2:7-1:4:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:2:7-1:3:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:6:11-1:10:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:7:12-1:8:13", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:9:14-1:10:15", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,2:2:18-2:3:19", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,2:2:18-2:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,2:2:18-2:3:19", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,4:0:22-4:1:23", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,4:0:22-4:1:23", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,4:0:22-4:1:23", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:2:7-1:4:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:2:7-1:3:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:6:11-1:10:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:7:12-1:8:13", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,1:9:14-1:10:15", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,4:0:22-4:1:23", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,4:0:22-4:1:23", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,2:2:18-2:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scope_outer.d2,2:2:18-2:3:19", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/second_index.exp.json b/testdata/d2oracle/TestReconnectEdge/second_index.exp.json new file mode 100644 index 000000000..86d13adfe --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/second_index.exp.json @@ -0,0 +1,509 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:0:0-7:0:67", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:0:0-2:1:32", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:8:8-2:0:31", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,1:2:12-1:20:30", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,1:2:12-1:14:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,1:2:12-1:7:17", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,1:8:18-1:14:24", + "value": [ + { + "string": "stroke", + "raw_string": "stroke" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,1:16:26-1:20:30", + "value": [ + { + "string": "blue", + "raw_string": "blue" + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:0:33-5:1:64", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:0:33-3:6:39", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:0:33-3:2:35", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:0:33-3:1:34", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:4:37-3:6:39", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:5:38-3:6:39", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:8:41-5:0:63", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,4:2:45-4:19:62", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,4:2:45-4:14:57", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,4:2:45-4:7:50", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,4:8:51-4:14:57", + "value": [ + { + "string": "stroke", + "raw_string": "stroke" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,4:16:59-4:19:62", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,6:0:65-6:1:66", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,6:0:65-6:1:66", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,6:0:65-6:1:66", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "stroke": { + "value": "blue" + } + }, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "stroke": { + "value": "red" + } + }, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:0:33-3:2:35", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:0:33-3:1:34", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:4:37-3:6:39", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,3:5:38-3:6:39", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,6:0:65-6:1:66", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/second_index.d2,6:0:65-6:1:66", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/src.exp.json b/testdata/d2oracle/TestReconnectEdge/src.exp.json new file mode 100644 index 000000000..a7651be9a --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/src.exp.json @@ -0,0 +1,369 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,0:0:0-4:0:13", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,1:0:2-1:1:3", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,2:0:4-2:1:5", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,2:0:4-2:1:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:0:6-3:6:12", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:0:6-3:6:12", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:0:6-3:2:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:0:6-3:1:7", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:4:10-3:6:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:5:11-3:6:12", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:4:10-3:6:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:5:11-3:6:12", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,2:0:4-2:1:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:0:6-3:2:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/src.d2,3:0:6-3:1:7", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +}