# testing

The following details the testing factilities in place for pwa/p2js.
On startup (desktop only) pwa/phix/test.exw is transpiled to js and compared line-by-line to test.exw.js
and the same file is also "transpiled" to phix (iyswim) and compared line-by-line to test.exw.exw.
Likewise pwa/phix/test.js is transpiled to phix/js and compared line-by-line to test.js.exw and test.js.js.
Those files should contain everything in mappings and more, and are likely to and in fact should be extended on a fairly regular basis.
Obviously phix ==> js is foremost, reverse-transpilation should help ensure that we don&rsquo break big things when fixing small niggles.
In an ideal world, perhaps, you could transpile phix ==> js ==> phix and verify it all still works, but at the moment that’s a bit of a pipe dream.
Note that transpiling something to the same target is in fact slightly more difficult than transpiling it to a different target, and in particular gives the precedence handling a thorough workout. On that note, parenthesis are not stored explicitly in the parse tree, but re-generated as needed from the structure of the tree and the relative precedence of the operators involved. The fact that there are subtle differences in the operator precedences between Phix and JavaScript makes it a ripe source for confusion and outright bugs, do not be fooled by the apparently trivial nature of some tests.
The file pwa/printf_tests.html contains some early printf tests. It is both manually-written and intended to be run manually.
Likewise pwa/Phib_Window.html and pwa/Simple_window.html contain early but still runnable manually written demos.
As yet there are no tests whatsoever for anything other than phix <==> js, the limit of my aspirations in that regard is C ==> phix that significantly reduces repetetive editing as opposed to an output that will actually run. I have also been using this to syntax colour entries on rosettacode, and it will also happily syntax colour javascript (both via ctrl M aka mediawiki). I have also managed to parse p2js.js and pGUI.js and regerate them with several significant syntax errors: once all that is fixed it should form a suitable basis for a minifier.
There are no tests as yet that we still get some particular error message, not that the error handling in pwa/p2js is up to scratch yet either.
The file pwa/test.htm is overwritten (desktop only) by the run function of pwa/p2js