eliscript 0.0.1 → 0.0.2
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/README.md +59 -0
- package/bootstrap/README.md +26 -0
- package/bootstrap/backends/README.md +515 -0
- package/bootstrap/backends/async.eli +230 -0
- package/bootstrap/backends/binary.eli +173 -0
- package/bootstrap/backends/capabilities.eli +74 -0
- package/bootstrap/backends/elf.eli +246 -0
- package/bootstrap/backends/managed.eli +5976 -0
- package/bootstrap/backends/memory.eli +100 -0
- package/bootstrap/backends/native.eli +2000 -0
- package/bootstrap/backends/numeric.eli +1362 -0
- package/bootstrap/backends/optimize.eli +79 -0
- package/bootstrap/backends/regexp.eli +2263 -0
- package/bootstrap/backends/sha256.eli +138 -0
- package/bootstrap/backends/wasm.eli +1161 -0
- package/bootstrap/compiler/analyzer.eli +165 -77
- package/bootstrap/compiler/compiler.eli +43 -19
- package/bootstrap/compiler/emitter.eli +780 -170
- package/bootstrap/compiler/expander.eli +136 -45
- package/bootstrap/compiler/formatter.eli +8 -1
- package/bootstrap/compiler/ir.eli +148 -45
- package/bootstrap/compiler/lower.eli +29 -2
- package/bootstrap/compiler/project.eli +51 -21
- package/bootstrap/compiler/reader.eli +128 -36
- package/bootstrap/compiler/source-map.eli +46 -4
- package/bootstrap/compiler/symbol.eli +2 -1
- package/bootstrap/compiler/syntax.eli +47 -12
- package/bootstrap/compiler/transient-analysis.eli +40 -4
- package/bootstrap/host/check-cli-legacy.mjs +163 -0
- package/bootstrap/host/check-cli.mjs +59 -158
- package/bootstrap/host/check-cli.mjs.map +1 -0
- package/bootstrap/host/compiler-session.eli +1579 -0
- package/bootstrap/host/compiler-tools.eli +513 -0
- package/bootstrap/host/eliscript-cli-legacy.mjs +37 -0
- package/bootstrap/host/eliscript-cli.mjs +53 -33
- package/bootstrap/host/eliscript-cli.mjs.map +1 -0
- package/bootstrap/host/project-cli-legacy.mjs +295 -0
- package/bootstrap/host/project-cli.mjs +74 -289
- package/bootstrap/host/project-cli.mjs.map +1 -0
- package/bootstrap/host/project-legacy.mjs +1080 -0
- package/bootstrap/host/project.mjs +210 -1060
- package/bootstrap/host/project.mjs.map +1 -0
- package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
- package/bootstrap/runtime/memory.eli +30379 -0
- package/browser/host.mjs +89 -0
- package/compiler/eliscript-analyzer.el +371 -4
- package/compiler/eliscript-cli.el +84 -1
- package/compiler/eliscript-emitter.el +1189 -256
- package/compiler/eliscript-expander.el +147 -10
- package/compiler/eliscript-ir-emitter.el +725 -208
- package/compiler/eliscript-lower.el +127 -1
- package/compiler/eliscript-portable.el +177 -51
- package/compiler/eliscript-project.el +20 -2
- package/compiler/eliscript-reader.el +141 -57
- package/compiler/eliscript-source-map.el +26 -12
- package/compiler/eliscript-transient-analysis.el +382 -19
- package/dist/backends/async.mjs +561 -0
- package/dist/backends/async.mjs.macro-origins.json +1 -0
- package/dist/backends/async.mjs.map +1 -0
- package/dist/backends/binary.mjs +381 -0
- package/dist/backends/binary.mjs.macro-origins.json +1 -0
- package/dist/backends/binary.mjs.map +1 -0
- package/dist/backends/capabilities.mjs +237 -0
- package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
- package/dist/backends/capabilities.mjs.map +1 -0
- package/dist/backends/elf.mjs +540 -0
- package/dist/backends/elf.mjs.macro-origins.json +1 -0
- package/dist/backends/elf.mjs.map +1 -0
- package/dist/backends/managed.mjs +10616 -0
- package/dist/backends/managed.mjs.macro-origins.json +1 -0
- package/dist/backends/managed.mjs.map +1 -0
- package/dist/backends/memory.mjs +278 -0
- package/dist/backends/memory.mjs.macro-origins.json +1 -0
- package/dist/backends/memory.mjs.map +1 -0
- package/dist/backends/native.mjs +4099 -0
- package/dist/backends/native.mjs.macro-origins.json +1 -0
- package/dist/backends/native.mjs.map +1 -0
- package/dist/backends/numeric.mjs +2458 -0
- package/dist/backends/numeric.mjs.macro-origins.json +1 -0
- package/dist/backends/numeric.mjs.map +1 -0
- package/dist/backends/optimize.mjs +204 -0
- package/dist/backends/optimize.mjs.macro-origins.json +1 -0
- package/dist/backends/optimize.mjs.map +1 -0
- package/dist/backends/regexp.mjs +2033 -0
- package/dist/backends/regexp.mjs.macro-origins.json +1 -0
- package/dist/backends/regexp.mjs.map +1 -0
- package/dist/backends/sha256.mjs +310 -0
- package/dist/backends/sha256.mjs.macro-origins.json +1 -0
- package/dist/backends/sha256.mjs.map +1 -0
- package/dist/backends/wasm.mjs +2258 -0
- package/dist/backends/wasm.mjs.macro-origins.json +1 -0
- package/dist/backends/wasm.mjs.map +1 -0
- package/dist/bootstrap/analyzer.mjs +1908 -776
- package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -1
- package/dist/bootstrap/compiler.mjs +450 -142
- package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/compiler.mjs.map +1 -1
- package/dist/bootstrap/emitter.mjs +3083 -909
- package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/emitter.mjs.map +1 -1
- package/dist/bootstrap/expander.mjs +2887 -1233
- package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/expander.mjs.map +1 -1
- package/dist/bootstrap/formatter.mjs +582 -218
- package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/formatter.mjs.map +1 -1
- package/dist/bootstrap/ir.mjs +670 -116
- package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/ir.mjs.map +1 -1
- package/dist/bootstrap/lower.mjs +866 -257
- package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/lower.mjs.map +1 -1
- package/dist/bootstrap/package.json +1 -0
- package/dist/bootstrap/project.mjs +1168 -498
- package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/project.mjs.map +1 -1
- package/dist/bootstrap/reader.mjs +674 -175
- package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/reader.mjs.map +1 -1
- package/dist/bootstrap/runtime/math.mjs +1117 -0
- package/dist/bootstrap/runtime/math.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
- package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +430 -119
- package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/source-map.mjs.map +1 -1
- package/dist/bootstrap/symbol.mjs +229 -53
- package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/symbol.mjs.map +1 -1
- package/dist/bootstrap/syntax.mjs +205 -7
- package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/syntax.mjs.map +1 -1
- package/dist/bootstrap/transient-analysis.mjs +1185 -489
- package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -1
- package/dist/browser/compiler.js +199 -6478
- package/dist/browser/host.mjs +446 -0
- package/dist/browser/loader.js +1 -0
- package/dist/browser/loader.mjs +231 -0
- package/dist/browser/worker.mjs +60 -0
- package/dist/compiler-artifact.json +1 -0
- package/dist/host/compiler-session.mjs +2980 -0
- package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-session.mjs.map +1 -0
- package/dist/host/compiler-tools.mjs +1084 -0
- package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-tools.mjs.map +1 -0
- package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
- package/dist/literal-sources/runtime/core/collection.eli +579 -0
- package/dist/literal-sources/runtime/core/data-text.eli +290 -0
- package/dist/literal-sources/runtime/core/data.eli +22 -0
- package/dist/literal-sources/runtime/core/identifier.eli +44 -0
- package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
- package/dist/literal-sources/runtime/core/list.eli +19 -0
- package/dist/literal-sources/runtime/core/map.eli +9 -0
- package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
- package/dist/literal-sources/runtime/core/metadata.eli +23 -0
- package/dist/literal-sources/runtime/core/object.eli +8 -0
- package/dist/literal-sources/runtime/core/order.eli +123 -0
- package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
- package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
- package/dist/literal-sources/runtime/core/protocol.eli +28 -0
- package/dist/literal-sources/runtime/core/queue.eli +9 -0
- package/dist/literal-sources/runtime/core/record.eli +191 -0
- package/dist/literal-sources/runtime/core/regex.eli +158 -0
- package/dist/literal-sources/runtime/core/sequence.eli +305 -0
- package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
- package/dist/literal-sources/runtime/core/set.eli +9 -0
- package/dist/literal-sources/runtime/core/sorted.eli +408 -0
- package/dist/literal-sources/runtime/core/text.eli +14 -0
- package/dist/literal-sources/runtime/core/transducer.eli +268 -0
- package/dist/literal-sources/runtime/core/transient.eli +17 -0
- package/dist/literal-sources/runtime/core/truth.eli +4 -0
- package/dist/literal-sources/runtime/core/type.eli +232 -0
- package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
- package/dist/literal-sources/runtime/core/value.eli +19 -0
- package/dist/literal-sources/runtime/core/vector.eli +20 -0
- package/dist/literal-sources/runtime/literals.eli +23 -0
- package/dist/literal-sources/runtime/testing/value.eli +6 -0
- package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
- package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
- package/dist/literal-sources/runtime/wire/schema.eli +193 -0
- package/dist/literal-sources/stdlib/bit.eli +36 -0
- package/dist/literal-sources/stdlib/core/data.eli +306 -0
- package/dist/literal-sources/stdlib/core/object.eli +89 -0
- package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
- package/dist/literal-sources/stdlib/core/set.eli +312 -0
- package/dist/literal-sources/stdlib/core/text.eli +103 -0
- package/dist/literal-sources/stdlib/managed-literal-protocols.eli +483 -0
- package/dist/literal-sources/stdlib/managed-literals.eli +1414 -0
- package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
- package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
- package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
- package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
- package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
- package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
- package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
- package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
- package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
- package/dist/literal-sources/stdlib/value.eli +325 -0
- package/dist/package.json +10 -0
- package/dist/runtime/math.mjs +1116 -0
- package/dist/runtime/math.mjs.macro-origins.json +1 -0
- package/dist/runtime/math.mjs.map +1 -0
- package/dist/runtime/unicode-case-data.mjs +10124 -0
- package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/runtime/unicode-case.mjs +280 -0
- package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case.mjs.map +1 -0
- package/dist/runtime.eli +30379 -0
- package/dist/stage3-release.json +1 -0
- package/editor/README.md +1 -1
- package/editor/eliscript-mode.el +1 -1
- package/editor/eliscript-repl.el +1 -1
- package/package.json +97 -10
- package/platform/http.mjs +20 -0
- package/runtime/array-text.mjs +159 -0
- package/runtime/core/map-internals.mjs +27 -9
- package/runtime/core/object-impl.mjs +26 -17
- package/runtime/core/object-impl.mjs.map +1 -1
- package/runtime/core/protocol-impl.mjs +682 -255
- package/runtime/core/protocol-impl.mjs.map +1 -1
- package/runtime/core/protocol.mjs +4 -0
- package/runtime/core/record.mjs +23 -2
- package/runtime/core/regex.mjs +4 -0
- package/runtime/core/sorted.mjs +53 -0
- package/runtime/core/text-impl.mjs +167 -48
- package/runtime/core/text-impl.mjs.map +1 -1
- package/runtime/core/type.mjs +75 -3
- package/runtime/core/vector.mjs +6 -0
- package/runtime/math.eli +429 -0
- package/runtime/math.mjs +1116 -0
- package/runtime/math.mjs.map +1 -0
- package/runtime/number-radix.mjs +105 -0
- package/runtime/unicode-case-data.eli +29 -0
- package/runtime/unicode-case-data.mjs +10124 -0
- package/runtime/unicode-case-data.mjs.map +1 -0
- package/runtime/unicode-case.eli +100 -0
- package/runtime/unicode-case.mjs +280 -0
- package/runtime/unicode-case.mjs.map +1 -0
- package/runtime/wire/http-rpc.mjs +168 -0
- package/runtime/wire/markdown.mjs +196 -0
- package/runtime/wire/schema.mjs +109 -0
- package/stdlib/README.md +54 -0
- package/stdlib/core/protocol.eli +81 -17
- package/stdlib/core/seq.eli +1 -1
- package/stdlib/core/zipper.eli +114 -47
- package/stdlib/gepo.eli +12 -0
- package/stdlib/interop/js.eli +56 -15
- package/stdlib/managed-literal-protocols.eli +483 -0
- package/stdlib/managed-literals.eli +1414 -0
- package/stdlib/managed-protocol-error.eli +32 -0
- package/stdlib/managed-queue-state.eli +65 -0
- package/stdlib/managed-runtime-collection-internals.eli +60 -0
- package/stdlib/managed-runtime-collection.eli +579 -0
- package/stdlib/managed-runtime-data-text.eli +290 -0
- package/stdlib/managed-runtime-data.eli +22 -0
- package/stdlib/managed-runtime-identifier.eli +44 -0
- package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
- package/stdlib/managed-runtime-list.eli +19 -0
- package/stdlib/managed-runtime-literals.eli +23 -0
- package/stdlib/managed-runtime-map.eli +9 -0
- package/stdlib/managed-runtime-metadata-internals.eli +6 -0
- package/stdlib/managed-runtime-metadata.eli +23 -0
- package/stdlib/managed-runtime-object.eli +8 -0
- package/stdlib/managed-runtime-order.eli +123 -0
- package/stdlib/managed-runtime-persistent-kind.eli +28 -0
- package/stdlib/managed-runtime-protocol.eli +28 -0
- package/stdlib/managed-runtime-queue.eli +9 -0
- package/stdlib/managed-runtime-record.eli +191 -0
- package/stdlib/managed-runtime-regex.eli +158 -0
- package/stdlib/managed-runtime-sequence.eli +305 -0
- package/stdlib/managed-runtime-set-algebra.eli +28 -0
- package/stdlib/managed-runtime-set.eli +9 -0
- package/stdlib/managed-runtime-sorted.eli +408 -0
- package/stdlib/managed-runtime-text.eli +14 -0
- package/stdlib/managed-runtime-transducer.eli +268 -0
- package/stdlib/managed-runtime-transient.eli +17 -0
- package/stdlib/managed-runtime-truth.eli +4 -0
- package/stdlib/managed-runtime-type.eli +232 -0
- package/stdlib/managed-runtime-value-internals.eli +13 -0
- package/stdlib/managed-runtime-value.eli +19 -0
- package/stdlib/managed-runtime-vector.eli +20 -0
- package/stdlib/managed-sorted-state.eli +233 -0
- package/stdlib/managed-testing-value.eli +6 -0
- package/stdlib/managed-transient-state.eli +348 -0
- package/stdlib/managed-value-state.eli +153 -0
- package/stdlib/managed-vector-view-state.eli +102 -0
- package/stdlib/managed-wire-http-rpc.eli +362 -0
- package/stdlib/managed-wire-markdown.eli +275 -0
- package/stdlib/managed-wire-schema.eli +193 -0
- package/stdlib/mdp.eli +7 -0
- package/stdlib/mds.eli +4 -0
- package/stdlib/persistent-vector.eli +23 -6
- package/tools/acceptance/check-legacy.mjs +687 -0
- package/tools/acceptance/check.eli +431 -0
- package/tools/acceptance/compile-evidence.el +49 -0
- package/tools/acceptance/finalize-legacy.mjs +498 -0
- package/tools/acceptance/finalize.eli +270 -0
- package/tools/backends/benchmark.mjs +175 -0
- package/tools/backends/build.mjs +135 -0
- package/tools/backends/compile.mjs +94 -0
- package/tools/backends/compiler-bootstrap.mjs +1001 -0
- package/tools/backends/compiler-browser.mjs +361 -0
- package/tools/backends/compiler-build.mjs +1628 -0
- package/tools/backends/compiler-cli-legacy.mjs +334 -0
- package/tools/backends/compiler-cli.mjs +29 -0
- package/tools/backends/compiler-corpus-bit.mjs +234 -0
- package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
- package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
- package/tools/backends/compiler-corpus-debugging.mjs +221 -0
- package/tools/backends/compiler-corpus-emitter.mjs +324 -0
- package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
- package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
- package/tools/backends/compiler-corpus-execution.mjs +3324 -0
- package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
- package/tools/backends/compiler-corpus-generations.mjs +208 -0
- package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
- package/tools/backends/compiler-corpus-host-context.mjs +550 -0
- package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
- package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
- package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
- package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
- package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
- package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
- package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
- package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
- package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
- package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
- package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
- package/tools/backends/compiler-corpus-matchers.mjs +173 -0
- package/tools/backends/compiler-corpus-original-program.mjs +612 -0
- package/tools/backends/compiler-corpus-process.mjs +765 -0
- package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
- package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
- package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
- package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
- package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
- package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
- package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
- package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
- package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
- package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
- package/tools/backends/compiler-corpus-reference.mjs +241 -0
- package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
- package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
- package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
- package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
- package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
- package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
- package/tools/backends/compiler-corpus.mjs +2054 -0
- package/tools/backends/compiler-debug.mjs +142 -0
- package/tools/backends/compiler-matrix.mjs +1955 -0
- package/tools/backends/compiler-metadata.mjs +203 -0
- package/tools/backends/compiler-package-browser.mjs +120 -0
- package/tools/backends/compiler-package-legacy.mjs +654 -0
- package/tools/backends/compiler-package.mjs +464 -0
- package/tools/backends/compiler-project.mjs +126 -0
- package/tools/backends/compiler-session.mjs +843 -0
- package/tools/backends/compiler-sha256.mjs +152 -0
- package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
- package/tools/backends/compiler-worker.mjs +573 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
- package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
- package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
- package/tools/backends/dist/record-grid.mjs +1256 -0
- package/tools/backends/dist/record-grid.mjs.map +1 -0
- package/tools/backends/dist/release-cli.mjs +460 -0
- package/tools/backends/dist/release-cli.mjs.map +1 -0
- package/tools/backends/dist/run-artifact.mjs +517 -0
- package/tools/backends/dist/run-artifact.mjs.map +1 -0
- package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
- package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
- package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
- package/tools/backends/managed-foreign-binding.mjs +497 -0
- package/tools/backends/managed-host-legacy.mjs +1181 -0
- package/tools/backends/managed-host-lifecycle.mjs +310 -0
- package/tools/backends/managed-host-object-provider.mjs +155 -0
- package/tools/backends/managed-host-object-realm.mjs +797 -0
- package/tools/backends/managed-host-proxy.mjs +71 -0
- package/tools/backends/managed-host-runtime.mjs +5868 -0
- package/tools/backends/managed-host.mjs +716 -0
- package/tools/backends/managed-module-graph-legacy.mjs +308 -0
- package/tools/backends/managed-module-graph.mjs +694 -0
- package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
- package/tools/backends/managed-runtime.mjs +939 -0
- package/tools/backends/managed-source-view-legacy.mjs +332 -0
- package/tools/backends/managed-source-view.mjs +959 -0
- package/tools/backends/memory-runtime.mjs +100 -0
- package/tools/backends/native-benchmark.mjs +88 -0
- package/tools/backends/native-managed-runtime.mjs +677 -0
- package/tools/backends/native-memory.mjs +768 -0
- package/tools/backends/native-node-memory.mjs +142 -0
- package/tools/backends/native-node-runner.mjs +99 -0
- package/tools/backends/native-node-watchdog.mjs +19 -0
- package/tools/backends/native-node-worker.mjs +75 -0
- package/tools/backends/stage3-targets.mjs +486 -0
- package/tools/bootstrap-command.el +13 -0
- package/tools/bootstrap-runtime.el +101 -0
- package/tools/bootstrap-seed.el +55 -0
- package/tools/project/check-cli.eli +31 -0
- package/tools/project/project-cli.eli +42 -0
- package/tools/project/project.eli +122 -0
- package/tools/runtime/unicode-case-profiles.mjs +13 -0
- package/tools/runtime/unicode-case-runtime.el +57 -0
- package/tools/testing/source-debugging-corpus-host.eli +16 -0
- package/tools/testing/source-debugging.eli +139 -0
- package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
- package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
- package/tools/testing/stdlib-bit.eli +104 -0
- package/tools/testing/stdlib-bit.mjs +255 -0
- package/bin/eliscript-bootstrap +0 -15
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
import {posix} from 'node:path';
|
|
2
|
+
import {loadCompilerSources} from './compiler-build.mjs';
|
|
3
|
+
|
|
4
|
+
// Public fixture observations and the complete original suite replay serve
|
|
5
|
+
// separate roles. The latter retains the original raw heap/descriptor/trap
|
|
6
|
+
// assertions and runs them with the actual selected compiler namespaces.
|
|
7
|
+
// Every observation calls the selected product's real exported functions. The
|
|
8
|
+
// comparison product is independently emitted by the original Seed oracle.
|
|
9
|
+
const prelude = `import assert from 'node:assert/strict';
|
|
10
|
+
import {readFile} from 'node:fs/promises';
|
|
11
|
+
import {resolve} from 'node:path';
|
|
12
|
+
import {pathToFileURL} from 'node:url';
|
|
13
|
+
const root=process.env.ELISCRIPT_ORIGINAL_SOURCE_ROOT;
|
|
14
|
+
const product=process.argv[2], entry=process.argv[3];
|
|
15
|
+
const reference=process.env.ELISCRIPT_ORIGINAL_REFERENCE_PRODUCT_ROOT;
|
|
16
|
+
if(!root||!reference)throw new Error('original fixture execution requires its independent Seed product');
|
|
17
|
+
const m=await import(pathToFileURL(resolve(product,entry)).href);
|
|
18
|
+
const oracle=await import(pathToFileURL(resolve(reference,entry)).href);
|
|
19
|
+
let runtime;
|
|
20
|
+
if(process.env.ELISCRIPT_ORIGINAL_TARGET!=='javascript'){
|
|
21
|
+
const configuration=process.env.ELISCRIPT_ORIGINAL_PROGRAM_CONTEXT;
|
|
22
|
+
if(!configuration)throw new Error('selected binary fixture requires its real runtime context');
|
|
23
|
+
const {readCompilerMetadata}=await import(pathToFileURL(resolve(root,'tools/backends/compiler-metadata.mjs')).href);
|
|
24
|
+
const input=await readCompilerMetadata(configuration);
|
|
25
|
+
const {openOriginalProgramContext}=await import(pathToFileURL(resolve(root,'tools/backends/compiler-corpus-host-context.mjs')).href);
|
|
26
|
+
runtime=(await openOriginalProgramContext(input,{identity:configuration})).runtime;
|
|
27
|
+
runtime.auto(__ELISCRIPT_ORIGINAL_AUTO__);
|
|
28
|
+
}
|
|
29
|
+
let observations=0;
|
|
30
|
+
function compare(label,observe){
|
|
31
|
+
const expected=observe(oracle),actual=observe(m);
|
|
32
|
+
assert.deepEqual(actual,expected,label);observations++;
|
|
33
|
+
if(runtime){runtime.collect();assert.equal(runtime.stats().frameDepth,0,label+' restores private frames');}
|
|
34
|
+
}
|
|
35
|
+
function outcome(action){try{return{value:action()};}catch(error){return{error:{name:error?.name}};}}
|
|
36
|
+
function named(module,name,...args){return module[name.replaceAll('-','_')](...args);}
|
|
37
|
+
function finish(){
|
|
38
|
+
assert(observations>0,'a fixture must execute assertions, not merely compile');
|
|
39
|
+
if(runtime){runtime.closeModule();runtime.collect();assert.equal(runtime.live(),0);assert.equal(runtime.stats().frameDepth,0);}
|
|
40
|
+
console.log(JSON.stringify({observations}));
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const arithmetic = `
|
|
45
|
+
const numbers=[0,-0,1,-1,NaN,Infinity,-Infinity,Number.MIN_VALUE,-Number.MIN_VALUE,Number.MAX_VALUE,2**53,1e16,.1,-.25];
|
|
46
|
+
for(const x of numbers){
|
|
47
|
+
for(const name of['negate','reciprocal','increment','decrement','unary-add','unary-multiply'])compare(name,mod=>named(mod,name,x));
|
|
48
|
+
for(const y of numbers)for(const name of['add','subtract','multiply','divide','equal','distinct','not-equal','less','less-equal','greater','greater-equal','snapshot'])compare(name,mod=>named(mod,name,x,y));
|
|
49
|
+
}
|
|
50
|
+
for(const name of['zero','one'])compare(name,mod=>named(mod,name));
|
|
51
|
+
for(const x of[undefined,null,false,true,'',' ','x','-0','0x10','中\\ud800'])for(const name of['increment','decrement'])compare(name,mod=>named(mod,name,x));
|
|
52
|
+
const triples=[[1,1e16,-1e16],[1e16,-1e16,1],[Number.MAX_VALUE,2,.5],[-0,0,-0],[NaN,1,2],[1,NaN,2],[1,1,2],[1,2,1],[3,2,1],[0,1,1],[Infinity,-Infinity,Number.MIN_VALUE]];
|
|
53
|
+
for(const inputs of triples)for(const name of['ordered-sum','ordered-product','ordered-subtract','ordered-divide','equal-three','distinct-three','less-three','compare-snapshot'])compare(name,mod=>named(mod,name,...inputs));
|
|
54
|
+
for(const pair of[[2,1],[NaN,NaN]])compare('comparison effects',mod=>mod.comparison_effects(...pair));
|
|
55
|
+
const values=[null,false,true,undefined,...numbers,'','x','中😀\\ud800'];
|
|
56
|
+
for(const left of values)for(const right of values)for(const name of['equal','identical','distinct','not-equal'])compare(name,mod=>named(mod,name,left,right));
|
|
57
|
+
for(const [a,b]of[[{},{}],[[],[]],[{},[]]])for(const name of['equal','identical','distinct'])compare('opaque '+name,mod=>[named(mod,name,a,a),named(mod,name,a,b)]);
|
|
58
|
+
const strings=['','a','aa','\\0','中','😀','\\ud800','\\udfff','\\ud800x'];
|
|
59
|
+
for(const left of strings)for(const right of strings)for(const name of['less','less-equal','greater','greater-equal'])compare(name,mod=>named(mod,name,left,right));
|
|
60
|
+
for(const name of['sum-to','recursive-sum'])for(const n of[0,1,8,32])compare(name,mod=>named(mod,name,n));
|
|
61
|
+
for(let i=0;i<100;i++)compare('repeated numeric loop',mod=>mod.sum_to(32));
|
|
62
|
+
let state=0x6239c71;const next=()=>{state^=state<<13;state^=state>>>17;state^=state<<5;return state>>>0;},view=new DataView(new ArrayBuffer(8));
|
|
63
|
+
const random=()=>{view.setUint32(0,next(),true);view.setUint32(4,next(),true);return view.getFloat64(0,true);};
|
|
64
|
+
for(let i=0;i<512;i++){const pair=[random(),random()];for(const name of['add','subtract','multiply','divide','equal','distinct','less','less-equal','greater','greater-equal'])compare(name,mod=>named(mod,name,...pair));}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const word = `
|
|
68
|
+
const numbers=[0,-0,1,-1,.1,-.1,3.5,-3.5,NaN,Infinity,-Infinity,Number.MIN_VALUE,-Number.MIN_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,2**31-1,2**31,2**32-1,2**32+1,-(2**32)-1,2**52+1,2**53-1,2**53+2,2**83,2**84];
|
|
69
|
+
for(const x of numbers){for(const name of['signed','unsigned','invert'])compare(name,mod=>named(mod,name,x));for(const y of numbers)for(const name of['remainder','modulo','mask','union','exclusive','shift-left','shift-right','logical-right','multiply','snapshot','remainder-snapshot'])compare(name,mod=>named(mod,name,x,y));}
|
|
70
|
+
for(const pair of[[1,.1],[1e16,3],[Number.MAX_VALUE,3],[Number.MAX_VALUE,Number.MIN_VALUE],[Number.MIN_VALUE*3,Number.MIN_VALUE*2],[1,Number.MIN_VALUE*3],[-4,2],[-0,3],[3,-0],[1,Infinity],[Infinity,1]])compare('subnormal remainder',mod=>mod.remainder(...pair));
|
|
71
|
+
for(const triple of[[17,5,2],[-17,5,2],[Number.MAX_VALUE,3,.1],[NaN,1,2],[17,0,2]])compare('remainder-many',mod=>mod.remainder_many(...triple));
|
|
72
|
+
for(let e=-1074;e<=1023;e++)for(const x of[2**e,-(2**e)])for(const name of['signed','unsigned','invert'])compare(name,mod=>named(mod,name,x));
|
|
73
|
+
for(let e=0;e<85;e++)for(const x of[2**e+1,2**e+.5,-(2**e+1),-(2**e+.5)])for(const name of['signed','unsigned'])compare(name,mod=>named(mod,name,x));
|
|
74
|
+
for(const x of[-1,-2,2**31,2**32-1,0x7fffffff,0x80000001,0xfffffffd])for(const count of[-65,-33,-32,-31,-1,0,1,20,31,32,33,63,64,65,2**32+1,NaN,Infinity])for(const name of['shift-left','shift-right','logical-right'])compare(name,mod=>named(mod,name,x,count));
|
|
75
|
+
for(const pair of[[0xffffffff,0xffffffff],[0xffffffff,0xfffffffd],[0x80000001,0x80000001],[0x7fffffff,0x7fffffff]])compare('multiply',mod=>mod.multiply(...pair));
|
|
76
|
+
let state=0x4e69537;const next=()=>{state^=state<<13;state^=state>>>17;state^=state<<5;return state>>>0;},bits=new DataView(new ArrayBuffer(8));
|
|
77
|
+
const random=()=>{bits.setUint32(0,next(),true);bits.setUint32(4,next(),true);return bits.getFloat64(0,true);};
|
|
78
|
+
for(let i=0;i<2048;i++){const x=random(),y=random();for(const name of['remainder','signed','unsigned','mask','exclusive','multiply','logical-right'])compare(name,mod=>named(mod,name,...(name==='signed'||name==='unsigned'?[x]:[x,y])));const pair=[next(),next()];compare('integer imul',mod=>mod.multiply(...pair));}
|
|
79
|
+
for(const seed of[0,-0,NaN,Infinity,Number.MAX_VALUE,0x80000001])compare('loop-mix',mod=>mod.loop_mix(128,seed));
|
|
80
|
+
for(let x=0;x<64;x++)for(let y=1;y<32;y++)for(const sign of[1,-1])compare('exhaustive subnormal remainder',mod=>mod.remainder(sign*x*Number.MIN_VALUE,y*Number.MIN_VALUE));
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
const callbacks = `
|
|
84
|
+
const methods=[['map','map'],['filter','filter'],['for-each','forEach'],['some','some'],['every','every'],['find','find'],['find-index','findIndex'],['find-last','findLast'],['find-last-index','findLastIndex']];
|
|
85
|
+
const sparse=[];sparse.length=6;sparse[1]=false;sparse[3]=3;sparse[5]=undefined;
|
|
86
|
+
for(const values of[[0,-0,NaN,'',null,undefined,false,Number.MIN_VALUE,'中😀',true,Infinity],sparse])for(const[name,method]of methods)compare(name,mod=>named(mod,name+'-with',values.slice(),mod.identity()));
|
|
87
|
+
for(const[name]of methods)compare('arguments '+name,mod=>{const values=[false,true,false],log=[];named(mod,name+'-with',values,mod.collect_arguments(log));return log.map(args=>[args[0],args[1],args[2]===values,args.length]);});
|
|
88
|
+
for(const values of[[],[undefined],[1],[1,2,3],[-0],[-0,Number.MIN_VALUE,Infinity],Array(5)])for(const[name]of[['reduce'],['reduce-right']])compare(name,mod=>[outcome(()=>named(mod,name+'-with',values.slice(),mod.sum_callback())),named(mod,name==='reduce'?'reduce-initial':'reduce-right-initial',values.slice(),mod.sum_callback(),-0)]);
|
|
89
|
+
for(const name of['reduce-initial','reduce-right-initial'])compare(name,mod=>{const values=[1,2,3],log=[];const out=named(mod,name,values,mod.ordered_callback(log),0);return[out,log.map(row=>[row[0],row[1],row[2]===values])];});
|
|
90
|
+
for(const[name]of methods)compare('live '+name,mod=>{const values=[1,2,3,4];const out=named(mod,name+'-with',values,mod.mutation_callback(values));return[out,values];});
|
|
91
|
+
compare('capture order',mod=>{const values=[1,2],other=[8],marker=[false];const out=mod.evaluation_order(values,other,marker);return[out,marker];});
|
|
92
|
+
for(const receiver of[null,undefined])compare('nullish lookup',mod=>{const marker=[false];return[outcome(()=>mod.nullish_order(receiver,marker)),marker];});
|
|
93
|
+
compare('own captured method',mod=>mod.map_shadow([1,2],mod.shadow_value()));
|
|
94
|
+
compare('replaced builtin',mod=>{const values=[1,2],first=mod.map_replaced(values,mod.identity());return[first,outcome(()=>mod.map_with(values,mod.identity()))];});
|
|
95
|
+
compare('reentrant map',mod=>mod.map_recursive([0,1,2,-0,Number.MIN_VALUE]));
|
|
96
|
+
for(const[name]of[...methods,['reduce'],['reduce-right']])for(const bad of[null,undefined,false,true])compare('invalid '+name,mod=>outcome(()=>named(mod,name+'-with',[],bad)));
|
|
97
|
+
compare('first error',mod=>{const marker=[false];return[outcome(()=>mod.first_error([1,2],marker)),marker];});
|
|
98
|
+
compare('stable sort',mod=>mod.sort_stable());
|
|
99
|
+
for(const values of[[3,1,2],[-0,NaN,1],['b','a'],[undefined,,3,1]])for(const name of['sort-default','sort-copy','sort-nan-ties'])compare(name,mod=>{const items=values.slice(),out=named(mod,name,items);return[out,out===items,items,Object.keys(out)];});
|
|
100
|
+
for(const reverse of[false,true])compare('numeric sort',mod=>mod.sort_numeric([3,1,2],reverse));
|
|
101
|
+
compare('sort copy mutation',mod=>{const items=[3,1,2];return[mod.sort_copy_mutation(items),items];});
|
|
102
|
+
compare('concat shared children',mod=>mod.concat_summary());
|
|
103
|
+
compare('concat one level',mod=>{const nested=[7],items=[,undefined,nested],out=mod.concat_copy(items,items);assert.equal(out[2],out[5]);nested[0]=9;return[out,Object.keys(out),out===items];});
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
const arrays = `
|
|
107
|
+
for(const values of[[undefined,null,false],[true,-0,NaN],['中😀',Number.MIN_VALUE,Infinity]])compare('array construction',mod=>{const out=mod.make(...values);return[out,mod.size(out),mod.nth_value(1,out),mod.at(out,2),mod.get_value(out,'missing',7)];});
|
|
108
|
+
compare('array identity and copy',mod=>{const a=mod.empty();assert.equal(mod.write(a,1,undefined),undefined);mod.write(a,3,'last');const b=mod.copy(a);assert.notEqual(a,b);return[a,b,mod.keys(a),mod.keys(b),mod.has(a,0),mod.has(a,1),mod.has(a,'length')];});
|
|
109
|
+
for(const[start,end]of[['1','5'],['0x2','Infinity'],['-2',undefined],['not-number','4'],[true,false],[null,'3.5'],['0xbcf8f9bdba22840724d028768a8a77b3e6b0f283670085477910eccc4e9d6b278a11db79c280d4e9c237774812029ac7ce82daaafca38',undefined]])compare('primitive slice',mod=>{const out=mod.interval([true,,undefined,false,,true],start,end);return[out,Object.keys(out)];});
|
|
110
|
+
compare('mutations',mod=>{const a=[];const out=[mod.append(a,1,2),mod.append_none(a),mod.remove_last(a),mod.truncate(a,5)];out.push(a.slice(),mod.keys(a));return out;});
|
|
111
|
+
compare('self cycle',mod=>{const out=mod.nested(1,2);assert.equal(out[0],out);return[out[1],out.length];});
|
|
112
|
+
compare('operand order',mod=>{const a=[1,2,3],b=[8],marker=[false];return[mod.key_order(a),mod.fallback_order(a),mod.append_order(a,b),a,b,mod.pop_extra(a,marker),marker,mod.slice_extra(a,0,2,marker),mod.write_order(a,b),a[0]===b];});
|
|
113
|
+
for(const n of[0,1,8,32,128])compare('grow loop',mod=>mod.grow_loop(n));
|
|
114
|
+
for(const receiver of[null,undefined])compare('nullish write',mod=>{const marker=[false];return[outcome(()=>mod.null_write(receiver,marker)),marker];});
|
|
115
|
+
compare('named properties and assoc',mod=>{const a=[];for(const key of['tag','2','01','1','__proto__'])mod.write(a,key,key==='__proto__'?null:key);const b=mod.assoc(a,'other',7);return[mod.keys(a),mod.keys(b),mod.at(a,'tag'),mod.has(a,'other'),mod.at(b,'other')];});
|
|
116
|
+
for(const name of['append-shadow','pop-shadow','slice-shadow'])compare(name,mod=>{const a=[1,2],marker=[false];a[name.split('-')[0]==='append'?'push':name.split('-')[0]]=false;return[outcome(()=>named(mod,name,a,marker)),marker];});
|
|
117
|
+
compare('captured push',mod=>{const a=[];return[mod.append_replace(a),a,a.push];});
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
const construction = `
|
|
121
|
+
compare('canonical constructors',mod=>[mod.identities(),mod.empty_of(),mod.exercise()]);
|
|
122
|
+
const sparse=[];sparse.length=4;sparse[1]=undefined;sparse[3]=false;
|
|
123
|
+
for(const values of[[],sparse,'A😀\\ud800Z',new Set(['a','b']),new Map([[1,'a'],[2,'b']]),{length:2.9,0:'x'},[8,9].values()])compare('Array.from',mod=>{const input=typeof values?.next==='function'?[8,9].values():values;return[mod.from(input),mod.of(undefined,false,null),mod.direct(typeof values?.next==='function'?[8,9].values():values),mod.member(typeof values?.next==='function'?[8,9].values():values)];});
|
|
124
|
+
compare('mapper',mod=>mod.map([4,5],mod.mapper()));
|
|
125
|
+
for(const values of[undefined,null,false,1])compare('from rejection or arraylike',mod=>outcome(()=>mod.from(values)));
|
|
126
|
+
for(const mapper of[null,false,true,1,{}])compare('mapper validation',mod=>outcome(()=>mod.from([],mapper)));
|
|
127
|
+
compare('collection iterator',mod=>{const set=mod.collection([1,2,2],false),map=mod.collection([[1,'a'],[2,'b']],true);return[mod.from(mod.iterator(set)),mod.from(map),mod.own(mod.of(undefined),0)];});
|
|
128
|
+
`;
|
|
129
|
+
|
|
130
|
+
const search = `
|
|
131
|
+
const values=[0,-0,NaN,'中😀',false,null,undefined,0];const sparse=Array(5);sparse[1]=undefined;sparse[3]=NaN;
|
|
132
|
+
const starts=[undefined,null,false,true,NaN,Infinity,-Infinity,-0,0,.9,-.9,1.9,-1.9,4,5,9,-9,2**31,-(2**31),2**32,-(2**32),2**53,-(2**53),Number.MIN_VALUE,-Number.MIN_VALUE,'2','-2','x'];
|
|
133
|
+
for(const items of[[],values,sparse])for(const needle of[undefined,null,false,NaN,0,-0,'中😀','missing'])for(const start of starts)for(const name of['includes','index','last'])compare(name,mod=>named(mod,name,items,needle,start));
|
|
134
|
+
for(const items of[[],values,sparse])for(const name of['missing-includes','missing-index','missing-last'])compare(name,mod=>named(mod,name,items));
|
|
135
|
+
for(const items of[[],values,sparse])for(const needle of values)compare('default last',mod=>mod.default_last(items,needle));
|
|
136
|
+
let seed=0x831ac519;const next=()=>seed=(Math.imul(seed,1664525)+1013904223)>>>0,pool=[undefined,null,false,true,NaN,-0,0,Number.MIN_VALUE,'','中😀','\\ud800',-3,2];
|
|
137
|
+
for(let k=0;k<128;k++){const values=Array.from({length:next()%32},()=>pool[next()%pool.length]);for(let i=0;i<values.length;i++)if(next()%4===0)delete values[i];for(let t=0;t<8;t++){const needle=pool[next()%pool.length],start=(next()%100-50)/3;for(const name of['includes','index','last'])compare('seeded '+name,mod=>named(mod,name,values,needle,start));}}
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
const properties = `
|
|
141
|
+
compare('identities and integer order',mod=>[mod.identities(),mod.exercise()]);
|
|
142
|
+
for(const source of[{},[1,,undefined],'😀',false,1,Symbol('key'),null,undefined])compare('keys/hasOwn',mod=>[outcome(()=>mod.keys(source)),outcome(()=>mod.direct_keys(source)),...['0','1','length','missing','__proto__'].map(key=>[outcome(()=>mod.own(source,key)),outcome(()=>mod.direct_own(source,key))])]);
|
|
143
|
+
for(const factory of[()=>({2:'two',1:'one',z:3}),()=>[1,,undefined],()=>new Map([[1,2]]),()=>new Set([1]),()=>[1,2].values()])compare('assign own properties',mod=>{const source=factory();source.tag=7;const target={first:0};assert.equal(mod.assign(target,null,source,undefined,'😀'),target);return[mod.keys(target),target.tag,target[0],target[1],mod.member(target,'first')];});
|
|
144
|
+
compare('assign effects and partial mutation',mod=>{const trace=[],source={get a(){trace.push('a');return 1;},get b(){trace.push('b');throw 'marker';}},target={};let error;try{mod.direct_assign(target,source);}catch(value){error=value;}return[target,trace,error];});
|
|
145
|
+
compare('own property key hook',mod=>{const trace=[],key={[Symbol.toPrimitive](hint){trace.push(hint);return 'x';}};return[mod.own({x:1},key),trace];});
|
|
146
|
+
compare('frozen target',mod=>outcome(()=>mod.assign(Object.freeze({x:1}),{x:2})));
|
|
147
|
+
compare('own proto assignment',mod=>{const source=Object.create(null);source.__proto__={inherited:7};const target={};mod.assign(target,source);return[Object.getPrototypeOf(target).inherited,Object.hasOwn(target,'__proto__')];});
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
const emptyBindings = `
|
|
151
|
+
for(const value of[undefined,null,false,true,-0,NaN,Infinity,Number.MIN_VALUE,'中😀\\ud800'])for(const name of['parallel-value','sequential-value','capture-value'])compare(name,mod=>named(mod,name,value));
|
|
152
|
+
compare('nil default',mod=>mod.default_value());
|
|
153
|
+
for(const n of[0,1,8,32])compare('binding loop',mod=>mod.loop_value(n));
|
|
154
|
+
compare('escaped cells',mod=>{const a=mod.escape_value(),b=mod.escape_value();return[a(null),a(-0),a(null),b(null),a(NaN),a(null),b(7),b(null)];});
|
|
155
|
+
compare('initializer effects',mod=>{const trace={};return[mod.effect_value(trace),trace];});
|
|
156
|
+
`;
|
|
157
|
+
|
|
158
|
+
const control = `
|
|
159
|
+
const values=[null,false,true,undefined,0,-0,NaN,Infinity,-Infinity,Number.MIN_VALUE,42.5,'','中😀\\ud800',{},[]];
|
|
160
|
+
for(const value of values)for(const name of['identity','truth','invert','once','optional-result','unless-result','recurse'])compare(name,mod=>named(mod,name,value));
|
|
161
|
+
for(const a of values)for(const b of values)for(const name of['both','either','parallel','sequential','effects','clauses','call-choose'])compare(name,mod=>named(mod,name,a,b));
|
|
162
|
+
for(const condition of values)compare('choose',mod=>mod.choose(condition,-0,'no'));
|
|
163
|
+
for(const name of['unicode','negative-zero','finite-number','undefined-result','empty-and','empty-or'])compare(name,mod=>named(mod,name));
|
|
164
|
+
`;
|
|
165
|
+
|
|
166
|
+
const variadic = `
|
|
167
|
+
for(const args of[[],[undefined],[null],[false],[1],[1,undefined],[1,null,2,false,undefined],[-0,NaN,Infinity,-Infinity,Number.MIN_VALUE]])for(const name of['mixed','optional-one','pack'])compare(name,mod=>named(mod,name,...args));
|
|
168
|
+
compare('source and rest identity',mod=>[mod.source_calls(),mod.fresh_rest(),mod.call_none(mod.mixed_value()),mod.call_three(mod.mixed_value(),1,undefined,2)]);
|
|
169
|
+
compare('shared capture',mod=>{const fn=mod.make_capture(1,2);return[undefined,null,2,false].map(value=>mod.call_capture(fn,value,1));});
|
|
170
|
+
compare('rest snapshots',mod=>{const items=[1];return[mod.rest_snapshots(items),items];});
|
|
171
|
+
compare('callee capture',mod=>mod.apply_callee_order([]));
|
|
172
|
+
for(const input of[()=>Array(4),()=>'A😀\\ud800Z',()=>new Set([1,2]),()=>new Map([[1,2]]),()=>[1,2].values()])compare('spread iterable',mod=>mod.apply_values(mod.pack_value(),input()));
|
|
173
|
+
for(const value of[null,undefined,false,true,1,{}])compare('spread failure',mod=>outcome(()=>mod.apply_values(mod.pack_value(),value)));
|
|
174
|
+
compare('partially consumed iterator',mod=>{const iterator=mod.values_iterator([1,2]);assert.equal(mod.iterator_done(iterator),false);const out=mod.apply_values(mod.pack_value(),iterator);assert.equal(mod.iterator_done(iterator),true);return out;});
|
|
175
|
+
compare('noncallable consumes iterable',mod=>{const iterator=mod.values_iterator([1,2]);const out=outcome(()=>mod.apply_values(false,iterator));return[out,mod.iterator_done(iterator)];});
|
|
176
|
+
compare('earlier spread failure',mod=>{const marker=[false];return[outcome(()=>mod.first_error(false,marker)),marker];});
|
|
177
|
+
`;
|
|
178
|
+
|
|
179
|
+
const exceptions = `
|
|
180
|
+
for(const value of[undefined,null,false,true,-0,NaN,Infinity,-Infinity,Number.MIN_VALUE,'中😀\\ud800',{},[]])compare('source throw identity',mod=>{assert.equal(mod.caught(value),value);assert.equal(mod.indirect(value),value);assert.equal(mod.across(24,value),value);assert.equal(mod.call_handler(mod.handler_closure(value)),value);const trace=[];assert.equal(mod.normal(value,trace),value);const nested=[];assert.equal(mod.nested(value,nested),value);const shadow=mod.shadow(value);assert.equal(shadow[0],value);return[trace,nested,shadow[1]];});
|
|
181
|
+
compare('finally replacement',mod=>{const first={},second={},trace=[];let out;try{mod.replaced(first,second,trace);}catch(error){assert.equal(error,second);out=true;}assert.equal(trace[0],first);return[out,trace.slice(1),mod.handler_throw(first,second)===second];});
|
|
182
|
+
for(let kind=0;kind<4;kind++)for(const message of[undefined,'','中😀\\ud800'])compare('Error constructors',mod=>{const marker={},error=mod.make_error(kind,message,{cause:marker});assert.equal(error.cause,marker);return[mod.error_summary(error),Object.keys(error),error instanceof [Error,TypeError,RangeError,SyntaxError][kind]];});
|
|
183
|
+
`;
|
|
184
|
+
|
|
185
|
+
const catchBindings = `
|
|
186
|
+
for(const value of[[],[1],[1,2,3,4,5],'A😀\\ud800Z',new Set([1,2,3,4])])compare('iterator destructuring',mod=>mod.array(value));
|
|
187
|
+
for(const value of[{}, {left:undefined,right:null}, {left:false,right:3}])compare('object defaults',mod=>[mod.object(value),mod.captured(value),mod.tdz(value)]);
|
|
188
|
+
for(const value of[null,undefined,false,7,{}])compare('invalid iterator',mod=>mod.invalid(value));
|
|
189
|
+
compare('protocol failure',mod=>mod.protocol());
|
|
190
|
+
`;
|
|
191
|
+
|
|
192
|
+
const symbols = `
|
|
193
|
+
compare('symbol identities and protocols',mod=>[mod.identities(),mod.exercise()]);
|
|
194
|
+
for(const args of[[],[undefined],[null],[''],['中😀\\ud800'],[7]])compare('unique symbols',mod=>{const a=mod.create(...args),b=mod.create(...args);return[mod.equal(a,a),mod.equal(a,b),mod.description(a),mod.label(a),mod.text(a),mod.key(a)];});
|
|
195
|
+
for(const name of['','shared','中😀\\ud800'])compare('registered symbols',mod=>{const a=mod.registered(name),b=mod.registered(name);return[mod.equal(a,b),mod.key(a),mod.description(a)];});
|
|
196
|
+
compare('well known symbols',mod=>[mod.iterator()===Symbol.iterator,mod.primitive()===Symbol.toPrimitive]);
|
|
197
|
+
compare('symbol property identity',mod=>{const key=mod.create('x'),a={},b={};mod.write(a,key,7);mod.assign(b,a);assert.equal(mod.symbols(b)[0],key);return[mod.own(a,key),mod.member(b,key),mod.keys(a),mod.json(a)];});
|
|
198
|
+
`;
|
|
199
|
+
|
|
200
|
+
const collections = `
|
|
201
|
+
for(const source of[[],[[1,'a'],[2,'b'],[1,'changed']]])compare('Map constructor and iterators',mod=>{const map=mod.from_map(source),alias=mod.set_value(map,3,'c');assert.equal(alias,map);return[mod.size(map),mod.lookup(map,1),mod.has(map,3),Array.from(mod.entries(map)),Array.from(mod.keys(map)),Array.from(mod.values(map)),mod.lookup_none(map)];});
|
|
202
|
+
for(const source of[[],[1,2,2,NaN,-0,0],'A😀'])compare('Set constructor and iterators',mod=>{const set=mod.from_set(source);assert.equal(mod.add_value(set,7),set);return[mod.size(set),mod.has(set,7),Array.from(mod.entries(set)),Array.from(mod.keys(set)),Array.from(mod.values(set)),mod.delete_value(set,7),mod.delete_value(set,7),mod.clear(set),mod.size(set)];});
|
|
203
|
+
for(const set of[false,true])for(let mode=0;mode<4;mode++)compare('live forEach mutation',mod=>mod.for_each_mutate(set,mode));
|
|
204
|
+
for(const set of[false,true])compare('forEach capture and reentry',mod=>{const items=set?mod.from_set([1,2]):mod.from_map([[1,'a'],[2,'b']]),trace=[false],log=[];mod.visit(items,log);const reentrant=mod.for_each_reentrant(items);const captured=mod.for_each_builtin_capture(items,[],trace);return[log,reentrant,captured,trace];});
|
|
205
|
+
for(const set of[false,true])compare('own methods and effects',mod=>{const items=set?mod.empty_set():mod.empty_map(),trace=[false];const result=mod.for_each_own_capture(items,trace);return[result,trace];});
|
|
206
|
+
for(const set of[false,true])for(const bad of[null,undefined,false,true])compare('empty callback validation',mod=>outcome(()=>mod.for_each_with(set?mod.empty_set():mod.empty_map(),bad)));
|
|
207
|
+
for(const count of[0,1,8,32,128])for(const name of['map-loop','set-loop'])compare(name,mod=>Array.from(named(mod,name,count)));
|
|
208
|
+
compare('collection own properties',mod=>{const map=mod.raw_map(),set=mod.raw_set();mod.write(map,'tag',7);mod.write(set,'tag',9);return[mod.own(map,'tag'),mod.own(map,'size'),mod.own_keys(map),mod.read_value(map,'tag'),mod.read_value(set,'tag'),mod.assoc(map,'other',11)];});
|
|
209
|
+
`;
|
|
210
|
+
|
|
211
|
+
const objects = `
|
|
212
|
+
compare('ordinary construction',mod=>[mod.make(-0,NaN),mod.duplicate(1,2),mod.computed('😀',7),mod.empty()]);
|
|
213
|
+
compare('own order and prototypes',mod=>{const parent={inherited:7},object=mod.inherit(parent,9);assert.equal(mod.proto(object),parent);const nullProto=mod.null_proto();assert.equal(Object.getPrototypeOf(nullProto),null);const data=mod.proto_data(7);return[mod.read_value(object,'inherited'),mod.has(object,'inherited'),mod.keys(object),mod.has(data,'__proto__'),mod.read_value(data,'__proto__')];});
|
|
214
|
+
compare('copy and exact getters',mod=>{const object=mod.make(undefined,null),copy=mod.assoc(object,'extra',7);return[object,copy,mod.nth_value('x',object),mod.default_value(object,'absent',-0),mod.default_order(object,'x'),mod.size(object)];});
|
|
215
|
+
compare('object evaluation order',mod=>{const object={old:1},key='tag',copy=mod.assoc_order(object,key),other={};assert.equal(mod.write_order(object,other),other);assert.equal(object.saved,other);return[copy,object.old,mod.read_value(copy,key)];});
|
|
216
|
+
compare('cycle and mutation',mod=>{const object=mod.self_cycle(-0);assert.equal(object.self,object);assert.equal(mod.write(object,'tag',7),7);return[object.v,mod.keys(object),mod.has(object,'tag')];});
|
|
217
|
+
for(const count of[0,1,8,32,128])compare('object growth',mod=>{const object=mod.grow_loop(count);return[Object.keys(object),Object.values(object)];});
|
|
218
|
+
for(const object of[null,undefined])compare('member first error',mod=>outcome(()=>mod.fault(object,'x')));
|
|
219
|
+
`;
|
|
220
|
+
|
|
221
|
+
const moduleBindings = `
|
|
222
|
+
compare('initializers and live exports',mod=>{assert(Object.is(mod.negative_zero,-0));assert.equal(mod.state.self,mod.state);assert.equal(mod.read_state(),mod.state);assert.equal(mod.identity_value(),mod.identity);const out=[mod.initialization_log.slice(),mod.first,mod.second,mod.counter,mod.unset,mod.missing];for(let i=0;i<8;i++)out.push(mod.tick());mod.write_counter(9);out.push(mod.counter,mod.read_counter(),mod.local_counter(3),mod.emitted_alias(99));const closure=mod.captured_global();out.push(closure(2),closure(3),mod.read_counter());for(let i=0;i<96;i++)mod.allocate();assert.equal(mod.read_state(),mod.state);out.push(mod.state.values.slice(),mod.state.label);return out;});
|
|
223
|
+
compare('dynamic export reassignment',mod=>{const first=mod.current,initial=mod.call_current(-0,NaN,true);mod.set_current(mod.identity);assert.equal(mod.current,mod.identity);assert.notEqual(mod.current,first);return[initial,mod.call_current(-0)];});
|
|
224
|
+
`;
|
|
225
|
+
|
|
226
|
+
const project = `
|
|
227
|
+
compare('linked defaults namespaces and live bindings',mod=>{assert.equal(mod.api.history,mod.history);assert.equal(mod.api.identity,mod.identity);assert.equal(mod.initial.self,mod.initial);const initial=[mod.counter,mod.current(),mod.read(),mod.history.slice(),mod.order.slice(),mod.alias(99)];for(const delta of[4,-0,-1,2]){mod.increment(delta);assert.equal(mod.counter,mod.current());}const snapshot=mod.snapshot();assert.equal(snapshot.extra,7);assert.equal(snapshot.history,mod.history);const names=mod.names();const denied=outcome(()=>mod.forbidden());return[initial,mod.counter,mod.history.slice(),names,denied.error?.name,mod.initial.values,mod.initial.label];});
|
|
228
|
+
`;
|
|
229
|
+
|
|
230
|
+
const builtin = `
|
|
231
|
+
const values=[undefined,null,false,true,0,-0,NaN,Infinity,-Infinity,Number.MIN_VALUE,Number.MAX_VALUE,'',' ','12','-0','x','中😀\\ud800',[],{},[1]];
|
|
232
|
+
for(const input of values)for(const name of['number-call','string-call','boolean-call','finite-call','nan-call','integer-call','safe-call','array-call','coercive-finite','coercive-nan','math-round-call','math-floor-call','math-ceil-call','math-trunc-call'])compare(name,mod=>named(mod,name,input));
|
|
233
|
+
for(const name of['number-empty','string-empty','boolean-empty','same-number','same-finite','math-empty','same-round','object-same-empty','same-object-is','freeze-empty','frozen-empty','same-freeze'])compare(name,mod=>named(mod,name));
|
|
234
|
+
for(const input of values)compare('apply and held builtins',mod=>[mod.number_apply([input]),mod.invoke_one(mod.held_number(),input)]);
|
|
235
|
+
compare('extra argument effects',mod=>{const trace={};return[mod.number_extra('12',trace),trace];});
|
|
236
|
+
compare('callback firstclass',mod=>[mod.number_map(['1','2','x']),mod.finite_map([1,NaN,'2'])]);
|
|
237
|
+
for(const left of values)for(const right of values)compare('Object.is exact',mod=>[mod.object_same(left,right),mod.object_same_alias(left,right)]);
|
|
238
|
+
for(const primitive of[undefined,null,false,1,'x'])compare('primitive integrity',mod=>[mod.freeze_call(primitive),mod.frozen_call(primitive)]);
|
|
239
|
+
compare('frozen source object',mod=>{const object={tag:1};assert.equal(mod.freeze_alias(object),object);return[mod.frozen_call(object),outcome(()=>mod.integrity_write(object)).error?.name];});
|
|
240
|
+
`;
|
|
241
|
+
|
|
242
|
+
const typeofFixture = `
|
|
243
|
+
const values=[undefined,null,false,true,0,-0,NaN,Infinity,-Infinity,Number.MIN_VALUE,Number.MAX_VALUE,'','中😀\\ud800',{},[],()=>1];
|
|
244
|
+
for(const value of values)compare('typeof and captured member',mod=>[mod.type_value(value),mod.type_underscore(value),mod.type_member({item:value}),mod.type_deep({child:{item:value}}),mod.type_shadow(value),mod.invoke(mod.capture(value))]);
|
|
245
|
+
for(const value of values)compare('existing predicates and imported paths',mod=>[mod.type_intrinsic(value),mod.is_nil(value),mod.is_undefined(value),mod.is_null(value),mod.is_nullish(value),mod.type_index([{item:value}]),mod.type_index_key([{'a.b':value}]),mod.invoke(mod.capture_index([{item:value}]))]);
|
|
246
|
+
for(const value of[undefined,null,false,-0,NaN,'中😀\\ud800'])compare('module typeof writes',mod=>[mod.write_global(value),mod.type_global()]);
|
|
247
|
+
compare('missing member',mod=>mod.type_member({}));
|
|
248
|
+
for(const value of[null,undefined])compare('member error',mod=>outcome(()=>mod.type_member(value)).error?.name);
|
|
249
|
+
let state=0x294f61d7;const next=()=>state=(Math.imul(state,1664525)+1013904223)>>>0,bits=new DataView(new ArrayBuffer(8));
|
|
250
|
+
for(let i=0;i<1024;i++){bits.setUint32(0,next());bits.setUint32(4,next());const value=bits.getFloat64(0);compare('IEEE type identity',mod=>[mod.type_value(value),Object.is(mod.make_box(value).item,value)]);}
|
|
251
|
+
`;
|
|
252
|
+
|
|
253
|
+
const regexp = `
|
|
254
|
+
for(const value of['0','-0','+1','.5','1.','1.e2','1e-2','+1e','0x10','x','','1\\n',null,true,65,NaN,Infinity])compare('numeric regexp',mod=>mod.numeric(value));
|
|
255
|
+
for(const value of['','a','aa','bc','abc','ab','1','a\\nb','a\\nb\\nc','wordx','words','\\0','😀','\\ud800','zzab12'])for(const name of['groups','nullable','unicode'])compare(name,mod=>{const match=named(mod,name,value);return match===null?null:{values:Array.from(match),index:mod.meta(match,'index'),input:mod.meta(match,'input'),groups:mod.meta(match,'groups'),keys:mod.keys(match)};});
|
|
256
|
+
for(const text of['b','a\\nb','ab','b\\n','a\\nb\\nc'])compare('multiline',mod=>mod.line(text));
|
|
257
|
+
compare('regexp call capture',mod=>{const trace={};return[mod.capture('12',trace),trace];});
|
|
258
|
+
`;
|
|
259
|
+
|
|
260
|
+
const replacement = `
|
|
261
|
+
for(const text of['','a','aa','aba','中😀a\\ud800','a b ','a\\t'])for(const search of['','a','b','中','😀',undefined,null,false,1])for(const replacement of['','$&',"$\x60","$'",'$$','$1','$01','$12',undefined,null,false,-0])compare('replace',mod=>mod.replace_value(text,search,replacement));
|
|
262
|
+
for(const text of['','a','b','ab','xaba','中😀a'])for(const template of['$1/$2','$01/$02','$12','$99','$&',"$\x60/$'",'$$'])compare('captured replacement',mod=>mod.replace_captures(text,template));
|
|
263
|
+
for(const text of['','x','x ','x\\t','x \\t','中😀\\ud800 '])compare('regexp replacement callback',mod=>[mod.trim_comment(text),mod.replace_callback(text)]);
|
|
264
|
+
`;
|
|
265
|
+
|
|
266
|
+
const arrayText = `
|
|
267
|
+
const shared=[1,null,'中😀\\ud800'];
|
|
268
|
+
for(const values of[[],Array(4),[null,undefined,false,true,-0,.5,NaN,Infinity,-Infinity,Number.MIN_VALUE,'中😀\\ud800'],[shared,shared]])for(const separator of[undefined,null,false,-0,.5,'',',','😀\\ud800'])compare('join primitives and holes',mod=>mod.join_value(values,separator));
|
|
269
|
+
for(const value of[undefined,null,false,-0,NaN,Number.MIN_VALUE,'中😀\\ud800'])for(const factory of['custom-value','fallback-value'])compare('join conversion hooks',mod=>{const trace={},out=mod.default_value([named(mod,factory,trace,value)]);return[out,trace];});
|
|
270
|
+
compare('separator length snapshot',mod=>{const items=['x'],trace={};return[mod.join_value(items,mod.growing_separator(items,trace)),items,trace];});
|
|
271
|
+
compare('empty separator conversion',mod=>{const items=[],trace={};return[mod.join_value(items,mod.growing_separator(items,trace)),items,trace];});
|
|
272
|
+
compare('live values',mod=>{const items=[null,'old'];items[0]=mod.live_element(items);return[mod.join_value(items,'|'),items[1]];});
|
|
273
|
+
compare('shrinking values',mod=>{const items=[null,null,null];items[0]=mod.shrinking_element(items);return[mod.join_value(items,'|'),items.length];});
|
|
274
|
+
compare('custom result identity',mod=>{const value={},trace={},items=[];assert.equal(mod.text_order(items,value,trace),value);assert.equal(mod.text_value(mod.own_join(items,value)),value);return trace;});
|
|
275
|
+
compare('reentrant cycle recovery',mod=>{const items=[null],trace={};items[0]=mod.reentrant_element(items,trace);const error=outcome(()=>mod.default_value(items));items.length=0;return[error.error?.name,mod.default_value(items)];});
|
|
276
|
+
compare('selected cyclic join error',mod=>{const items=[1];items.push(items,3);let caught;try{mod.join_value(items,':');}catch(error){assert.equal(error.eliscriptDiagnostic?.code,'ELI-RT0009');caught=error.name;}return caught;});
|
|
277
|
+
compare('ignored arguments',mod=>{const trace={};return[mod.extra_value([1,2],':',trace),trace];});
|
|
278
|
+
`;
|
|
279
|
+
|
|
280
|
+
const functionProperties = `
|
|
281
|
+
for(let mode=0;mode<6;mode++)for(const key of reflectionKeys)compare('function own reflection',mod=>mod.reflection_snapshot(mode,key));
|
|
282
|
+
for(let mode=0;mode<6;mode++)compare('function key lists and prototype',mod=>mod.reflection_shape(mode));
|
|
283
|
+
for(let mode=0;mode<3;mode++)compare('function accessor lookup and callee order',mod=>mod.reflection_effects(mode));
|
|
284
|
+
for(let iteration=0;iteration<4;iteration++)compare('canonical functions and call effects',mod=>[mod.cached(),mod.call_number('12'),mod.call_string(2),mod.call_finite(2),mod.static_finite(2),mod.call_symbol(),mod.call_error(),mod.effects()]);
|
|
285
|
+
`;
|
|
286
|
+
|
|
287
|
+
const strings = `
|
|
288
|
+
const texts=['','x','a\\0b','中😀\\ud800x\\udfff','ababa','\\ud83d\\ude00','\\ud83dx\\ude00'];
|
|
289
|
+
const positions=[null,false,true,undefined,NaN,Infinity,-Infinity,0,-0,.5,-.5,1,-1,3.5,-3.5,Number.MIN_VALUE,-Number.MIN_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,2**32-1,2**32];
|
|
290
|
+
for(const text of texts){
|
|
291
|
+
for(const name of['size','identity','value','trim','trim-start','trim-end','well-formed','repair','scan','concat-empty','char-empty','at-empty','slice-empty','substring-empty','substr-empty','find-empty','repeat-empty'])compare(name,mod=>named(mod,name,text));
|
|
292
|
+
for(const key of[0,-0,1,2,99,-1,.5,NaN,Infinity,'0','1','01','','length'])for(const name of['read-value','default-value'])compare(name,mod=>name==='default-value'?mod.default_value(text,key,'fallback'):mod.read_value(text,key));
|
|
293
|
+
for(const key of['0','1','length'])compare('nth-value',mod=>mod.nth_value(key,text));
|
|
294
|
+
for(const position of positions)for(const name of['at','char-at','char-code','code-point'])compare(name,mod=>named(mod,name,text,position));
|
|
295
|
+
for(const start of positions)for(const end of positions)for(const name of['slice','substring','substr'])compare(name,mod=>named(mod,name,text,start,end));
|
|
296
|
+
for(const search of['','x','a','aba','\\0','😀','\\ud800',null,false,true,undefined,0,-0,-1,NaN,Infinity,-Infinity])for(const position of positions)for(const name of['find','last','includes','starts','ends'])compare(name,mod=>named(mod,name,text,search,position));
|
|
297
|
+
for(const count of[null,false,true,undefined,NaN,-0,-.5,0,.5,1,3.5])compare('repeat',mod=>mod.repeat(text,count));
|
|
298
|
+
for(const value of[null,false,true,undefined,0,-0,2**32-1,-1,NaN,Infinity,-Infinity,'中😀'])compare('variadic concat',mod=>mod.concat(text,value,'!',value));
|
|
299
|
+
compare('ignored string arguments',mod=>{const trace={};return[mod.ignored(text,trace),trace,mod.ignored_identity(text,{})];});
|
|
300
|
+
compare('constructor and receiver capture',mod=>[mod.capture(text,1,'xy'),mod.concat_capture(text,1,2),mod.default_order(text,0)]);
|
|
301
|
+
}
|
|
302
|
+
for(const values of[[0,65,65535],[-0,55296,56320],[128512,128513,65],[NaN,Infinity,-Infinity],['65',null,true]]){
|
|
303
|
+
compare('fromCharCode',mod=>mod.from_units(...values));compare('fromCodePoint',mod=>outcome(()=>mod.from_points(...values)));
|
|
304
|
+
}
|
|
305
|
+
for(const value of[-1,-0,0,65,55296,65535,65536,128512,1114111,1114112,1.5,NaN,Infinity])compare('single character constructors',mod=>[mod.from_unit(value),mod.global_unit(value),outcome(()=>mod.from_point(value)),outcome(()=>mod.global_point(value)),mod.constructor_capture(value)]);
|
|
306
|
+
compare('empty character constructors',mod=>[mod.empty_units(),mod.empty_points()]);
|
|
307
|
+
compare('constructor effects',mod=>{const trace={};return[mod.constructor_effects(65,trace),trace];});
|
|
308
|
+
compare('format split callback',mod=>[mod.format_symbol('HELLO-WORLD',255),mod.split_fields('a,b; c d'),mod.replace_callback('a中a')]);
|
|
309
|
+
let seed=0x84fbd9a;const next=()=>{seed^=seed<<13;seed^=seed>>>17;seed^=seed<<5;return seed>>>0;},bits=new DataView(new ArrayBuffer(8));
|
|
310
|
+
for(let i=0;i<1024;i++){const units=Array.from({length:next()%64},()=>next()%65536),text=String.fromCharCode(...units),needle=i%3?text.slice(next()%(text.length+1),next()%(text.length+1)):String.fromCharCode(next()%65536);bits.setUint32(0,next(),true);bits.setUint32(4,next(),true);const position=bits.getFloat64(0,true);for(const name of['at','char-at','char-code','code-point'])compare('seeded '+name,mod=>named(mod,name,text,position));for(const name of['find','last','includes','starts','ends'])compare('seeded '+name,mod=>named(mod,name,text,needle,position));for(const name of['slice','substring','substr']){const end=(next()%65)-32;compare('seeded '+name,mod=>named(mod,name,text,position,end));}for(const name of['well-formed','repair'])compare('seeded '+name,mod=>named(mod,name,text));}
|
|
311
|
+
`;
|
|
312
|
+
|
|
313
|
+
const callables = `
|
|
314
|
+
compare('escaping nested recursive closures',mod=>[mod.make_adder(4)(5),mod.nested(4)(5)(6),mod.recursive()(24),mod.outer_write(4)(),mod.shadow(4)()]);
|
|
315
|
+
compare('shared sibling cells',mod=>{const pair=mod.make_pair(4),values=[];for(let i=0;i<32;i++){values.push(pair[0](),pair[1]());}assert.equal(mod.from_slot(pair),37);return[values,mod.capture_each(4).map(fn=>fn()),mod.named_same(),mod.fresh_same(),mod.repeated_same()];});
|
|
316
|
+
compare('function identity',mod=>{assert.equal(mod.named_value(),mod.named_value());assert.notEqual(mod.fresh_function(),mod.fresh_function());return[mod.apply_one(mod.named_value(),4),mod.from_slot(mod.make_pair(4)),mod.callee_order()];});
|
|
317
|
+
compare('callee and argument order',mod=>{const marker=[false];const out=outcome(()=>mod.invoke_order(false,marker));return[out.error?.name,marker,mod.apply_extra(mod.named_value(),marker),marker.slice()];});
|
|
318
|
+
compare('parallel and sequential captures',mod=>{const functions=mod.sequential_captures(4);return[mod.parallel_capture(4)(),functions.map(fn=>fn()),mod.hygienic_capture(1,2,3,4,5)(),mod.captured_arguments(4)];});
|
|
319
|
+
compare('twelve arguments and discarded extras',mod=>{const marker=[false];return[mod.many(1,2,3,4,5,6,7,8,9,10,11,12),mod.many_extra(mod.many_value(),marker),marker,mod.many_extra(mod.many_lambda(),marker)];});
|
|
320
|
+
compare('funcall exact values',mod=>{const marker=[false];return[mod.funcall_one(mod.named_value(),-0),mod.funcall_order(mod.ordered_values,marker),marker];});
|
|
321
|
+
`;
|
|
322
|
+
|
|
323
|
+
const jsCons = `
|
|
324
|
+
for(const tail of[null,undefined,[],[undefined,,false],'A😀\\ud800Z',new Set([1,2]),new Map([[1,2]]),false,true,1,{}])compare('js-cons spread',mod=>[mod.safe('head',tail),mod.raw_nullish(tail)]);
|
|
325
|
+
for(let mode=0;mode<3;mode++)compare('js-cons operand effects',mod=>mod.effects(mode));
|
|
326
|
+
for(let mode=0;mode<8;mode++)compare('js-cons protocol',mod=>mod.protocol(mode));
|
|
327
|
+
compare('js-cons own dense indices',mod=>{const out=mod.prepend('head',[,undefined]);return[out,mod.own(out,'0'),mod.own(out,'1'),mod.own(out,'2'),mod.recover()];});
|
|
328
|
+
`;
|
|
329
|
+
|
|
330
|
+
const persistentVector = `
|
|
331
|
+
for(const count of[0,1,31,32,33,63,64,65,1023,1024,1025,1056,1057])compare('full persistent Vector boundaries '+count,mod=>mod.vector_case(count));
|
|
332
|
+
`;
|
|
333
|
+
|
|
334
|
+
function section(source,start,end){
|
|
335
|
+
const first=source.indexOf(start),last=source.indexOf(end,first+start.length);
|
|
336
|
+
if(first<0||last<0)throw new TypeError('original managed fixture source boundary changed: '+start);
|
|
337
|
+
return source.slice(first,last);
|
|
338
|
+
}
|
|
339
|
+
// Read the cooked value without importing or evaluating the original suite.
|
|
340
|
+
// Bindings are exact, explicitly transported source expressions, not JS code.
|
|
341
|
+
export function readOriginalManagedStaticTemplate(source,name,bindings=new Map()){
|
|
342
|
+
if(!/^[$A-Z_a-z][$\w]*$/.test(name))throw new TypeError('invalid original managed template name');
|
|
343
|
+
const declaration=new RegExp('\\bconst\\s+'+name.replaceAll('$','\\$')+'\\s*=\\s*`').exec(source);
|
|
344
|
+
const failure=message=>new TypeError('original managed template '+name+': '+message);
|
|
345
|
+
if(!declaration)throw failure('declaration changed');
|
|
346
|
+
let at=declaration.index+declaration[0].length,value='';
|
|
347
|
+
while(at<source.length){
|
|
348
|
+
const unit=source[at++];
|
|
349
|
+
if(unit==='`'){
|
|
350
|
+
while(at<source.length&&/\s/.test(source[at]))at++;
|
|
351
|
+
if(source[at]!==';')throw failure('closing template must end its declaration');
|
|
352
|
+
return value;
|
|
353
|
+
}
|
|
354
|
+
if(unit==='$'&&source[at]==='{'){
|
|
355
|
+
at++;let matched=false;
|
|
356
|
+
for(const[expression,replacement]of bindings){
|
|
357
|
+
if(typeof expression!=='string'||typeof replacement!=='string')throw failure('invalid explicit interpolation');
|
|
358
|
+
if(source.startsWith(expression+'}',at)){
|
|
359
|
+
value+=replacement;at+=expression.length+1;matched=true;break;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if(!matched)throw failure('unbound interpolation');
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
// Template raw CR/CRLF is cooked as LF, including unescaped source text.
|
|
366
|
+
if(unit==='\r'){if(source[at]==='\n')at++;value+='\n';continue;}
|
|
367
|
+
if(unit!=='\\'){value+=unit;continue;}
|
|
368
|
+
if(at===source.length)throw failure('unterminated escape');
|
|
369
|
+
const escape=source[at++];
|
|
370
|
+
if(escape==='\n'||escape==='\u2028'||escape==='\u2029')continue;
|
|
371
|
+
if(escape==='\r'){if(source[at]==='\n')at++;continue;}
|
|
372
|
+
if(/[0-9]/.test(escape)){
|
|
373
|
+
if(escape!=='0'||/[0-9]/.test(source[at]??''))throw failure('invalid decimal escape');
|
|
374
|
+
value+='\0';continue;
|
|
375
|
+
}
|
|
376
|
+
if(escape==='x'||escape==='u'){
|
|
377
|
+
if(escape==='u'&&source[at]==='{'){
|
|
378
|
+
const end=source.indexOf('}',++at),hex=end<0?'':source.slice(at,end);
|
|
379
|
+
if(!/^[0-9a-fA-F]+$/.test(hex))throw failure('invalid Unicode escape');
|
|
380
|
+
const point=parseInt(hex,16);
|
|
381
|
+
if(point>0x10ffff)throw failure('invalid Unicode code point');
|
|
382
|
+
value+=String.fromCodePoint(point);at=end+1;continue;
|
|
383
|
+
}
|
|
384
|
+
const count=escape==='x'?2:4,hex=source.slice(at,at+count);
|
|
385
|
+
if(!new RegExp('^[0-9a-fA-F]{'+count+'}$').test(hex))throw failure('invalid hexadecimal escape');
|
|
386
|
+
value+=String.fromCharCode(parseInt(hex,16));at+=count;continue;
|
|
387
|
+
}
|
|
388
|
+
const simple={n:'\n',r:'\r',t:'\t',b:'\b',f:'\f',v:'\v'};
|
|
389
|
+
// NonEscapeCharacter (including escaped $, quotes and backticks) retains
|
|
390
|
+
// its UTF16 unit. In particular, \${ is static text, not interpolation.
|
|
391
|
+
value+=Object.hasOwn(simple,escape)?simple[escape]:escape;
|
|
392
|
+
}
|
|
393
|
+
throw failure('unterminated template');
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function reflectionTemplateBindings(source){
|
|
397
|
+
const declaration=/\bconst\s+wellKnownSymbolNames\s*=\s*\[([^\]]*)\]\s*;/.exec(source);
|
|
398
|
+
if(!declaration)throw new TypeError('original managed reflection symbol declaration changed');
|
|
399
|
+
const entries=declaration[1].trim().split(',').map(entry=>entry.trim());
|
|
400
|
+
if(!entries.length||entries.some(entry=>!/^'[A-Za-z]+'$/.test(entry)))
|
|
401
|
+
throw new TypeError('original managed reflection symbols must be static names');
|
|
402
|
+
const names=entries.map(entry=>entry.slice(1,-1));
|
|
403
|
+
const expression='wellKnownSymbolNames.map(name=>`(js* "Symbol.${name}")`).join(\' \')';
|
|
404
|
+
return new Map([[expression,names.map(name=>'(js* "Symbol.'+name+'")').join(' ')]]);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function mathBody(source){
|
|
408
|
+
// The binary16/precise-sum models and every seeded sample count come from
|
|
409
|
+
// the actual original suite, not from the target implementation.
|
|
410
|
+
return section(source,'const unaryNames =','beforeAll(')+
|
|
411
|
+
section(source,'function adjacent(','function checkPressure(')+`
|
|
412
|
+
for(const name of['namespace-summary','namespace-tag-description','lexical-shadow','namespace-mutation','namespace-extension','namespace-constant-errors'])compare(name,mod=>named(mod,name));
|
|
413
|
+
for(const key of constants)compare('Math constants',mod=>mod.constant_description(key));
|
|
414
|
+
for(const key of[...Object.keys(methodLengths),'f16round','sumPrecise'])compare('Math methods',mod=>mod.method_description(key));
|
|
415
|
+
for(const dynamic of[false,true])for(const abrupt of[false,true])compare('Math callee capture',mod=>mod.callee_order(dynamic,abrupt));
|
|
416
|
+
for(const abrupt of[false,true])compare('Math computed key order',mod=>mod.key_order(abrupt));
|
|
417
|
+
for(const name of unaryNames)for(const input of primitives)compare(name,mod=>[named(mod,'direct-'+name,input),mod.math_invoke(name,input)]);
|
|
418
|
+
for(let bit=0;bit<32;bit++)for(const input of[2**bit,2**bit-1,2**bit+1,-(2**bit)])compare('clz32 bit boundary',mod=>mod.direct_clz32(input));
|
|
419
|
+
const pairs=[[0,-0],[NaN,7],[Infinity,-Infinity],[-1,5],[0xffffffff,5],[0x80000000,2],[0x7fffffff,0x7fffffff],[0xffffffff,0xffffffff],[2**53-1,-(2**32)-1],['0xffffffff','-1'],[undefined,true],[null,'3']];
|
|
420
|
+
let state=0x1c7a6e39;const next=()=>state=(Math.imul(state,1664525)+1013904223)>>>0;
|
|
421
|
+
for(let index=0;index<64;index++)pairs.push([next(),next()]);
|
|
422
|
+
for(const[left,right]of pairs)compare('Math imul',mod=>[mod.direct_imul(left,right),mod.math_invoke('imul',left,right)]);
|
|
423
|
+
for(const name of[...unaryNames,'imul','f16round']){
|
|
424
|
+
for(const args of[[],[undefined],[null],[-0,99,'ignored']])compare(name+' arity',mod=>mod.math_invoke(name,...args));
|
|
425
|
+
for(const call of['conversion-order','conversion-hint','primitive-rejections'])compare(call,mod=>named(mod,call,name));
|
|
426
|
+
for(let mode=0;mode<3;mode++)compare('conversion abrupt',mod=>mod.conversion_abrupt(name,mode));
|
|
427
|
+
}
|
|
428
|
+
for(const name of['min','max']){
|
|
429
|
+
compare('extreme conversion order',mod=>mod.extreme_order(name));
|
|
430
|
+
for(const args of[[],[-0],[0,-0],[-0,0],[NaN,4],[4,NaN],[undefined],[1,9,-7,2]])compare(name,mod=>mod.math_invoke(name,...args));
|
|
431
|
+
}
|
|
432
|
+
for(const input of[...froundBoundaries(),...froundRandom()])compare('fround exact samples',mod=>[mod.direct_fround(input),mod.math_invoke('fround',input),mod.invoke_held(mod.namespace_get('fround'),input)]);
|
|
433
|
+
for(const input of[...f16Boundaries(),...froundRandom().slice(0,48),...primitives]){
|
|
434
|
+
const expected=f16Model(input);assert(Object.is(m.direct_f16round(input),expected));assert(Object.is(m.math_invoke('f16round',input),expected));
|
|
435
|
+
assert(Object.is(m.invoke_held(m.namespace_get('f16round'),input),expected));observations++;
|
|
436
|
+
}
|
|
437
|
+
for(const values of sumSamples()){
|
|
438
|
+
const expected=sumPreciseModel(values);assert(Object.is(m.sum_direct(values),expected));assert(Object.is(m.sum_dynamic(values),expected));
|
|
439
|
+
assert(Object.is(m.invoke_held(m.namespace_get('sumPrecise'),values),expected));observations++;
|
|
440
|
+
}
|
|
441
|
+
for(let mode=0;mode<=29;mode++){assert.deepEqual(m.sum_iterator_case(mode),sumIteratorObservation(mode));observations++;if(runtime){runtime.collect();assert.equal(runtime.stats().frameDepth,0);}}
|
|
442
|
+
compare('sum argument order',mod=>mod.sum_extra_order());compare('sum arraylike rejection',mod=>mod.sum_array_like_rejection());
|
|
443
|
+
compare('state and held values',mod=>{const held=mod.namespace_get('fround');mod.set_namespace_state(-0);assert(Object.is(mod.read_namespace_state(),-0));const out=mod.invoke_held(held,-0);assert(mod.delete_namespace_state());return out;});
|
|
444
|
+
`;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function numberBody(source){return section(source,"const whitespace =",'function scaledDecimal(')+
|
|
448
|
+
section(source,'function scaledDecimal(','test(')+`
|
|
449
|
+
for(const input of[null,false,true,undefined,NaN,Infinity,-Infinity,-0,Number.MIN_VALUE,Number.MAX_VALUE,...tokens])compare('complete Number grammar',mod=>mod.parse(input));
|
|
450
|
+
for(const token of tokens)compare('ECMAScript whitespace',mod=>mod.parse(whitespace+token+whitespace));
|
|
451
|
+
const exponents=new Set([-1075,-1074,-1023,-1022,-53,-52,-1,0,1,52,53,969,970]);
|
|
452
|
+
for(let exponent=-1075;exponent<=970;exponent+=17)exponents.add(exponent);
|
|
453
|
+
for(const exponent of exponents)for(const significand of[1n,(1n<<53n)-1n,(1n<<53n)+1n])for(const delta of[-1n,0n,1n]){const input=binaryDecimal(significand,exponent,delta);compare('exact decimal tie',mod=>[mod.parse(input),mod.parse('-'+input)]);}
|
|
454
|
+
for(const input of['0'.repeat(4096)+'1','1'+'0'.repeat(4096)+'e-4096','0.'+'0'.repeat(4096)+'1e4097','1.'+'0'.repeat(4096)+'1','0x'+'f'.repeat(512),'0b1'+'0'.repeat(1075),'0o'+'7'.repeat(400),'1e'+'0'.repeat(4096)+'2'])compare('long coefficients',mod=>[mod.parse(input),mod.parse(input+'x')]);
|
|
455
|
+
const next=random(0xac3b79d5);
|
|
456
|
+
for(let i=0;i<1024;i++){
|
|
457
|
+
const digits=Array.from({length:1+next()%96},()=>String(next()%10)).join(''),point=next()%(digits.length+1),input=(next()&1?'-':'')+digits.slice(0,point)+'.'+digits.slice(point)+'e'+(next()%1201-600);
|
|
458
|
+
compare('random decimal grammar',mod=>mod.parse(input));
|
|
459
|
+
const radix=[2,8,16][next()%3],prefix=radix===2?'0b':radix===8?'0o':'0x',text=prefix+Array.from({length:1+next()%128},()=>(next()%radix).toString(radix)).join('');
|
|
460
|
+
assert(Object.is(m.parse(text),Number(BigInt(text))));observations++;
|
|
461
|
+
}
|
|
462
|
+
for(const input of[null,false,true,undefined,'','中😀\\ud800',NaN,Infinity,-Infinity,-0,Number.MIN_VALUE,Number.MAX_VALUE,1e-7,1e-6,1e20,1e21,.1,.5,1000000000000000100,2**53-1,2**53,2**53+2])compare('shortest text',mod=>mod.text(input));
|
|
463
|
+
const nextBits=random(0x9f43bb71),bits=new DataView(new ArrayBuffer(8));
|
|
464
|
+
for(let i=0;i<2048;i++){bits.setUint32(0,nextBits(),true);bits.setUint32(4,nextBits(),true);compare('random binary64 text',mod=>mod.text(bits.getFloat64(0,true)));}
|
|
465
|
+
for(const input of[.5,-.5,1e-7,1e-6,1e20,1e21,Number.MIN_VALUE,Number.MAX_VALUE,NaN,Infinity,-Infinity,-0])compare('numeric property key',mod=>mod.named_key(input));
|
|
466
|
+
for(const input of['','1','-1','1.9','-1.9','0x2','0b10',whitespace+'2'+whitespace,'NaN','Infinity','-Infinity','invalid','5e-324'])compare('position conversion',mod=>mod.position(input));
|
|
467
|
+
compare('str argument snapshot',mod=>mod.join('first',-0));
|
|
468
|
+
`;}
|
|
469
|
+
|
|
470
|
+
function jsonBody(source){return section(source,'const valid =','test(')+`
|
|
471
|
+
for(const text of valid)compare('JSON grammar canonical form',mod=>mod.canonical_value(text));
|
|
472
|
+
for(const text of invalid)compare('invalid JSON and effects',mod=>{const trace={};const error=outcome(()=>mod.parse_extra(text,trace));return[error.error?.name,trace];});
|
|
473
|
+
compare('JSON omission and sparse arrays',mod=>{const b=[undefined,NaN,'中😀\\ud800\\0\\n"\\\\',-0];b.length=6;const value={'2':'中😀\\ud800\\0\\n"\\\\',b,a:undefined,nan:NaN,zero:-0};return[mod.stringify_value(value),mod.pretty_value(value,2),mod.select_value(value,['b','nan','b'],'😀abcdefghijk'),mod.stringify_value(undefined),mod.same_parser()];});
|
|
474
|
+
for(const text of['-0','-1e-9999','5e-324','2.2250738585072014e-308','1.7976931348623157e308','1e9999','9007199254740993'])compare('JSON number exactness',mod=>mod.parse_value(text));
|
|
475
|
+
for(const space of['','x','\\ud800','123456789😀','😀abcdefghijk',-0,-Infinity,Infinity,NaN,-2,1.9,12])compare('JSON indentation',mod=>mod.pretty_value({a:1},space));
|
|
476
|
+
let seed=0x69107df3;const next=()=>seed=(Math.imul(seed,1664525)+1013904223)>>>0;
|
|
477
|
+
const strings=['','中😀','\\ud800','\\udc00','\\0\\b\\n','"\\\\/\\u2028','__proto__'];
|
|
478
|
+
const value=depth=>{const choice=next()%(depth?7:5);if(choice===0)return null;if(choice===1)return!!(next()&1);if(choice===2)return strings[next()%strings.length];if(choice<5)return(next()-0x80000000)*10**(next()%601-300);if(choice===5)return Array.from({length:next()%4},()=>value(depth-1));const entries=[];for(let i=next()%4;i>0;i--)entries.push([['a','2','1','__proto__',''][next()%5],value(depth-1)]);return Object.fromEntries(entries);};
|
|
479
|
+
for(let i=0;i<256;i++){const text=JSON.stringify(value(4));compare('seeded JSON tree',mod=>[mod.canonical_value(text),outcome(()=>mod.parse_value(text+'#')).error?.name]);}
|
|
480
|
+
compare('JSON cycles and repeated aliases',mod=>{const shared={a:1},cycle={};cycle.self=cycle;return[mod.stringify_value([shared,shared]),outcome(()=>mod.stringify_value(cycle)).error?.name];});
|
|
481
|
+
compare('JSON proto own descriptor',mod=>{const object=mod.parse_value('{"__proto__":7}');assert(mod.own_value(object,'__proto__'));return[mod.key_value(object,'__proto__'),Object.keys(object)];});
|
|
482
|
+
`;}
|
|
483
|
+
|
|
484
|
+
function primitiveBody(source){return section(source,"const hex=",'const box=')+`
|
|
485
|
+
const inputs=[null,false,true,undefined,0,-0,1,-1,NaN,Infinity,Number.MIN_VALUE,.5,'','0','-0','1.5',' 0x10 ','0b101','0o77','invalid','中😀\\ud800'];
|
|
486
|
+
for(const x of inputs){for(const name of['negate','reciprocal','increment','decrement','signed','unsigned','invert','identity-add','identity-multiply'])compare(name,mod=>named(mod,name,x));for(const y of inputs)for(const name of['add','subtract','multiply','divide','remainder','mask','union','exclusive','shift-left','shift-right','logical-right','product-word','equal','less','less-equal','greater','greater-equal'])compare(name,mod=>named(mod,name,x,y));}
|
|
487
|
+
for(const values of[['1',2,3],[1,2,'3'],[null,false,'x'],['invalid',1,2],['10','2',3],[-0,'0',null],[undefined,1,'x']]){for(const name of['ordered-add','ordered-subtract','comparison-snapshot'])compare(name,mod=>named(mod,name,...values));for(const name of['snapshot','comparison-effects'])compare(name,mod=>named(mod,name,...values.slice(0,2)));}
|
|
488
|
+
for(const name of['identity-add','identity-multiply'])compare('opaque identity',mod=>{const object={};return named(mod,name,object)===object;});
|
|
489
|
+
for(const name of['subtract','multiply','divide','remainder','less','less-equal','greater','greater-equal']){const value=Number(BigInt(hex));assert(Object.is(named(m,name,hex,value),expected[name](hex,value)));observations++;}
|
|
490
|
+
let state=0x57a39b21;const next=()=>{state^=state<<13;state^=state>>>17;state^=state<<5;return state>>>0;},bits=new DataView(new ArrayBuffer(8));
|
|
491
|
+
for(let i=0;i<512;i++){bits.setUint32(0,next(),true);bits.setUint32(4,next(),true);const value=bits.getFloat64(0,true),text=String(value);for(const name of['add','subtract','multiply','remainder','less','greater-equal'])compare(name,mod=>named(mod,name,text,value));}
|
|
492
|
+
for(const n of[0,1,3,-0,NaN,-1,2.5,'3'])for(const seed of[-0,NaN,Infinity,.123,'0.123',hex])compare('closed scalar loop',mod=>mod.scalar_loop(n,seed));
|
|
493
|
+
compare('source hooks and bigint',mod=>{const trace=[],left={valueOf(){trace.push('left');return 5;}},right={valueOf(){trace.push('right');return 2;}};return[mod.subtract(left,right),trace,mod.subtract(5n,2n),mod.negate(5n),mod.shift_left(5n,2n),outcome(()=>mod.subtract(5n,2)).error?.name,outcome(()=>mod.product_word(5n,2n)).error?.name];});
|
|
494
|
+
`;}
|
|
495
|
+
|
|
496
|
+
// Original Bun suites use the original Bun runner. The plugin only replaces
|
|
497
|
+
// their build I/O entry with namespaces of the complete selected compiler
|
|
498
|
+
// product; it never transforms a test body or substitutes an emitter/parser.
|
|
499
|
+
// Explicit frontend rebuilds still use the original build transport with that
|
|
500
|
+
// actual frontend, so its Seed/selfhost checks retain the original algorithms.
|
|
501
|
+
function transportCompilerData(value,seen=new Map()){
|
|
502
|
+
if(value===null||typeof value!=='object')return value;
|
|
503
|
+
if(seen.has(value))return seen.get(value);
|
|
504
|
+
let output;
|
|
505
|
+
if(ArrayBuffer.isView(value)){
|
|
506
|
+
const buffer=transportCompilerData(value.buffer,seen);
|
|
507
|
+
output=value instanceof DataView?new DataView(buffer,value.byteOffset,value.byteLength):
|
|
508
|
+
new value.constructor(buffer,value.byteOffset,value.length);
|
|
509
|
+
seen.set(value,output);return output;
|
|
510
|
+
}
|
|
511
|
+
if(value instanceof ArrayBuffer){output=value.slice(0);seen.set(value,output);return output;}
|
|
512
|
+
if(value instanceof Map){output=new Map();seen.set(value,output);for(const[key,item]of value)output.set(transportCompilerData(key,seen),transportCompilerData(item,seen));return output;}
|
|
513
|
+
if(value instanceof Set){output=new Set();seen.set(value,output);for(const item of value)output.add(transportCompilerData(item,seen));return output;}
|
|
514
|
+
output=Array.isArray(value)?[]:Object.create(Object.getPrototypeOf(value)===null?null:Object.prototype);
|
|
515
|
+
seen.set(value,output);
|
|
516
|
+
for(const key of Reflect.ownKeys(value)){
|
|
517
|
+
const descriptor=Object.getOwnPropertyDescriptor(value,key);
|
|
518
|
+
if(!descriptor)throw new TypeError('compiler result changed during data transport');
|
|
519
|
+
if(!Object.hasOwn(descriptor,'value'))throw new TypeError('compiler data results cannot contain accessors');
|
|
520
|
+
Object.defineProperty(output,key,{...descriptor,value:transportCompilerData(descriptor.value,seen)});
|
|
521
|
+
}
|
|
522
|
+
if(!Object.isExtensible(value))Object.preventExtensions(output);
|
|
523
|
+
return output;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
async function runOriginalSuite({suite:relativeSuite,sourceRoot,moduleRecords},product){
|
|
527
|
+
const moduleIds=moduleRecords.map(record=>record.id);
|
|
528
|
+
const buildPath=resolve(sourceRoot,'tools/backends/build.mjs'),suite=resolve(sourceRoot,relativeSuite);
|
|
529
|
+
const directory=await mkdtemp(resolve(tmpdir(),'eliscript-original-selected-suite-'));
|
|
530
|
+
try{
|
|
531
|
+
const original=await readFile(buildPath,'utf8'),declaration='export async function buildBackends(';
|
|
532
|
+
const at=original.indexOf(declaration);
|
|
533
|
+
assert(at>=0&&original.indexOf(declaration,at+declaration.length)<0,'original build transport declaration is unique');
|
|
534
|
+
const renamed=original.slice(0,at)+'async function originalSelectedFrontendBuild('+original.slice(at+declaration.length);
|
|
535
|
+
const addition=`
|
|
536
|
+
export async function buildBackends(options={}){
|
|
537
|
+
const transport=globalThis[Symbol.for('eliscript.original.selected-backends')];
|
|
538
|
+
if(!transport)throw new Error('the selected backend product is not installed');
|
|
539
|
+
const actual=await transport.load();
|
|
540
|
+
if(options.frontend!==undefined||options.seed===true)return originalSelectedFrontendBuild({...options,frontend:options.frontend??actual.compiler});
|
|
541
|
+
let selectedDirectory=actual.directory;
|
|
542
|
+
if(options.outputRoot!==undefined){
|
|
543
|
+
const outputRoot=resolve(options.outputRoot);selectedDirectory=resolve(outputRoot,'backends');
|
|
544
|
+
if(await realpath(outputRoot).catch(error=>{if(error.code==='ENOENT')return outputRoot;throw error;})===await realpath(actual.product))throw new Error('original build output must not overwrite the selected compiler artifact');
|
|
545
|
+
// Forwarders preserve the actual namespace/registry identity and cannot
|
|
546
|
+
// overwrite the selected artifact when an original multi-generation case
|
|
547
|
+
// later rebuilds its temporary output directory.
|
|
548
|
+
for(const id of actual.moduleIds){
|
|
549
|
+
const target=resolve(outputRoot,id);await mkdir(dirname(target),{recursive:true});
|
|
550
|
+
const url=pathToFileURL(resolve(actual.product,id)).href;
|
|
551
|
+
const namespace=await import(url);
|
|
552
|
+
const lines=['import * as actual from '+JSON.stringify(url)+';','const transportCompilerData='+actual.transportCompilerData.toString()+';'];
|
|
553
|
+
let index=0;
|
|
554
|
+
for(const key of Object.keys(namespace)){
|
|
555
|
+
const local='transported'+index++;
|
|
556
|
+
lines.push('const '+local+'=typeof actual['+JSON.stringify(key)+']==="function"?function(...args){return transportCompilerData(Reflect.apply(actual['+JSON.stringify(key)+'],undefined,args));}:transportCompilerData(actual['+JSON.stringify(key)+']);');
|
|
557
|
+
lines.push('export {'+local+' as '+JSON.stringify(key)+'};');
|
|
558
|
+
}
|
|
559
|
+
await writeFile(target,lines.join('\\n')+'\\n');
|
|
560
|
+
const record=actual.moduleRecords.find(record=>record.id===id);
|
|
561
|
+
actual.browserModules.set(await realpath(target),{filename:resolve(root,record.filename),compiler:actual.compiler});
|
|
562
|
+
}
|
|
563
|
+
const dependencies=resolve(outputRoot,'node_modules');await mkdir(dependencies,{recursive:true});
|
|
564
|
+
const link=resolve(dependencies,'eliscript');try{await symlink(root,link,'dir');}catch(error){if(error.code!=='EEXIST')throw error;if(await realpath(link)!==await realpath(root))throw new Error('backend transport resolves a different runtime package');}
|
|
565
|
+
}
|
|
566
|
+
return {...actual,directory:selectedDirectory,async loadLiteralModules(){const literalSources=await loadLiteralSources({sourceRoot:root});return{literalSources,literalModules:literalSources.map(record=>({id:record.id,program:actual.compiler.compile_ir_string(record.source,record.filename)}))};}};
|
|
567
|
+
}
|
|
568
|
+
`;
|
|
569
|
+
const plugin=resolve(directory,'selected-backends-preload.mjs'),interceptPath=resolve(directory,'selected-backends-interception.json');
|
|
570
|
+
const pluginSource=[
|
|
571
|
+
"import {resolve} from 'node:path';import {pathToFileURL} from 'node:url';",
|
|
572
|
+
"import {realpath,writeFile,readFile} from 'node:fs/promises';",
|
|
573
|
+
'const product='+JSON.stringify(product)+',buildPath='+JSON.stringify(buildPath)+',interceptPath='+JSON.stringify(interceptPath)+';',
|
|
574
|
+
'const canonicalBuildPath=await realpath(buildPath);',
|
|
575
|
+
'const transportCompilerData='+transportCompilerData.toString()+';',
|
|
576
|
+
"const functionTransports=new WeakMap();function namespaceTransport(namespace){const result=Object.create(null);for(const key of Object.keys(namespace))Object.defineProperty(result,key,{enumerable:true,get(){const value=namespace[key];if(typeof value!=='function')return transportCompilerData(value);if(!functionTransports.has(value))functionTransports.set(value,function(...args){return transportCompilerData(Reflect.apply(value,undefined,args));});return functionTransports.get(value);}});return Object.freeze(result);}",
|
|
577
|
+
"const directory=resolve(product,'backends'),selected={directory,product,transportCompilerData,moduleRecords:"+JSON.stringify(moduleRecords)+",moduleIds:"+JSON.stringify(moduleIds)+",browserModules:new Map()};",
|
|
578
|
+
"let loading;selected.load=async function(){if(!loading)loading=(async()=>{selected.compiler=namespaceTransport(await import(pathToFileURL(resolve(product,'bootstrap/compiler.mjs')).href));for(const[key,name]of[['optimizer','optimize'],['numeric','numeric'],['wasm','wasm'],['native','native'],['sha256','sha256'],['regexp','regexp'],['managed','managed'],['memory','memory']])selected[key]=namespaceTransport(await import(pathToFileURL(resolve(directory,name+'.mjs')).href));return selected;})().catch(error=>{loading=undefined;throw error;});return loading;};",
|
|
579
|
+
"globalThis[Symbol.for('eliscript.original.selected-backends')]=selected;",
|
|
580
|
+
// Original browser tests request JavaScript bundles. Only that I/O path
|
|
581
|
+
// obtains JavaScript emitted by the actual selected compiler; ordinary
|
|
582
|
+
// Node/Bun imports keep the selected machine namespaces above.
|
|
583
|
+
"const originalBundle=Bun.build;Bun.build=function(options){if(options?.target!=='browser')return Reflect.apply(originalBundle,Bun,[options]);const transport={name:'selected-compiler-browser-source',setup(builder){builder.onLoad({filter:/[.]mjs$/},async args=>{const record=selected.browserModules.get(await realpath(args.path));if(!record)return;const source=await readFile(record.filename,'utf8');return{contents:record.compiler.compile_string(source,record.filename),loader:'js',resolveDir:resolve(args.path,'..')};});}};return Reflect.apply(originalBundle,Bun,[{...options,plugins:[...(options.plugins??[]),transport]}]);};",
|
|
584
|
+
'const contents='+JSON.stringify(renamed+addition)+';',
|
|
585
|
+
"Bun.plugin({name:'actual-selected-compiler-backends',setup(builder){builder.onLoad({filter:/build[.]mjs$/},async args=>{if(await realpath(args.path)!==canonicalBuildPath)return;await writeFile(interceptPath,JSON.stringify({product,modules:selected.moduleIds}));return{contents,loader:'js'};});}});",
|
|
586
|
+
].join('\n');
|
|
587
|
+
await writeFile(plugin,pluginSource);
|
|
588
|
+
const env={...process.env},args=[];
|
|
589
|
+
if(env.ELISCRIPT_ORIGINAL_PROGRAM_CONTEXT)args.push('--preload',
|
|
590
|
+
pathToFileURL(resolve(sourceRoot,'tools/backends/compiler-corpus-host-context.mjs')).href);
|
|
591
|
+
// The actual Bun runner retains every original declaration and deadline.
|
|
592
|
+
// No --timeout, test-name filter or rewritten assertion body is involved.
|
|
593
|
+
args.push('--preload',plugin,'test',suite);
|
|
594
|
+
const child=spawn(process.env.BUN??'bun',args,{cwd:sourceRoot,env,
|
|
595
|
+
detached:process.platform!=='win32',stdio:['ignore','pipe','pipe']});
|
|
596
|
+
child.stdout.on('data',chunk=>process.stderr.write(chunk));
|
|
597
|
+
child.stderr.on('data',chunk=>process.stderr.write(chunk));
|
|
598
|
+
let stopped=false,killTimer;
|
|
599
|
+
const kill=signal=>{
|
|
600
|
+
if(child.exitCode!==null||child.signalCode!==null)return;
|
|
601
|
+
try{if(process.platform!=='win32'&&child.pid)process.kill(-child.pid,signal);else child.kill(signal);}
|
|
602
|
+
catch(error){if(error.code!=='ESRCH')throw error;}
|
|
603
|
+
};
|
|
604
|
+
const cancel=signal=>{if(stopped)return;stopped=true;kill(signal);killTimer=setTimeout(()=>kill('SIGKILL'),1000);killTimer.unref?.();};
|
|
605
|
+
const interrupt=()=>cancel('SIGINT'),terminate=()=>cancel('SIGTERM');
|
|
606
|
+
process.on('SIGINT',interrupt);process.on('SIGTERM',terminate);
|
|
607
|
+
try{
|
|
608
|
+
const result=await new Promise((resolve,reject)=>{child.once('error',reject);child.once('close',(code,signal)=>resolve({code,signal}));});
|
|
609
|
+
assert.equal(stopped,false,'the original suite was cancelled');assert.equal(result.signal,null);
|
|
610
|
+
assert.equal(result.code,0,'the complete original suite must pass with the actual selected compiler product');
|
|
611
|
+
}finally{clearTimeout(killTimer);process.removeListener('SIGINT',interrupt);process.removeListener('SIGTERM',terminate);}
|
|
612
|
+
const interception=JSON.parse(await readFile(interceptPath,'utf8'));
|
|
613
|
+
assert.equal(interception.product,product);assert.deepEqual(interception.modules,moduleIds,
|
|
614
|
+
'the original default bootstrap may not silently replace the selected compiler');
|
|
615
|
+
console.log(JSON.stringify({suite:relativeSuite,completeOriginalSuite:true}));
|
|
616
|
+
}finally{await rm(directory,{recursive:true,force:true});}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function originalSuiteHost(suites,sourceRoot,moduleRecords){return[
|
|
620
|
+
"import assert from 'node:assert/strict';",
|
|
621
|
+
"import {mkdtemp,writeFile,rm,readFile} from 'node:fs/promises';",
|
|
622
|
+
"import {resolve} from 'node:path';import {tmpdir} from 'node:os';",
|
|
623
|
+
"import {pathToFileURL} from 'node:url';import {spawn} from 'node:child_process';",
|
|
624
|
+
'const transportCompilerData='+transportCompilerData.toString()+';',
|
|
625
|
+
'const run='+runOriginalSuite.toString()+';',
|
|
626
|
+
'for(const suite of '+JSON.stringify(suites)+')await run({suite,sourceRoot:'+JSON.stringify(sourceRoot)+',moduleRecords:'+JSON.stringify(moduleRecords)+'},process.argv[2]);',
|
|
627
|
+
].join('\n');}
|
|
628
|
+
|
|
629
|
+
const replaySuites=[
|
|
630
|
+
'wasm-managed-arithmetic','wasm-managed-word','wasm-managed-array-callbacks',
|
|
631
|
+
'wasm-managed-arrays','wasm-managed-array-index-storage','wasm-managed-array-text','wasm-managed-callables',
|
|
632
|
+
'wasm-managed-control','wasm-managed-empty-bindings','wasm-managed-exceptions',
|
|
633
|
+
'wasm-managed-catch-destructuring','wasm-managed-function-properties',
|
|
634
|
+
'wasm-managed-json','wasm-managed-json-callbacks','wasm-managed-math','wasm-managed-math-transcendental','wasm-managed-module-bindings',
|
|
635
|
+
'wasm-managed-number-conversion','wasm-managed-objects','wasm-managed-primitive-operators',
|
|
636
|
+
'wasm-managed-regexp','wasm-managed-regexp-indices','wasm-managed-regexp-unicode-sets','wasm-managed-regexp-property-data','wasm-managed-replacement','wasm-managed-source-collections',
|
|
637
|
+
'wasm-managed-strings','wasm-managed-variadic-calls','wasm-managed-tables',
|
|
638
|
+
'wasm-managed-runtime','wasm-managed-js-cons','managed-persistent-vector',
|
|
639
|
+
'wasm-managed-array-construction','wasm-managed-array-search','wasm-managed-object-properties',
|
|
640
|
+
'wasm-managed-symbols','wasm-managed-builtins','wasm-managed-typeof',
|
|
641
|
+
'wasm-managed-project-linking','direct-wasm-backend','wasm-memory-f64-unary','wasm-memory-static-data','native-memory-data-copy',
|
|
642
|
+
'regexp-property-outlining',
|
|
643
|
+
].map(name=>'tests/'+name+'.test.mjs');
|
|
644
|
+
|
|
645
|
+
function selectedOriginalSuites(locators){
|
|
646
|
+
// The frozen original locator inventory, rather than the working directory,
|
|
647
|
+
// is authoritative. A newly retained managed suite must enter this replay
|
|
648
|
+
// without waiting for a second hand-maintained list of its test titles.
|
|
649
|
+
const suites=new Set(replaySuites);
|
|
650
|
+
for(const locator of locators){
|
|
651
|
+
if(typeof locator.file==='string'&&
|
|
652
|
+
/^tests\/(?:wasm-managed-[a-z0-9-]+|wasm-memory-f64-[a-z0-9-]+|managed-persistent-vector|managed-stdlib-value-json|direct-wasm-backend)[.]test[.]mjs$/.test(locator.file))
|
|
653
|
+
suites.add(locator.file);
|
|
654
|
+
}
|
|
655
|
+
return [...suites].sort();
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
async function dependencies(text, initial) {
|
|
659
|
+
const result=new Map(),pending=[...initial];
|
|
660
|
+
while(pending.length){
|
|
661
|
+
const item=pending.shift();if(result.has(item.id))continue;
|
|
662
|
+
const source=item.source??await text(item.filename);
|
|
663
|
+
result.set(item.id,{...item,source});
|
|
664
|
+
for(const match of source.matchAll(/\(import(?:-portable)?\s+"([^"\n]+)"/g)){
|
|
665
|
+
if(!match[1].startsWith('.'))continue;
|
|
666
|
+
const target=posix.normalize(posix.join(posix.dirname(item.id),match[1]));
|
|
667
|
+
if(target.startsWith('../'))throw new TypeError('original managed fixture dependency escapes project');
|
|
668
|
+
// The actual canonical private runtime graph is supplied by the compiler
|
|
669
|
+
// session. Relative public source dependencies remain explicit modules.
|
|
670
|
+
if(target.startsWith('runtime/'))continue;
|
|
671
|
+
const id=target.endsWith('.eli')?target.slice(0,-4)+'.mjs':target;
|
|
672
|
+
const filename=id==='persistent-vector.mjs'?'stdlib/persistent-vector.eli':
|
|
673
|
+
target.endsWith('.mjs')?target.slice(0,-4)+'.eli':target;
|
|
674
|
+
if(!result.has(id)&&!pending.some(value=>value.id===id))pending.push({id,filename});
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return [...result.values()];
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const plans = [
|
|
681
|
+
['arithmetic','tests/wasm-managed-arithmetic.test.mjs',arithmetic],
|
|
682
|
+
['word','tests/wasm-managed-word.test.mjs',word],
|
|
683
|
+
['array-callbacks','tests/wasm-managed-array-callbacks.test.mjs',callbacks],
|
|
684
|
+
['arrays','tests/wasm-managed-arrays.test.mjs',arrays],
|
|
685
|
+
['array-construction','tests/wasm-managed-array-construction.test.mjs',construction],
|
|
686
|
+
['array-search','tests/wasm-managed-array-search.test.mjs',search],
|
|
687
|
+
['object-properties','tests/wasm-managed-object-properties.test.mjs',properties],
|
|
688
|
+
['empty-bindings','tests/wasm-managed-empty-bindings.test.mjs',emptyBindings],
|
|
689
|
+
['control','tests/wasm-managed-control.test.mjs',control],
|
|
690
|
+
['variadic-calls','tests/wasm-managed-variadic-calls.test.mjs',variadic],
|
|
691
|
+
['exceptions','tests/wasm-managed-exceptions.test.mjs',exceptions],
|
|
692
|
+
['catch-destructuring','tests/wasm-managed-catch-destructuring.test.mjs',catchBindings],
|
|
693
|
+
['symbols','tests/wasm-managed-symbols.test.mjs',symbols],
|
|
694
|
+
['source-collections','tests/wasm-managed-source-collections.test.mjs',collections],
|
|
695
|
+
['objects','tests/wasm-managed-objects.test.mjs',objects],
|
|
696
|
+
['module-bindings','tests/wasm-managed-module-bindings.test.mjs',moduleBindings],
|
|
697
|
+
['builtins','tests/wasm-managed-builtins.test.mjs',builtin],
|
|
698
|
+
['typeof','tests/wasm-managed-typeof.test.mjs',typeofFixture],
|
|
699
|
+
['regexp','tests/wasm-managed-regexp.test.mjs',regexp],
|
|
700
|
+
['replacement','tests/wasm-managed-replacement.test.mjs',replacement],
|
|
701
|
+
['array-text','tests/wasm-managed-array-text.test.mjs',arrayText],
|
|
702
|
+
['strings','tests/wasm-managed-strings.test.mjs',strings],
|
|
703
|
+
['callables','tests/wasm-managed-callables.test.mjs',callables],
|
|
704
|
+
['js-cons','tests/wasm-managed-js-cons.test.mjs',jsCons],
|
|
705
|
+
];
|
|
706
|
+
|
|
707
|
+
export async function bindOriginalManagedSourceEvidence({records,locators,text,file,bindCoverage}){
|
|
708
|
+
for(const plan of [
|
|
709
|
+
{record:'stable-compatibility:program:tests/fixtures/declarative-protocol.eli',
|
|
710
|
+
fixture:'tests/fixtures/declarative-protocol.eli',host:'tests/fixtures/declarative-protocol-host.mjs',
|
|
711
|
+
calls:['new declarations.Box(7)','declarations.describe(box)','declarations.measure(5, 4)']},
|
|
712
|
+
{record:'stable-compatibility:program:stdlib/multimethod.eli',
|
|
713
|
+
fixture:'tests/fixtures/declarative-multimethod.eli',host:'tests/fixtures/multimethod-host.mjs',
|
|
714
|
+
calls:['const [modulePath, declarativePath] = process.argv.slice(2);',
|
|
715
|
+
'declarativeModule.render("text", "hello")','declarativeModule.render("number", 21)']},
|
|
716
|
+
{record:'stable-compatibility:program:tests/fixtures/core-expression-forms.eli',
|
|
717
|
+
fixture:'tests/fixtures/core-expression-forms.eli',host:'tests/fixtures/core-expression-forms-host.mjs',
|
|
718
|
+
calls:['const module = await import(modulePath);','module.expression_form_report()']},
|
|
719
|
+
]){
|
|
720
|
+
const selected=locators.filter(locator=>[plan.fixture,plan.host].includes(locator.file));
|
|
721
|
+
if(!selected.length)continue;
|
|
722
|
+
const record=records.find(record=>record.id===plan.record);
|
|
723
|
+
if(!record||record.kind!=='project'||record.execution?.kind!=='original-program')
|
|
724
|
+
throw new TypeError('original executed source evidence lost its actual project: '+plan.record);
|
|
725
|
+
const module=record.modules?.find(module=>module.filename===plan.fixture);
|
|
726
|
+
const source=await text(plan.fixture),host=await text(plan.host);
|
|
727
|
+
if(!module||module.source!==source||record.execution.host!==plan.host||record.execution.hostSource!==host||
|
|
728
|
+
!plan.calls.every(call=>host.includes(call))||
|
|
729
|
+
!(module.id===record.entry||record.execution.argumentModules?.includes(module.id))||
|
|
730
|
+
!record.request.entries?.includes(module.id))
|
|
731
|
+
throw new TypeError('original fixture evidence is not an actually executed input: '+plan.fixture);
|
|
732
|
+
if(typeof bindCoverage!=='function')throw new TypeError('original executed source evidence requires its coverage binder');
|
|
733
|
+
const sourceIdentity=await file(plan.fixture),hostIdentity=await file(plan.host),bindings=[];
|
|
734
|
+
for(const locator of selected){
|
|
735
|
+
const original=locator.file===plan.fixture?source:host;
|
|
736
|
+
if(typeof locator.contains!=='string'||!original.includes(locator.contains))
|
|
737
|
+
throw new TypeError('original executed source locator changed: '+locator.id);
|
|
738
|
+
bindings.push({coverageId:locator.id,file:locator.file,
|
|
739
|
+
sourceSha256:locator.file===plan.fixture?sourceIdentity.sha256:hostIdentity.sha256,
|
|
740
|
+
module:module.id,host:plan.host,hostSourceSha256:hostIdentity.sha256,actualCalls:[...plan.calls]});
|
|
741
|
+
}
|
|
742
|
+
bindCoverage(record,bindings.map(binding=>binding.coverageId));
|
|
743
|
+
record.original={...record.original,sourceEvidenceBindings:[...(record.original?.sourceEvidenceBindings??[]),...bindings]};
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export async function addOriginalManagedFixtureAdapters({add,text,file,stableFiles,locators,sourceRoot,records=[],bindCoverage}) {
|
|
748
|
+
await bindOriginalManagedSourceEvidence({records,locators,text,file,bindCoverage});
|
|
749
|
+
const legacyFixture='tests/fixtures/compatibility/native-containers-v1.eli';
|
|
750
|
+
if(stableFiles.has(legacyFixture)){
|
|
751
|
+
const contractFile='contracts/compatibility-rehearsal.json',contract=JSON.parse(await text(contractFile));
|
|
752
|
+
const migrations=contract.migrations?.filter(migration=>migration.legacySource===legacyFixture);
|
|
753
|
+
if(contract.format!=='eliscript-compatibility-rehearsal'||migrations?.length!==1)
|
|
754
|
+
throw new TypeError('original legacy container migration declaration changed');
|
|
755
|
+
const expected=migrations[0].expectedLegacyDiagnostic;
|
|
756
|
+
if(!expected||['code','phase','message'].some(key=>typeof expected[key]!=='string'))
|
|
757
|
+
throw new TypeError('original legacy container diagnostic declaration changed');
|
|
758
|
+
const source=await text(legacyFixture),identity=await file(legacyFixture);
|
|
759
|
+
const contractIdentity=await file(contractFile),host='tools/compatibility/rehearse.mjs',hostIdentity=await file(host);
|
|
760
|
+
add({id:'original-sequence:legacy-native-container-rejection',kind:'sequence',
|
|
761
|
+
coverage:['stable-compatibility:'+legacyFixture],
|
|
762
|
+
steps:[{id:'complete-original-legacy-source',request:{operation:'stage',stage:'emitter',source,filename:legacyFixture},
|
|
763
|
+
error:{code:expected.code,phase:expected.phase,expectFields:[
|
|
764
|
+
{path:['message'],value:expected.message},{path:['location','file'],value:legacyFixture},
|
|
765
|
+
]}}],expected:{kind:'sequence'},
|
|
766
|
+
original:{manifest:'stable-compatibility',fixture:legacyFixture,sourceSha256:identity.sha256,classification:'invalid',
|
|
767
|
+
contract:{file:contractFile,sourceSha256:contractIdentity.sha256},host,hostSourceSha256:hostIdentity.sha256,
|
|
768
|
+
expectedLegacyDiagnostic:structuredClone(expected)}});
|
|
769
|
+
}
|
|
770
|
+
async function append(name,suite,body,initial,coverage,options={}){
|
|
771
|
+
const sourceEvidence=await file(suite);
|
|
772
|
+
const modules=await dependencies(text,initial);
|
|
773
|
+
for(const module of modules)await file(module.filename);
|
|
774
|
+
for(const hostRuntime of['node','bun'])add({
|
|
775
|
+
id:'original-managed-fixture:'+name+':'+hostRuntime,kind:'project',coverage:[...coverage],
|
|
776
|
+
entry:initial[0].id,modules:structuredClone(modules),auto:options.auto??1,
|
|
777
|
+
request:{operation:'project',resolveImports:true,phased:true,entries:modules.map(module=>module.id)},
|
|
778
|
+
memory:structuredClone(options.memory??{initialPages:4,maximumPages:256}),
|
|
779
|
+
execution:{kind:'original-program',host:'tests/__eliscript_managed_fixture_'+name+'_'+hostRuntime+'.mjs',
|
|
780
|
+
hostSource:prelude.replace('__ELISCRIPT_ORIGINAL_AUTO__',String(options.auto??1))+body+'\nfinish();\n',hostRuntime,arguments:[{directory:true},{literal:initial[0].id}],
|
|
781
|
+
referenceArtifact:true,aliases:true,childProcesses:'inherit-selected-artifact',zeroImports:true,
|
|
782
|
+
timeoutMs:options.timeoutMs??30000,
|
|
783
|
+
runtimeOptions:structuredClone(options.budget??{maxSlots:1024,initialBytes:65536,maxBytes:16777216})},
|
|
784
|
+
expected:{kind:'seed-program',oracleRequired:true},
|
|
785
|
+
original:{manifest:'stable-compatibility',fixture:initial[0].filename,suite,sourceSha256:sourceEvidence.sha256,
|
|
786
|
+
semanticCoverage:'source-fixture-public-operations',
|
|
787
|
+
targetSpecificAssertions:{javascript:'actual selected source exports compared to the independent Seed product',
|
|
788
|
+
binary:'the same actual selected source calls plus real automatic collection, private-frame restoration and close/live-zero'},
|
|
789
|
+
unclaimedAssertions:'Raw ABI, malformed IR, dynamic runtime injection and untransported individual suite cases retain their existing mandatory gate and missing locators.'},
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
for(const[name,suite,body]of plans){
|
|
793
|
+
const fixture='tests/fixtures/wasm-managed-'+name+'.eli';
|
|
794
|
+
if(!stableFiles.has(fixture))continue;
|
|
795
|
+
await append(name,suite,body,[{id:'entry.mjs',filename:fixture}],['stable-compatibility:'+fixture]);
|
|
796
|
+
}
|
|
797
|
+
for(const[name,suite,body]of[
|
|
798
|
+
['math','tests/wasm-managed-math.test.mjs',mathBody],
|
|
799
|
+
['number-conversion','tests/wasm-managed-number-conversion.test.mjs',numberBody],
|
|
800
|
+
['json','tests/wasm-managed-json.test.mjs',jsonBody],
|
|
801
|
+
['primitive-operators','tests/wasm-managed-primitive-operators.test.mjs',primitiveBody],
|
|
802
|
+
]){
|
|
803
|
+
const fixture='tests/fixtures/wasm-managed-'+name+'.eli';
|
|
804
|
+
if(stableFiles.has(fixture))await append(name,suite,body(await text(suite)),[{id:'entry.mjs',filename:fixture}],['stable-compatibility:'+fixture]);
|
|
805
|
+
}
|
|
806
|
+
const functionFixture='tests/fixtures/wasm-managed-function-properties.eli';
|
|
807
|
+
if(stableFiles.has(functionFixture)){
|
|
808
|
+
const suite='tests/wasm-managed-function-properties.test.mjs',original=await text(functionFixture),source=await text(suite);
|
|
809
|
+
const end=original.lastIndexOf(')');if(end<0)throw new TypeError('original function fixture module boundary changed');
|
|
810
|
+
const extension=readOriginalManagedStaticTemplate(source,'reflectionSource',reflectionTemplateBindings(source));
|
|
811
|
+
await append('function-properties',suite,
|
|
812
|
+
section(source,'const wellKnownSymbolNames=','const reflectionSource=')+functionProperties,
|
|
813
|
+
[{id:'entry.mjs',filename:functionFixture,source:original.slice(0,end)+extension+original.slice(end)}],
|
|
814
|
+
['stable-compatibility:'+functionFixture]);
|
|
815
|
+
}
|
|
816
|
+
const vectorFixture='tests/fixtures/wasm-managed-persistent-vector.eli';
|
|
817
|
+
if(stableFiles.has(vectorFixture))for(const auto of[65536,1])await append('persistent-vector-auto-'+auto,
|
|
818
|
+
'tests/managed-persistent-vector.test.mjs',auto===1?"compare('collecting persistent Vector callbacks',mod=>mod.vector_case(33));":persistentVector,
|
|
819
|
+
[{id:'entry.mjs',filename:vectorFixture}],['stable-compatibility:'+vectorFixture],
|
|
820
|
+
{auto,memory:{initialPages:4,maximumPages:1024},budget:{maxSlots:8192,initialBytes:262144,maxBytes:16777216},timeoutMs:auto===1?30000:120000});
|
|
821
|
+
const fixture='tests/fixtures/wasm-managed-project-entry.eli',state='tests/fixtures/wasm-managed-project-state.eli';
|
|
822
|
+
if(stableFiles.has(fixture)&&stableFiles.has(state))await append('project-entry','tests/direct-wasm-backend.test.mjs',project,
|
|
823
|
+
[{id:'tests/fixtures/wasm-managed-project-entry.mjs',filename:fixture}],
|
|
824
|
+
['stable-compatibility:'+fixture,'stable-compatibility:'+state]);
|
|
825
|
+
// The full original suites also run their raw ABI, malformed-IR and injected
|
|
826
|
+
// runtime cases. Their compiler/backends are the selected complete product,
|
|
827
|
+
// not the host's default bootstrap. Each suite retains the real Bun runner,
|
|
828
|
+
// every original test body, all native platform conditions, all original
|
|
829
|
+
// Node subprocesses, and each original per-test/beforeAll timeout.
|
|
830
|
+
const sources=await loadCompilerSources({sourceRoot});
|
|
831
|
+
for(const record of[...sources.modules,sources.runtime,...sources.literalSources])await file(record.filename);
|
|
832
|
+
await file('tools/backends/build.mjs');
|
|
833
|
+
await file('tools/backends/compiler-corpus-host-context.mjs');
|
|
834
|
+
const suiteBindings=[],suiteCoverage=[],selectedSuites=selectedOriginalSuites(locators);
|
|
835
|
+
for(const suite of selectedSuites){
|
|
836
|
+
const source=await text(suite),identity=await file(suite);
|
|
837
|
+
const fixtureCoverage=[...stableFiles].filter(name=>name.startsWith('tests/fixtures/wasm-managed-')&&
|
|
838
|
+
name.endsWith('.eli')&&source.includes(name)).map(name=>'stable-compatibility:'+name);
|
|
839
|
+
const sourceInputs=[];
|
|
840
|
+
const trie='tests/fixtures/regexp-property-original-trie.eli';
|
|
841
|
+
if(suite==='tests/regexp-property-outlining.test.mjs'&&stableFiles.has(trie)){
|
|
842
|
+
for(const actual of ["readFile('"+trie+"','utf8')",'reconstructed=inline(definitions.get(rootName))',
|
|
843
|
+
"'(module regexp.original '+reconstructed",'originalJS.regexp_property_id_base',
|
|
844
|
+
'assert(irNodes(originalRoot.find(node=>node.kind===\'function-declaration\'&&node.value===rootName))>1000)'])
|
|
845
|
+
if(!source.includes(actual))throw new TypeError('original property trie execution boundary changed: '+actual);
|
|
846
|
+
sourceInputs.push({file:trie,sourceSha256:(await file(trie)).sha256,
|
|
847
|
+
execution:'complete original definitions reconstructed, compiled and compared by the unmodified suite'});
|
|
848
|
+
fixtureCoverage.push('stable-compatibility:'+trie);
|
|
849
|
+
}
|
|
850
|
+
const originalCoverage=locators.filter(locator=>locator.file===suite&&typeof locator.contains==='string'&&
|
|
851
|
+
source.includes(locator.contains)).map(locator=>locator.id);
|
|
852
|
+
suiteCoverage.push(...fixtureCoverage,...originalCoverage);
|
|
853
|
+
suiteBindings.push({file:suite,sourceSha256:identity.sha256,coverage:[...fixtureCoverage,...originalCoverage],
|
|
854
|
+
...(sourceInputs.length?{sourceInputs}:{})});
|
|
855
|
+
}
|
|
856
|
+
if(suiteCoverage.length)add({id:'original-managed-suite:complete-fixture-suites',kind:'project',
|
|
857
|
+
coverage:[...new Set(suiteCoverage)],
|
|
858
|
+
modules:structuredClone(sources.modules),entry:sources.entry,auto:65536,
|
|
859
|
+
request:{operation:'project',phased:true,resolveImports:true,entries:sources.modules.map(module=>module.id),
|
|
860
|
+
literalSources:structuredClone(sources.literalSources)},
|
|
861
|
+
memory:{initialPages:128,maximumPages:4096},
|
|
862
|
+
execution:{kind:'original-program',host:'tests/__eliscript_selected_managed_fixture_suites.mjs',
|
|
863
|
+
hostSource:originalSuiteHost(selectedSuites,sourceRoot,sources.modules.map(({id,filename})=>({id,filename}))),hostRuntime:'bun',
|
|
864
|
+
arguments:[{directory:true}],referenceArtifact:true,aliases:true,zeroImports:true,
|
|
865
|
+
childProcesses:'inherit-selected-artifact',timeoutMs:1800000,
|
|
866
|
+
runtimeOptions:{maxSlots:131072,initialBytes:8388608,maxBytes:67108864,auto:65536}},
|
|
867
|
+
expected:{kind:'seed-program',oracleRequired:true},
|
|
868
|
+
original:{manifest:'stable-compatibility',suites:suiteBindings,
|
|
869
|
+
semanticCoverage:'complete-original-suite-with-selected-compiler-namespaces',
|
|
870
|
+
originalHost:'bun',testSource:'unmodified',testRunner:'bun test',
|
|
871
|
+
compilerProduct:'complete actual frontend and backend graph in the selected output target',
|
|
872
|
+
sourceProgramABI:'original suite binary ABI is retained, including genuine WASM and explicitly declared native cases',
|
|
873
|
+
targetSpecificAssertions:{all:'original suite assertions and every declared resource/deadline remain unmodified'},
|
|
874
|
+
timeoutScope:'outer process ceiling retains the original compatibility job 30-minute limit; original case limits are enforced by the original Bun runner'},
|
|
875
|
+
});
|
|
876
|
+
// Return no whole-suite coverage. A public source fixture recipe must never
|
|
877
|
+
// hide a missing raw-ABI or dynamically compiled case in the same test file.
|
|
878
|
+
return [];
|
|
879
|
+
}
|