d2ir: Fixup lazy globs across imports
This commit is contained in:
parent
b1f9083ba1
commit
64c2c8467a
4 changed files with 1436 additions and 4 deletions
|
|
@ -475,9 +475,6 @@ func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) {
|
||||||
if !gctx.refctx.Key.HasTripleGlob() {
|
if !gctx.refctx.Key.HasTripleGlob() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if gctx.refctx.ScopeMap != impn.Map() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
gctx2 := gctx.copy()
|
gctx2 := gctx.copy()
|
||||||
gctx2.refctx.ScopeMap = dst
|
gctx2.refctx.ScopeMap = dst
|
||||||
c.compileKey(gctx2.refctx)
|
c.compileKey(gctx2.refctx)
|
||||||
|
|
|
||||||
|
|
@ -735,7 +735,7 @@ two
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "import-glob",
|
name: "import-glob/1",
|
||||||
run: func(t testing.TB) {
|
run: func(t testing.TB) {
|
||||||
m, err := compileFS(t, "index.d2", map[string]string{
|
m, err := compileFS(t, "index.d2", map[string]string{
|
||||||
"index.d2": "before; ...@globs.d2; after",
|
"index.d2": "before; ...@globs.d2; after",
|
||||||
|
|
@ -750,6 +750,26 @@ two
|
||||||
assertQuery(t, m, 0, 0, "meow", "after")
|
assertQuery(t, m, 0, 0, "meow", "after")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "import-glob/2",
|
||||||
|
run: func(t testing.TB) {
|
||||||
|
m, err := compileFS(t, "index.d2", map[string]string{
|
||||||
|
"index.d2": `...@rules.d2
|
||||||
|
hi
|
||||||
|
`,
|
||||||
|
"rules.d2": `***.style.fill: red
|
||||||
|
***: meow
|
||||||
|
x`,
|
||||||
|
})
|
||||||
|
assert.Success(t, err)
|
||||||
|
|
||||||
|
assertQuery(t, m, 6, 0, nil, "")
|
||||||
|
assertQuery(t, m, 2, 0, "meow", "hi")
|
||||||
|
assertQuery(t, m, 2, 0, "meow", "x")
|
||||||
|
assertQuery(t, m, 0, 0, "red", "hi.style.fill")
|
||||||
|
assertQuery(t, m, 0, 0, "red", "x.style.fill")
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
runa(t, tca)
|
runa(t, tca)
|
||||||
|
|
|
||||||
1415
testdata/d2ir/TestCompile/patterns/import-glob/2.exp.json
generated
vendored
Normal file
1415
testdata/d2ir/TestCompile/patterns/import-glob/2.exp.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue