[stdlib] Begin exposing the NSString API directly on String

Because we're using a "brute-force" combination of conversion to
NSString and forwarding, this code will continue to work when String
is replaced by NewString.  It may not be fast yet, but at least it
will flesh out the experience for Cocoa programmers

Swift SVN r11034
This commit is contained in:
Dave Abrahams
2013-12-09 18:44:58 +00:00
parent 4ddd82cc89
commit 00e4a84b74
4 changed files with 144 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
// RUN: rm -rf %t/clang-module-cache
// RUN: %swift -i -module-cache-path=%t/clang-module-cache -sdk=%sdk %s | FileCheck %s
// REQUIRES: sdk
// REQUIRES: swift_interpreter
import Foundation
func testClassMethods() {
var encodings: NSStringEncoding[] = String.availableStringEncodings()
// CHECK: available encodings found
// CHECK-NOT: 0 available encodings
println("\(encodings.count) available encodings found")
// CHECK-NEXT: defaultCStringEncoding is available
var defaultCStringEncoding = String.defaultCStringEncoding()
for e in encodings {
if e == defaultCStringEncoding {
println("defaultCStringEncoding is available")
}
}
// CHECK-NEXT: It is called
println("It is called \"\(String.localizedNameOfStringEncoding(defaultCStringEncoding))\"")
var path = String.pathWithComponents(["flugelhorn", "baritone", "bass"])
// CHECK-NEXT: <flugelhorn/baritone/bass>
println("<\(path)>")
// CHECK-NEXT: true
println(String.string() == "")
// CHECK-NEXT: <sox>
var chars: unichar[] = [ unichar('s'.value), unichar('o'.value), unichar('x'.value) ]
var sox: String = String.stringWithCharacters(chars.base, chars.count)
println("<\(sox)>")
}
testClassMethods()
// CHECK: done!
println("done!")