Add Testing for cxjs Functions#128
Conversation
|
I haven't reached coverage of all the functions I'd like to test yet, so this will stay a draft until then. |
c16db1c to
14bea6b
Compare
Clean up and improve formatting/style.
2c33d17 to
6b30c8f
Compare
|
@greptileai Review please |
Greptile SummaryThis PR adds a comprehensive JS test suite (33 test files, 1,482 tests) for the
Confidence Score: 5/5Safe to merge — the only runtime code change is a minor correctness improvement in four aggregate functions, and the rest is additive test infrastructure. All eight instanceof replacements in ht_render.js are mechanically equivalent for normal inputs and strictly better for cross-realm arrays. The 1,482 new tests use a well-isolated vm sandbox with no shared mutable state between test files, and the expected values were verified against the actual implementations. The Makefile targets have proper fallback logic and correctly unquoted shell globs. No files require special attention.
|
| Filename | Overview |
|---|---|
| centrallix-os/sys/js/ht_render.js | Replaces instanceof Array/instanceof Object with Array.isArray() and typeof checks in four aggregate functions; strictly more correct, no behavioral regression for normal inputs. |
| centrallix-os/sys/js/tests/_setup.js | VM sandbox that loads ht_render.js into a minimal browser-stub context; stubs cover all top-level globals accessed at parse/init time. Approach is sound for this test scope. |
| centrallix/Makefile.in | Adds test-js and test-js-coverage phony targets with runtime NODE fallback; shell glob is unquoted so the shell expands it before Node sees it. |
| centrallix-os/sys/js/tests/cxjs_getdate.test.js | Uses a FakeDate class that remaps local-time methods to UTC, eliminating timezone dependency; clock-offset edge cases (day/month/year boundary crossings) are well covered. |
| centrallix-os/sys/js/tests/cxjs_round.test.js | Exhaustive coverage of the custom rounding algorithm, including negative dec, float precision pitfalls, signed-zero propagation, and overflow/underflow via extreme magnitudes and dec values. |
| centrallix-os/sys/js/tests/cxjs_convert.test.js | Covers integer/double/string conversions including currency-prefix stripping logic; edge cases like 1e3, hex, signed zero, and falsy-but-non-null datatypes are all exercised. |
| centrallix-os/sys/js/tests/cxjs_count.test.js | Tests array, object, and scalar inputs including sparse arrays and inherited enumerable properties; verifies null/undefined/NaN exclusion behavior. |
| centrallix-os/sys/js/tests/htr_boolean.test.js | Covers htr_boolean truthy/falsy paths including string case variants, numeric coercion via ==, and array-to-number coercion edge cases. |
| centrallix-os/sys/js/tests/cxjs_rand.test.js | Validates range, non-determinism, seed-warning behavior, and the null/undefined no-warning path using a captured console.warn counter. |
| centrallix/configure.ac | Adds a single AC_PATH_PROG([NODE], [node], []) line; standard autoconf pattern, consistent with other tool probes. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["make test-js"] --> B["Detect node binary\n(configure / PATH fallback)"]
B --> C["node --test\ncentrallix-os/sys/js/tests/*.test.js"]
C --> D["Each test file:\nrequire('./_setup')"]
D --> E["_setup.js\nvm.createContext(sandbox)"]
E --> F["vm.runInContext(\nht_render.js, sandbox\n)"]
F --> G["sandbox exports:\ncxjs_* / htr_* functions"]
G --> H["Test assertions\nassert.equal / assert.ok"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A["make test-js"] --> B["Detect node binary\n(configure / PATH fallback)"]
B --> C["node --test\ncentrallix-os/sys/js/tests/*.test.js"]
C --> D["Each test file:\nrequire('./_setup')"]
D --> E["_setup.js\nvm.createContext(sandbox)"]
E --> F["vm.runInContext(\nht_render.js, sandbox\n)"]
F --> G["sandbox exports:\ncxjs_* / htr_* functions"]
G --> H["Test assertions\nassert.equal / assert.ok"]
Reviews (2): Last reviewed commit: "Update Makefile to find tests in shell c..." | Re-trigger Greptile
|
This PR is ready for human review. |
This PR creates a new set of test suites using
node:testto test the JS client-side Centrallix functions, and also addsmake test-jsin thecentrallixdirectory to run the new tests.Stats