# WASM Regression Tests ## How to run 1. Build the business WASM module: ```powershell npm run build ``` 2. Run the regression suite: ```powershell npm run test:wasm ``` 3. Build and run in one step: ```powershell npm test ``` The runner loads `public/wasm/smart_math.js`, calls `init_func`, then executes the business API through `func`. ## Test program - Runner: `scripts/run_wasm_tests.js` - Entry exports used: - `_init_func` - `_func` - `_smart_free_string` The runner is data-driven for stable request samples, and adds two dynamic FK/IK roundtrip cases so inverse kinematics is checked against forward kinematics instead of hard-coded pose strings. ## Test data ### Kinematics - `tests/testdata/kinematics/list_robots.json` - Verifies the built-in robot initialization completed and at least two robots are available. - `tests/testdata/kinematics/forward_zero.json` - Verifies TCP forward kinematics at zero joints. - `tests/testdata/kinematics/forward_all_joints_path.json` - Verifies all-joint forward export for two frames. - `tests/testdata/kinematics/roundtrip_single_seed.json` - Seed joints for FK -> IK -> FK single-pose regression. - `tests/testdata/kinematics/roundtrip_path_seed.json` - Seed joints for two-pose path interpolation regression. ### SPC - `tests/testdata/spc/basic_5x30.json` - Canonical 150-point SPC sample. - Uses the actual command name `Cmd_Spc`. ### Four-bar / Crank slider - `tests/testdata/fourbar/crank_slider_valid.json` - Normal calculation case. - `tests/testdata/fourbar/crank_slider_invalid.json` - Invalid parameter case to verify validation and error return. ### Quadruped robot - `tests/testdata/quadruped/calculate_points_from_motor_angles.json` - Verifies reverse result export from motor angles. - `tests/testdata/quadruped/perform_forward_kinematics.json` - Verifies gait trajectory generation with explicit gait/system parameters. ## What is asserted - Top-level API success and required result fields. - Expected frame count / robot count / array length. - Four-bar validation errors for bad inputs. - SPC subgroup size and spec limits. - Quadruped result structure. - FK/IK roundtrip tolerances: - single pose position tolerance: `0.002` - single pose quaternion tolerance: `0.002` - path endpoint position tolerance: `0.01` ## Notes - The old ad-hoc files such as `tests/fixtures/legacy/spc_in.txt` and `tests/fixtures/legacy/WorkTest.json` are still useful as raw references, but the regression runner uses the normalized data under `tests/testdata`. - If you change URDF, robot naming, or quadruped default config, update the corresponding files under `tests/testdata` first.