Skip to content

Commit 0a4ba82

Browse files
committed
gen: add $env
1 parent ccfad1d commit 0a4ba82

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/gen/gen.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func node(depth int) string {
140140
if depth <= 0 {
141141
return oneOf(list[fn]{
142142
{nilNode, 1},
143+
{envNode, 1},
143144
{floatNode, 1},
144145
{integerNode, 1},
145146
{stringNode, 1},
@@ -171,6 +172,10 @@ func nilNode(_ int) string {
171172
return "nil"
172173
}
173174

175+
func envNode(_ int) string {
176+
return "$env"
177+
}
178+
174179
func floatNode(_ int) string {
175180
return "1.0"
176181
}
@@ -192,7 +197,7 @@ func booleanNode(_ int) string {
192197

193198
func identifierNode(_ int) string {
194199
if maybe() {
195-
return "x"
200+
return "foobar"
196201
}
197202
return random(dict)
198203
}
@@ -359,5 +364,12 @@ func sequenceNode(depth int) string {
359364
}
360365

361366
func variableNode(depth int) string {
362-
return fmt.Sprintf("let x = %v; %v", node(depth-1), node(depth-1))
367+
e := node(depth - 1)
368+
if e == "foobar" {
369+
return "~!@"
370+
}
371+
if !strings.Contains(e, "foobar") {
372+
return "~!@"
373+
}
374+
return fmt.Sprintf("let foobar = %v; %v", node(depth-1), e)
363375
}

0 commit comments

Comments
 (0)