add compile test

This commit is contained in:
Antoine Poivey 2023-03-30 18:43:16 +02:00
parent 58b596854b
commit e96eb4c6f0
No known key found for this signature in database
GPG key ID: 6AA1C83421F1A287
4 changed files with 60 additions and 0 deletions

View file

@ -2221,6 +2221,30 @@ layers: {
}`,
expErr: `d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:9: invalid underscore usage`,
},
{
name: "border-radius-negative",
text: `x
x: {
style.border-radius: -1
}`,
expErr: `d2/testdata/d2compiler/TestCompile/border-radius-negative.d2:3:24: expected "border-radius" to be a number between 0 and 20`,
},
{
name: "border-radius-more-than-20",
text: `x
x: {
style.border-radius: 21
}`,
expErr: `d2/testdata/d2compiler/TestCompile/border-radius-more-than-20.d2:3:24: expected "border-radius" to be a number between 0 and 20`,
},
{
name: "border-radius-more-than-100-percent",
text: `x
x: {
style.border-radius: 1.5
}`,
expErr: `d2/testdata/d2compiler/TestCompile/border-radius-more-than-100-percent.d2:3:24: expected "border-radius" to be an integer if greater than 1`,
},
}
for _, tc := range testCases {

View file

@ -0,0 +1,12 @@
{
"graph": null,
"err": {
"ioerr": null,
"errs": [
{
"range": "d2/testdata/d2compiler/TestCompile/border-radius-more-than-100-percent.d2,2:23:30-2:26:33",
"errmsg": "d2/testdata/d2compiler/TestCompile/border-radius-more-than-100-percent.d2:3:24: expected \"border-radius\" to be an integer if greater than 1"
}
]
}
}

View file

@ -0,0 +1,12 @@
{
"graph": null,
"err": {
"ioerr": null,
"errs": [
{
"range": "d2/testdata/d2compiler/TestCompile/border-radius-more-than-20.d2,2:23:30-2:25:32",
"errmsg": "d2/testdata/d2compiler/TestCompile/border-radius-more-than-20.d2:3:24: expected \"border-radius\" to be a number between 0 and 20"
}
]
}
}

View file

@ -0,0 +1,12 @@
{
"graph": null,
"err": {
"ioerr": null,
"errs": [
{
"range": "d2/testdata/d2compiler/TestCompile/border-radius-negative.d2,2:23:30-2:25:32",
"errmsg": "d2/testdata/d2compiler/TestCompile/border-radius-negative.d2:3:24: expected \"border-radius\" to be a number between 0 and 20"
}
]
}
}