Files
swift-mirror/test/Interpreter/SDK/objc_blocks.swift
Joe Groff a7d1d7e252 Add SDK-dependent Interpreter tests.
In the lit.site.cfg, if a MODULES_SDK is available, add a '%sdk' substitution and enable REQUIRES: sdk tests. Add some tests under test/Interpreter/SDK to test some basic ObjC interop features.

Swift SVN r4243
2013-02-28 23:44:41 +00:00

32 lines
818 B
Swift

// RUN: %swift -sdk=%sdk -constraint-checker -i %s | FileCheck %s
// REQUIRES: sdk
import Foundation
func getBlockWithContext(suffix:String)
-> (NSString, CPointer<BOOL>) -> ()
{
return func(line, stop) {
print(line)
println(suffix)
}
}
// CHECK: apple cha! cha! cha!
// CHECK: banana cha! cha! cha!
// CHECK: cherry cha! cha! cha!
// CHECK: grape cha! cha! cha!
NSString("apple\nbanana\ncherry\ngrape\n").enumerateLinesUsingBlock(
func(line, _) {
print(line)
println(" cha! cha! cha!")
})
// CHECK: apple talkin' bout my generation
// CHECK: banana talkin' bout my generation
// CHECK: cherry talkin' bout my generation
// CHECK: grape talkin' bout my generation
NSString("apple\nbanana\ncherry\ngrape\n").enumerateLinesUsingBlock(
getBlockWithContext(" talkin' bout my generation"))