d2ir: Add recursive scenario/step test
This commit is contained in:
parent
9d0c73cef2
commit
26a72e3e0c
2 changed files with 55 additions and 0 deletions
|
|
@ -43,6 +43,8 @@ func (c *compiler) compileScenarios(m *Map) {
|
||||||
}
|
}
|
||||||
base := m.Copy(sf).(*Map)
|
base := m.Copy(sf).(*Map)
|
||||||
sf.Composite = Overlay(base, sf.Map())
|
sf.Composite = Overlay(base, sf.Map())
|
||||||
|
c.compileScenarios(sf.Map()
|
||||||
|
c.compileSteps(sf.Map()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,6 +71,8 @@ func (c *compiler) compileSteps(m *Map) {
|
||||||
base = steps.Fields[i-1].Map().Copy(sf).(*Map)
|
base = steps.Fields[i-1].Map().Copy(sf).(*Map)
|
||||||
}
|
}
|
||||||
sf.Composite = Overlay(base, sf.Map())
|
sf.Composite = Overlay(base, sf.Map())
|
||||||
|
c.compileScenarios(sf.Map()
|
||||||
|
c.compileSteps(sf.Map()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -413,6 +413,57 @@ steps: {
|
||||||
assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche")
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "recursive",
|
||||||
|
run: func(t testing.TB) {
|
||||||
|
m, err := compile(t, `x -> y
|
||||||
|
steps: {
|
||||||
|
bingo: { p.q.z }
|
||||||
|
nuclear: {
|
||||||
|
quiche
|
||||||
|
scenarios: {
|
||||||
|
bavarian: {
|
||||||
|
perseverance
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`)
|
||||||
|
assert.Success(t, err)
|
||||||
|
|
||||||
|
assertQuery(t, m, 16, 3, nil, "")
|
||||||
|
|
||||||
|
assertQuery(t, m, 0, 0, nil, "x")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "y")
|
||||||
|
assertQuery(t, m, 0, 0, nil, `(x -> y)[0]`)
|
||||||
|
|
||||||
|
assertQuery(t, m, 5, 1, nil, "steps.bingo")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.bingo.x")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.bingo.y")
|
||||||
|
assertQuery(t, m, 0, 0, nil, `steps.bingo.(x -> y)[0]`)
|
||||||
|
assertQuery(t, m, 2, 0, nil, "steps.bingo.p")
|
||||||
|
assertQuery(t, m, 1, 0, nil, "steps.bingo.p.q")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.bingo.p.q.z")
|
||||||
|
|
||||||
|
assertQuery(t, m, 6, 1, nil, "steps.nuclear")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.x")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.y")
|
||||||
|
assertQuery(t, m, 0, 0, nil, `steps.nuclear.(x -> y)[0]`)
|
||||||
|
assertQuery(t, m, 2, 0, nil, "steps.nuclear.p")
|
||||||
|
assertQuery(t, m, 1, 0, nil, "steps.nuclear.p.q")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.p.q.z")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche")
|
||||||
|
|
||||||
|
assertQuery(t, m, 6, 1, nil, "steps.nuclear.scenarios.bavarian")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.x")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.y")
|
||||||
|
assertQuery(t, m, 0, 0, nil, `steps.nuclear.scenarios.bavarian.(x -> y)[0]`)
|
||||||
|
assertQuery(t, m, 2, 0, nil, "steps.nuclear.scenarios.bavarian.p")
|
||||||
|
assertQuery(t, m, 1, 0, nil, "steps.nuclear.scenarios.bavarian.p.q")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.p.q.z")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.quiche")
|
||||||
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.perseverance")
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
runa(t, tca)
|
runa(t, tca)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue