mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This was a type checker performance issue, but testing that this code also runs is also general goodness, as we need more of these simple runtime tests to baseline functionality. As part of this, consolidate the Fibonacci runtime test with this test. The new test file is generally named; we can rename it if someone comes up with a better name. Swift SVN r20559
23 lines
381 B
Swift
23 lines
381 B
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
|
|
func fib() {
|
|
var (a, b) = (0, 1)
|
|
while b < 10 {
|
|
println(b)
|
|
(a, b) = (b, a+b)
|
|
}
|
|
}
|
|
fib()
|
|
|
|
// CHECK: 1
|
|
// CHECK: 1
|
|
// CHECK: 2
|
|
// CHECK: 3
|
|
// CHECK: 5
|
|
// CHECK: 8
|
|
|
|
// From: <rdar://problem/17796401>
|
|
let two_one = Array(lazy([1, 2, 3, 4]).reverse().filter { $0 % 2 == 0 }.map { $0 / 2 })
|
|
println(two_one)
|
|
// CHECK: [2, 1]
|