Skip to content

Commit c8eb207

Browse files
committed
unified: Add tests with 'while let'
1 parent e7bff85 commit c8eb207

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

unified/ql/test/library-tests/variables/test.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,30 @@ func t34() {
307307
print(x) // $ access=x2
308308
}
309309
}
310+
311+
// While-let optional binding
312+
func t35(optional: Int?) { // name=optional1
313+
while let x = optional { // $ access=optional1 // name=x1
314+
print(x) // $ MISSING: access=x1
315+
}
316+
}
317+
318+
// While with a sequence of variable bindings in the condition
319+
func t36(a: Int?, b: Int?) {
320+
while let x = a, // $ access=a
321+
let y = b, // $ access=b
322+
x < y { // $ $ access=x access=y
323+
print(x) // $ MISSING: access=x
324+
print(y) // $ MISSING: access=y
325+
}
326+
}
327+
328+
// While-let with a sequence of shadowing variable declarations
329+
func t37() {
330+
let x = 1 // name=x1
331+
while let x = x, // $ access=x1 // name=x2
332+
let x = x, // $ access=x2 // name=x3
333+
x > 0 { // $ access=x3
334+
print(x) // $ MISSING: access=x3 SPURIOUS: access=x1
335+
}
336+
}

0 commit comments

Comments
 (0)