update
This commit is contained in:
parent
9c99212762
commit
691b45733d
7 changed files with 23 additions and 149 deletions
|
|
@ -38,7 +38,8 @@ func (c *compiler) compileScenarios(m *Map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, sf := range scenarios.Fields {
|
for _, sf := range scenarios.Fields {
|
||||||
if sf.Map() == nil {
|
if sf.Map() == nil || sf.Primary() != nil {
|
||||||
|
c.errorf(sf.References[0].Context.Key, "invalid scenario")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
base := m.CopyBase(sf)
|
base := m.CopyBase(sf)
|
||||||
|
|
@ -59,14 +60,16 @@ func (c *compiler) compileSteps(m *Map) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i, sf := range steps.Fields {
|
for i, sf := range steps.Fields {
|
||||||
if sf.Map() == nil {
|
if sf.Map() == nil || sf.Primary() != nil {
|
||||||
|
c.errorf(sf.References[0].Context.Key, "invalid step")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var base *Map
|
var base *Map
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
base = m.CopyBase(sf)
|
base = m.CopyBase(sf)
|
||||||
} else {
|
} else {
|
||||||
if steps.Fields[i-1].Map() == nil {
|
if steps.Fields[i-1].Map() == nil || steps.Fields[i-1].Primary() != nil {
|
||||||
|
c.errorf(steps.Fields[i-1].References[0].Context.Key, "invalid step")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
base = steps.Fields[i-1].Map().CopyBase(sf)
|
base = steps.Fields[i-1].Map().CopyBase(sf)
|
||||||
|
|
|
||||||
|
|
@ -420,6 +420,23 @@ steps: {
|
||||||
assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche")
|
assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "steps_panic",
|
||||||
|
run: func(t testing.TB) {
|
||||||
|
_, err := compile(t, `steps: {
|
||||||
|
shape: sql_table
|
||||||
|
id: int {constraint: primary_key}
|
||||||
|
}
|
||||||
|
scenarios: {
|
||||||
|
shape: sql_table
|
||||||
|
hey: int {constraint: primary_key}
|
||||||
|
}`)
|
||||||
|
assert.ErrorString(t, err, `TestCompile/steps/steps_panic.d2:6:3: invalid scenario
|
||||||
|
TestCompile/steps/steps_panic.d2:7:3: invalid scenario
|
||||||
|
TestCompile/steps/steps_panic.d2:2:3: invalid step
|
||||||
|
TestCompile/steps/steps_panic.d2:3:3: invalid step`)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "recursive",
|
name: "recursive",
|
||||||
run: func(t testing.TB) {
|
run: func(t testing.TB) {
|
||||||
|
|
|
||||||
22
e2etests/testdata/todo/steps_panic/dagre/board.exp.json
generated
vendored
22
e2etests/testdata/todo/steps_panic/dagre/board.exp.json
generated
vendored
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"fontFamily": "SourceSansPro",
|
|
||||||
"shapes": [],
|
|
||||||
"connections": [],
|
|
||||||
"scenarios": [
|
|
||||||
{
|
|
||||||
"name": "hey",
|
|
||||||
"fontFamily": "SourceSansPro",
|
|
||||||
"shapes": [],
|
|
||||||
"connections": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"fontFamily": "SourceSansPro",
|
|
||||||
"shapes": [],
|
|
||||||
"connections": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<svg
|
|
||||||
id="d2-svg"
|
|
||||||
style="background: white;"
|
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
width="200" height="200" viewBox="-100 -100 200 200"><style type="text/css">
|
|
||||||
<![CDATA[
|
|
||||||
.shape {
|
|
||||||
shape-rendering: geometricPrecision;
|
|
||||||
stroke-linejoin: round;
|
|
||||||
}
|
|
||||||
.connection {
|
|
||||||
stroke-linecap: round;
|
|
||||||
stroke-linejoin: round;
|
|
||||||
}
|
|
||||||
.blend {
|
|
||||||
mix-blend-mode: multiply;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
]]>
|
|
||||||
</style><script type="application/javascript"><![CDATA[window.addEventListener("DOMContentLoaded", () => {
|
|
||||||
if (document.documentElement.getAttribute("id") !== "d2-svg") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const svgEl = document.documentElement;
|
|
||||||
let width = parseInt(svgEl.getAttribute("width"), 10);
|
|
||||||
let height = parseInt(svgEl.getAttribute("height"), 10);
|
|
||||||
let ratio;
|
|
||||||
if (width > height) {
|
|
||||||
if (width > window.innerWidth) {
|
|
||||||
ratio = window.innerWidth / width;
|
|
||||||
}
|
|
||||||
} else if (height > window.innerHeight) {
|
|
||||||
ratio = window.innerHeight / height;
|
|
||||||
}
|
|
||||||
if (ratio) {
|
|
||||||
svgEl.setAttribute("width", width * ratio - 16);
|
|
||||||
svgEl.setAttribute("height", height * ratio - 16);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
]]></script><mask id="121760133" maskUnits="userSpaceOnUse" x="-100" y="-100" width="200" height="200">
|
|
||||||
<rect x="-100" y="-100" width="200" height="200" fill="white"></rect>
|
|
||||||
|
|
||||||
</mask><style type="text/css"><![CDATA[]]></style></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.3 KiB |
22
e2etests/testdata/todo/steps_panic/elk/board.exp.json
generated
vendored
22
e2etests/testdata/todo/steps_panic/elk/board.exp.json
generated
vendored
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"fontFamily": "SourceSansPro",
|
|
||||||
"shapes": [],
|
|
||||||
"connections": [],
|
|
||||||
"scenarios": [
|
|
||||||
{
|
|
||||||
"name": "hey",
|
|
||||||
"fontFamily": "SourceSansPro",
|
|
||||||
"shapes": [],
|
|
||||||
"connections": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"fontFamily": "SourceSansPro",
|
|
||||||
"shapes": [],
|
|
||||||
"connections": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<svg
|
|
||||||
id="d2-svg"
|
|
||||||
style="background: white;"
|
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
width="200" height="200" viewBox="-100 -100 200 200"><style type="text/css">
|
|
||||||
<![CDATA[
|
|
||||||
.shape {
|
|
||||||
shape-rendering: geometricPrecision;
|
|
||||||
stroke-linejoin: round;
|
|
||||||
}
|
|
||||||
.connection {
|
|
||||||
stroke-linecap: round;
|
|
||||||
stroke-linejoin: round;
|
|
||||||
}
|
|
||||||
.blend {
|
|
||||||
mix-blend-mode: multiply;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
]]>
|
|
||||||
</style><script type="application/javascript"><![CDATA[window.addEventListener("DOMContentLoaded", () => {
|
|
||||||
if (document.documentElement.getAttribute("id") !== "d2-svg") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const svgEl = document.documentElement;
|
|
||||||
let width = parseInt(svgEl.getAttribute("width"), 10);
|
|
||||||
let height = parseInt(svgEl.getAttribute("height"), 10);
|
|
||||||
let ratio;
|
|
||||||
if (width > height) {
|
|
||||||
if (width > window.innerWidth) {
|
|
||||||
ratio = window.innerWidth / width;
|
|
||||||
}
|
|
||||||
} else if (height > window.innerHeight) {
|
|
||||||
ratio = window.innerHeight / height;
|
|
||||||
}
|
|
||||||
if (ratio) {
|
|
||||||
svgEl.setAttribute("width", width * ratio - 16);
|
|
||||||
svgEl.setAttribute("height", height * ratio - 16);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
]]></script><mask id="121760133" maskUnits="userSpaceOnUse" x="-100" y="-100" width="200" height="200">
|
|
||||||
<rect x="-100" y="-100" width="200" height="200" fill="white"></rect>
|
|
||||||
|
|
||||||
</mask><style type="text/css"><![CDATA[]]></style></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.3 KiB |
|
|
@ -159,18 +159,6 @@ small code: |go
|
||||||
width: 4
|
width: 4
|
||||||
height: 3
|
height: 3
|
||||||
}
|
}
|
||||||
`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "steps_panic",
|
|
||||||
script: `steps: {
|
|
||||||
shape: sql_table
|
|
||||||
id: int {constraint: primary_key}
|
|
||||||
}
|
|
||||||
scenarios: {
|
|
||||||
shape: sql_table
|
|
||||||
hey: int {constraint: primary_key}
|
|
||||||
}
|
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue