diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 8e284f6b6..91699de5b 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -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 { diff --git a/testdata/d2compiler/TestCompile/border-radius-more-than-100-percent.exp.json b/testdata/d2compiler/TestCompile/border-radius-more-than-100-percent.exp.json new file mode 100644 index 000000000..604c3015b --- /dev/null +++ b/testdata/d2compiler/TestCompile/border-radius-more-than-100-percent.exp.json @@ -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" + } + ] + } +} diff --git a/testdata/d2compiler/TestCompile/border-radius-more-than-20.exp.json b/testdata/d2compiler/TestCompile/border-radius-more-than-20.exp.json new file mode 100644 index 000000000..fd3b9618f --- /dev/null +++ b/testdata/d2compiler/TestCompile/border-radius-more-than-20.exp.json @@ -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" + } + ] + } +} diff --git a/testdata/d2compiler/TestCompile/border-radius-negative.exp.json b/testdata/d2compiler/TestCompile/border-radius-negative.exp.json new file mode 100644 index 000000000..25584f80a --- /dev/null +++ b/testdata/d2compiler/TestCompile/border-radius-negative.exp.json @@ -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" + } + ] + } +}