mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This is needed if we compile StdlibUnittest with -sil-serialize-all So far I added the imports only in files which needed them. But this may change, depending on the optimizer (inlining). Adding them in all files doesn't harm and avoids confusion if someone makes an unrelated change which would result in such a linker error.
56 lines
1.4 KiB
Swift
56 lines
1.4 KiB
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import StdlibUnittest
|
|
|
|
// Also import modules which are used by StdlibUnittest internally. This
|
|
// workaround is needed to link all required libraries in case we compile
|
|
// StdlibUnittest with -sil-serialize-all.
|
|
import SwiftPrivate
|
|
#if _runtime(_ObjC)
|
|
import ObjectiveC
|
|
#endif
|
|
|
|
import Foundation
|
|
|
|
var NSArrayAPI = TestSuite("NSArrayAPI")
|
|
|
|
NSArrayAPI.test("mixed types with AnyObject") {
|
|
if true {
|
|
let result: AnyObject = [1, "two"]
|
|
let expect: NSArray = [1, "two"]
|
|
expectEqual(expect, result as! NSArray)
|
|
}
|
|
if true {
|
|
let result: AnyObject = [1, 2]
|
|
let expect: NSArray = [1, 2]
|
|
expectEqual(expect, result as! NSArray)
|
|
}
|
|
}
|
|
|
|
NSArrayAPI.test("CustomStringConvertible") {
|
|
let result = String(NSArray(objects:"A", "B", "C", "D"))
|
|
let expect = "(\n A,\n B,\n C,\n D\n)"
|
|
expectEqual(expect, result)
|
|
}
|
|
|
|
NSArrayAPI.test("copy construction") {
|
|
let expected = ["A", "B", "C", "D"]
|
|
let x = NSArray(array: expected as NSArray)
|
|
expectEqual(expected, x as! Array)
|
|
let y = NSMutableArray(array: expected as NSArray)
|
|
expectEqual(expected, y as NSArray as! Array)
|
|
}
|
|
|
|
var NSMutableArrayAPI = TestSuite("NSMutableArrayAPI")
|
|
|
|
NSMutableArrayAPI.test("CustomStringConvertible") {
|
|
let result = String(NSMutableArray(objects:"A", "B", "C", "D"))
|
|
let expect = "(\n A,\n B,\n C,\n D\n)"
|
|
expectEqual(expect, result)
|
|
}
|
|
|
|
runAllTests()
|