Kotlin testing the restriction in DSL

112 Views Asked by At

We are writing a DSL in Kotlin, and we have added a few restrictions in that DSL. For eg,

table {
  tr {
    td {
    }
  }
}

Here, we restrict td should not be called inside another td.

How do we test this? Is there any dsl-testkit or matcher library in kotlin that lets us do something like "shouldNot compile" does in scalatest

1

There are 1 best solutions below

0
On

One solution is to use the Kotlin scripting engine, make it run a script with your DSL constructs that should be rejected and assert that the script didn't compile.

Links that you may find useful: