yamadapc / jsdoctest

Run jsdoc examples as doctests.
https://yamadapc.github.io/jsdoctest
MIT License
92 stars 9 forks source link

Design the method for running doctests #2

Closed yamadapc closed 9 years ago

yamadapc commented 9 years ago

Injecting the test runner into the code works and won't require the users to export all testable functions, but isn't very composable and will make it hard to make multiple files with doctests to be executed smoothly with a single runner process. It's also subject to weird naming bugs.

The current hack, of appending asserts into the source and then calling eval on it is obviously completely unacceptable.

This will take some time to figure out, since we'll have to explore available options.

yamadapc commented 9 years ago

For the record, sandboxing with the vm module doesn't seem like a viable option. There's no way to make the sandboxed environment support modules, unless we actually inject the parent processes' Module instances into it, which doesn't seem like a very good idea.

This may be possible with some hacking and module system code study though.