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:

  * Should we bother that it doesn't compile with `c`? Known issue? I think 
part of the problem is that the `describe` and `it` functions have been 
overloaded with both `string` and `cstring`.
  * When writing some larger test code, the Visual Studio Code linter flags 
this internal error for almost every line of code, which is pretty annoying to 
work with. Typically I can use `.nims` or `nim.cfg` to modify the way Visual 
Studio Code compiles (or rather "nimsuggests") a file, e.g., for define 
switches. I was trying to find a way to configure the backend as well from the 
config files, but I haven't found a way yet. Is this possible?


Reply via email to