mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-28 15:55:14 +00:00
fixes #25751 This pull request improves the JavaScript backend code generation and expands test coverage, particularly around temporary and loop variables, as well as object destruction behavior. The main changes include updating the code generator to handle more symbol kinds and adding tests to ensure proper destruction and option handling. **JavaScript code generation improvements:** * Updated `genSymAddr` in `compiler/jsgen.nim` to support additional symbol kinds, specifically `skTemp` and `skForVar`, ensuring correct address generation for temporaries and loop variables. **Test suite enhancements:** * Added tests in `tests/js/test2.nim` to verify correct behavior of option types, object destruction (`=destroy`), and to check for backend-specific crashes. This includes printing results of option-returning functions and confirming destruction messages. * Updated expected output in `tests/js/test2.nim` to include results from new tests and destruction messages, ensuring the test suite reflects the latest code behavior.
notes
Prefer moving tests to a non-js directory so that they get tested across all backends automatically. Ideally, tests/js should be reserved to code that only makes sense in js.
Note also that tests for a js specific module (e.g.: std/jsbigints) belong to tests/stdlib, (e.g.: tests/stdlib/tjsbigints.nim)