Skip to content

Commit f5cb099

Browse files
mpvlmvdan
authored andcommitted
internal/core/adt: add tests for 4011
Issue #4011 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I0b4026875f6563e6eac5f5f09f8c25951c7b0cc0 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1220038 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1220067 Reviewed-by: Roger Peppe <[email protected]>
1 parent a340364 commit f5cb099

File tree

1 file changed

+196
-0
lines changed

1 file changed

+196
-0
lines changed

cue/testdata/eval/deref.txtar

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

0 commit comments

Comments
 (0)