Files
swift-mirror/test/Interpreter/algorithms.swift
Ted Kremenek 14e83b7bff Add test case for '<rdar://problem/17796401> Swift Compiler never finishes compiling lazy collection reverse/filter/map'
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
2014-07-25 20:47:20 +00:00

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]