functionalscript 0.44.0 → 0.46.0
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 +5 -3
- package/fjs/asn.1/module.f.mjs +8 -1
- package/fjs/asn.1/proof.f.d.mts +15 -0
- package/fjs/asn.1/proof.f.mjs +31 -3
- package/fjs/asserts/module.f.d.mts +14 -0
- package/fjs/asserts/module.f.mjs +20 -0
- package/fjs/asserts/proof.f.d.mts +3 -0
- package/fjs/asserts/proof.f.mjs +15 -1
- package/fjs/basen/base128/module.f.mjs +22 -5
- package/fjs/basen/base128/proof.f.d.mts +3 -1
- package/fjs/basen/base128/proof.f.mjs +3 -1
- package/fjs/basen/base64/module.f.mjs +7 -3
- package/fjs/basen/base64/proof.f.d.mts +3 -1
- package/fjs/basen/base64/proof.f.mjs +7 -4
- package/fjs/basen/cbase32/proof.f.d.mts +3 -1
- package/fjs/basen/cbase32/proof.f.mjs +3 -1
- package/fjs/bnf/data/module.f.d.mts +32 -6
- package/fjs/bnf/data/module.f.mjs +112 -7
- package/fjs/bnf/data/proof.f.d.mts +2 -0
- package/fjs/bnf/data/proof.f.mjs +74 -4
- package/fjs/bnf/data/types.d.ts +20 -2
- package/fjs/bnf/descent/module.f.d.mts +34 -5
- package/fjs/bnf/descent/module.f.mjs +176 -54
- package/fjs/bnf/descent/proof.f.d.mts +3 -0
- package/fjs/bnf/descent/proof.f.mjs +189 -27
- package/fjs/bnf/descent/types.d.ts +24 -18
- package/fjs/bnf/ll1/module.f.d.mts +74 -6
- package/fjs/bnf/ll1/module.f.mjs +297 -95
- package/fjs/bnf/ll1/proof.f.d.mts +17 -2
- package/fjs/bnf/ll1/proof.f.mjs +372 -137
- package/fjs/bnf/ll1/types.d.ts +25 -27
- package/fjs/bnf/matcher/module.f.d.mts +66 -0
- package/fjs/bnf/matcher/module.f.mjs +81 -0
- package/fjs/bnf/matcher/proof.f.d.mts +10 -0
- package/fjs/bnf/matcher/proof.f.mjs +79 -0
- package/fjs/bnf/matcher/types.d.ts +54 -0
- package/fjs/bnf/module.f.d.mts +15 -6
- package/fjs/bnf/module.f.mjs +52 -11
- package/fjs/bnf/proof.f.d.mts +2 -0
- package/fjs/bnf/proof.f.mjs +79 -3
- package/fjs/bnf/testlib.f.d.mts +31 -0
- package/fjs/bnf/testlib.f.mjs +80 -0
- package/fjs/bnf/token_symbol/module.f.d.mts +4 -3
- package/fjs/bnf/token_symbol/module.f.mjs +7 -6
- package/fjs/bnf/token_symbol/proof.f.mjs +5 -2
- package/fjs/bnf/token_symbol/types.d.ts +2 -2
- package/fjs/bnf/types.d.ts +10 -3
- package/fjs/cas/cli/module.f.d.mts +1 -1
- package/fjs/cas/cli/module.f.mjs +14 -20
- package/fjs/cas/cli/proof.f.d.mts +4 -4
- package/fjs/cas/cli/proof.f.mjs +47 -34
- package/fjs/cas/evo/module.f.d.mts +71 -31
- package/fjs/cas/evo/module.f.mjs +223 -138
- package/fjs/cas/evo/proof.f.d.mts +10 -1
- package/fjs/cas/evo/proof.f.mjs +311 -226
- package/fjs/cas/evo/types.d.ts +45 -9
- package/fjs/cas/module.f.d.mts +18 -32
- package/fjs/cas/module.f.mjs +164 -176
- package/fjs/cas/proof.f.d.mts +11 -8
- package/fjs/cas/proof.f.mjs +259 -147
- package/fjs/cas/types.d.ts +24 -10
- package/fjs/ci/common/module.f.d.mts +1 -1
- package/fjs/ci/common/module.f.mjs +1 -0
- package/fjs/ci/config/module.f.d.mts +3 -3
- package/fjs/ci/config/module.f.mjs +3 -3
- package/fjs/ci/module.f.d.mts +5 -5
- package/fjs/ci/module.f.mjs +8 -7
- package/fjs/ci/nix/module.f.d.mts +7 -5
- package/fjs/ci/nix/module.f.mjs +13 -12
- package/fjs/ci/nix/proof.f.d.mts +2 -0
- package/fjs/ci/nix/proof.f.mjs +4 -4
- package/fjs/ci/proof.f.d.mts +4 -2
- package/fjs/ci/proof.f.mjs +13 -8
- package/fjs/cli/module.f.d.mts +4 -6
- package/fjs/cli/module.f.mjs +4 -8
- package/fjs/cli/proof.f.d.mts +4 -2
- package/fjs/cli/proof.f.mjs +21 -18
- package/fjs/cli/types.d.ts +2 -3
- package/fjs/common/monoid/module.f.d.mts +70 -12
- package/fjs/common/monoid/module.f.mjs +177 -14
- package/fjs/common/monoid/proof.f.d.mts +12 -1
- package/fjs/common/monoid/proof.f.mjs +88 -4
- package/fjs/common/monoid/types.d.ts +23 -0
- package/fjs/crypto/hmac/module.f.mjs +2 -2
- package/fjs/crypto/secp/proof.f.d.mts +3 -1
- package/fjs/crypto/secp/proof.f.mjs +3 -1
- package/fjs/crypto/sha2/module.f.mjs +3 -1
- package/fjs/crypto/sha2/proof.f.d.mts +4 -1
- package/fjs/crypto/sha2/proof.f.mjs +27 -1
- package/fjs/crypto/sha2/types.d.ts +11 -0
- package/fjs/crypto/sign/module.f.mjs +2 -2
- package/fjs/crypto/vdf/module.f.d.mts +23 -4
- package/fjs/crypto/vdf/module.f.mjs +6 -4
- package/fjs/dev/module.f.d.mts +17 -5
- package/fjs/dev/module.f.mjs +60 -30
- package/fjs/dev/update/module.f.d.mts +11 -3
- package/fjs/dev/update/module.f.mjs +16 -11
- package/fjs/dev/update/proof.f.d.mts +4 -3
- package/fjs/dev/update/proof.f.mjs +11 -7
- package/fjs/djs/module.f.d.mts +13 -5
- package/fjs/djs/module.f.mjs +31 -16
- package/fjs/djs/parser/module.f.d.mts +16 -3
- package/fjs/djs/parser/module.f.mjs +135 -16
- package/fjs/djs/parser/proof.f.d.mts +8 -1
- package/fjs/djs/parser/proof.f.mjs +287 -13
- package/fjs/djs/parser/types.d.ts +7 -1
- package/fjs/djs/proof.f.d.mts +20 -1
- package/fjs/djs/proof.f.mjs +190 -12
- package/fjs/djs/serializer/module.f.d.mts +25 -8
- package/fjs/djs/serializer/module.f.mjs +66 -19
- package/fjs/djs/serializer/proof.f.d.mts +5 -0
- package/fjs/djs/serializer/proof.f.mjs +23 -1
- package/fjs/djs/tokenizer/module.f.d.mts +17 -5
- package/fjs/djs/tokenizer/module.f.mjs +120 -73
- package/fjs/djs/tokenizer/proof.f.d.mts +3 -0
- package/fjs/djs/tokenizer/proof.f.mjs +86 -67
- package/fjs/djs/transpiler/module.f.d.mts +13 -19
- package/fjs/djs/transpiler/module.f.mjs +79 -72
- package/fjs/djs/transpiler/types.d.ts +29 -0
- package/fjs/djs/types.d.ts +7 -1
- package/fjs/effects/list/module.f.d.mts +23 -12
- package/fjs/effects/list/module.f.mjs +16 -12
- package/fjs/effects/list/types.d.ts +27 -7
- package/fjs/effects/memory/module.f.d.mts +6 -3
- package/fjs/effects/memory/module.f.mjs +7 -7
- package/fjs/effects/memory/proof.f.d.mts +4 -0
- package/fjs/effects/memory/proof.f.mjs +18 -9
- package/fjs/effects/memory/types.d.ts +4 -3
- package/fjs/effects/mock/module.f.d.mts +28 -4
- package/fjs/effects/mock/module.f.mjs +39 -5
- package/fjs/effects/mock/types.d.ts +10 -1
- package/fjs/effects/module.d.mts +12 -2
- package/fjs/effects/module.f.d.mts +469 -281
- package/fjs/effects/module.f.mjs +538 -299
- package/fjs/effects/module.mjs +11 -2
- package/fjs/effects/node/memory/module.d.mts +7 -2
- package/fjs/effects/node/memory/module.mjs +9 -5
- package/fjs/effects/node/memory/proof.d.mts +2 -0
- package/fjs/effects/node/memory/proof.mjs +12 -5
- package/fjs/effects/node/module.d.mts +8 -2
- package/fjs/effects/node/module.f.d.mts +183 -43
- package/fjs/effects/node/module.f.mjs +260 -62
- package/fjs/effects/node/module.mjs +61 -50
- package/fjs/effects/node/proof.f.d.mts +28 -2
- package/fjs/effects/node/proof.f.mjs +161 -42
- package/fjs/effects/node/types.d.ts +106 -18
- package/fjs/effects/node/virtual/module.f.d.mts +21 -4
- package/fjs/effects/node/virtual/module.f.mjs +113 -70
- package/fjs/effects/node/virtual/proof.f.d.mts +31 -2
- package/fjs/effects/node/virtual/proof.f.mjs +201 -8
- package/fjs/effects/proof.f.d.mts +69 -34
- package/fjs/effects/proof.f.mjs +413 -130
- package/fjs/effects/types.d.ts +161 -33
- package/fjs/emergent_testing/all.test.d.mts +8 -0
- package/fjs/emergent_testing/all.test.mjs +14 -0
- package/fjs/emergent_testing/module.f.d.mts +22 -10
- package/fjs/emergent_testing/module.f.mjs +119 -85
- package/fjs/emergent_testing/proof.f.d.mts +21 -7
- package/fjs/emergent_testing/proof.f.mjs +169 -35
- package/fjs/emergent_testing/types.d.ts +22 -4
- package/fjs/fsc/bnf.f.d.mts +3 -0
- package/fjs/fsc/bnf.f.mjs +4 -1
- package/fjs/fsc/json.f.d.mts +3 -0
- package/fjs/fsc/json.f.mjs +4 -1
- package/fjs/fsc/module.f.d.mts +9 -0
- package/fjs/fsc/module.f.mjs +5 -3
- package/fjs/fsm/module.f.d.mts +14 -4
- package/fjs/fsm/module.f.mjs +54 -37
- package/fjs/fsm/proof.f.d.mts +5 -0
- package/fjs/fsm/proof.f.mjs +87 -115
- package/fjs/js/keywords/module.f.d.mts +52 -0
- package/fjs/js/keywords/module.f.mjs +72 -0
- package/fjs/{emergent_testing/scenarios/return-value.pass.d.ts → js/keywords/proof.f.d.mts} +1 -1
- package/fjs/js/keywords/proof.f.mjs +13 -0
- package/fjs/js/tokenizer/module.f.d.mts +30 -3
- package/fjs/js/tokenizer/module.f.mjs +161 -211
- package/fjs/js/tokenizer/proof.f.d.mts +1 -0
- package/fjs/js/tokenizer/proof.f.mjs +54 -24
- package/fjs/js/tokenizer/types.d.ts +33 -24
- package/fjs/mcp/cas/module.f.d.mts +1 -6
- package/fjs/mcp/cas/module.f.mjs +55 -51
- package/fjs/mcp/cas/proof.f.d.mts +15 -0
- package/fjs/mcp/cas/proof.f.mjs +174 -0
- package/fjs/mcp/evo/module.f.d.mts +19 -10
- package/fjs/mcp/evo/module.f.mjs +48 -27
- package/fjs/mcp/evo/proof.f.d.mts +6 -1
- package/fjs/mcp/evo/proof.f.mjs +115 -31
- package/fjs/mcp/module.f.d.mts +39 -4
- package/fjs/mcp/module.f.mjs +14 -12
- package/fjs/mcp/proof.f.d.mts +13 -1
- package/fjs/mcp/proof.f.mjs +120 -61
- package/fjs/media/html/module.f.d.mts +12 -0
- package/fjs/media/html/module.f.mjs +7 -5
- package/fjs/media/html/proof.f.d.mts +3 -0
- package/fjs/media/html/proof.f.mjs +4 -1
- package/fjs/media/json/extended/module.f.d.mts +82 -0
- package/fjs/media/json/extended/module.f.mjs +153 -0
- package/fjs/media/json/extended/proof.f.d.mts +42 -0
- package/fjs/media/json/extended/proof.f.mjs +127 -0
- package/fjs/media/json/extended/types.d.ts +23 -0
- package/fjs/media/json/module.f.d.mts +8 -2
- package/fjs/media/json/module.f.mjs +43 -41
- package/fjs/media/json/number/module.f.d.mts +59 -0
- package/fjs/media/json/number/module.f.mjs +136 -0
- package/fjs/media/json/number/proof.f.d.mts +24 -0
- package/fjs/media/json/number/proof.f.mjs +86 -0
- package/fjs/media/json/number/types.d.ts +28 -0
- package/fjs/media/json/parser/module.f.d.mts +25 -13
- package/fjs/media/json/parser/module.f.mjs +133 -72
- package/fjs/media/json/parser/proof.f.d.mts +5 -0
- package/fjs/media/json/parser/proof.f.mjs +31 -1
- package/fjs/media/json/parser/types.d.ts +38 -14
- package/fjs/media/json/rtti/module.f.d.mts +1 -1
- package/fjs/media/json/rtti/module.f.mjs +1 -1
- package/fjs/media/json/rtti/proof.f.d.mts +3 -0
- package/fjs/media/json/rtti/proof.f.mjs +12 -12
- package/fjs/media/json/schema/module.f.d.mts +61 -27
- package/fjs/media/json/schema/module.f.mjs +218 -63
- package/fjs/media/json/schema/proof.f.d.mts +41 -1
- package/fjs/media/json/schema/proof.f.mjs +220 -9
- package/fjs/media/json/serializer/module.f.d.mts +44 -0
- package/fjs/media/json/serializer/module.f.mjs +71 -9
- package/fjs/media/json/tokenizer/module.f.d.mts +8 -0
- package/fjs/media/json/tokenizer/module.f.mjs +31 -8
- package/fjs/media/json/tokenizer/proof.f.d.mts +6 -0
- package/fjs/media/json/tokenizer/proof.f.mjs +62 -21
- package/fjs/media/json/types.d.ts +36 -10
- package/fjs/media/lock/module.f.d.mts +100 -0
- package/fjs/media/lock/module.f.mjs +125 -0
- package/fjs/media/lock/proof.f.d.mts +33 -0
- package/fjs/media/lock/proof.f.mjs +196 -0
- package/fjs/media/lock/types.d.ts +15 -0
- package/fjs/media/module.f.d.mts +6 -5
- package/fjs/media/module.f.mjs +8 -7
- package/fjs/media/nix/module.f.d.mts +13 -0
- package/fjs/media/nix/module.f.mjs +4 -2
- package/fjs/media/nix/proof.f.d.mts +3 -0
- package/fjs/media/nix/proof.f.mjs +4 -1
- package/fjs/media/note/module.f.d.mts +121 -0
- package/fjs/media/note/module.f.mjs +131 -0
- package/fjs/media/note/proof.f.d.mts +29 -0
- package/fjs/media/note/proof.f.mjs +150 -0
- package/fjs/media/note/types.d.ts +10 -0
- package/fjs/media/proof.f.d.mts +4 -1
- package/fjs/media/proof.f.mjs +40 -21
- package/fjs/media/revision/module.f.d.mts +83 -7
- package/fjs/media/revision/module.f.mjs +127 -23
- package/fjs/media/revision/proof.f.d.mts +14 -0
- package/fjs/media/revision/proof.f.mjs +93 -2
- package/fjs/media/revision/types.d.ts +34 -5
- package/fjs/media/type/module.f.d.mts +53 -18
- package/fjs/media/type/module.f.mjs +87 -97
- package/fjs/media/type/proof.f.d.mts +17 -0
- package/fjs/media/type/proof.f.mjs +73 -13
- package/fjs/module.d.mts +5 -0
- package/fjs/module.f.d.mts +8 -0
- package/fjs/module.f.mjs +33 -10
- package/fjs/module.mjs +6 -0
- package/fjs/nanvm/proof.f.mjs +3 -3
- package/fjs/nanvm/rust/module.f.mjs +1 -1
- package/fjs/nanvm/update/module.f.d.mts +4 -4
- package/fjs/nanvm/update/module.f.mjs +8 -9
- package/fjs/nanvm/update/proof.f.mjs +4 -3
- package/fjs/path/module.f.d.mts +8 -0
- package/fjs/path/module.f.mjs +4 -2
- package/fjs/proof.f.d.mts +7 -3
- package/fjs/proof.f.mjs +41 -12
- package/fjs/protocol/json_rpc/module.f.d.mts +3 -3
- package/fjs/protocol/json_rpc/module.f.mjs +10 -7
- package/fjs/protocol/json_rpc/proof.f.d.mts +6 -0
- package/fjs/protocol/json_rpc/proof.f.mjs +26 -5
- package/fjs/protocol/mcp/module.f.d.mts +10 -13
- package/fjs/protocol/mcp/module.f.mjs +74 -58
- package/fjs/protocol/mcp/proof.f.d.mts +16 -3
- package/fjs/protocol/mcp/proof.f.mjs +224 -69
- package/fjs/protocol/mcp/stdio/module.f.d.mts +17 -11
- package/fjs/protocol/mcp/stdio/module.f.mjs +39 -33
- package/fjs/protocol/mcp/stdio/proof.f.d.mts +5 -3
- package/fjs/protocol/mcp/stdio/proof.f.mjs +46 -13
- package/fjs/protocol/mcp/stdio/types.d.ts +14 -0
- package/fjs/protocol/mcp/types.d.ts +17 -6
- package/fjs/sul/id/module.f.d.mts +4 -0
- package/fjs/sul/id/module.f.mjs +6 -6
- package/fjs/sul/level/hash/module.f.d.mts +4 -1
- package/fjs/sul/level/hash/module.f.mjs +6 -4
- package/fjs/sul/level/hash/proof.f.d.mts +4 -0
- package/fjs/sul/level/hash/proof.f.mjs +7 -4
- package/fjs/sul/level/literal/module.f.d.mts +4 -1
- package/fjs/sul/level/literal/module.f.mjs +4 -3
- package/fjs/sul/level/literal/proof.f.d.mts +3 -0
- package/fjs/sul/level/literal/proof.f.mjs +4 -1
- package/fjs/sul/module.f.d.mts +5 -3
- package/fjs/sul/module.f.mjs +23 -17
- package/fjs/sul/proof.f.d.mts +4 -0
- package/fjs/sul/proof.f.mjs +5 -2
- package/fjs/text/ascii/module.f.d.mts +26 -0
- package/fjs/text/ascii/module.f.mjs +49 -1
- package/fjs/text/ascii/proof.f.d.mts +10 -0
- package/fjs/text/ascii/proof.f.mjs +33 -1
- package/fjs/text/code_point/module.f.d.mts +29 -3
- package/fjs/text/code_point/module.f.mjs +32 -9
- package/fjs/text/code_point/proof.f.d.mts +2 -0
- package/fjs/text/code_point/proof.f.mjs +39 -0
- package/fjs/text/module.f.d.mts +4 -2
- package/fjs/text/module.f.mjs +4 -3
- package/fjs/text/proof.f.d.mts +3 -0
- package/fjs/text/proof.f.mjs +4 -1
- package/fjs/text/sgr/module.f.d.mts +6 -5
- package/fjs/text/sgr/module.f.mjs +8 -8
- package/fjs/text/sgr/proof.f.d.mts +3 -0
- package/fjs/text/sgr/proof.f.mjs +4 -1
- package/fjs/text/utf16/module.f.d.mts +5 -1
- package/fjs/text/utf16/module.f.mjs +38 -35
- package/fjs/text/utf16/proof.f.d.mts +3 -1
- package/fjs/text/utf16/proof.f.mjs +19 -2
- package/fjs/text/utf8/module.f.d.mts +9 -5
- package/fjs/text/utf8/module.f.mjs +20 -20
- package/fjs/types/array/module.f.d.mts +2 -1
- package/fjs/types/array/module.f.mjs +16 -4
- package/fjs/types/bigfloat/module.f.d.mts +21 -1
- package/fjs/types/bigfloat/module.f.mjs +33 -7
- package/fjs/types/bigfloat/proof.f.d.mts +1 -0
- package/fjs/types/bigfloat/proof.f.mjs +46 -0
- package/fjs/types/bigint/module.f.d.mts +4 -0
- package/fjs/types/bigint/module.f.mjs +4 -3
- package/fjs/types/bit_vec/module.f.d.mts +10 -16
- package/fjs/types/bit_vec/module.f.mjs +99 -95
- package/fjs/types/bit_vec/proof.f.d.mts +6 -0
- package/fjs/types/bit_vec/proof.f.mjs +31 -5
- package/fjs/types/btree/find/module.f.d.mts +5 -1
- package/fjs/types/btree/find/module.f.mjs +5 -5
- package/fjs/types/btree/find/proof.f.d.mts +5 -1
- package/fjs/types/btree/find/proof.f.mjs +5 -3
- package/fjs/types/btree/module.f.d.mts +3 -0
- package/fjs/types/btree/module.f.mjs +3 -2
- package/fjs/types/btree/proof.f.d.mts +5 -1
- package/fjs/types/btree/proof.f.mjs +5 -3
- package/fjs/types/btree/remove/module.f.d.mts +11 -0
- package/fjs/types/btree/remove/module.f.mjs +10 -10
- package/fjs/types/btree/remove/proof.f.d.mts +3 -0
- package/fjs/types/btree/remove/proof.f.mjs +4 -1
- package/fjs/types/btree/set/module.f.d.mts +9 -0
- package/fjs/types/btree/set/module.f.mjs +14 -17
- package/fjs/types/btree/set/proof.f.d.mts +3 -0
- package/fjs/types/btree/set/proof.f.mjs +16 -1
- package/fjs/types/btree/types/module.f.d.mts +2 -1
- package/fjs/types/btree/types/module.f.mjs +2 -1
- package/fjs/types/byte_set/module.f.d.mts +20 -4
- package/fjs/types/byte_set/module.f.mjs +18 -8
- package/fjs/types/byte_set/proof.f.d.mts +3 -1
- package/fjs/types/byte_set/proof.f.mjs +10 -8
- package/fjs/types/function/compare/module.f.d.mts +3 -2
- package/fjs/types/function/compare/module.f.mjs +13 -5
- package/fjs/types/function/module.f.d.mts +8 -1
- package/fjs/types/function/module.f.mjs +8 -1
- package/fjs/types/function/operator/module.f.d.mts +2 -1
- package/fjs/types/function/operator/module.f.mjs +2 -2
- package/fjs/types/list/module.f.d.mts +10 -3
- package/fjs/types/list/module.f.mjs +6 -4
- package/fjs/types/list/proof.f.d.mts +4 -1
- package/fjs/types/list/proof.f.mjs +4 -2
- package/fjs/types/nibble_set/module.f.d.mts +2 -1
- package/fjs/types/nibble_set/module.f.mjs +2 -2
- package/fjs/types/nominal/module.f.d.mts +2 -1
- package/fjs/types/nominal/module.f.mjs +2 -1
- package/fjs/types/nullable/module.f.d.mts +26 -6
- package/fjs/types/nullable/module.f.mjs +25 -6
- package/fjs/types/nullable/proof.f.d.mts +4 -0
- package/fjs/types/nullable/proof.f.mjs +15 -0
- package/fjs/types/number/module.f.d.mts +4 -0
- package/fjs/types/number/module.f.mjs +4 -3
- package/fjs/types/object/module.f.d.mts +26 -4
- package/fjs/types/object/module.f.mjs +26 -7
- package/fjs/types/object/proof.f.d.mts +5 -2
- package/fjs/types/object/proof.f.mjs +6 -3
- package/fjs/types/object/structurally_same/module.f.d.mts +39 -0
- package/fjs/types/object/structurally_same/module.f.mjs +59 -0
- package/fjs/types/object/structurally_same/proof.f.d.mts +6 -0
- package/fjs/types/object/structurally_same/proof.f.mjs +73 -0
- package/fjs/types/ordered_map/module.f.d.mts +5 -0
- package/fjs/types/ordered_map/module.f.mjs +5 -4
- package/fjs/types/ordered_map/proof.f.d.mts +3 -0
- package/fjs/types/ordered_map/proof.f.mjs +4 -1
- package/fjs/types/patricia_trie/module.f.d.mts +2 -1
- package/fjs/types/patricia_trie/module.f.mjs +27 -12
- package/fjs/types/patricia_trie/proof.f.d.mts +3 -0
- package/fjs/types/patricia_trie/proof.f.mjs +4 -1
- package/fjs/types/prime_field/module.f.d.mts +3 -1
- package/fjs/types/prime_field/module.f.mjs +3 -2
- package/fjs/types/range/module.f.d.mts +2 -1
- package/fjs/types/range/module.f.mjs +2 -2
- package/fjs/types/range_map/module.f.d.mts +6 -0
- package/fjs/types/range_map/module.f.mjs +6 -9
- package/fjs/types/range_map/proof.f.d.mts +5 -1
- package/fjs/types/range_map/proof.f.mjs +5 -3
- package/fjs/types/range_set/module.f.d.mts +5 -0
- package/fjs/types/range_set/module.f.mjs +1 -0
- package/fjs/types/range_set/proof.f.d.mts +3 -0
- package/fjs/types/range_set/proof.f.mjs +4 -1
- package/fjs/types/result/module.d.mts +8 -0
- package/fjs/types/result/module.f.d.mts +37 -7
- package/fjs/types/result/module.f.mjs +38 -8
- package/fjs/types/result/module.mjs +9 -1
- package/fjs/types/result/proof.f.d.mts +5 -0
- package/fjs/types/result/proof.f.mjs +22 -2
- package/fjs/types/rtti/common/module.f.d.mts +44 -14
- package/fjs/types/rtti/common/module.f.mjs +42 -36
- package/fjs/types/rtti/common/proof.f.d.mts +4 -0
- package/fjs/types/rtti/common/proof.f.mjs +10 -7
- package/fjs/types/rtti/data/module.f.d.mts +134 -0
- package/fjs/types/rtti/data/module.f.mjs +1053 -0
- package/fjs/types/rtti/data/proof.f.d.mts +76 -0
- package/fjs/types/rtti/data/proof.f.mjs +589 -0
- package/fjs/types/rtti/data/types.d.ts +83 -0
- package/fjs/types/rtti/module.f.d.mts +12 -5
- package/fjs/types/rtti/module.f.mjs +7 -5
- package/fjs/types/rtti/parse/module.f.d.mts +48 -0
- package/fjs/types/rtti/parse/module.f.mjs +45 -34
- package/fjs/types/rtti/parse/proof.f.d.mts +3 -2
- package/fjs/types/rtti/parse/proof.f.mjs +51 -52
- package/fjs/types/rtti/proof.f.d.mts +3 -1
- package/fjs/types/rtti/proof.f.mjs +6 -2
- package/fjs/types/rtti/ts/module.f.d.mts +68 -9
- package/fjs/types/rtti/ts/module.f.mjs +258 -30
- package/fjs/types/rtti/ts/proof.f.d.mts +44 -0
- package/fjs/types/rtti/ts/proof.f.mjs +152 -4
- package/fjs/types/rtti/ts/types.d.ts +25 -1
- package/fjs/types/rtti/types.d.ts +40 -0
- package/fjs/types/sorted_list/module.f.d.mts +4 -1
- package/fjs/types/sorted_list/module.f.mjs +21 -12
- package/fjs/types/sorted_list/proof.f.d.mts +3 -1
- package/fjs/types/sorted_list/proof.f.mjs +3 -1
- package/fjs/types/sorted_set/module.f.d.mts +49 -1
- package/fjs/types/sorted_set/module.f.mjs +26 -2
- package/fjs/types/sorted_set/proof.f.d.mts +4 -1
- package/fjs/types/sorted_set/proof.f.mjs +19 -2
- package/fjs/types/string/module.f.d.mts +4 -0
- package/fjs/types/string/module.f.mjs +4 -3
- package/fjs/types/string_set/module.f.d.mts +3 -1
- package/fjs/types/string_set/module.f.mjs +3 -2
- package/fjs/types/ts/module.f.d.mts +2 -0
- package/fjs/types/ts/module.f.mjs +3 -3
- package/fjs/types/ts/proof.f.d.mts +1 -0
- package/fjs/types/ts/proof.f.mjs +5 -0
- package/fjs/types/ts/types.d.ts +6 -1
- package/fjs/types/uint8array/module.f.d.mts +13 -2
- package/fjs/types/uint8array/module.f.mjs +20 -15
- package/fjs/website/module.f.d.mts +5 -2
- package/fjs/website/module.f.mjs +6 -8
- package/fjs/website/proof.f.mjs +2 -1
- package/package.json +3 -3
- package/fjs/asn.1/types.js +0 -6
- package/fjs/asserts/types.js +0 -6
- package/fjs/basen/types.js +0 -6
- package/fjs/bnf/data/types.js +0 -6
- package/fjs/bnf/descent/types.js +0 -6
- package/fjs/bnf/ll1/types.js +0 -6
- package/fjs/bnf/token_symbol/types.js +0 -6
- package/fjs/bnf/types.js +0 -6
- package/fjs/cas/evo/types.js +0 -7
- package/fjs/cas/types.js +0 -6
- package/fjs/ci/common/types.js +0 -1
- package/fjs/ci/nix/types.js +0 -6
- package/fjs/ci/types.js +0 -6
- package/fjs/cli/types.js +0 -6
- package/fjs/common/monoid/types.js +0 -6
- package/fjs/crypto/pow/types.js +0 -6
- package/fjs/crypto/secp/types.js +0 -6
- package/fjs/crypto/sha2/types.js +0 -6
- package/fjs/crypto/sign/types.js +0 -6
- package/fjs/crypto/vdf/types.js +0 -6
- package/fjs/dev/package_json/module.f.d.mts +0 -32
- package/fjs/dev/package_json/module.f.mjs +0 -37
- package/fjs/dev/package_json/proof.f.d.mts +0 -6
- package/fjs/dev/package_json/proof.f.mjs +0 -32
- package/fjs/dev/types.js +0 -6
- package/fjs/djs/ast/types.js +0 -8
- package/fjs/djs/parser/types.js +0 -7
- package/fjs/djs/tokenizer/types.js +0 -7
- package/fjs/djs/types.js +0 -7
- package/fjs/effects/eff/module.f.d.mts +0 -10
- package/fjs/effects/eff/module.f.mjs +0 -68
- package/fjs/effects/eff/proof.f.d.mts +0 -12
- package/fjs/effects/eff/proof.f.mjs +0 -66
- package/fjs/effects/eff/types.d.ts +0 -71
- package/fjs/effects/eff/types.js +0 -6
- package/fjs/effects/list/types.js +0 -6
- package/fjs/effects/memory/types.js +0 -6
- package/fjs/effects/mock/types.js +0 -6
- package/fjs/effects/node/types.js +0 -6
- package/fjs/effects/node/virtual/types.js +0 -7
- package/fjs/effects/types.js +0 -6
- package/fjs/emergent_testing/all.test.d.ts +0 -1
- package/fjs/emergent_testing/all.test.js +0 -5
- package/fjs/emergent_testing/scenarios/all.d.ts +0 -1
- package/fjs/emergent_testing/scenarios/all.js +0 -1
- package/fjs/emergent_testing/scenarios/async-subtests.fail.d.ts +0 -6
- package/fjs/emergent_testing/scenarios/async-subtests.fail.js +0 -9
- package/fjs/emergent_testing/scenarios/async-subtests.pass.d.ts +0 -6
- package/fjs/emergent_testing/scenarios/async-subtests.pass.js +0 -9
- package/fjs/emergent_testing/scenarios/async.fail.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/async.fail.js +0 -6
- package/fjs/emergent_testing/scenarios/async.pass.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/async.pass.js +0 -5
- package/fjs/emergent_testing/scenarios/fail.fail.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/fail.fail.js +0 -3
- package/fjs/emergent_testing/scenarios/return-value.pass.js +0 -4
- package/fjs/emergent_testing/scenarios/thenable.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/thenable.pass.js +0 -11
- package/fjs/emergent_testing/scenarios/thenable2.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/thenable2.pass.js +0 -3
- package/fjs/emergent_testing/scenarios/throw.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/throw.pass.js +0 -3
- package/fjs/emergent_testing/types.js +0 -6
- package/fjs/js/tokenizer/types.js +0 -6
- package/fjs/media/html/types.js +0 -6
- package/fjs/media/json/parser/types.js +0 -6
- package/fjs/media/json/tokenizer/types.js +0 -6
- package/fjs/media/json/types.js +0 -13
- package/fjs/media/nix/types.js +0 -6
- package/fjs/media/revision/types.js +0 -8
- package/fjs/media/type/types.js +0 -6
- package/fjs/media/types.js +0 -7
- package/fjs/nanvm/types.js +0 -11
- package/fjs/protocol/json_rpc/types.js +0 -8
- package/fjs/protocol/mcp/types.js +0 -8
- package/fjs/sul/id/types.js +0 -6
- package/fjs/sul/level/hash/types.js +0 -6
- package/fjs/sul/level/literal/types.js +0 -6
- package/fjs/sul/types.js +0 -6
- package/fjs/text/sgr/types.js +0 -6
- package/fjs/text/types.js +0 -6
- package/fjs/text/utf16/types.js +0 -6
- package/fjs/text/utf8/types.js +0 -6
- package/fjs/types/array/types.js +0 -6
- package/fjs/types/bigfloat/types.js +0 -6
- package/fjs/types/bigint/types.js +0 -6
- package/fjs/types/bit_vec/types.js +0 -6
- package/fjs/types/btree/find/types.js +0 -6
- package/fjs/types/btree/types/types.js +0 -6
- package/fjs/types/byte_set/types.js +0 -6
- package/fjs/types/function/compare/types.js +0 -6
- package/fjs/types/function/operator/types.js +0 -6
- package/fjs/types/function/types.js +0 -6
- package/fjs/types/list/types.js +0 -6
- package/fjs/types/nibble_set/types.js +0 -6
- package/fjs/types/nominal/types.js +0 -6
- package/fjs/types/nullable/types.js +0 -6
- package/fjs/types/object/types.js +0 -8
- package/fjs/types/option/types.js +0 -6
- package/fjs/types/ordered_map/types.js +0 -6
- package/fjs/types/patricia_trie/types.js +0 -6
- package/fjs/types/phantom/types.js +0 -11
- package/fjs/types/prime_field/types.js +0 -6
- package/fjs/types/range/types.js +0 -6
- package/fjs/types/range_map/types.js +0 -6
- package/fjs/types/result/types.js +0 -6
- package/fjs/types/rtti/common/types.js +0 -1
- package/fjs/types/rtti/parse/types.js +0 -1
- package/fjs/types/rtti/ts/types.js +0 -1
- package/fjs/types/rtti/types.js +0 -1
- package/fjs/types/rtti/validate/module.f.d.mts +0 -6
- package/fjs/types/rtti/validate/module.f.mjs +0 -169
- package/fjs/types/rtti/validate/proof.f.d.mts +0 -125
- package/fjs/types/rtti/validate/proof.f.mjs +0 -437
- package/fjs/types/rtti/validate/types.d.ts +0 -6
- package/fjs/types/rtti/validate/types.js +0 -1
- package/fjs/types/sorted_list/types.js +0 -6
- package/fjs/types/sorted_set/types.js +0 -6
- package/fjs/types/string_set/types.js +0 -6
- package/fjs/types/ts/types.js +0 -8
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import {
|
|
3
|
-
* @import {
|
|
2
|
+
* @import { RunInstance } from '../effects/mock/types.ts'
|
|
3
|
+
* @import { Effect, NotImplemented } from '../effects/types.ts'
|
|
4
|
+
* @import { NodeProgramOptions, OpResult, Sandbox, Write } from '../effects/node/types.ts'
|
|
4
5
|
* @import { JsModule } from '../effects/node/virtual/types.ts'
|
|
5
6
|
* @import { Reporter } from './types.ts'
|
|
6
|
-
* @import { All, Await, Test, TestContext } from '../effects/node/types.ts'
|
|
7
|
+
* @import { All, Await, Import, Readdir, Test, TestContext } from '../effects/node/types.ts'
|
|
7
8
|
* @import { Ts } from '../types/rtti/ts/types.ts'
|
|
8
9
|
*/
|
|
9
10
|
|
|
11
|
+
import { exitCode } from '../effects/node/module.f.mjs'
|
|
10
12
|
import { log } from '../effects/node/module.f.mjs'
|
|
11
13
|
import { defaultNodeProgramOptions, emptyState, virtual } from '../effects/node/virtual/module.f.mjs'
|
|
12
|
-
import { assert, assertEq } from '../asserts/module.f.mjs'
|
|
14
|
+
import { assert, assertEq, todo } from '../asserts/module.f.mjs'
|
|
13
15
|
import {
|
|
14
|
-
testAll,
|
|
16
|
+
testAll, fmtPath, fmtTerm, fmtImport, ghEscape, isInteger, isIdentifier,
|
|
15
17
|
registerModule, parseTestSet,
|
|
16
|
-
defaultTest,
|
|
18
|
+
defaultTest, main, register,
|
|
17
19
|
} from './module.f.mjs'
|
|
18
20
|
import { run as mockRun } from '../effects/mock/module.f.mjs'
|
|
19
21
|
import { shouldLoad } from '../dev/module.f.mjs'
|
|
20
22
|
import { parse as parseJson } from '../media/json/module.f.mjs'
|
|
21
23
|
import { array, number as rttiNumber, or, string as rttiString } from '../types/rtti/module.f.mjs'
|
|
22
24
|
import { parse as rttiParse } from '../types/rtti/parse/module.f.mjs'
|
|
23
|
-
import { unwrap } from '../types/result/module.f.mjs'
|
|
25
|
+
import { error, ok, unwrap } from '../types/result/module.f.mjs'
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* The mock reporter's stdout lines. A schema rather than a hand-written type:
|
|
@@ -43,7 +45,7 @@ const parseEvent = rttiParse(event)
|
|
|
43
45
|
|
|
44
46
|
/** @typedef {Reporter<Sandbox | Write>} _TestReporter */
|
|
45
47
|
|
|
46
|
-
/** @type {(e: _Event) =>
|
|
48
|
+
/** @type {(e: _Event) => Effect<Write, void, NotImplemented>} */
|
|
47
49
|
const writeEvent = e => log(JSON.stringify(e))
|
|
48
50
|
|
|
49
51
|
/** @type {(stdout: string) => readonly _Event[]} */
|
|
@@ -75,18 +77,18 @@ const ok1 = () => ({ result: /** @type {const} */ (['ok', undefined]), duration:
|
|
|
75
77
|
const run = (dir, initCwd = '.') => {
|
|
76
78
|
const reporter = makeReporter()
|
|
77
79
|
const state = { ...emptyState, root: dir }
|
|
78
|
-
const [finalState,
|
|
79
|
-
return [parseEvents(finalState.stdout), exitCode]
|
|
80
|
+
const [finalState, code] = virtual(state)(testAll(reporter)(options(initCwd)))
|
|
81
|
+
return [parseEvents(finalState.stdout), exitCode(code)]
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
// Runs the
|
|
83
|
-
// terminal and GitHub output formats can be asserted directly.
|
|
84
|
+
// Runs the `fjs t` entry point (`main`) and returns its captured stdout/stderr
|
|
85
|
+
// so the terminal and GitHub output formats can be asserted directly.
|
|
84
86
|
/** @type {(dir: Record<string, JsModule>, github?: boolean) => readonly [string, string, number]} */
|
|
85
87
|
const runMain = (dir, github = false) => {
|
|
86
88
|
const state = { ...emptyState, root: dir }
|
|
87
89
|
const opts = options('.', github)
|
|
88
|
-
const [finalState,
|
|
89
|
-
return [finalState.stdout, finalState.stderr, exitCode]
|
|
90
|
+
const [finalState, code] = virtual(state)(main(opts))
|
|
91
|
+
return [finalState.stdout, finalState.stderr, exitCode(code)]
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
// flat object: two passing tests
|
|
@@ -166,10 +168,10 @@ export const returnValueSubTree = () => {
|
|
|
166
168
|
const [events, exit] = run({
|
|
167
169
|
'r.proof.f.ts': () => ({
|
|
168
170
|
proof: {
|
|
169
|
-
outer:
|
|
171
|
+
outer: () => ({
|
|
170
172
|
result: /** @type {const} */ (['ok', { inner }]),
|
|
171
173
|
duration: 0,
|
|
172
|
-
})
|
|
174
|
+
}),
|
|
173
175
|
}
|
|
174
176
|
}),
|
|
175
177
|
})
|
|
@@ -299,13 +301,45 @@ export const githubReporterOutput = () => {
|
|
|
299
301
|
)
|
|
300
302
|
}
|
|
301
303
|
|
|
304
|
+
/** @typedef {All | Import | Readdir | Sandbox | Write} _FailOps */
|
|
305
|
+
|
|
306
|
+
// A reporter that cannot write neither panics nor reports success. The failed
|
|
307
|
+
// `result` line short-circuits its own test, leaves `allOk` as the first error,
|
|
308
|
+
// skips the summary, and reaches the program tail — which answers exit `1`.
|
|
309
|
+
//
|
|
310
|
+
// `write` fails for every stream here, including the one `errorExit` reports
|
|
311
|
+
// the failure on, so the exit code rather than a message is what is observable:
|
|
312
|
+
// a run that cannot say anything at all still says it failed.
|
|
313
|
+
export const reporterWriteFailure = () => {
|
|
314
|
+
/** @type {RunInstance<_FailOps, undefined>} */
|
|
315
|
+
let runner
|
|
316
|
+
runner = mockRun(/** @type {Parameters<typeof mockRun<_FailOps, undefined>>[0]} */ ({
|
|
317
|
+
readdir: (_path, _o) => s => [s, ok([{ name: 'a.proof.f.ts', parentPath: '.', isFile: true }])],
|
|
318
|
+
import: _path => s => [s, ok({ proof: { x: () => { } } })],
|
|
319
|
+
all: (...effects) => s => {
|
|
320
|
+
const [st, rs] = effects.reduce(
|
|
321
|
+
([st1, rs1], e) => {
|
|
322
|
+
const [ns, r] = runner(st1)(e)
|
|
323
|
+
return [ns, [...rs1, r]]
|
|
324
|
+
},
|
|
325
|
+
/** @type {readonly [undefined, readonly unknown[]]} */([s, []]),
|
|
326
|
+
)
|
|
327
|
+
return [st, ok(rs)]
|
|
328
|
+
},
|
|
329
|
+
sandbox: (/** @type {() => unknown} */ f) => (/** @type {undefined} */ s) =>
|
|
330
|
+
[s, ok({ result: ok(f()), duration: 0 })],
|
|
331
|
+
write: (_stream, _data) => s => [s, error(/** @type {const} */(['notImplemented', 'write']))],
|
|
332
|
+
}))
|
|
333
|
+
const [, code] = runner(undefined)(
|
|
334
|
+
/** @type {Effect<_FailOps, 0, number>} */(main(options('.'))))
|
|
335
|
+
assertEq(exitCode(code), 1)
|
|
336
|
+
}
|
|
337
|
+
|
|
302
338
|
/** @typedef {readonly string[]} _RegisterMockState */
|
|
303
339
|
|
|
304
340
|
/** @typedef {Test | All | Await} _RegisterMockOps */
|
|
305
341
|
|
|
306
|
-
/**
|
|
307
|
-
* @typedef {(s: _RegisterMockState) => <T>(e: Effect<_RegisterMockOps, T>) => readonly [_RegisterMockState, T]} _RegisterRunner
|
|
308
|
-
*/
|
|
342
|
+
/** @typedef {RunInstance<_RegisterMockOps, _RegisterMockState>} _RegisterRunner */
|
|
309
343
|
|
|
310
344
|
/**
|
|
311
345
|
* The `test` op body for a `registerModule` mock; `runner` is threaded in explicitly (rather than closed over) so it can recurse into sub-effects returned by `fn`.
|
|
@@ -314,8 +348,8 @@ export const githubReporterOutput = () => {
|
|
|
314
348
|
* ctx: TestContext,
|
|
315
349
|
* name: string,
|
|
316
350
|
* expectFailure: boolean,
|
|
317
|
-
* fn: (t: TestContext) => Effect<_RegisterMockOps, void>,
|
|
318
|
-
* ) => (s: _RegisterMockState) => readonly [_RegisterMockState, void]} _RegisterTestOp
|
|
351
|
+
* fn: (t: TestContext) => Effect<_RegisterMockOps, void, never>,
|
|
352
|
+
* ) => (s: _RegisterMockState) => readonly [_RegisterMockState, OpResult<void>]} _RegisterTestOp
|
|
319
353
|
*/
|
|
320
354
|
|
|
321
355
|
/** @type {TestContext} */
|
|
@@ -332,15 +366,17 @@ const makeRegisterRunner = testOp => {
|
|
|
332
366
|
let runner
|
|
333
367
|
runner = mockRun(/** @type {Parameters<typeof mockRun<_RegisterMockOps, _RegisterMockState>>[0]} */ ({
|
|
334
368
|
test: (ctx, name, xf, fn) => testOp(runner, ctx, name, xf, fn),
|
|
335
|
-
all: (...effects) => s =>
|
|
336
|
-
effects.reduce(
|
|
337
|
-
([
|
|
338
|
-
const [ns, r] = runner(
|
|
339
|
-
return
|
|
369
|
+
all: (...effects) => s => {
|
|
370
|
+
const [st, rs] = effects.reduce(
|
|
371
|
+
([st1, rs1], e) => {
|
|
372
|
+
const [ns, r] = runner(st1)(e)
|
|
373
|
+
return [ns, [...rs1, r]]
|
|
340
374
|
},
|
|
341
375
|
/** @type {readonly [_RegisterMockState, readonly unknown[]]} */ ([s, []]),
|
|
342
|
-
)
|
|
343
|
-
|
|
376
|
+
)
|
|
377
|
+
return [st, ok(rs)]
|
|
378
|
+
},
|
|
379
|
+
await: p => s => /** @type {const} */ ([s, ok([p])]),
|
|
344
380
|
}))
|
|
345
381
|
return runner
|
|
346
382
|
}
|
|
@@ -348,7 +384,7 @@ const makeRegisterRunner = testOp => {
|
|
|
348
384
|
// registerModule appends ' ...' for inline runners (Bun).
|
|
349
385
|
// This mock never invokes the registered callback; it only records names.
|
|
350
386
|
export const registerSuffixes = () => {
|
|
351
|
-
const runner = makeRegisterRunner((_runner, _ctx, name, _xf, _fn) => s => [[...s, name], undefined])
|
|
387
|
+
const runner = makeRegisterRunner((_runner, _ctx, name, _xf, _fn) => s => [[...s, name], ok(undefined)])
|
|
352
388
|
|
|
353
389
|
const proof = /** @type {const} */ ({
|
|
354
390
|
ok: () => {},
|
|
@@ -368,6 +404,33 @@ export const registerSuffixes = () => {
|
|
|
368
404
|
assertEq(inlineNames[1], 'import("./a.f.ts").proof.throw.a()')
|
|
369
405
|
}
|
|
370
406
|
|
|
407
|
+
// The registered callback panics when its own effects cannot be dispatched.
|
|
408
|
+
// `Test` hands the body to an external framework that reads a throw and
|
|
409
|
+
// nothing else, so a body that could not run must not be reported as a pass —
|
|
410
|
+
// which is why `registerOne` ends in a `catchStep` that throws rather than in
|
|
411
|
+
// a channel nobody reads.
|
|
412
|
+
const registerBodyPanicsOnUndispatchableEffect = () => {
|
|
413
|
+
/** @type {_RegisterRunner} */
|
|
414
|
+
let runner
|
|
415
|
+
runner = mockRun(/** @type {Parameters<typeof mockRun<_RegisterMockOps, _RegisterMockState>>[0]} */ ({
|
|
416
|
+
test: (ctx, _name, _xf, fn) => s => [runner(s)(fn(ctx))[0], ok(undefined)],
|
|
417
|
+
all: (...effects) => s => {
|
|
418
|
+
const [st, rs] = effects.reduce(
|
|
419
|
+
([st1, rs1], e) => {
|
|
420
|
+
const [ns, r] = runner(st1)(e)
|
|
421
|
+
return [ns, [...rs1, r]]
|
|
422
|
+
},
|
|
423
|
+
/** @type {readonly [_RegisterMockState, readonly unknown[]]} */ ([s, []]),
|
|
424
|
+
)
|
|
425
|
+
return [st, ok(rs)]
|
|
426
|
+
},
|
|
427
|
+
// The runner has no `await`, which is what the body's channel carries.
|
|
428
|
+
await: _p => s => [s, error(/** @type {const} */ (['notImplemented', 'await']))],
|
|
429
|
+
}))
|
|
430
|
+
const proof = /** @type {const} */ ({ a: () => Promise.resolve(undefined) })
|
|
431
|
+
runner([])(registerModule(registerNoopCtx, './a.f.ts', proof, ''))
|
|
432
|
+
}
|
|
433
|
+
|
|
371
434
|
// A `throw`-tagged test whose function completes without throwing (the
|
|
372
435
|
// external framework, not this module, is responsible for turning that into
|
|
373
436
|
// a failure via `expectFailure`). registerModule's own callback must still
|
|
@@ -381,7 +444,7 @@ export const registerThrowsWithoutThrowing = () => {
|
|
|
381
444
|
const runner = makeRegisterRunner((runner, ctx, name, xf, fn) => s => {
|
|
382
445
|
assert(xf)
|
|
383
446
|
const [ns] = runner(s)(fn(ctx))
|
|
384
|
-
return [[...ns, name], undefined]
|
|
447
|
+
return [[...ns, name], ok(undefined)]
|
|
385
448
|
})
|
|
386
449
|
|
|
387
450
|
// Returns a sub-tree that would register more tests if it were walked.
|
|
@@ -396,11 +459,76 @@ export const registerThrowsWithoutThrowing = () => {
|
|
|
396
459
|
// registerModule with an empty proof object registers zero tests and
|
|
397
460
|
// returns without invoking the mock's `test` op at all.
|
|
398
461
|
export const registerEmptyProof = () => {
|
|
399
|
-
const runner = makeRegisterRunner((_runner, _ctx, name, _xf, _fn) => s => [[...s, name], undefined])
|
|
462
|
+
const runner = makeRegisterRunner((_runner, _ctx, name, _xf, _fn) => s => [[...s, name], ok(undefined)])
|
|
400
463
|
const [names] = runner([])(registerModule(registerNoopCtx, './a.f.ts', {}, ''))
|
|
401
464
|
assertEq(names.length, 0)
|
|
402
465
|
}
|
|
403
466
|
|
|
467
|
+
// register (the NodeProgram entry point) against an empty virtual root: no
|
|
468
|
+
// modules to register means registerModuleMap short-circuits before ever
|
|
469
|
+
// calling the selected TestContext's `test` op, so this reaches that branch
|
|
470
|
+
// without hitting the virtual harness's `test: todo` stub.
|
|
471
|
+
export const registerEmptyModuleMap = () => {
|
|
472
|
+
const state = { ...emptyState, root: {} }
|
|
473
|
+
const [, code] = virtual(state)(register(options('.')))
|
|
474
|
+
assertEq(exitCode(code), 0)
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// register's `star`/`ctx` selection, proven observably: the virtual harness's
|
|
478
|
+
// own `test` op is `todo`, so a non-empty root can't go through `virtual()`
|
|
479
|
+
// here without throwing. Instead this interprets register's effect with a
|
|
480
|
+
// fully synthetic runner (discovery faked via `readdir`/`import`, mirroring
|
|
481
|
+
// makeRegisterRunner's approach to `test`/`all`/`await`) that records which
|
|
482
|
+
// TestContext object and which registered name each `test` call received —
|
|
483
|
+
// so a swapped `engine` ternary or a deleted `inlineTestContext` branch
|
|
484
|
+
// changes what's observed here, not just whether the line ran.
|
|
485
|
+
export const registerSelectsContextAndStar = () => {
|
|
486
|
+
/** @type {TestContext} */
|
|
487
|
+
const nodeCtx = { test: todo }
|
|
488
|
+
/** @type {TestContext} */
|
|
489
|
+
const bunCtx = { test: todo }
|
|
490
|
+
|
|
491
|
+
/** @type {(extra: Partial<NodeProgramOptions>) => readonly (readonly [TestContext, string])[]} */
|
|
492
|
+
const runRegister = extra => {
|
|
493
|
+
/** @type {(readonly [TestContext, string])[]} */
|
|
494
|
+
let calls = []
|
|
495
|
+
/** @type {RunInstance<_RegisterMockOps | Readdir | Import, undefined>} */
|
|
496
|
+
let runner
|
|
497
|
+
runner = mockRun(/** @type {Parameters<typeof mockRun<_RegisterMockOps | Readdir | Import, undefined>>[0]} */ ({
|
|
498
|
+
readdir: (_path, _o) => s => [s, ok([{ name: 'a.proof.f.ts', parentPath: '.', isFile: true }])],
|
|
499
|
+
import: _path => s => [s, ok({ proof: { ok: () => {} } })],
|
|
500
|
+
all: (...effects) => s => {
|
|
501
|
+
const [st, rs] = effects.reduce(
|
|
502
|
+
([st1, rs1], e) => {
|
|
503
|
+
const [ns, r] = runner(st1)(e)
|
|
504
|
+
return [ns, [...rs1, r]]
|
|
505
|
+
},
|
|
506
|
+
/** @type {readonly [undefined, readonly unknown[]]} */ ([s, []]),
|
|
507
|
+
)
|
|
508
|
+
return [st, ok(rs)]
|
|
509
|
+
},
|
|
510
|
+
await: p => s => [s, ok([p])],
|
|
511
|
+
test: (ctx, name, _xf, _fn) => s => { calls = [...calls, [ctx, name]]; return [s, ok(undefined)] },
|
|
512
|
+
}))
|
|
513
|
+
runner(undefined)(/** @type {Effect<_RegisterMockOps | Readdir | Import, 0, number>} */ (register({
|
|
514
|
+
...defaultNodeProgramOptions, env: {}, testContext: nodeCtx, bunTestContext: bunCtx, ...extra,
|
|
515
|
+
})))
|
|
516
|
+
return calls
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Node engine, non-inline context: registers under nodeCtx, no ' ...' suffix.
|
|
520
|
+
const nodeCalls = runRegister({})
|
|
521
|
+
assertEq(nodeCalls.length, 1)
|
|
522
|
+
assert(nodeCalls[0][0] === nodeCtx)
|
|
523
|
+
assertEq(nodeCalls[0][1], 'import("./a.proof.f.ts").proof.ok()')
|
|
524
|
+
|
|
525
|
+
// Bun engine, inline context: registers under bunCtx, with ' ...' suffix.
|
|
526
|
+
const bunCalls = runRegister({ inlineTestContext: true, engine: 'bun' })
|
|
527
|
+
assertEq(bunCalls.length, 1)
|
|
528
|
+
assert(bunCalls[0][0] === bunCtx)
|
|
529
|
+
assertEq(bunCalls[0][1], 'import("./a.proof.f.ts").proof.ok() ...')
|
|
530
|
+
}
|
|
531
|
+
|
|
404
532
|
// direct unit tests for the pure path-format helpers
|
|
405
533
|
export const helpers = {
|
|
406
534
|
isInteger: () => {
|
|
@@ -472,13 +600,13 @@ export const helpers = {
|
|
|
472
600
|
parseTestSet: {
|
|
473
601
|
nullReturnsEmpty: () => {
|
|
474
602
|
const result = parseTestSet(false, null)
|
|
475
|
-
|
|
476
|
-
assertEq(
|
|
603
|
+
assert(result instanceof Array, result)
|
|
604
|
+
assertEq(result.length, 0)
|
|
477
605
|
},
|
|
478
606
|
functionWithParamsReturnsEmpty: () => {
|
|
479
607
|
const result = parseTestSet(false, (/** @type {number} */ _x) => _x)
|
|
480
|
-
|
|
481
|
-
assertEq(
|
|
608
|
+
assert(result instanceof Array, result)
|
|
609
|
+
assertEq(result.length, 0)
|
|
482
610
|
},
|
|
483
611
|
},
|
|
484
612
|
}
|
|
@@ -495,6 +623,9 @@ const defaultReporterExpectedToThrow = () => {
|
|
|
495
623
|
}
|
|
496
624
|
|
|
497
625
|
export const proof = {
|
|
626
|
+
throw: {
|
|
627
|
+
registerBodyPanicsOnUndispatchableEffect,
|
|
628
|
+
},
|
|
498
629
|
flat,
|
|
499
630
|
nested,
|
|
500
631
|
throwKey,
|
|
@@ -510,9 +641,12 @@ export const proof = {
|
|
|
510
641
|
defaultReporterOutputLargeDuration,
|
|
511
642
|
defaultReporterFailOutput,
|
|
512
643
|
githubReporterOutput,
|
|
644
|
+
reporterWriteFailure,
|
|
513
645
|
registerSuffixes,
|
|
514
646
|
registerThrowsWithoutThrowing,
|
|
515
647
|
registerEmptyProof,
|
|
648
|
+
registerEmptyModuleMap,
|
|
649
|
+
registerSelectsContextAndStar,
|
|
516
650
|
defaultReporterExpectedToThrow,
|
|
517
651
|
helpers
|
|
518
652
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import type { Effect, Operation } from '../effects/types.ts';
|
|
7
|
-
import type { SandboxResult } from '../effects/node/types.ts';
|
|
7
|
+
import type { IoChannel, SandboxResult } from '../effects/node/types.ts';
|
|
8
8
|
/** A zero-argument test function whose return value may contain sub-tests. */
|
|
9
9
|
export type TestFn = () => unknown;
|
|
10
10
|
/**
|
|
@@ -37,11 +37,29 @@ export type Path = readonly (string | null)[];
|
|
|
37
37
|
* leading to the current location; `null` marks a function-call boundary, e.g.
|
|
38
38
|
* `['outer', null, 'inner']` means `outer` was invoked and its return value
|
|
39
39
|
* contained `inner`.
|
|
40
|
+
*
|
|
41
|
+
* **Every method is fallible**, because reporting is IO and IO can fail: a
|
|
42
|
+
* write to a closed pipe, a runner that cannot dispatch `write` at all. The
|
|
43
|
+
* runner propagates what a method answers, so a reporter that cannot emit ends
|
|
44
|
+
* the run rather than being silently ignored.
|
|
45
|
+
*
|
|
46
|
+
* `result` and `summary` in particular *must* carry their `Result` in the type.
|
|
47
|
+
* They used to answer a raw effect of `void`, and TypeScript accepts an effect of
|
|
48
|
+
* any value type where a `void` one is expected — so an implementation whose
|
|
49
|
+
* writes were fallible type-checked while its failures went nowhere. That is
|
|
50
|
+
* the hazard the error channel exists to remove, and a `void` return position hides
|
|
51
|
+
* it exactly where a reporter's whole job is to perform IO.
|
|
52
|
+
*
|
|
53
|
+
* The channel is the standard node one ({@link IoChannel}) rather than a type
|
|
54
|
+
* parameter: a reporter is free in which *operations* it performs, but it fails
|
|
55
|
+
* the way node IO fails, and pinning it here keeps the type — and the program
|
|
56
|
+
* tail that reports it — free of a parameter every caller would have to thread
|
|
57
|
+
* through unchanged.
|
|
40
58
|
*/
|
|
41
59
|
export type Reporter<O extends Operation> = {
|
|
42
|
-
readonly result: (file: string, path: Path, r: SandboxResult<unknown>, throws: boolean) => Effect<O, void>;
|
|
43
|
-
readonly summary: (pass: number, fail: number, time: number) => Effect<O, void>;
|
|
44
|
-
readonly test: (file: string, path: Path, set: TestEntry) => Effect<O, SandboxResult<unknown
|
|
60
|
+
readonly result: (file: string, path: Path, r: SandboxResult<unknown>, throws: boolean) => Effect<O, void, IoChannel>;
|
|
61
|
+
readonly summary: (pass: number, fail: number, time: number) => Effect<O, void, IoChannel>;
|
|
62
|
+
readonly test: (file: string, path: Path, set: TestEntry) => Effect<O, SandboxResult<unknown>, IoChannel>;
|
|
45
63
|
};
|
|
46
64
|
/** @internal */
|
|
47
65
|
export type _TestState = {
|
package/fjs/fsc/bnf.f.d.mts
CHANGED
package/fjs/fsc/bnf.f.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { Rule } from '../bnf/types.ts'
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { range, remove, set, option } from '../bnf/module.f.mjs'
|
|
2
|
-
/** @import { Rule } from '../bnf/types.ts' */
|
|
3
6
|
import { digit, json, unicode, ws0, ws1, wsNoNewLine0 } from './json.f.mjs'
|
|
4
7
|
|
|
5
8
|
/** @type {Rule} */
|
package/fjs/fsc/json.f.d.mts
CHANGED
package/fjs/fsc/json.f.mjs
CHANGED
package/fjs/fsc/module.f.d.mts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FunctionalScript command utilities for compile workflows.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*
|
|
6
|
+
* @import { RangeMapArray, RangeMerge } from '../types/range_map/types.ts'
|
|
7
|
+
* @import { List } from '../types/list/types.ts'
|
|
8
|
+
* @import { Range } from '../types/range/types.ts'
|
|
9
|
+
*/
|
|
1
10
|
import type { RangeMapArray } from '../types/range_map/types.ts';
|
|
2
11
|
export type _Result = readonly [readonly string[], _ToResult];
|
|
3
12
|
export type _ToResult = (codePoint: number) => _Result;
|
package/fjs/fsc/module.f.mjs
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
* FunctionalScript command utilities for compile workflows.
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
|
+
*
|
|
6
|
+
* @import { RangeMapArray, RangeMerge } from '../types/range_map/types.ts'
|
|
7
|
+
* @import { List } from '../types/list/types.ts'
|
|
8
|
+
* @import { Range } from '../types/range/types.ts'
|
|
5
9
|
*/
|
|
10
|
+
|
|
6
11
|
import { strictEqual } from '../types/function/operator/module.f.mjs'
|
|
7
12
|
import { merge as rangeMapMerge, fromRange, get } from '../types/range_map/module.f.mjs'
|
|
8
|
-
/** @import { RangeMapArray, RangeMerge } from '../types/range_map/types.ts' */
|
|
9
13
|
import { reduce as listReduce, toArray, map } from '../types/list/module.f.mjs'
|
|
10
|
-
/** @import { List } from '../types/list/types.ts' */
|
|
11
14
|
import { range as asciiRange } from '../text/ascii/module.f.mjs'
|
|
12
15
|
import { flip, fn } from '../types/function/module.f.mjs'
|
|
13
16
|
import { one } from '../types/range/module.f.mjs'
|
|
14
|
-
/** @import { Range } from '../types/range/types.ts' */
|
|
15
17
|
import { assertEq } from '../asserts/module.f.mjs'
|
|
16
18
|
|
|
17
19
|
const fromCharCode = String.fromCharCode
|
package/fjs/fsm/module.f.d.mts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @import { ByteSet } from '../types/byte_set/types.ts'
|
|
9
9
|
* @import { SortedSet } from '../types/sorted_set/types.ts'
|
|
10
10
|
* @import { RangeMap, Properties, RangeMapArray, Entry } from '../types/range_map/types.ts'
|
|
11
|
-
* @import { Fold
|
|
11
|
+
* @import { Fold } from '../types/function/operator/types.ts'
|
|
12
12
|
*/
|
|
13
13
|
import type { List } from '../types/list/types.ts';
|
|
14
14
|
import type { StringMap } from '../types/object/types.ts';
|
|
@@ -17,10 +17,20 @@ import type { RangeMapArray } from '../types/range_map/types.ts';
|
|
|
17
17
|
export type _Rule = readonly [string, ByteSet, string];
|
|
18
18
|
export type Grammar = List<_Rule>;
|
|
19
19
|
export type _Dfa = StringMap<RangeMapArray<string>>;
|
|
20
|
-
/** @
|
|
20
|
+
/** @typedef {readonly [string, ByteSet, string]} _Rule */
|
|
21
|
+
/** @typedef {List<_Rule>} Grammar */
|
|
22
|
+
/** @typedef {StringMap<RangeMapArray<string>>} _Dfa */
|
|
23
|
+
/**
|
|
24
|
+
* The byte set of an inclusive ASCII character range, written as the two
|
|
25
|
+
* endpoint characters: `toRange('az')`.
|
|
26
|
+
*
|
|
27
|
+
* `fjs/text/ascii` owns "two-character string to inclusive `Range`", including
|
|
28
|
+
* the one-character case where both endpoints are that character, so this is
|
|
29
|
+
* its composition with `byte_set.range` and nothing more.
|
|
30
|
+
*
|
|
31
|
+
* @type {(s: string) => ByteSet}
|
|
32
|
+
*/
|
|
21
33
|
export declare const toRange: (s: string) => ByteSet;
|
|
22
|
-
/** @type {(s: string) => ByteSet} */
|
|
23
|
-
export declare const toUnion: (s: string) => ByteSet;
|
|
24
34
|
/** @type {(grammar: Grammar) => _Dfa} */
|
|
25
35
|
export declare const dfa: (grammar: Grammar) => _Dfa;
|
|
26
36
|
/** @type {(dfa: _Dfa) => (input: List<number>) => List<string>} */
|
package/fjs/fsm/module.f.mjs
CHANGED
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
* @import { ByteSet } from '../types/byte_set/types.ts'
|
|
9
9
|
* @import { SortedSet } from '../types/sorted_set/types.ts'
|
|
10
10
|
* @import { RangeMap, Properties, RangeMapArray, Entry } from '../types/range_map/types.ts'
|
|
11
|
-
* @import { Fold
|
|
11
|
+
* @import { Fold } from '../types/function/operator/types.ts'
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { equal, isEmpty, fold,
|
|
15
|
-
import { toRangeMap,
|
|
16
|
-
import { intersect, union as sortedSetUnion } from '../types/sorted_set/module.f.mjs'
|
|
14
|
+
import { equal, isEmpty, fold, map, toArray, foldScan, empty as emptyList } from '../types/list/module.f.mjs'
|
|
15
|
+
import { toRangeMap, range } from '../types/byte_set/module.f.mjs'
|
|
16
|
+
import { intersect, toKey, union as sortedSetUnion } from '../types/sorted_set/module.f.mjs'
|
|
17
17
|
import { merge, get as rangeMapGet } from '../types/range_map/module.f.mjs'
|
|
18
18
|
import { strictEqual } from '../types/function/operator/module.f.mjs'
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
19
|
+
import { range as asciiRange } from '../text/ascii/module.f.mjs'
|
|
20
|
+
import { compose } from '../types/function/module.f.mjs'
|
|
21
|
+
import { at } from '../types/object/module.f.mjs'
|
|
22
22
|
import { cmp } from '../types/string/module.f.mjs'
|
|
23
23
|
|
|
24
24
|
/** @typedef {readonly [string, ByteSet, string]} _Rule */
|
|
@@ -27,22 +27,18 @@ import { cmp } from '../types/string/module.f.mjs'
|
|
|
27
27
|
|
|
28
28
|
/** @typedef {StringMap<RangeMapArray<string>>} _Dfa */
|
|
29
29
|
|
|
30
|
-
const stringifyIdentity = stringify(identity)
|
|
31
30
|
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export const
|
|
43
|
-
const codePoints = stringToList(s)
|
|
44
|
-
return fold(toUnionOp)(empty)(codePoints)
|
|
45
|
-
}
|
|
31
|
+
/**
|
|
32
|
+
* The byte set of an inclusive ASCII character range, written as the two
|
|
33
|
+
* endpoint characters: `toRange('az')`.
|
|
34
|
+
*
|
|
35
|
+
* `fjs/text/ascii` owns "two-character string to inclusive `Range`", including
|
|
36
|
+
* the one-character case where both endpoints are that character, so this is
|
|
37
|
+
* its composition with `byte_set.range` and nothing more.
|
|
38
|
+
*
|
|
39
|
+
* @type {(s: string) => ByteSet}
|
|
40
|
+
*/
|
|
41
|
+
export const toRange = compose(asciiRange)(range)
|
|
46
42
|
|
|
47
43
|
/** @type {Properties<SortedSet<string>>} */
|
|
48
44
|
const mergeOp = { union: sortedSetUnion(cmp), equal: equal(strictEqual), def: [] }
|
|
@@ -50,50 +46,71 @@ const mergeOp = { union: sortedSetUnion(cmp), equal: equal(strictEqual), def: []
|
|
|
50
46
|
/** @type {(s: string) => (set: SortedSet<string>) => boolean} */
|
|
51
47
|
const hasState = s => set => !isEmpty(intersect(cmp)([s])(set))
|
|
52
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Labels a byte set's ranges with the rule they lead to: a range inside the set
|
|
51
|
+
* transitions to `ruleOut`, one outside transitions nowhere.
|
|
52
|
+
*
|
|
53
|
+
* `byte_set.toRangeMap` answers only whether each range is in the set; which
|
|
54
|
+
* state that means is a DFA question, so it is answered here.
|
|
55
|
+
*
|
|
56
|
+
* @type {(ruleOut: string) => (entry: Entry<boolean>) => Entry<SortedSet<string>>}
|
|
57
|
+
*/
|
|
58
|
+
const labelRange = ruleOut => ([inSet, max]) => [inSet ? [ruleOut] : [], max]
|
|
59
|
+
|
|
53
60
|
/** @type {(set: SortedSet<string>) => Fold<_Rule, RangeMap<SortedSet<string>>>} */
|
|
54
61
|
const foldOp = set => ([ruleIn, bs, ruleOut]) => rm => {
|
|
55
|
-
if (hasState(ruleIn)(set)) {
|
|
62
|
+
if (hasState(ruleIn)(set)) {
|
|
63
|
+
return merge(mergeOp)(rm)(map(labelRange(ruleOut))(toRangeMap(bs)))
|
|
64
|
+
}
|
|
56
65
|
return rm
|
|
57
66
|
}
|
|
58
67
|
|
|
59
|
-
/**
|
|
60
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Renders an entry's state set as its `_Dfa` key, keeping the range boundary.
|
|
70
|
+
*
|
|
71
|
+
* @type {(entry: Entry<SortedSet<string>>) => Entry<string>}
|
|
72
|
+
*/
|
|
73
|
+
const keyEntry = ([sortedSet, max]) => [toKey(sortedSet), max]
|
|
61
74
|
|
|
62
|
-
const
|
|
75
|
+
const keyEntries = map(keyEntry)
|
|
63
76
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Drops an entry's range boundary, leaving the state set.
|
|
79
|
+
*
|
|
80
|
+
* @type {(entry: Entry<SortedSet<string>>) => SortedSet<string>}
|
|
81
|
+
*/
|
|
82
|
+
const entryValue = ([value]) => value
|
|
66
83
|
|
|
67
|
-
const
|
|
84
|
+
const entryValues = map(entryValue)
|
|
68
85
|
|
|
69
86
|
/** @type {(grammar: Grammar) => Fold<SortedSet<string>, _Dfa>} */
|
|
70
87
|
const addEntry = grammar => set => dfa => {
|
|
71
|
-
const s =
|
|
72
|
-
if (s
|
|
88
|
+
const s = toKey(set)
|
|
89
|
+
if (at(s)(dfa) !== null) { return dfa }
|
|
73
90
|
const setMap = fold(foldOp(set))(emptyList)(grammar)
|
|
74
|
-
const stringMap = toArray(
|
|
91
|
+
const stringMap = toArray(keyEntries(setMap))
|
|
75
92
|
const newDfa = { ...dfa, [s]: stringMap }
|
|
76
|
-
const newStates =
|
|
93
|
+
const newStates = entryValues(setMap)
|
|
77
94
|
return fold(addEntry(grammar))(newDfa)(newStates)
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
/** @type {string[]} */
|
|
81
98
|
const emptyState = []
|
|
82
99
|
|
|
83
|
-
const
|
|
100
|
+
const emptyStateKey = toKey(emptyState)
|
|
84
101
|
|
|
85
102
|
const initialState = ['']
|
|
86
103
|
|
|
87
|
-
const
|
|
104
|
+
const initialStateKey = toKey(initialState)
|
|
88
105
|
|
|
89
106
|
/** @type {(grammar: Grammar) => _Dfa} */
|
|
90
107
|
export const dfa = grammar => addEntry(grammar)(initialState)({})
|
|
91
108
|
|
|
92
|
-
const get = rangeMapGet(
|
|
109
|
+
const get = rangeMapGet(emptyStateKey)
|
|
93
110
|
|
|
94
111
|
/** @type {(dfa: _Dfa) => Fold<number, string>} */
|
|
95
112
|
const runOp = dfa => input => s => get(dfa[s] ?? [])(input)
|
|
96
113
|
|
|
97
114
|
/** @type {(dfa: _Dfa) => (input: List<number>) => List<string>} */
|
|
98
115
|
export const run = dfa => input =>
|
|
99
|
-
foldScan(runOp(dfa))(
|
|
116
|
+
foldScan(runOp(dfa))(initialStateKey)(input)
|