File tree 5 files changed +18
-15
lines changed
5 files changed +18
-15
lines changed Original file line number Diff line number Diff line change 2
2
3
3
> - https://github.com/cicada-lang/propagator/issues/3
4
4
5
+ assertBeliefSystemReasons
5
6
barometer-belief-system.test.ts -- finishing
6
7
` beliefSystemQuery `
7
8
Original file line number Diff line number Diff line change 1
- import { Belief , isBelief , type Reasons } from "../belief/index.js"
1
+ import { Belief , isBelief } from "../belief/index.js"
2
2
import { isNothing , nothing , type Nothing } from "../cell/index.js"
3
3
import { implies , merge , type MergeConflict } from "../merge/index.js"
4
+ import type { Reasons } from "../reason/index.js"
4
5
import { setIsSubsetOf } from "../utils/Set.js"
5
6
import { BeliefSystem } from "./BeliefSystem.js"
6
7
Original file line number Diff line number Diff line change 1
1
import assert from "node:assert"
2
+ import { toReasons , type Reasons } from "../reason/index.js"
2
3
import { isNonNullObject } from "../utils/isNonNullObject.js"
3
4
import { log } from "../utils/log.js"
4
5
5
- export type Reason = string
6
- export type Reasons = Set < Reason >
7
- export type ReasonLike = Reasons | Array < Reason >
8
-
9
- export function toReason ( x : ReasonLike ) : Reasons {
10
- if ( x instanceof Array ) {
11
- return new Set ( x )
12
- }
13
-
14
- return x
15
- }
16
-
17
6
export type Belief < T > = {
18
7
"@type" : "Belief"
19
8
value : T
@@ -24,7 +13,7 @@ export function Belief<T>(
24
13
value : T ,
25
14
reasons : Reasons | Array < string > ,
26
15
) : Belief < T > {
27
- reasons = toReason ( reasons )
16
+ reasons = toReasons ( reasons )
28
17
29
18
return {
30
19
"@type" : "Belief" ,
@@ -60,7 +49,7 @@ export function assertBeliefReasons(
60
49
}
61
50
62
51
if ( reasons !== undefined ) {
63
- reasons = toReason ( reasons )
52
+ reasons = toReasons ( reasons )
64
53
65
54
assert . deepStrictEqual ( target . reasons , reasons )
66
55
}
Original file line number Diff line number Diff line change
1
+ export type Reason = string
2
+ export type Reasons = Set < Reason >
3
+ export type ReasonLike = Reasons | Array < Reason >
4
+
5
+ export function toReasons ( x : ReasonLike ) : Reasons {
6
+ if ( x instanceof Array ) {
7
+ return new Set ( x )
8
+ }
9
+
10
+ return x
11
+ }
Original file line number Diff line number Diff line change
1
+ export * from "./Reason.js"
You can’t perform that action at this time.
0 commit comments