Skip to content

Commit 61a8b03

Browse files
committed
internal/core/adt: add tests for issue 3826
Issue #3826 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I819dd2859060a32bc556e4bbd5a518e14dabd1ee Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211799 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 673d30f commit 61a8b03

File tree

2 files changed

+310
-24
lines changed

2 files changed

+310
-24
lines changed

cue/testdata/definitions/root5.txtar

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
-- in.cue --
2+
_schema // embed schema through indirections
3+
_schema: #Schema
4+
#Schema: a?: b?: string
5+
a: b: "foo"
6+
c: "foo"
7+
8+
9+
x: {
10+
_schema // embed schema through indirections
11+
_schema: #Schema
12+
#Schema: a?: b?: string
13+
a: b: "foo"
14+
c: "foo"
15+
}
16+
-- out/eval/stats --
17+
Leaks: 0
18+
Freed: 20
19+
Reused: 14
20+
Allocs: 6
21+
Retain: 6
22+
23+
Unifications: 20
24+
Conjuncts: 34
25+
Disjuncts: 26
26+
-- out/evalalpha --
27+
Errors:
28+
c: field not allowed:
29+
./in.cue:5:1
30+
x: field not allowed:
31+
./in.cue:8:1
32+
33+
Result:
34+
(_|_){
35+
// [eval]
36+
_schema: ~(#Schema)
37+
#Schema: (#struct){
38+
a?: (#struct){
39+
b?: (string){ string }
40+
}
41+
}
42+
a: (#struct){
43+
b: (string){ "foo" }
44+
}
45+
c: (_|_){
46+
// [eval] c: field not allowed:
47+
// ./in.cue:5:1
48+
}
49+
x: (_|_){
50+
// [eval] x: field not allowed:
51+
// ./in.cue:8:1
52+
_schema: ~(x.#Schema)
53+
#Schema: (#struct){
54+
a?: (#struct){
55+
b?: (string){ string }
56+
}
57+
}
58+
a: (_|_){
59+
// [eval] x.a: field not allowed:
60+
// ./in.cue:11:11
61+
// ./in.cue:12:2
62+
b: (_|_){
63+
// [eval] x.a.b: field not allowed:
64+
// ./in.cue:11:15
65+
// ./in.cue:12:5
66+
}
67+
}
68+
c: (_|_){
69+
// [eval] x.c: field not allowed:
70+
// ./in.cue:13:2
71+
}
72+
}
73+
}
74+
-- diff/-out/evalalpha<==>+out/eval --
75+
diff old new
76+
--- old
77+
+++ new
78+
@@ -1,9 +1,13 @@
79+
-(#struct){
80+
- _schema: (#struct){
81+
- a?: (#struct){
82+
- b?: (string){ string }
83+
- }
84+
- }
85+
+Errors:
86+
+c: field not allowed:
87+
+ ./in.cue:5:1
88+
+x: field not allowed:
89+
+ ./in.cue:8:1
90+
+
91+
+Result:
92+
+(_|_){
93+
+ // [eval]
94+
+ _schema: ~(#Schema)
95+
#Schema: (#struct){
96+
a?: (#struct){
97+
b?: (string){ string }
98+
@@ -12,21 +16,32 @@
99+
a: (#struct){
100+
b: (string){ "foo" }
101+
}
102+
- c: (string){ "foo" }
103+
- x: (#struct){
104+
- _schema: (#struct){
105+
- a?: (#struct){
106+
- b?: (string){ string }
107+
- }
108+
- }
109+
+ c: (_|_){
110+
+ // [eval] c: field not allowed:
111+
+ // ./in.cue:5:1
112+
+ }
113+
+ x: (_|_){
114+
+ // [eval] x: field not allowed:
115+
+ // ./in.cue:8:1
116+
+ _schema: ~(x.#Schema)
117+
#Schema: (#struct){
118+
a?: (#struct){
119+
b?: (string){ string }
120+
}
121+
}
122+
- a: (#struct){
123+
- b: (string){ "foo" }
124+
- }
125+
- c: (string){ "foo" }
126+
+ a: (_|_){
127+
+ // [eval] x.a: field not allowed:
128+
+ // ./in.cue:11:11
129+
+ // ./in.cue:12:2
130+
+ b: (_|_){
131+
+ // [eval] x.a.b: field not allowed:
132+
+ // ./in.cue:11:15
133+
+ // ./in.cue:12:5
134+
+ }
135+
+ }
136+
+ c: (_|_){
137+
+ // [eval] x.c: field not allowed:
138+
+ // ./in.cue:13:2
139+
+ }
140+
}
141+
}
142+
-- out/eval --
143+
(#struct){
144+
_schema: (#struct){
145+
a?: (#struct){
146+
b?: (string){ string }
147+
}
148+
}
149+
#Schema: (#struct){
150+
a?: (#struct){
151+
b?: (string){ string }
152+
}
153+
}
154+
a: (#struct){
155+
b: (string){ "foo" }
156+
}
157+
c: (string){ "foo" }
158+
x: (#struct){
159+
_schema: (#struct){
160+
a?: (#struct){
161+
b?: (string){ string }
162+
}
163+
}
164+
#Schema: (#struct){
165+
a?: (#struct){
166+
b?: (string){ string }
167+
}
168+
}
169+
a: (#struct){
170+
b: (string){ "foo" }
171+
}
172+
c: (string){ "foo" }
173+
}
174+
}
175+
-- out/compile --
176+
--- in.cue
177+
{
178+
〈0;_schema〉
179+
_schema: 〈0;#Schema〉
180+
#Schema: {
181+
a?: {
182+
b?: string
183+
}
184+
}
185+
a: {
186+
b: "foo"
187+
}
188+
c: "foo"
189+
x: {
190+
〈0;_schema〉
191+
_schema: 〈0;#Schema〉
192+
#Schema: {
193+
a?: {
194+
b?: string
195+
}
196+
}
197+
a: {
198+
b: "foo"
199+
}
200+
c: "foo"
201+
}
202+
}

0 commit comments

Comments
 (0)