fmt
This commit is contained in:
parent
2fcc9ed140
commit
9f0c24f5d7
3 changed files with 43 additions and 47 deletions
|
|
@ -10,50 +10,50 @@ func testCompileImports(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
tca := []testCase{
|
||||
{
|
||||
name: "value",
|
||||
run: func(t testing.TB) {
|
||||
m, err := compileFS(t, "index.d2", map[string]string{
|
||||
"index.d2": "x: @x.d2",
|
||||
"x.d2": `shape: circle
|
||||
{
|
||||
name: "value",
|
||||
run: func(t testing.TB) {
|
||||
m, err := compileFS(t, "index.d2", map[string]string{
|
||||
"index.d2": "x: @x.d2",
|
||||
"x.d2": `shape: circle
|
||||
label: meow`,
|
||||
})
|
||||
assert.Success(t, err)
|
||||
assertQuery(t, m, 3, 0, nil, "")
|
||||
assertQuery(t, m, 2, 0, nil, "x")
|
||||
assertQuery(t, m, 0, 0, "circle", "x.shape")
|
||||
assertQuery(t, m, 0, 0, "meow", "x.label")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "nested",
|
||||
run: func(t testing.TB) {
|
||||
m, err := compileFS(t, "index.d2", map[string]string{
|
||||
"index.d2": "x: @x.y",
|
||||
"x.d2": `y: {
|
||||
})
|
||||
assert.Success(t, err)
|
||||
assertQuery(t, m, 3, 0, nil, "")
|
||||
assertQuery(t, m, 2, 0, nil, "x")
|
||||
assertQuery(t, m, 0, 0, "circle", "x.shape")
|
||||
assertQuery(t, m, 0, 0, "meow", "x.label")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "nested",
|
||||
run: func(t testing.TB) {
|
||||
m, err := compileFS(t, "index.d2", map[string]string{
|
||||
"index.d2": "x: @x.y",
|
||||
"x.d2": `y: {
|
||||
shape: circle
|
||||
label: meow
|
||||
}`,
|
||||
})
|
||||
assert.Success(t, err)
|
||||
assertQuery(t, m, 3, 0, nil, "")
|
||||
assertQuery(t, m, 2, 0, nil, "x")
|
||||
assertQuery(t, m, 0, 0, "circle", "x.shape")
|
||||
assertQuery(t, m, 0, 0, "meow", "x.label")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "spread",
|
||||
run: func(t testing.TB) {
|
||||
m, err := compileFS(t, "index.d2", map[string]string{
|
||||
"index.d2": "...@x.d2",
|
||||
"x.d2": "x: wowa",
|
||||
})
|
||||
assert.Success(t, err)
|
||||
assertQuery(t, m, 1, 0, nil, "")
|
||||
assertQuery(t, m, 0, 0, "wowa", "x")
|
||||
},
|
||||
},
|
||||
})
|
||||
assert.Success(t, err)
|
||||
assertQuery(t, m, 3, 0, nil, "")
|
||||
assertQuery(t, m, 2, 0, nil, "x")
|
||||
assertQuery(t, m, 0, 0, "circle", "x.shape")
|
||||
assertQuery(t, m, 0, 0, "meow", "x.label")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "spread",
|
||||
run: func(t testing.TB) {
|
||||
m, err := compileFS(t, "index.d2", map[string]string{
|
||||
"index.d2": "...@x.d2",
|
||||
"x.d2": "x: wowa",
|
||||
})
|
||||
assert.Success(t, err)
|
||||
assertQuery(t, m, 1, 0, nil, "")
|
||||
assertQuery(t, m, 0, 0, "wowa", "x")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
runa(t, tca)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func Parse(path string, r io.RuneReader, opts *ParseOptions) (*d2ast.Map, error)
|
|||
func ParseKey(key string) (*d2ast.KeyPath, error) {
|
||||
p := &parser{
|
||||
reader: strings.NewReader(key),
|
||||
err: &ParseError{},
|
||||
err: &ParseError{},
|
||||
}
|
||||
|
||||
k := p.parseKey()
|
||||
|
|
@ -75,7 +75,7 @@ func ParseKey(key string) (*d2ast.KeyPath, error) {
|
|||
func ParseMapKey(mapKey string) (*d2ast.Key, error) {
|
||||
p := &parser{
|
||||
reader: strings.NewReader(mapKey),
|
||||
err: &ParseError{},
|
||||
err: &ParseError{},
|
||||
}
|
||||
|
||||
mk := p.parseMapKey()
|
||||
|
|
@ -91,7 +91,7 @@ func ParseMapKey(mapKey string) (*d2ast.Key, error) {
|
|||
func ParseValue(value string) (d2ast.Value, error) {
|
||||
p := &parser{
|
||||
reader: strings.NewReader(value),
|
||||
err: &ParseError{},
|
||||
err: &ParseError{},
|
||||
}
|
||||
|
||||
v := p.parseValue()
|
||||
|
|
|
|||
4
go.sum
generated
4
go.sum
generated
|
|
@ -329,10 +329,6 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
|
||||
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230320053557-dcb5aac7d972 h1:HS7fg2GzGsqRLApsoh7ztaLMvXzxSln/Hfz4wy4tIDA=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230320053557-dcb5aac7d972/go.mod h1:eMWv0sOtD9T2RUl90DLWfuShZCYp4NrsqNpI8eqO6U4=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230604220107-5ffc52e2e534 h1:6RWrCAg2bzrmGCXd063nkqaHYJHd3KiN3lVfchm4o5I=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230604220107-5ffc52e2e534/go.mod h1:eMWv0sOtD9T2RUl90DLWfuShZCYp4NrsqNpI8eqO6U4=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230604222829-11c3c60fec14 h1:oy5vtt6O2qYxeSpqWhyevrdUenFfuhphixozUlpL6qY=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230604222829-11c3c60fec14/go.mod h1:eMWv0sOtD9T2RUl90DLWfuShZCYp4NrsqNpI8eqO6U4=
|
||||
rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=
|
||||
|
|
|
|||
Loading…
Reference in a new issue