Most of unit tests have a very simple pattern:
const result = util.transpileAndExecute(`
return foo(${case});
`)
expect(result).toBe(foo(case))
Because foo has to be available both in transpiled string and test module, it may become quite complex (when instead of foo(case) there are some complex constructs). Instead we may emit both Lua and JS, execute JS in a vm and compare results.
Most of unit tests have a very simple pattern:
Because
foohas to be available both in transpiled string and test module, it may become quite complex (when instead offoo(case)there are some complex constructs). Instead we may emit both Lua and JS, execute JS in a vm and compare results.