I'm currently experimenting with wrapping some JS test framework. A minimal example:
import future
proc describe(description: cstring, body: () -> void) {.importc.}
proc describe(description: string, body: () -> void) =
describe(description.cstring, body)
proc it(description: cstring, body: () -> void) {.importc.}
proc it(description: string, body: () -> void) =
it(description.cstring, body)
type
Expect = ref object
proc expect[T](x: T): Expect {.importc.}
proc toBe[T](e: Expect, x: T) {.importcpp.}
describe("The test suite"):
it("should work"):
var a = 1
expect(a).toBe(1)
When using the JS backend, this compiles and works pretty well already. However using the standard c backend, this produces an error Error: internal error: environment misses: a. Two questions:
Ignore me: Overloading on string and cstring does not make much sense here. Problem solved by omitting the string version...
Would still be interested in the backend config question though.