trilean 1.13.9 → 1.13.11

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.
@@ -1,157 +0,0 @@
1
- import { t as globalExpect } from "./index.CZzC1gGg-D3-vRdPe.js";
2
- import { createEvaluator, evaluatePredicate, evaluateValue } from "./evaluator-factory.js";
3
- // src/evaluator-indeterminacy-helpers.ts
4
- /**
5
- * Shared fixture machinery for the two split indeterminacy test files (evaluator.indeterminacy-table.unit.test.ts, evaluator.indeterminacy-cases.unit.test.ts): systematic, table-driven coverage of README.md's "Indeterminacy reference" section, one fixture per node-kind x reason-code combination that section documents, for every `PredicateNode`/`ExpressionNode` kind implemented. This complements, rather than replaces, the ad hoc behavioural tests already spread across the evaluator.*.test.ts files and truth-tables.unit.test.ts.
6
- */
7
- function isPlainRecord(value) {
8
- return typeof value === "object" && value !== null && !Array.isArray(value);
9
- }
10
- function isUnknownArray(value) {
11
- return Array.isArray(value);
12
- }
13
- /** A single resolver pool shared by every fixture below, covering every named key/table/collection any fixture needs. Fixtures that need genuinely different resolver behaviour (the delegate/call rows) supply their own. */
14
- const baseResolvers = {
15
- resolveValue: async (key, context) => {
16
- if (key === "present") return Promise.resolve({
17
- found: true,
18
- value: {
19
- kind: "number",
20
- value: 10,
21
- unit: { m: 1 }
22
- }
23
- });
24
- if (key === "presentText") return Promise.resolve({
25
- found: true,
26
- value: {
27
- kind: "text",
28
- value: "hello"
29
- }
30
- });
31
- if (typeof key === "string" && isPlainRecord(context) && key in context) {
32
- const value = context[key];
33
- if (typeof value === "number") return Promise.resolve({
34
- found: true,
35
- value: {
36
- kind: "number",
37
- value
38
- }
39
- });
40
- if (typeof value === "string") return Promise.resolve({
41
- found: true,
42
- value: {
43
- kind: "text",
44
- value
45
- }
46
- });
47
- }
48
- return Promise.resolve({ found: false });
49
- },
50
- resolveLookup: async (table) => {
51
- if (table === "table1") return Promise.resolve({
52
- found: true,
53
- value: {
54
- kind: "number",
55
- value: 100
56
- }
57
- });
58
- return Promise.resolve({ found: false });
59
- },
60
- resolveCollection: async (collection, context) => {
61
- if (collection === "single-notfound") return Promise.resolve([{}]);
62
- if (collection === "single-wrongtype") return Promise.resolve([{ value: "x" }]);
63
- if (collection === "single-domainerror") return Promise.resolve([{}]);
64
- if (collection === "empty") return Promise.resolve([]);
65
- if (collection === "one-item") return Promise.resolve([{}]);
66
- if (collection === "nested-outer") return Promise.resolve([{ values: [{ amount: 1 }, { amount: 2 }] }, { values: [{ amount: 10 }] }]);
67
- if (collection === "values" && isPlainRecord(context)) {
68
- const values = context.values;
69
- return Promise.resolve(isUnknownArray(values) ? values : []);
70
- }
71
- return Promise.resolve([]);
72
- }
73
- };
74
- const numberLiteral = (value) => ({
75
- kind: "numberLiteral",
76
- value
77
- });
78
- const missingRef = {
79
- kind: "reference",
80
- key: "missing"
81
- };
82
- const divideByZero = {
83
- kind: "arithmetic",
84
- op: "divide",
85
- left: numberLiteral(1),
86
- right: numberLiteral(0)
87
- };
88
- const wrongTypeArithmetic = {
89
- kind: "arithmetic",
90
- op: "add",
91
- left: {
92
- kind: "textLiteral",
93
- value: "x"
94
- },
95
- right: numberLiteral(1)
96
- };
97
- const trueGuard = {
98
- kind: "compare",
99
- op: "eq",
100
- left: numberLiteral(1),
101
- right: numberLiteral(1)
102
- };
103
- const falseGuard = {
104
- kind: "compare",
105
- op: "eq",
106
- left: numberLiteral(1),
107
- right: numberLiteral(2)
108
- };
109
- const missingGuard = {
110
- kind: "compare",
111
- op: "eq",
112
- left: missingRef,
113
- right: numberLiteral(1)
114
- };
115
- /** Arbitrary non-`{-1,0,1,2}` magnitudes used below, named individually so each numeric literal only appears once (`@typescript-eslint/no-magic-numbers` only exempts -1/0/1/2 and object-literal property values, not values passed as plain call arguments). */
116
- const memberOfProbeValue = 5;
117
- const reduceInitialSeed = 5;
118
- const laterConditionalCaseValue = 3;
119
- const untouchedReduceInitial = 42;
120
- const uniqueHitPolicyThirdCaseValue = 3;
121
- const isDefinite = { status: "definite" };
122
- const isNotFound = {
123
- status: "indeterminate",
124
- code: "not-found"
125
- };
126
- const isWrongType = {
127
- status: "indeterminate",
128
- code: "wrong-type"
129
- };
130
- const isDomainError = {
131
- status: "indeterminate",
132
- code: "domain-error"
133
- };
134
- function pred(description, node, expected, overrides = {}) {
135
- const { context, resolvers = baseResolvers, functions } = overrides;
136
- const { evaluatePredicate: evaluate } = functions ? createEvaluator({ functions }) : { evaluatePredicate };
137
- return {
138
- description,
139
- expected,
140
- run: async () => evaluate(node, context, resolvers)
141
- };
142
- }
143
- function expr(description, node, expected, overrides = {}) {
144
- const { context, resolvers = baseResolvers, functions } = overrides;
145
- const { evaluateValue: evaluate } = functions ? createEvaluator({ functions }) : { evaluateValue };
146
- return {
147
- description,
148
- expected,
149
- run: async () => evaluate(node, context, resolvers)
150
- };
151
- }
152
- async function runFixture({ run, expected }) {
153
- const result = await run();
154
- globalExpect(result.status).toBe(expected.status);
155
- if (expected.status === "indeterminate" && result.status === "indeterminate") globalExpect(result.reason.code).toBe(expected.code);
156
- }
157
- export { baseResolvers, divideByZero, expr, falseGuard, isDefinite, isDomainError, isNotFound, isPlainRecord, isUnknownArray, isWrongType, laterConditionalCaseValue, memberOfProbeValue, missingGuard, missingRef, numberLiteral, pred, reduceInitialSeed, runFixture, trueGuard, uniqueHitPolicyThirdCaseValue, untouchedReduceInitial, wrongTypeArithmetic };