@@ -0,0 +1,134 @@
1+:: Path-declaration evidence retains sources, scope and reader-derived graphs.
2+/+ jibb, jibb-import
3+/* prelude %jibb /lib/jibb/prelude/jibb
4+/* internal %jibb /lib/jibb/internal/jibb
5+/* sur %txt /tests/type-api-paths/todo-sur/txt
6+/* action %txt /tests/type-api-paths/todo-action/txt
7+/* todos %txt /tests/type-api-paths/todos/txt
8+/* update %txt /tests/type-api-paths/todo-update/txt
9+/* item %txt /tests/type-api-paths/todo-item/txt
10+/* api %txt /tests/type-api-paths/scry/txt
11+|%
12+++ text
13+ |= lines=wain
14+ ^- @t
15+ (rap 3 (turn lines |=(line=@t (cat 3 line '\0a'))))
16+++ synthetic-evidence-status
17+ ^- @t
18+ :: A deliberately partial prelude preserves names even when inference fails.
19+ =/ public=@t '++ forbidden (missing "x")\0a+$ hidden (missing @t)\0a'
20+ =/ prepared=(unit iprelude:jibb) (prepare-prelude:jibb public)
21+ ?~ prepared 'partial prelude did not prepare'
22+ ?. (lien values.u.prepared |=(x=term =(%forbidden x))) 'unavailable value not reserved'
23+ ?. ?=(~ (ienv-lookup:jibb %forbidden values.iface.u.prepared)) 'forbidden value unexpectedly inferred'
24+ ?. (lien molds.u.prepared |=(x=term =(%hidden x))) 'unavailable mold not reserved'
25+ ?. ?=(~ (find-jibb-mold:jibb %hidden iface.u.prepared)) 'hidden mold unexpectedly inferred'
26+ =/ api=@t '/= dep /ui/dep\0a/% %todo\0a+$ paths [%items /items todo]\0a'
27+ =/ dep=@t '/= leaf /ui/leaf\0a++ value thing.leaf\0a'
28+ =/ leaf=@t '++ thing "x"\0a'
29+ =/ marks=imark-externals:jibb ~[[%todo [%& [%atom %t ~]]]]
30+ =/ externals=iexternals:jibb ~[[%unused %other [%& [%atom %p ~]]]]
31+ =/ modules=jbundle:jibb ~[[/ui/dep/jibb dep] [/ui/leaf/jibb leaf]]
32+ =/ result (api-path-evidence-source:jibb /ui/api/demo/jibb api externals marks modules prepared)
33+ ?: ?=(%| -.result) p.result
34+ =/ evidence=iapi-path-evidence:jibb p.result
35+ ?. =(at.evidence /ui/api/demo/jibb) 'API path not retained'
36+ ?. =(source.evidence api) 'API source not retained'
37+ ?. =(prepared.evidence u.prepared) 'complete prepared prelude not retained'
38+ ?. =(source.iface.prepared.evidence `public) 'prelude source not retained'
39+ ?. =(externals.evidence externals) 'external reader graph not retained'
40+ ?. =(marks.evidence marks) 'mark reader graph not retained'
41+ =/ d=(unit ifile:jibb) (find-jibb-cache:jibb /ui/dep/jibb dependencies.evidence)
42+ ?~ d 'dependency not retained'
43+ ?. =(source.u.d `dep) 'dependency source not retained'
44+ =/ l=(unit ifile:jibb) (find-jibb-cache:jibb /ui/leaf/jibb dependencies.evidence)
45+ ?~ l 'transitive dependency not retained'
46+ ?. =(source.u.l `leaf) 'transitive dependency source not retained'
47+ ?. ?=([* ~] paths.evidence) 'incorrect path count'
48+ ?. =(full.path.i.paths.evidence %todo) 'full mark name not retained'
49+ ?. =([%atom %t] full.i.paths.evidence) 'full mark type not retained'
50+ ?. =(%watchable (api-path-watchability:jibb `evidence %items)) 'normal path not watchable'
51+ ?. =(%unknown (api-path-watchability:jibb `evidence %missing)) 'missing path not unknown'
52+ ?. =(%unknown (api-path-watchability:jibb ~ %items)) 'missing evidence not unknown'
53+ =/ dup=iapi-path-evidence:jibb evidence(paths [i.paths.evidence paths.evidence])
54+ ?. =(%unknown (api-path-watchability:jibb `dup %items)) 'duplicate case query not unknown'
55+ =/ scry=@t '/% %todo\0a+$ paths [%items /items todo scry=/peek]\0a'
56+ =/ sr (api-path-evidence-source:jibb /ui/api/demo/jibb scry ~ marks ~ prepared)
57+ ?: ?=(%| -.sr) 'scry declaration rejected'
58+ ?. =(%not-watchable (api-path-watchability:jibb `p.sr %items)) 'scry path watchable'
59+ =/ clash=@t '/% %todo\0a+$ paths [%forbidden /one todo]\0a'
60+ ?. ?=([%| *] (api-path-evidence-source:jibb /ui/api/demo/jibb clash ~ marks ~ prepared)) 'reserved value did not reject derived path'
61+ ?. ?=([%| *] (api-path-evidence-source:jibb /ui/api/demo/jibb api externals ~ modules prepared)) 'missing mark accepted'
62+ ?. ?=([%| *] (api-path-evidence-source:jibb /ui/api/demo/jibb api externals (weld marks marks) modules prepared)) 'duplicate mark accepted'
63+ ?. ?=([%| *] (api-path-evidence-source:jibb /ui/demo/jibb api externals marks modules prepared)) 'non-API path accepted'
64+ ?. ?=([%| *] (api-path-evidence-source:jibb /ui/api/demo/jibb api externals marks modules ~)) 'missing prelude accepted'
65+ =/ direct=@t '/= secret /lib/jibb/internal\0a/% %todo\0a+$ paths [%items /items todo]\0a'
66+ ?. ?=([%| *] (api-path-evidence-source:jibb /ui/api/demo/jibb direct ~ marks ~ prepared)) 'direct private import accepted'
67+ =/ indirect=jbundle:jibb ~[[/ui/dep/jibb '/= secret /lib/jibb/internal\0a++ value "x"\0a']]
68+ ?. ?=([%| *] (api-path-evidence-source:jibb /ui/api/demo/jibb api ~ marks indirect prepared)) 'transitive private import accepted'
69+ =/ cyclic=jbundle:jibb ~[[/ui/dep/jibb '/= back /ui/dep\0a++ value "x"\0a']]
70+ ?. ?=([%| *] (api-path-evidence-source:jibb /ui/api/demo/jibb api ~ marks cyclic prepared)) 'cycle accepted'
71+ 'normal watchable; scry not watchable; missing and duplicate unknown'
72+++ real-evidence-status
73+ |= [prelude=@t internal=@t sur=@t action=@t todos=@t update=@t item=@t api=@t]
74+ ^- @t
75+ =/ prepared (prepare-prelude-with-internal:jibb prelude internal)
76+ ?~ prepared 'prelude did not prepare'
77+ =/ todo=type -:(ride -:!>(..zuse) sur)
78+ =/ subject=type [%cell [%face %todo todo] -:!>(..zuse)]
79+ =/ ma=* (read-mark:jibb-import %todo-action -:(ride subject action))
80+ =/ mt=* (read-mark:jibb-import %todos -:(ride subject todos))
81+ =/ mu=* (read-mark:jibb-import %todo-update -:(ride subject update))
82+ =/ mi=* (read-mark:jibb-import %todo-item -:(ride subject item))
83+ =/ marks=imark-externals:jibb ~[[%todo-action ma] [%todos mt] [%todo-update mu] [%todo-item mi]]
84+ =/ result (api-path-evidence-source:jibb /ui/api/todo/jibb api ~ marks ~ prepared)
85+ ?: ?=(%| -.result) p.result
86+ =/ evidence=iapi-path-evidence:jibb p.result
87+ ?. =(source.evidence api) 'API source not retained'
88+ ?. =(marks.evidence marks) 'mark reader graphs not retained'
89+ ?. =((lent paths.evidence) 3) 'incorrect path count'
90+ =/ changes=(list iapi-path-typed:jibb)
91+ (skim paths.evidence |=(p=iapi-path-typed:jibb =(%changes name.path.p)))
92+ ?. ?=([* ~] changes) 'changes path missing'
93+ ?. =(full.path.i.changes %todos) 'full mark missing'
94+ ?. ?=([* ~] diffs.i.changes) 'diff missing'
95+ ?. =(name.i.diffs.i.changes %todo-update) 'diff mark missing'
96+ =/ by-id=(list iapi-path-typed:jibb)
97+ (skim paths.evidence |=(p=iapi-path-typed:jibb =(%todo-by-id name.path.p)))
98+ ?. ?=([* ~] by-id) 'by-id path missing'
99+ ?. ?=(^ scry.path.i.by-id) 'scry path missing'
100+ =/ typed=(list pseg:jibb) (skim segments.path.i.by-id |=(p=pseg:jibb ?=(%typed -.p)))
101+ ?. ?=([* ~] typed) 'typed path missing'
102+ ?> ?=(%typed -.i.typed)
103+ ?. &(=(name.i.typed %id) =(aura.i.typed %ud)) 'typed path incorrect'
104+ ?. =(%watchable (api-path-watchability:jibb `evidence %todos)) 'watchable todos not proved'
105+ ?. =(%not-watchable (api-path-watchability:jibb `evidence %todo-by-id)) 'scry-only case incorrectly classified'
106+ ?. =(%unknown (api-path-watchability:jibb `evidence %missing)) 'unknown case incorrectly classified'
107+ =/ original (api-path-analysis-source:jibb /ui/api/todo/jibb api ~ marks ~ prepared)
108+ ?: ?=(%| -.original) 'original analyzer rejected todo source'
109+ ?. =(paths.evidence p.original) 'typed path evidence differs from original analyzer'
110+ ?. =(prepared.evidence u.prepared) 'actual complete prepared prelude not retained'
111+ =/ todo-full=(unit itype:jibb) (find-imported-mark:jibb %todos marks ~[%todo-action %todos %todo-update %todo-item])
112+ =/ todo-diff=(unit itype:jibb) (find-imported-mark:jibb %todo-update marks ~[%todo-action %todos %todo-update %todo-item])
113+ ?~ todo-full 'real full reader type unavailable'
114+ ?~ todo-diff 'real diff reader type unavailable'
115+ ?. =(full.i.changes u.todo-full) 'real full reader type differs'
116+ ?. =(typ.i.diffs.i.changes u.todo-diff) 'real diff reader type differs'
117+ 'real todo path evidence passed'
118+++ test-api-evidence-synthetic
119+ ^- tang
120+ =/ outcome=@t synthetic-evidence-status
121+ ?: =(outcome 'normal watchable; scry not watchable; missing and duplicate unknown') ~
122+ ~[leaf+(trip outcome)]
123+++ test-api-evidence-real
124+ ^- tang
125+ ?~ sur ~[leaf+"API evidence fixture sur is missing"]
126+ ?~ action ~[leaf+"API evidence fixture action is missing"]
127+ ?~ todos ~[leaf+"API evidence fixture todos is missing"]
128+ ?~ update ~[leaf+"API evidence fixture update is missing"]
129+ ?~ item ~[leaf+"API evidence fixture item is missing"]
130+ ?~ api ~[leaf+"API evidence fixture api is missing"]
131+ =/ outcome=@t (real-evidence-status prelude internal (text sur) (text action) (text todos) (text update) (text item) (text api))
132+ ?: =(outcome 'real todo path evidence passed') ~
133+ ~[leaf+(trip outcome)]
134+--