mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Allows us to write in terms of the "ideal" traversal protocol while maintaining compatibilty with the existing one Swift SVN r5101
26 lines
582 B
Swift
26 lines
582 B
Swift
// RUN: %swift -i -constraint-checker %s
|
|
|
|
// Check to make sure we are actually getting Optionals out of this
|
|
// Generator
|
|
var w = asGenerator((1..2).getEnumeratorType())
|
|
var maybe_one = w.next()
|
|
assert(maybe_one != None)
|
|
for one in maybe_one {
|
|
assert(one == 1)
|
|
}
|
|
assert(w.next() == None)
|
|
|
|
// Test round-trip Generator/Enumerator adaptation
|
|
var x = asGenerator((1..7).getEnumeratorType())
|
|
var y = asEnumerator(x)
|
|
var z = ZipEnumerator2(y, (1..7).getEnumeratorType())
|
|
|
|
var a : (Int,Int)
|
|
while !z.isEmpty() {
|
|
a = z.next()
|
|
assert(a.0 == a.1)
|
|
}
|
|
|
|
assert(a.0 == 6)
|
|
println("done.")
|