@divmain/jdm-asm 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2227 -29
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
- package/.github/workflows/ci.yml +0 -53
- package/.oxfmtrc.json +0 -16
- package/.oxlintrc.json +0 -183
- package/AGENTS.md +0 -81
- package/asconfig.json +0 -23
- package/benchmarks/fixtures.ts +0 -111
- package/benchmarks/input-fixtures.ts +0 -80
- package/benchmarks/run.ts +0 -913
- package/benchmarks/worker-pool.ts +0 -223
- package/benchmarks/worker.ts +0 -374
- package/scripts/run-all-tests.ts +0 -220
- package/src/compiler/EXPRESSION_SUBSETS.md +0 -228
- package/src/compiler/asc-compiler.ts +0 -315
- package/src/compiler/ast-types.ts +0 -215
- package/src/compiler/build.ts +0 -56
- package/src/compiler/cache.ts +0 -414
- package/src/compiler/code-generators.ts +0 -211
- package/src/compiler/codegen/index.ts +0 -15
- package/src/compiler/codegen/js-marshal.ts +0 -999
- package/src/compiler/codegen/js-validation.ts +0 -243
- package/src/compiler/codegen.ts +0 -19
- package/src/compiler/compile-time-validation.ts +0 -507
- package/src/compiler/cst-visitor.ts +0 -434
- package/src/compiler/errors.ts +0 -227
- package/src/compiler/expression-parser.ts +0 -536
- package/src/compiler/graph.ts +0 -197
- package/src/compiler/index.ts +0 -199
- package/src/compiler/input-validation.ts +0 -33
- package/src/compiler/marshal-gen.ts +0 -21
- package/src/compiler/nodes/context-resolvers.ts +0 -197
- package/src/compiler/nodes/decision-table.ts +0 -507
- package/src/compiler/nodes/decision.ts +0 -292
- package/src/compiler/nodes/expression-compiler.ts +0 -526
- package/src/compiler/nodes/expression.ts +0 -425
- package/src/compiler/nodes/function.ts +0 -316
- package/src/compiler/nodes/input.ts +0 -60
- package/src/compiler/nodes/switch.ts +0 -547
- package/src/compiler/optimizer.ts +0 -948
- package/src/compiler/orchestrator.ts +0 -352
- package/src/compiler/parser.ts +0 -115
- package/src/compiler/result-selection.ts +0 -161
- package/src/compiler/runtime/index.ts +0 -26
- package/src/compiler/runtime-codegen.ts +0 -211
- package/src/compiler/runtime-validation-codegen.ts +0 -294
- package/src/compiler/runtime.ts +0 -452
- package/src/compiler/schema.ts +0 -245
- package/src/compiler/switch-branch-detection.ts +0 -92
- package/src/compiler/types.ts +0 -136
- package/src/compiler/unary-ast-transforms.ts +0 -148
- package/src/compiler/unary-parser.ts +0 -301
- package/src/compiler/unary-transform.ts +0 -161
- package/src/compiler/utils.ts +0 -27
- package/src/compiler/virtual-fs.ts +0 -90
- package/src/compiler/wasm-instantiate.ts +0 -127
- package/src/index.ts +0 -1
- package/src/runtime/arrays.ts +0 -579
- package/src/runtime/context.ts +0 -189
- package/src/runtime/expressions.ts +0 -1811
- package/src/runtime/index.ts +0 -8
- package/src/runtime/memory.ts +0 -607
- package/src/runtime/strings.ts +0 -260
- package/src/runtime/tables.ts +0 -96
- package/src/runtime/tsconfig.json +0 -4
- package/src/runtime/values.ts +0 -209
- package/test-data/README.md +0 -83
- package/test-data/decision-tables/basic/8k.json +0 -87992
- package/test-data/decision-tables/basic/affiliate-commission-calculator.json +0 -228
- package/test-data/decision-tables/basic/airline-loyalty-points-calculations.json +0 -285
- package/test-data/decision-tables/basic/airline-upgrade-eligibility.json +0 -466
- package/test-data/decision-tables/basic/auto-insurance-premium-calculator.json +0 -412
- package/test-data/decision-tables/basic/booking-personalization-system.json +0 -553
- package/test-data/decision-tables/basic/care-team-assignment-system.json +0 -585
- package/test-data/decision-tables/basic/claim-validation-system.json +0 -307
- package/test-data/decision-tables/basic/clinical-lab-result-interpreter.json +0 -433
- package/test-data/decision-tables/basic/clinical-treatment-protocol.json +0 -474
- package/test-data/decision-tables/basic/credit-limit-adjustment.json +0 -479
- package/test-data/decision-tables/basic/customer-eligibility-engine.json +0 -551
- package/test-data/decision-tables/basic/customer-lifetime-value.json +0 -200
- package/test-data/decision-tables/basic/customer-onboarding-kyc-verification.json +0 -611
- package/test-data/decision-tables/basic/customer-service-escalation.json +0 -191
- package/test-data/decision-tables/basic/decision-table-discounts.json +0 -168
- package/test-data/decision-tables/basic/decision-table-shipping.json +0 -398
- package/test-data/decision-tables/basic/delivery-route-optimizer.json +0 -271
- package/test-data/decision-tables/basic/device-compatibility-checker.json +0 -303
- package/test-data/decision-tables/basic/disaster-relief-fund-allocation.json +0 -296
- package/test-data/decision-tables/basic/dynamic-fx-rate-pricing-system.json +0 -237
- package/test-data/decision-tables/basic/dynamic-marketplace-comission-calculator.json +0 -242
- package/test-data/decision-tables/basic/dynamic-shipping-cost-calculator.json +0 -378
- package/test-data/decision-tables/basic/dynamic-tarrif-engine.json +0 -289
- package/test-data/decision-tables/basic/dynamic-ticket-pricing.json +0 -325
- package/test-data/decision-tables/basic/empty-column-with-space.json +0 -100
- package/test-data/decision-tables/basic/empty-column-without-space.json +0 -100
- package/test-data/decision-tables/basic/environment-compliance-assessment.json +0 -386
- package/test-data/decision-tables/basic/expression-table-map.json +0 -313
- package/test-data/decision-tables/basic/flash-sale-eligibility.json +0 -366
- package/test-data/decision-tables/basic/flight-dispatch-decision-system.json +0 -455
- package/test-data/decision-tables/basic/flight-rebooking-fee-calculator.json +0 -406
- package/test-data/decision-tables/basic/government-assistance.json +0 -299
- package/test-data/decision-tables/basic/grant-funding-distribution.json +0 -307
- package/test-data/decision-tables/basic/hazardous-materials-management-system.json +0 -414
- package/test-data/decision-tables/basic/immigration-eligibility-evaluator.json +0 -765
- package/test-data/decision-tables/basic/import-duties-calculator.json +0 -318
- package/test-data/decision-tables/basic/insurance-agent-commission.json +0 -228
- package/test-data/decision-tables/basic/insurance-coverage-calculator.json +0 -362
- package/test-data/decision-tables/basic/insurance-underwriting-risk.json +0 -321
- package/test-data/decision-tables/basic/international-roaming-policy-manager.json +0 -199
- package/test-data/decision-tables/basic/legacy-plan-management.json +0 -434
- package/test-data/decision-tables/basic/marketplace-listing-verification-system.json +0 -334
- package/test-data/decision-tables/basic/medication-dosage-calculator.json +0 -318
- package/test-data/decision-tables/basic/merch-bags.json +0 -171
- package/test-data/decision-tables/basic/municipal-permit-evaluation-system.json +0 -364
- package/test-data/decision-tables/basic/mvno-partner-enablement.json +0 -313
- package/test-data/decision-tables/basic/partner-revenue-sharing.json +0 -244
- package/test-data/decision-tables/basic/payment-routing-and-fee-calculator.json +0 -475
- package/test-data/decision-tables/basic/policy-discount-calculator.json +0 -307
- package/test-data/decision-tables/basic/policy-eligibility-analyzer.json +0 -299
- package/test-data/decision-tables/basic/product-listing-scoring.json +0 -358
- package/test-data/decision-tables/basic/realtime-fraud-detection.json +0 -235
- package/test-data/decision-tables/basic/regional-compliance-manager.json +0 -278
- package/test-data/decision-tables/basic/returns-and-refund-policy.json +0 -366
- package/test-data/decision-tables/basic/returns-processing-system.json +0 -448
- package/test-data/decision-tables/basic/school-district-resource-allocation.json +0 -282
- package/test-data/decision-tables/basic/seat-map-optimization.json +0 -325
- package/test-data/decision-tables/basic/seller-fee-calculator.json +0 -307
- package/test-data/decision-tables/basic/service-level-agreement-enforcement.json +0 -575
- package/test-data/decision-tables/basic/smart-financial-product-matcher.json +0 -249
- package/test-data/decision-tables/basic/supply-chain-risk.json +0 -316
- package/test-data/decision-tables/basic/table-loop.json +0 -93
- package/test-data/decision-tables/basic/table.json +0 -76
- package/test-data/decision-tables/basic/traffic-violation-penalty-calculator.json +0 -436
- package/test-data/decision-tables/basic/transaction-compliance-classifier.json +0 -525
- package/test-data/decision-tables/basic/vehicle-claims-resolution.json +0 -310
- package/test-data/decision-tables/basic/warehouse-storage-location.json +0 -345
- package/test-data/decision-tables/hit-policy-collect/collect-multiple-matches.json +0 -127
- package/test-data/decision-tables/hit-policy-collect/collect-no-match.json +0 -95
- package/test-data/decision-tables/hit-policy-first/first-match.json +0 -103
- package/test-data/decision-tables/hit-policy-first/no-match.json +0 -95
- package/test-data/decision-tables/hit-policy-output-order/output-order-respected.json +0 -94
- package/test-data/decision-tables/hit-policy-output-order/string-output-order.json +0 -94
- package/test-data/decision-tables/hit-policy-priority/priority-respected.json +0 -86
- package/test-data/decision-tables/hit-policy-rule-order/rule-order-respected.json +0 -94
- package/test-data/decision-tables/hit-policy-unique/all-match-error.json +0 -89
- package/test-data/decision-tables/hit-policy-unique/multiple-match-error.json +0 -89
- package/test-data/decision-tables/hit-policy-unique/no-match.json +0 -88
- package/test-data/decision-tables/hit-policy-unique/unique-match.json +0 -99
- package/test-data/expressions/arithmetic/error-cyclic.json +0 -114
- package/test-data/expressions/arithmetic/error-missing-input.json +0 -54
- package/test-data/expressions/arithmetic/error-missing-output.json +0 -54
- package/test-data/expressions/arithmetic/expression-default.json +0 -93
- package/test-data/expressions/arithmetic/expression-fields.json +0 -94
- package/test-data/expressions/arithmetic/expression-loop.json +0 -94
- package/test-data/expressions/arithmetic/expression-passthrough.json +0 -108
- package/test-data/expressions/arithmetic/expression.json +0 -69
- package/test-data/expressions/arithmetic/nested-request.json +0 -125
- package/test-data/expressions/arithmetic/number-function.json +0 -58
- package/test-data/expressions/arithmetic/test-number-functions.json +0 -68
- package/test-data/expressions/functions/all.json +0 -149
- package/test-data/expressions/functions/avg.json +0 -89
- package/test-data/expressions/functions/filter.json +0 -109
- package/test-data/expressions/functions/flat.json +0 -167
- package/test-data/expressions/functions/map-strings.json +0 -65
- package/test-data/expressions/functions/map.json +0 -73
- package/test-data/expressions/functions/reduce.json +0 -49
- package/test-data/expressions/functions/some.json +0 -175
- package/test-data/expressions/functions/sort-strings.json +0 -97
- package/test-data/expressions/functions/sort.json +0 -97
- package/test-data/expressions/logical/logical-and.json +0 -116
- package/test-data/expressions/logical/logical-complex.json +0 -260
- package/test-data/expressions/logical/logical-not.json +0 -111
- package/test-data/expressions/logical/logical-or.json +0 -123
- package/test-data/expressions/string/string-comparison.json +0 -128
- package/test-data/expressions/string/string-concat.json +0 -106
- package/test-data/expressions/string/string-contains.json +0 -125
- package/test-data/expressions/string/string-endsWith.json +0 -113
- package/test-data/expressions/string/string-indexOf.json +0 -131
- package/test-data/expressions/string/string-join.json +0 -92
- package/test-data/expressions/string/string-lower.json +0 -94
- package/test-data/expressions/string/string-replace.json +0 -130
- package/test-data/expressions/string/string-split.json +0 -101
- package/test-data/expressions/string/string-startsWith.json +0 -113
- package/test-data/expressions/string/string-substring.json +0 -138
- package/test-data/expressions/string/string-trim.json +0 -100
- package/test-data/expressions/string/string-upper.json +0 -94
- package/test-data/other/custom.json +0 -51
- package/test-data/other/customer-input-schema.json +0 -34
- package/test-data/other/customer-output-schema.json +0 -34
- package/test-data/other/passthrough.json +0 -31
- package/test-data/sub-decisions/basic/$nodes-child.json +0 -31
- package/test-data/sub-decisions/basic/$nodes-parent.json +0 -49
- package/test-data/sub-decisions/basic/recursive-table1.json +0 -49
- package/test-data/sub-decisions/basic/recursive-table2.json +0 -49
- package/test-data/sub-decisions/complex-multi/approval-decision.json +0 -31
- package/test-data/sub-decisions/complex-multi/complex-dag.json +0 -175
- package/test-data/sub-decisions/complex-multi/credit-check.json +0 -31
- package/test-data/sub-decisions/complex-multi/customer-segmentation.json +0 -31
- package/test-data/sub-decisions/complex-multi/discount-eligibility.json +0 -31
- package/test-data/sub-decisions/complex-multi/eligibility-check.json +0 -31
- package/test-data/sub-decisions/complex-multi/final-offer.json +0 -31
- package/test-data/sub-decisions/complex-multi/income-verification.json +0 -31
- package/test-data/sub-decisions/complex-multi/linear-chain.json +0 -121
- package/test-data/sub-decisions/complex-multi/pricing-calculation.json +0 -31
- package/test-data/sub-decisions/complex-multi/product-eligibility.json +0 -31
- package/test-data/sub-decisions/complex-multi/risk-assessment.json +0 -31
- package/test-data/sub-decisions/complex-multi/shared-validation.json +0 -31
- package/test-data/sub-decisions/complex-multi/validation.json +0 -31
- package/test-data/sub-decisions/diamond/decision-a.json +0 -31
- package/test-data/sub-decisions/diamond/decision-b.json +0 -31
- package/test-data/sub-decisions/diamond/decision-c.json +0 -31
- package/test-data/sub-decisions/diamond/decision-shared.json +0 -31
- package/test-data/sub-decisions/diamond/diamond-pattern.json +0 -109
- package/test-data/sub-decisions/error-propagation/parent-calls-error.json +0 -44
- package/test-data/sub-decisions/error-propagation/sub-decision-with-error.json +0 -60
- package/test-data/switch-nodes/basic/account-dormancy-management.json +0 -245
- package/test-data/switch-nodes/basic/application-risk-assessment.json +0 -474
- package/test-data/switch-nodes/basic/cellular-data-rollover-system.json +0 -281
- package/test-data/switch-nodes/basic/clinical-pathway-selection.json +0 -454
- package/test-data/switch-nodes/basic/insurance-prior-authorization.json +0 -467
- package/test-data/switch-nodes/basic/last-mile-delivery-assignment.json +0 -373
- package/test-data/switch-nodes/basic/loan-approval.json +0 -469
- package/test-data/switch-nodes/basic/multi-switch.json +0 -498
- package/test-data/switch-nodes/basic/online-checkin-eligibility.json +0 -285
- package/test-data/switch-nodes/basic/order-consolidation-system.json +0 -493
- package/test-data/switch-nodes/basic/seller-approval-workflow.json +0 -383
- package/test-data/switch-nodes/basic/set-fee.json +0 -243
- package/test-data/switch-nodes/basic/shipping-carrier-selector.json +0 -379
- package/test-data/switch-nodes/basic/switch-node.json +0 -167
- package/test-data/switch-nodes/basic/switch-performance-2.json +0 -1307
- package/test-data/switch-nodes/basic/switch-performance.json +0 -691
- package/test-data/switch-nodes/basic/tax-exemption.json +0 -295
- package/test-data/switch-nodes/basic/warehouse-cross-docking.json +0 -313
- package/test-data/switch-nodes/default-cases/switch-with-default.json +0 -134
- package/test-data/zen-reference/$nodes-child.json +0 -69
- package/test-data/zen-reference/$nodes-parent.json +0 -34
- package/test-data/zen-reference/8k.json +0 -87992
- package/test-data/zen-reference/credit-analysis.json +0 -324
- package/test-data/zen-reference/custom.json +0 -51
- package/test-data/zen-reference/customer-input-schema.json +0 -34
- package/test-data/zen-reference/customer-output-schema.json +0 -34
- package/test-data/zen-reference/error-cyclic.json +0 -114
- package/test-data/zen-reference/error-missing-input.json +0 -54
- package/test-data/zen-reference/error-missing-output.json +0 -54
- package/test-data/zen-reference/expression.json +0 -69
- package/test-data/zen-reference/function-v2.json +0 -48
- package/test-data/zen-reference/function.json +0 -46
- package/test-data/zen-reference/graphs/account-dormancy-management.json +0 -245
- package/test-data/zen-reference/graphs/affiliate-commission-calculator.json +0 -228
- package/test-data/zen-reference/graphs/airline-loyalty-points-calculations.json +0 -285
- package/test-data/zen-reference/graphs/airline-upgrade-eligibility.json +0 -466
- package/test-data/zen-reference/graphs/aml.json +0 -537
- package/test-data/zen-reference/graphs/application-risk-assessment.json +0 -474
- package/test-data/zen-reference/graphs/auto-insurance-premium-calculator.json +0 -412
- package/test-data/zen-reference/graphs/booking-personalization-system.json +0 -553
- package/test-data/zen-reference/graphs/care-team-assignment-system.json +0 -585
- package/test-data/zen-reference/graphs/cellular-data-rollover-system.json +0 -281
- package/test-data/zen-reference/graphs/claim-validation-system.json +0 -307
- package/test-data/zen-reference/graphs/clinical-lab-result-interpreter.json +0 -433
- package/test-data/zen-reference/graphs/clinical-pathway-selection.json +0 -454
- package/test-data/zen-reference/graphs/clinical-treatment-protocol.json +0 -474
- package/test-data/zen-reference/graphs/company-analysis.json +0 -390
- package/test-data/zen-reference/graphs/credit-limit-adjustment.json +0 -479
- package/test-data/zen-reference/graphs/customer-eligibility-engine.json +0 -551
- package/test-data/zen-reference/graphs/customer-lifetime-value.json +0 -200
- package/test-data/zen-reference/graphs/customer-onboarding-kyc-verification.json +0 -611
- package/test-data/zen-reference/graphs/customer-service-escalation.json +0 -191
- package/test-data/zen-reference/graphs/decision-table-discounts.json +0 -168
- package/test-data/zen-reference/graphs/decision-table-shipping.json +0 -398
- package/test-data/zen-reference/graphs/delivery-route-optimizer.json +0 -271
- package/test-data/zen-reference/graphs/device-compatibility-checker.json +0 -303
- package/test-data/zen-reference/graphs/disaster-relief-fund-allocation.json +0 -296
- package/test-data/zen-reference/graphs/dynamic-fx-rate-pricing-system.json +0 -237
- package/test-data/zen-reference/graphs/dynamic-marketplace-comission-calculator.json +0 -242
- package/test-data/zen-reference/graphs/dynamic-shipping-cost-calculator.json +0 -378
- package/test-data/zen-reference/graphs/dynamic-tarrif-engine.json +0 -289
- package/test-data/zen-reference/graphs/dynamic-ticket-pricing.json +0 -325
- package/test-data/zen-reference/graphs/empty-column-with-space.json +0 -100
- package/test-data/zen-reference/graphs/empty-column-without-space.json +0 -100
- package/test-data/zen-reference/graphs/environment-compliance-assessment.json +0 -386
- package/test-data/zen-reference/graphs/expression-default.json +0 -93
- package/test-data/zen-reference/graphs/expression-fields.json +0 -94
- package/test-data/zen-reference/graphs/expression-loop.json +0 -94
- package/test-data/zen-reference/graphs/expression-passthrough.json +0 -108
- package/test-data/zen-reference/graphs/expression-table-map.json +0 -313
- package/test-data/zen-reference/graphs/flash-sale-eligibility.json +0 -366
- package/test-data/zen-reference/graphs/flight-dispatch-decision-system.json +0 -455
- package/test-data/zen-reference/graphs/flight-rebooking-fee-calculator.json +0 -406
- package/test-data/zen-reference/graphs/government-assistance.json +0 -299
- package/test-data/zen-reference/graphs/grant-funding-distribution.json +0 -307
- package/test-data/zen-reference/graphs/hazardous-materials-management-system.json +0 -414
- package/test-data/zen-reference/graphs/immigration-eligibility-evaluator.json +0 -765
- package/test-data/zen-reference/graphs/import-duties-calculator.json +0 -318
- package/test-data/zen-reference/graphs/insurance-agent-commission.json +0 -228
- package/test-data/zen-reference/graphs/insurance-breakdown.json +0 -421
- package/test-data/zen-reference/graphs/insurance-coverage-calculator.json +0 -362
- package/test-data/zen-reference/graphs/insurance-prior-authorization.json +0 -467
- package/test-data/zen-reference/graphs/insurance-underwriting-risk.json +0 -321
- package/test-data/zen-reference/graphs/international-roaming-policy-manager.json +0 -199
- package/test-data/zen-reference/graphs/last-mile-delivery-assignment.json +0 -373
- package/test-data/zen-reference/graphs/legacy-plan-management.json +0 -434
- package/test-data/zen-reference/graphs/loan-approval.json +0 -469
- package/test-data/zen-reference/graphs/marketplace-listing-verification-system.json +0 -334
- package/test-data/zen-reference/graphs/medication-dosage-calculator.json +0 -318
- package/test-data/zen-reference/graphs/merch-bags.json +0 -171
- package/test-data/zen-reference/graphs/multi-switch.json +0 -498
- package/test-data/zen-reference/graphs/municipal-permit-evaluation-system.json +0 -364
- package/test-data/zen-reference/graphs/mvno-partner-enablement.json +0 -313
- package/test-data/zen-reference/graphs/nested-request.json +0 -125
- package/test-data/zen-reference/graphs/online-checkin-eligibility.json +0 -285
- package/test-data/zen-reference/graphs/order-consolidation-system.json +0 -493
- package/test-data/zen-reference/graphs/partner-revenue-sharing.json +0 -244
- package/test-data/zen-reference/graphs/payment-routing-and-fee-calculator.json +0 -475
- package/test-data/zen-reference/graphs/policy-discount-calculator.json +0 -307
- package/test-data/zen-reference/graphs/policy-eligibility-analyzer.json +0 -299
- package/test-data/zen-reference/graphs/product-listing-scoring.json +0 -358
- package/test-data/zen-reference/graphs/realtime-fraud-detection.json +0 -235
- package/test-data/zen-reference/graphs/regional-compliance-manager.json +0 -278
- package/test-data/zen-reference/graphs/returns-and-refund-policy.json +0 -366
- package/test-data/zen-reference/graphs/returns-processing-system.json +0 -448
- package/test-data/zen-reference/graphs/school-district-resource-allocation.json +0 -282
- package/test-data/zen-reference/graphs/seat-map-optimization.json +0 -325
- package/test-data/zen-reference/graphs/seller-approval-workflow.json +0 -383
- package/test-data/zen-reference/graphs/seller-fee-calculator.json +0 -307
- package/test-data/zen-reference/graphs/service-level-agreement-enforcement.json +0 -575
- package/test-data/zen-reference/graphs/set-fee.json +0 -243
- package/test-data/zen-reference/graphs/shipping-carrier-selector.json +0 -379
- package/test-data/zen-reference/graphs/smart-financial-product-matcher.json +0 -249
- package/test-data/zen-reference/graphs/supply-chain-risk.json +0 -316
- package/test-data/zen-reference/graphs/table-loop.json +0 -93
- package/test-data/zen-reference/graphs/tax-exemption.json +0 -295
- package/test-data/zen-reference/graphs/traffic-violation-penalty-calculator.json +0 -436
- package/test-data/zen-reference/graphs/transaction-compliance-classifier.json +0 -525
- package/test-data/zen-reference/graphs/vehicle-claims-resolution.json +0 -310
- package/test-data/zen-reference/graphs/warehouse-cross-docking.json +0 -313
- package/test-data/zen-reference/graphs/warehouse-storage-location.json +0 -345
- package/test-data/zen-reference/http-function.json +0 -34
- package/test-data/zen-reference/infinite-function.json +0 -46
- package/test-data/zen-reference/js/imports.js +0 -25
- package/test-data/zen-reference/passthrough.json +0 -31
- package/test-data/zen-reference/recursive-table1.json +0 -49
- package/test-data/zen-reference/recursive-table2.json +0 -49
- package/test-data/zen-reference/sleep-function.json +0 -34
- package/test-data/zen-reference/switch-node.json +0 -167
- package/test-data/zen-reference/switch-performance-2.json +0 -1307
- package/test-data/zen-reference/switch-performance.json +0 -691
- package/test-data/zen-reference/table.json +0 -76
- package/tests/helpers/index.ts +0 -73
- package/tests/helpers/mock-context.ts +0 -231
- package/tests/helpers/round-trip.ts +0 -398
- package/tests/helpers/test-harness-comparison.ts +0 -325
- package/tests/helpers/test-harness-wasm.ts +0 -710
- package/tests/helpers/test-harness.ts +0 -28
- package/tests/helpers/wasm-test.ts +0 -659
- package/tests/integration/compilation-errors.test.ts +0 -864
- package/tests/integration/decision-tables.test.ts +0 -531
- package/tests/integration/edge-cases.test.ts +0 -787
- package/tests/integration/expressions.test.ts +0 -513
- package/tests/integration/function-node-integration.test.ts +0 -182
- package/tests/integration/sub-decisions.test.ts +0 -108
- package/tests/integration/switch-nodes.test.ts +0 -399
- package/tests/integration/unary-or-matching.test.ts +0 -53
- package/tests/integration/wasm-data-types.test.ts +0 -398
- package/tests/integration/wasm-errors.test.ts +0 -199
- package/tests/integration/wasm-execution.test.ts +0 -348
- package/tests/integration/wasm-memory.test.ts +0 -228
- package/tests/scripts/analyze-coverage.ts +0 -166
- package/tests/scripts/categorize-tests.ts +0 -396
- package/tests/scripts/coverage-analysis.ts +0 -836
- package/tests/unit/compiler/cache.test.ts +0 -238
- package/tests/unit/compiler/errors.test.ts +0 -316
- package/tests/unit/compiler/graph-scalability.test.ts +0 -510
- package/tests/unit/compiler/graph.test.ts +0 -878
- package/tests/unit/compiler/input-validation.test.ts +0 -447
- package/tests/unit/compiler/logical-and-parser.test.ts +0 -143
- package/tests/unit/compiler/logical-not-parser.test.ts +0 -107
- package/tests/unit/compiler/logical-or-parser.test.ts +0 -236
- package/tests/unit/compiler/marshal-gen/marshal-gen.test.ts +0 -97
- package/tests/unit/compiler/nodes/decision-table.test.ts +0 -103
- package/tests/unit/compiler/nodes/decision.test.ts +0 -182
- package/tests/unit/compiler/nodes/function-compile.test.ts +0 -204
- package/tests/unit/compiler/nodes/function.test.ts +0 -176
- package/tests/unit/compiler/nodes/input.test.ts +0 -30
- package/tests/unit/compiler/nodes/switch.test.ts +0 -127
- package/tests/unit/compiler/optimizer-cache.test.ts +0 -327
- package/tests/unit/compiler/optimizer-implementation.test.ts +0 -625
- package/tests/unit/compiler/parser.test.ts +0 -508
- package/tests/unit/compiler/runtime-error-cleanup.test.ts +0 -426
- package/tests/unit/compiler/runtime-validation.test.ts +0 -303
- package/tests/unit/compiler/runtime.test.ts +0 -221
- package/tests/unit/compiler/schema/schema.test.ts +0 -248
- package/tests/unit/compiler/unary-ast-transforms.test.ts +0 -245
- package/tsconfig.json +0 -27
- package/tsup.config.ts +0 -11
- package/vitest.config.ts +0 -12
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WASM Execution Integration Tests
|
|
3
|
-
*
|
|
4
|
-
* Core tests for compiling JDM to WASM and executing it.
|
|
5
|
-
* Tests the full pipeline: JDM -> AssemblyScript -> WASM -> Execution
|
|
6
|
-
*
|
|
7
|
-
* This is Phase 6 of the test improvement plan - critical integration tests
|
|
8
|
-
* that verify actual WASM compilation and execution.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { describe, it, expect } from 'vitest';
|
|
12
|
-
import { Type } from '@sinclair/typebox';
|
|
13
|
-
import { compile } from '../../src/compiler';
|
|
14
|
-
import { createExpressionJDM } from '../helpers';
|
|
15
|
-
import { runSimpleCompatibilityTest } from '../helpers/test-harness';
|
|
16
|
-
|
|
17
|
-
describe('WASM Execution Integration Tests', () => {
|
|
18
|
-
describe('Compilation Pipeline', () => {
|
|
19
|
-
it('should compile a minimal JDM to valid WASM binary', async () => {
|
|
20
|
-
const jdm = createExpressionJDM([{ key: 'result', value: '42' }]);
|
|
21
|
-
const inputSchema = Type.Object({});
|
|
22
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
23
|
-
|
|
24
|
-
const compiled = await compile({
|
|
25
|
-
jdm,
|
|
26
|
-
inputSchema,
|
|
27
|
-
outputSchema,
|
|
28
|
-
debug: true,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Verify WASM binary is valid
|
|
32
|
-
expect(compiled.wasm).toBeInstanceOf(Uint8Array);
|
|
33
|
-
expect(compiled.wasm.length).toBeGreaterThan(0);
|
|
34
|
-
|
|
35
|
-
// WASM magic number (0x00, 0x61, 0x73, 0x6D)
|
|
36
|
-
expect(compiled.wasm[0]).toBe(0x00);
|
|
37
|
-
expect(compiled.wasm[1]).toBe(0x61);
|
|
38
|
-
expect(compiled.wasm[2]).toBe(0x73);
|
|
39
|
-
expect(compiled.wasm[3]).toBe(0x6d);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should generate valid AssemblyScript code in debug mode', async () => {
|
|
43
|
-
const jdm = createExpressionJDM([{ key: 'result', value: 'x + y' }]);
|
|
44
|
-
const inputSchema = Type.Object({
|
|
45
|
-
x: Type.Number(),
|
|
46
|
-
y: Type.Number(),
|
|
47
|
-
});
|
|
48
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
49
|
-
|
|
50
|
-
const compiled = await compile({
|
|
51
|
-
jdm,
|
|
52
|
-
inputSchema,
|
|
53
|
-
outputSchema,
|
|
54
|
-
debug: true,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
expect(compiled.assemblyScript).toBeDefined();
|
|
58
|
-
expect(compiled.assemblyScript).toContain('export function evaluate');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should generate marshaling code', async () => {
|
|
62
|
-
const jdm = createExpressionJDM([{ key: 'result', value: '1' }]);
|
|
63
|
-
const inputSchema = Type.Object({ x: Type.Number() });
|
|
64
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
65
|
-
|
|
66
|
-
const compiled = await compile({
|
|
67
|
-
jdm,
|
|
68
|
-
inputSchema,
|
|
69
|
-
outputSchema,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
expect(compiled.marshalCode).toBeDefined();
|
|
73
|
-
expect(compiled.marshalCode).toContain('marshalInput');
|
|
74
|
-
expect(compiled.marshalCode).toContain('unmarshalOutput');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should generate validation code', async () => {
|
|
78
|
-
const jdm = createExpressionJDM([{ key: 'result', value: '1' }]);
|
|
79
|
-
const inputSchema = Type.Object({ x: Type.Number() });
|
|
80
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
81
|
-
|
|
82
|
-
const compiled = await compile({
|
|
83
|
-
jdm,
|
|
84
|
-
inputSchema,
|
|
85
|
-
outputSchema,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
expect(compiled.validationCode).toBeDefined();
|
|
89
|
-
expect(compiled.validationCode).toContain('validateInput');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('should compute schema hash', async () => {
|
|
93
|
-
const jdm = createExpressionJDM([{ key: 'result', value: '1' }]);
|
|
94
|
-
const inputSchema = Type.Object({ x: Type.Number() });
|
|
95
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
96
|
-
|
|
97
|
-
const compiled = await compile({
|
|
98
|
-
jdm,
|
|
99
|
-
inputSchema,
|
|
100
|
-
outputSchema,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
expect(compiled.schemaHash).toBeDefined();
|
|
104
|
-
expect(typeof compiled.schemaHash).toBe('bigint');
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('Arithmetic Expression Evaluation', () => {
|
|
109
|
-
it('should evaluate simple addition', async () => {
|
|
110
|
-
await runSimpleCompatibilityTest({
|
|
111
|
-
name: 'addition',
|
|
112
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a + b' }]),
|
|
113
|
-
input: { a: 5, b: 3 },
|
|
114
|
-
expected: { result: 8 },
|
|
115
|
-
skipZen: true,
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should evaluate subtraction', async () => {
|
|
120
|
-
await runSimpleCompatibilityTest({
|
|
121
|
-
name: 'subtraction',
|
|
122
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a - b' }]),
|
|
123
|
-
input: { a: 10, b: 4 },
|
|
124
|
-
expected: { result: 6 },
|
|
125
|
-
skipZen: true,
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('should evaluate multiplication', async () => {
|
|
130
|
-
await runSimpleCompatibilityTest({
|
|
131
|
-
name: 'multiplication',
|
|
132
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a * b' }]),
|
|
133
|
-
input: { a: 6, b: 7 },
|
|
134
|
-
expected: { result: 42 },
|
|
135
|
-
skipZen: true,
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should evaluate division', async () => {
|
|
140
|
-
await runSimpleCompatibilityTest({
|
|
141
|
-
name: 'division',
|
|
142
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a / b' }]),
|
|
143
|
-
input: { a: 20, b: 4 },
|
|
144
|
-
expected: { result: 5 },
|
|
145
|
-
skipZen: true,
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should evaluate complex arithmetic expressions', async () => {
|
|
150
|
-
await runSimpleCompatibilityTest({
|
|
151
|
-
name: 'complex-arithmetic',
|
|
152
|
-
jdm: createExpressionJDM([{ key: 'result', value: '(a + b) * c - d / e' }]),
|
|
153
|
-
input: { a: 2, b: 3, c: 4, d: 10, e: 2 },
|
|
154
|
-
// (2 + 3) * 4 - 10 / 2 = 5 * 4 - 5 = 20 - 5 = 15
|
|
155
|
-
expected: { result: 15 },
|
|
156
|
-
skipZen: true,
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('should evaluate floating point arithmetic', async () => {
|
|
161
|
-
await runSimpleCompatibilityTest({
|
|
162
|
-
name: 'float-arithmetic',
|
|
163
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a + b' }]),
|
|
164
|
-
input: { a: 0.1, b: 0.2 },
|
|
165
|
-
expected: { result: 0.30000000000000004 }, // IEEE 754 floating point
|
|
166
|
-
skipZen: true,
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('should evaluate modulo operation', async () => {
|
|
171
|
-
await runSimpleCompatibilityTest({
|
|
172
|
-
name: 'modulo',
|
|
173
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a % b' }]),
|
|
174
|
-
input: { a: 17, b: 5 },
|
|
175
|
-
expected: { result: 2 },
|
|
176
|
-
skipZen: true,
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('should evaluate negative numbers', async () => {
|
|
181
|
-
await runSimpleCompatibilityTest({
|
|
182
|
-
name: 'negative',
|
|
183
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a + b' }]),
|
|
184
|
-
input: { a: -10, b: 3 },
|
|
185
|
-
expected: { result: -7 },
|
|
186
|
-
skipZen: true,
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
describe('Boolean Operations', () => {
|
|
192
|
-
it('should evaluate boolean and', async () => {
|
|
193
|
-
await runSimpleCompatibilityTest({
|
|
194
|
-
name: 'boolean-and',
|
|
195
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a and b' }]),
|
|
196
|
-
input: { a: true, b: true },
|
|
197
|
-
expected: { result: true },
|
|
198
|
-
skipZen: true,
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('should evaluate boolean or', async () => {
|
|
203
|
-
await runSimpleCompatibilityTest({
|
|
204
|
-
name: 'boolean-or',
|
|
205
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a or b' }]),
|
|
206
|
-
input: { a: false, b: true },
|
|
207
|
-
expected: { result: true },
|
|
208
|
-
skipZen: true,
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('should evaluate boolean not', async () => {
|
|
213
|
-
await runSimpleCompatibilityTest({
|
|
214
|
-
name: 'boolean-not',
|
|
215
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'not a' }]),
|
|
216
|
-
input: { a: true },
|
|
217
|
-
expected: { result: false },
|
|
218
|
-
skipZen: true,
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('should evaluate comparison operators', async () => {
|
|
223
|
-
await runSimpleCompatibilityTest({
|
|
224
|
-
name: 'comparison',
|
|
225
|
-
jdm: createExpressionJDM([
|
|
226
|
-
{ key: 'isGreater', value: 'x > y' },
|
|
227
|
-
{ key: 'isEqual', value: 'x == y' },
|
|
228
|
-
{ key: 'isLessOrEqual', value: 'x <= y' },
|
|
229
|
-
]),
|
|
230
|
-
input: { x: 10, y: 5 },
|
|
231
|
-
expected: { isGreater: true, isEqual: false, isLessOrEqual: false },
|
|
232
|
-
skipZen: true,
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
describe('Array Operations', () => {
|
|
238
|
-
it('should evaluate sum() function', async () => {
|
|
239
|
-
await runSimpleCompatibilityTest({
|
|
240
|
-
name: 'sum',
|
|
241
|
-
jdm: createExpressionJDM([{ key: 'total', value: 'sum(numbers)' }]),
|
|
242
|
-
input: { numbers: [1, 2, 3, 4, 5] },
|
|
243
|
-
expected: { total: 15 },
|
|
244
|
-
skipZen: true,
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('should evaluate avg() function', async () => {
|
|
249
|
-
await runSimpleCompatibilityTest({
|
|
250
|
-
name: 'avg',
|
|
251
|
-
jdm: createExpressionJDM([{ key: 'average', value: 'avg(numbers)' }]),
|
|
252
|
-
input: { numbers: [10, 20, 30] },
|
|
253
|
-
expected: { average: 20 },
|
|
254
|
-
skipZen: true,
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('should evaluate filter() function', async () => {
|
|
259
|
-
await runSimpleCompatibilityTest({
|
|
260
|
-
name: 'filter',
|
|
261
|
-
jdm: createExpressionJDM([{ key: 'filtered', value: 'filter(numbers, # > 5)' }]),
|
|
262
|
-
input: { numbers: [1, 3, 5, 7, 9, 11] },
|
|
263
|
-
expected: { filtered: [7, 9, 11] },
|
|
264
|
-
skipZen: true,
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('should evaluate map() function', async () => {
|
|
269
|
-
await runSimpleCompatibilityTest({
|
|
270
|
-
name: 'map',
|
|
271
|
-
jdm: createExpressionJDM([{ key: 'doubled', value: 'map(numbers, # * 2)' }]),
|
|
272
|
-
input: { numbers: [1, 2, 3] },
|
|
273
|
-
expected: { doubled: [2, 4, 6] },
|
|
274
|
-
skipZen: true,
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('should evaluate all() function', async () => {
|
|
279
|
-
await runSimpleCompatibilityTest({
|
|
280
|
-
name: 'all',
|
|
281
|
-
jdm: createExpressionJDM([{ key: 'allPositive', value: 'all(numbers, # > 0)' }]),
|
|
282
|
-
input: { numbers: [1, 2, 3] },
|
|
283
|
-
expected: { allPositive: true },
|
|
284
|
-
skipZen: true,
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('should evaluate some() function', async () => {
|
|
289
|
-
await runSimpleCompatibilityTest({
|
|
290
|
-
name: 'some',
|
|
291
|
-
jdm: createExpressionJDM([{ key: 'hasNegative', value: 'some(numbers, # < 0)' }]),
|
|
292
|
-
input: { numbers: [1, -2, 3] },
|
|
293
|
-
expected: { hasNegative: true },
|
|
294
|
-
skipZen: true,
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
describe('String Operations', () => {
|
|
300
|
-
it('should evaluate string concatenation', async () => {
|
|
301
|
-
await runSimpleCompatibilityTest({
|
|
302
|
-
name: 'string-concat',
|
|
303
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'firstName + " " + lastName' }]),
|
|
304
|
-
input: { firstName: 'John', lastName: 'Doe' },
|
|
305
|
-
expected: { result: 'John Doe' },
|
|
306
|
-
skipZen: true,
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
describe('Nested Property Access', () => {
|
|
312
|
-
it('should evaluate nested property access', async () => {
|
|
313
|
-
await runSimpleCompatibilityTest({
|
|
314
|
-
name: 'nested-property',
|
|
315
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'user.profile.age + 10' }]),
|
|
316
|
-
input: { user: { profile: { age: 25 } } },
|
|
317
|
-
expected: { result: 35 },
|
|
318
|
-
skipZen: true,
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('should evaluate deeply nested properties', async () => {
|
|
323
|
-
await runSimpleCompatibilityTest({
|
|
324
|
-
name: 'deeply-nested',
|
|
325
|
-
jdm: createExpressionJDM([{ key: 'result', value: 'a.b.c.d.e' }]),
|
|
326
|
-
input: { a: { b: { c: { d: { e: 42 } } } } },
|
|
327
|
-
expected: { result: 42 },
|
|
328
|
-
skipZen: true,
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
describe('Multiple Outputs', () => {
|
|
334
|
-
it('should evaluate multiple expressions to multiple outputs', async () => {
|
|
335
|
-
await runSimpleCompatibilityTest({
|
|
336
|
-
name: 'multiple-outputs',
|
|
337
|
-
jdm: createExpressionJDM([
|
|
338
|
-
{ key: 'sum', value: 'a + b' },
|
|
339
|
-
{ key: 'product', value: 'a * b' },
|
|
340
|
-
{ key: 'difference', value: 'a - b' },
|
|
341
|
-
]),
|
|
342
|
-
input: { a: 10, b: 3 },
|
|
343
|
-
expected: { sum: 13, product: 30, difference: 7 },
|
|
344
|
-
skipZen: true,
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
});
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WASM Memory Management Tests
|
|
3
|
-
*
|
|
4
|
-
* Tests for memory allocation, growth, and lifecycle management in compiled WASM modules.
|
|
5
|
-
* Verifies that memory is properly allocated, doesn't leak, and handles growth correctly.
|
|
6
|
-
*
|
|
7
|
-
* This is Phase 6 of the test improvement plan - testing memory management behavior.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, it, expect } from 'vitest';
|
|
11
|
-
import { Type } from '@sinclair/typebox';
|
|
12
|
-
import { compile, type JDMDecision } from '../../src/compiler';
|
|
13
|
-
import { ensureMemory } from '../../src/compiler/runtime';
|
|
14
|
-
import { runSimpleCompatibilityTest } from '../helpers/test-harness';
|
|
15
|
-
import type { CompilationResult } from '../../src/compiler/types';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Create a minimal JDM decision for testing
|
|
19
|
-
*/
|
|
20
|
-
function createTestJDM(expression: string): JDMDecision {
|
|
21
|
-
return {
|
|
22
|
-
nodes: [
|
|
23
|
-
{
|
|
24
|
-
id: 'input-1',
|
|
25
|
-
type: 'inputNode' as any,
|
|
26
|
-
position: { x: 0, y: 0 },
|
|
27
|
-
name: 'Request',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
id: 'expr-1',
|
|
31
|
-
type: 'expressionNode' as any,
|
|
32
|
-
position: { x: 200, y: 0 },
|
|
33
|
-
name: 'Expression',
|
|
34
|
-
content: {
|
|
35
|
-
expressions: [{ id: 'e1', key: 'result', value: expression }],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 'output-1',
|
|
40
|
-
type: 'outputNode' as any,
|
|
41
|
-
position: { x: 400, y: 0 },
|
|
42
|
-
name: 'Response',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
edges: [
|
|
46
|
-
{ id: 'edge-1', sourceId: 'input-1', targetId: 'expr-1', type: 'edge' },
|
|
47
|
-
{ id: 'edge-2', sourceId: 'expr-1', targetId: 'output-1', type: 'edge' },
|
|
48
|
-
],
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Helper to instantiate WASM and get memory instance
|
|
54
|
-
*/
|
|
55
|
-
async function instantiateWasm(compiled: CompilationResult): Promise<{
|
|
56
|
-
instance: WebAssembly.Instance;
|
|
57
|
-
memory: WebAssembly.Memory;
|
|
58
|
-
evaluate: (ptr: number) => number;
|
|
59
|
-
}> {
|
|
60
|
-
const wasmArray = new Uint8Array(compiled.wasm);
|
|
61
|
-
const buffer = wasmArray.buffer.slice(
|
|
62
|
-
wasmArray.byteOffset,
|
|
63
|
-
wasmArray.byteOffset + wasmArray.byteLength,
|
|
64
|
-
);
|
|
65
|
-
const wasmModule = await WebAssembly.compile(buffer as ArrayBuffer);
|
|
66
|
-
const instance = await WebAssembly.instantiate(wasmModule, {
|
|
67
|
-
env: {
|
|
68
|
-
abort: () => {
|
|
69
|
-
throw new Error('WASM abort called');
|
|
70
|
-
},
|
|
71
|
-
'Date.now': () => Date.now(),
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
instance,
|
|
77
|
-
memory: instance.exports.memory as WebAssembly.Memory,
|
|
78
|
-
evaluate: instance.exports.evaluate as (ptr: number) => number,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
describe('WASM Memory Management Tests', () => {
|
|
83
|
-
describe('Memory Initialization', () => {
|
|
84
|
-
it('should create WASM instance with initial memory', async () => {
|
|
85
|
-
const jdm = createTestJDM('42');
|
|
86
|
-
const inputSchema = Type.Object({});
|
|
87
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
88
|
-
|
|
89
|
-
const compiled = await compile({ jdm, inputSchema, outputSchema });
|
|
90
|
-
const { memory } = await instantiateWasm(compiled);
|
|
91
|
-
|
|
92
|
-
// Initial memory should be at least 4 pages (256KB) based on build.ts config
|
|
93
|
-
expect(memory.buffer.byteLength).toBeGreaterThanOrEqual(4 * 65536);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('should export memory from WASM module', async () => {
|
|
97
|
-
const jdm = createTestJDM('x + 1');
|
|
98
|
-
const inputSchema = Type.Object({ x: Type.Number() });
|
|
99
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
100
|
-
|
|
101
|
-
const compiled = await compile({ jdm, inputSchema, outputSchema });
|
|
102
|
-
const { instance } = await instantiateWasm(compiled);
|
|
103
|
-
|
|
104
|
-
expect(instance.exports.memory).toBeDefined();
|
|
105
|
-
expect(instance.exports.memory).toBeInstanceOf(WebAssembly.Memory);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should export evaluate function from WASM module', async () => {
|
|
109
|
-
const jdm = createTestJDM('x + 1');
|
|
110
|
-
const inputSchema = Type.Object({ x: Type.Number() });
|
|
111
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
112
|
-
|
|
113
|
-
const compiled = await compile({ jdm, inputSchema, outputSchema });
|
|
114
|
-
const { instance } = await instantiateWasm(compiled);
|
|
115
|
-
|
|
116
|
-
expect(instance.exports.evaluate).toBeDefined();
|
|
117
|
-
expect(typeof instance.exports.evaluate).toBe('function');
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe('Memory Growth', () => {
|
|
122
|
-
it('should grow memory when ensureMemory is called with larger size', async () => {
|
|
123
|
-
const jdm = createTestJDM('1');
|
|
124
|
-
const inputSchema = Type.Object({});
|
|
125
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
126
|
-
|
|
127
|
-
const compiled = await compile({ jdm, inputSchema, outputSchema });
|
|
128
|
-
const { memory } = await instantiateWasm(compiled);
|
|
129
|
-
|
|
130
|
-
const initialSize = memory.buffer.byteLength;
|
|
131
|
-
|
|
132
|
-
// Request more memory than currently available
|
|
133
|
-
const requiredSize = initialSize + 65536 * 2; // 2 extra pages
|
|
134
|
-
ensureMemory(memory, requiredSize);
|
|
135
|
-
|
|
136
|
-
expect(memory.buffer.byteLength).toBeGreaterThanOrEqual(requiredSize);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should not grow memory when sufficient is available', async () => {
|
|
140
|
-
const jdm = createTestJDM('1');
|
|
141
|
-
const inputSchema = Type.Object({});
|
|
142
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
143
|
-
|
|
144
|
-
const compiled = await compile({ jdm, inputSchema, outputSchema });
|
|
145
|
-
const { memory } = await instantiateWasm(compiled);
|
|
146
|
-
|
|
147
|
-
const initialSize = memory.buffer.byteLength;
|
|
148
|
-
|
|
149
|
-
// Request less memory than available
|
|
150
|
-
ensureMemory(memory, initialSize - 1);
|
|
151
|
-
|
|
152
|
-
// Size should remain the same
|
|
153
|
-
expect(memory.buffer.byteLength).toBe(initialSize);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('should handle memory growth for large inputs', async () => {
|
|
157
|
-
const jdm = createTestJDM('sum(numbers)');
|
|
158
|
-
const inputSchema = Type.Object({ numbers: Type.Array(Type.Number()) });
|
|
159
|
-
const outputSchema = Type.Object({ result: Type.Number() });
|
|
160
|
-
|
|
161
|
-
const compiled = await compile({ jdm, inputSchema, outputSchema });
|
|
162
|
-
const { memory } = await instantiateWasm(compiled);
|
|
163
|
-
|
|
164
|
-
// Grow to handle a large array
|
|
165
|
-
const largeSize = 1024 * 1024; // 1MB
|
|
166
|
-
ensureMemory(memory, largeSize);
|
|
167
|
-
|
|
168
|
-
expect(memory.buffer.byteLength).toBeGreaterThanOrEqual(largeSize);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('Large Data Handling', () => {
|
|
173
|
-
it('should handle arrays with many elements', async () => {
|
|
174
|
-
// Create array with 1000 elements
|
|
175
|
-
const numbers = Array.from({ length: 1000 }, (_, i) => i + 1);
|
|
176
|
-
|
|
177
|
-
await runSimpleCompatibilityTest({
|
|
178
|
-
name: 'large-array-sum',
|
|
179
|
-
jdm: createTestJDM('sum(numbers)'),
|
|
180
|
-
input: { numbers },
|
|
181
|
-
// Sum of 1 to 1000 = 500500
|
|
182
|
-
expected: { result: 500500 },
|
|
183
|
-
skipZen: true,
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('should handle deeply nested objects', async () => {
|
|
188
|
-
await runSimpleCompatibilityTest({
|
|
189
|
-
name: 'deeply-nested',
|
|
190
|
-
jdm: createTestJDM('a.b.c.d.e'),
|
|
191
|
-
input: { a: { b: { c: { d: { e: 42 } } } } },
|
|
192
|
-
expected: { result: 42 },
|
|
193
|
-
skipZen: true,
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it('should handle object with many properties', async () => {
|
|
198
|
-
// Create object with many properties
|
|
199
|
-
const input: Record<string, number> = {};
|
|
200
|
-
for (let i = 0; i < 100; i++) {
|
|
201
|
-
input[`prop${i}`] = i;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
await runSimpleCompatibilityTest({
|
|
205
|
-
name: 'many-properties',
|
|
206
|
-
jdm: createTestJDM('prop50 + prop51'),
|
|
207
|
-
input,
|
|
208
|
-
expected: { result: 101 },
|
|
209
|
-
skipZen: true,
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('Memory Stability', () => {
|
|
215
|
-
it('should handle multiple evaluations without issues', async () => {
|
|
216
|
-
// Run multiple evaluations with different inputs
|
|
217
|
-
for (let i = 1; i <= 10; i++) {
|
|
218
|
-
await runSimpleCompatibilityTest({
|
|
219
|
-
name: `stability-test-${i}`,
|
|
220
|
-
jdm: createTestJDM('x * 2'),
|
|
221
|
-
input: { x: i },
|
|
222
|
-
expected: { result: i * 2 },
|
|
223
|
-
skipZen: true,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
});
|