mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Update the rest of the testsuite for the array syntax change.
Swift SVN r19223
This commit is contained in:
@@ -70,7 +70,7 @@ func test() {
|
||||
var object = NSObject()
|
||||
|
||||
var arrayInt = [10, 20, 30]
|
||||
var arrayOptionalInt : Int?[] = [10, .None, 30, .None, 20]
|
||||
var arrayOptionalInt : [Int?] = [10, .None, 30, .None, 20]
|
||||
var arrayString = ["Kate", "Sean", "Barry"]
|
||||
var arrayPerson = [Person(), Person()]
|
||||
var dictionary = [1 : "Kate", 2 : "Sean", 3 : "Barry"]
|
||||
|
||||
@@ -73,10 +73,10 @@ println(tuple)
|
||||
// Arrays are represented as an instantiation of Array.
|
||||
// CHECK-DAG: null, null, metadata ![[Array:.*]]} ; [ DW_TAG_structure_type ] [Array]
|
||||
// CHECK-DAG: metadata ![[Array]], i32 0,{{.*}}[ DW_TAG_variable ] [array_of_tuples] [line [[@LINE+1]]] [def]
|
||||
var array_of_tuples : (a : Int, b : Int)[] = [(1,2)]
|
||||
var twod : [Int][] = [[1]]
|
||||
var array_of_tuples : [(a : Int, b : Int)] = [(1,2)]
|
||||
var twod : [[Int]] = [[1]]
|
||||
|
||||
func bar( x: (a : Int, b : Int)[], y: [Int][] ) {
|
||||
func bar( x: [(a : Int, b : Int)], y: [[Int]] ) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ sil @_TFC15generic_classes11RootGenericD : $@cc(method) @thin <T> (RootGeneric<T
|
||||
|
||||
class RootGenericFixedLayout<T> {
|
||||
var x : UInt8
|
||||
var y : T[]
|
||||
var y : [T]
|
||||
var z : UInt8
|
||||
|
||||
init()
|
||||
|
||||
@@ -172,7 +172,7 @@ for nsd: NSDictionary! in nsa3 {
|
||||
let p:NSDictionary = nsd
|
||||
}
|
||||
|
||||
var nsa4: NSDictionary![] = []
|
||||
var nsa4: [NSDictionary!] = []
|
||||
for nsd2: NSDictionary! in nsa4 {
|
||||
let p:NSDictionary = nsd2
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func testEquatable<E: Equatable>(x: E) {}
|
||||
|
||||
func test_Equatable() {
|
||||
// CHECK-NEXT: Found 2.5 at index 1
|
||||
let array: NSNumber[] = [1, 2.5, 3.14159]
|
||||
let array: [NSNumber] = [1, 2.5, 3.14159]
|
||||
if let index = find(array, 2.5) {
|
||||
println("Found \(array[index]) at index \(index)")
|
||||
} else {
|
||||
|
||||
@@ -47,7 +47,7 @@ println("Active X objects = \(activeXObjects)")
|
||||
// Bridge an array of an implicitly unwrapped bridged value type.
|
||||
func testConvertArrayOfImplicitUnwrappedValue() {
|
||||
println("Converting array of IOU of String to NSArray...")
|
||||
var stringArr1: (String!)[] = ["Hello", "World"]
|
||||
var stringArr1: [String!] = ["Hello", "World"]
|
||||
|
||||
let stringNSArr1: NSArray = stringArr1
|
||||
|
||||
@@ -72,10 +72,10 @@ testConvertArrayOfImplicitUnwrappedValue()
|
||||
// Bridge an array of an implicitly unwrapped array value type.
|
||||
func testConvertArrayOfImplicitUnwrappedArray() {
|
||||
println("Converting array of IUO of Arrays of String to NSArray...")
|
||||
var stringArr1: (String!)[] = ["Hello", "World"]
|
||||
var stringArr1: [String!] = ["Hello", "World"]
|
||||
var stringArr2 = [getIUO("Welcome"), getIUO("Swift")]
|
||||
|
||||
var stringArrArr: (((String!)[])!)[] = []
|
||||
var stringArrArr: [[String!]!] = []
|
||||
stringArrArr.append(getIUO(stringArr1))
|
||||
stringArrArr.append(getIUO(stringArr2))
|
||||
|
||||
@@ -99,7 +99,7 @@ func testConvertArrayOfImplicitUnwrappedArray() {
|
||||
println("Element \(index) is not an NSArray")
|
||||
}
|
||||
|
||||
// FIXME: Downcast to (String!)[]
|
||||
// FIXME: Downcast to [String!]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func testConvertToArrayOfImplicitUnwrappedClass() {
|
||||
nsarr.addObject(X(value: 1))
|
||||
nsarr.addObject(X(value: 2))
|
||||
|
||||
var arr: (X!)[] = _convertNSArrayToArray(nsarr)
|
||||
var arr: [X!] = _convertNSArrayToArray(nsarr)
|
||||
|
||||
// CHECK: Class array count = 2
|
||||
// CHECK: Element 0 has value X(1)
|
||||
@@ -136,7 +136,7 @@ func testConvertToArrayOfImplicitUnwrappedString() {
|
||||
nsarr.addObject(NSString(string: "Hello"))
|
||||
nsarr.addObject(NSString(string: "World"))
|
||||
|
||||
var arr: (String!)[] = _convertNSArrayToArray(nsarr)
|
||||
var arr: [String!] = _convertNSArrayToArray(nsarr)
|
||||
|
||||
// CHECK: String array count = 2
|
||||
// CHECK: Element 0 has value Hello
|
||||
|
||||
@@ -21,7 +21,7 @@ println("NSData:")
|
||||
autoreleasepool {
|
||||
var bytes: UnsafePointer<UInt8>
|
||||
do {
|
||||
let data = NSData(bytes: [2, 3, 5, 7] as UInt8[], length: 4)
|
||||
let data = NSData(bytes: [2, 3, 5, 7] as [UInt8], length: 4)
|
||||
hangCanary(data)
|
||||
bytes = UnsafePointer<UInt8>(data.bytes)
|
||||
} while false // CHECK-NOT: died
|
||||
@@ -36,7 +36,7 @@ println("AnyObject:")
|
||||
autoreleasepool {
|
||||
var bytes: UnsafePointer<UInt8>
|
||||
do {
|
||||
let data = NSData(bytes: [11, 13, 17, 19] as UInt8[], length: 4)
|
||||
let data = NSData(bytes: [11, 13, 17, 19] as [UInt8], length: 4)
|
||||
hangCanary(data)
|
||||
let dataAsAny: AnyObject = data
|
||||
bytes = UnsafePointer<UInt8>(dataAsAny.bytes!)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// CHECK: 30
|
||||
// CHECK: hello world
|
||||
func main() {
|
||||
var arrOpt : (Int?)[] = [10,.None,20,.None,30]
|
||||
var arrOpt : [Int?] = [10,.None,20,.None,30]
|
||||
for item in arrOpt {
|
||||
switch item {
|
||||
case .None:
|
||||
|
||||
@@ -60,7 +60,7 @@ println()
|
||||
|
||||
// Create an array of (String, Bool) pairs. <rdar://problem/16916422>
|
||||
do {
|
||||
let x: (String, Bool)[] = [("foo", true)]
|
||||
let x: [(String, Bool)] = [("foo", true)]
|
||||
println(x[0].0) // CHECK: foo
|
||||
println(x[0].1) // CHECK: true
|
||||
} while false
|
||||
@@ -125,7 +125,7 @@ class Spoon: Runcible {
|
||||
let x: Int
|
||||
init(x: Int) { self.x = x }
|
||||
}
|
||||
let runceArray: Runcible[] = [Spoon(x: 219)]
|
||||
let runceArray: [Runcible] = [Spoon(x: 219)]
|
||||
// CHECK: 1 element
|
||||
// CHECK-NEXT: {{.*}}Spoon
|
||||
// CHECK-NEXT: x: 219
|
||||
|
||||
@@ -245,7 +245,7 @@ tryRunce(Optionable(Spoon()))
|
||||
tryRunce(Optionable(Hat()))
|
||||
|
||||
func optionableInts() {
|
||||
var optionables: Optionable<Int>[] = [
|
||||
var optionables: [Optionable<Int>] = [
|
||||
.Mere(219),
|
||||
.Nought,
|
||||
.Nought,
|
||||
@@ -285,7 +285,7 @@ func println(suit: Suit) {
|
||||
}
|
||||
|
||||
func optionableSuits() {
|
||||
var optionables: Optionable<Suit>[] = [
|
||||
var optionables: [Optionable<Suit>] = [
|
||||
.Mere(.Spades),
|
||||
.Mere(.Diamonds),
|
||||
.Nought,
|
||||
@@ -309,7 +309,7 @@ func optionableSuits() {
|
||||
optionableSuits()
|
||||
|
||||
func optionableRuncibles<T : Runcible>(x: T) {
|
||||
var optionables: Optionable<T>[] = [
|
||||
var optionables: [Optionable<T>] = [
|
||||
.Mere(x),
|
||||
.Nought,
|
||||
.Mere(x),
|
||||
|
||||
@@ -127,9 +127,9 @@ class NotObjC {}
|
||||
func testIgnoredParam(_: Int) {}
|
||||
func testIgnoredParams(_: Int, again _: Int) {}
|
||||
|
||||
func testArrayBridging(a: Methods[]) {}
|
||||
func testArrayBridging2(a: AnyObject[]) {}
|
||||
func testArrayBridging3(a: String[]) {}
|
||||
func testArrayBridging(a: [Methods]) {}
|
||||
func testArrayBridging2(a: [AnyObject]) {}
|
||||
func testArrayBridging3(a: [String]) {}
|
||||
}
|
||||
|
||||
typealias AliasForNSRect = NSRect
|
||||
@@ -239,7 +239,7 @@ class MyObject : NSObject {}
|
||||
@IBOutlet var outlet: AnyObject
|
||||
|
||||
var string = "abc"
|
||||
var array: AnyObject[] = []
|
||||
var array: [AnyObject] = []
|
||||
var dictionary: Dictionary<String, String> = [:]
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ class MyObject : NSObject {}
|
||||
// CHECK-NEXT: - (instancetype)init
|
||||
// CHECK-NEXT: @end
|
||||
@objc class PropertiesOverridden : Hive {
|
||||
override var bees : (AnyObject[])! {
|
||||
override var bees : [AnyObject]! {
|
||||
get {
|
||||
return super.bees
|
||||
}
|
||||
@@ -312,7 +312,7 @@ class MyObject : NSObject {}
|
||||
}
|
||||
|
||||
// <rdar://problem/17165953> Swift: @lazy property reflects back into Objective-C with two properties, one for underlying storage
|
||||
@lazy var cardPaths : String[] = []
|
||||
@lazy var cardPaths : [String] = []
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @interface Subscripts3
|
||||
|
||||
@@ -23,7 +23,7 @@ func posix_read(fd: Int32, buf: CMutableVoidPointer, sz: UInt) -> Int
|
||||
@final class Keyboard {
|
||||
init() { }
|
||||
|
||||
func read(inout buf: UInt8[]) -> Int {
|
||||
func read(inout buf: [UInt8]) -> Int {
|
||||
// ensure uniqueness before we allow buf to be modified
|
||||
buf.reserveCapacity(0)
|
||||
var r = buf.withUnsafePointerToElements {
|
||||
@@ -69,7 +69,7 @@ var kbd : Keyboard = Keyboard()
|
||||
@final class Console {
|
||||
init() { }
|
||||
|
||||
func write(inout buf: UInt8[]) -> Int {
|
||||
func write(inout buf: [UInt8]) -> Int {
|
||||
let count = buf.count
|
||||
var r = 0
|
||||
for var start = 0; start < count; start += 1024 {
|
||||
|
||||
@@ -10,11 +10,11 @@ func _convertStringToNSString(string: String) -> NSString
|
||||
func _convertNSStringToString(nsstring: NSString) -> String
|
||||
|
||||
// NSArray bridging entry points
|
||||
func _convertNSArrayToArray<T>(nsarr: NSArray) -> T[] {
|
||||
return T[]()
|
||||
func _convertNSArrayToArray<T>(nsarr: NSArray) -> [T] {
|
||||
return [T]()
|
||||
}
|
||||
|
||||
func _convertArrayToNSArray<T>(arr: T[]) -> NSArray {
|
||||
func _convertArrayToNSArray<T>(arr: [T]) -> NSArray {
|
||||
return NSArray()
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// CHECK-LABEL: sil @_TF25array_literal_abstraction14array_of_funcsFT_GSaFT_T__
|
||||
// CHECK: alloc_array $@callee_owned (@out (), @in ()) -> ()
|
||||
func array_of_funcs() -> (() -> ())[] {
|
||||
func array_of_funcs() -> [(() -> ())] {
|
||||
return [{}, {}]
|
||||
}
|
||||
|
||||
|
||||
@@ -27,69 +27,69 @@ func == (x: BridgedSwift, y: BridgedSwift) -> Bool { return true }
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast17testArrayDowncast
|
||||
// CHECK: bb0([[ARRAY:%[0-9]+]] : $Array<AnyObject>):
|
||||
func testArrayDowncast(array: AnyObject[]) -> BridgedObjC[] {
|
||||
func testArrayDowncast(array: [AnyObject]) -> [BridgedObjC] {
|
||||
// CHECK: [[DOWNCAST_FN:%[0-9]+]] = function_ref @_TFSs14_arrayDownCastU___FGSaQ__GSaQ0__ : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
|
||||
// CHECK: apply [[DOWNCAST_FN]]<AnyObject, BridgedObjC>([[ARRAY]]) : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
|
||||
return array as BridgedObjC[]
|
||||
return array as [BridgedObjC]
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast27testArrayDowncastFromObject
|
||||
// CHECK: bb0([[OBJ:%[0-9]+]] : $AnyObject):
|
||||
func testArrayDowncastFromObject(obj: AnyObject) -> BridgedObjC[] {
|
||||
func testArrayDowncastFromObject(obj: AnyObject) -> [BridgedObjC] {
|
||||
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFSa20bridgeFromObjectiveCU__fMGSaQ__FCSo7NSArrayGSaQ__ : $@thin <τ_0_0> (@owned NSArray, @thin Array<τ_0_0>.Type) -> @owned Array<τ_0_0>
|
||||
// CHECK: [[ARRAY_META:%[0-9]+]] = metatype $@thin Array<BridgedObjC>.Type
|
||||
// CHECK: [[NSARRAY_OBJ:%[0-9]+]] = unconditional_checked_cast [[OBJ]] : $AnyObject to $NSArray
|
||||
// CHECK: apply [[BRIDGE_FN]]<BridgedObjC>([[NSARRAY_OBJ]], [[ARRAY_META]]) : $@thin <τ_0_0> (@owned NSArray, @thin Array<τ_0_0>.Type) -> @owned Array<τ_0_0>
|
||||
return obj as BridgedObjC[]
|
||||
return obj as [BridgedObjC]
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast28testArrayDowncastFromNSArray
|
||||
// CHECK: bb0([[NSARRAY_OBJ:%[0-9]+]] : $NSArray):
|
||||
func testArrayDowncastFromNSArray(obj: NSArray) -> BridgedObjC[] {
|
||||
func testArrayDowncastFromNSArray(obj: NSArray) -> [BridgedObjC] {
|
||||
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFSa20bridgeFromObjectiveCU__fMGSaQ__FCSo7NSArrayGSaQ__ : $@thin <τ_0_0> (@owned NSArray, @thin Array<τ_0_0>.Type) -> @owned Array<τ_0_0>
|
||||
// CHECK: [[ARRAY_META:%[0-9]+]] = metatype $@thin Array<BridgedObjC>.Type
|
||||
// CHECK: apply [[BRIDGE_FN]]<BridgedObjC>([[NSARRAY_OBJ]], [[ARRAY_META]]) : $@thin <τ_0_0> (@owned NSArray, @thin Array<τ_0_0>.Type) -> @owned Array<τ_0_0>
|
||||
return obj as BridgedObjC[]
|
||||
return obj as [BridgedObjC]
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast28testArrayDowncastConditional
|
||||
// CHECK: bb0([[ARRAY:%[0-9]+]] : $Array<AnyObject>):
|
||||
func testArrayDowncastConditional(array: AnyObject[]) -> BridgedObjC[]? {
|
||||
func testArrayDowncastConditional(array: [AnyObject]) -> [BridgedObjC]? {
|
||||
// CHECK: [[DOWNCAST_FN:%[0-9]+]] = function_ref @_TFSs25_arrayDownCastConditionalU___FGSaQ__GSqGSaQ0___ : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
|
||||
// CHECK-NEXT: apply [[DOWNCAST_FN]]<AnyObject, BridgedObjC>([[ARRAY]]) : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
|
||||
return array as? BridgedObjC[]
|
||||
return array as? [BridgedObjC]
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast12testArrayIsa
|
||||
// CHECK: bb0([[ARRAY:%[0-9]+]] : $Array<AnyObject>)
|
||||
func testArrayIsa(array: AnyObject[]) -> Bool {
|
||||
func testArrayIsa(array: [AnyObject]) -> Bool {
|
||||
// CHECK: [[DOWNCAST_FN:%[0-9]+]] = function_ref @_TFSs25_arrayDownCastConditionalU___FGSaQ__GSqGSaQ0___ : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
|
||||
// CHECK-NEXT: apply [[DOWNCAST_FN]]<AnyObject, BridgedObjC>([[ARRAY]]) : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
|
||||
return array is BridgedObjC[] ? true : false
|
||||
return array is [BridgedObjC] ? true : false
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast24testArrayDowncastBridged
|
||||
// CHECK: bb0([[ARRAY:%[0-9]+]] : $Array<AnyObject>):
|
||||
func testArrayDowncastBridged(array: AnyObject[]) -> BridgedSwift[] {
|
||||
func testArrayDowncastBridged(array: [AnyObject]) -> [BridgedSwift] {
|
||||
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFSs26_arrayBridgeFromObjectiveCU___FGSaQ__GSaQ0__ : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
|
||||
// CHECK-NEXT: apply [[BRIDGE_FN]]<AnyObject, BridgedSwift>([[ARRAY]]) : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
|
||||
return array as BridgedSwift[]
|
||||
return array as [BridgedSwift]
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast35testArrayDowncastBridgedConditional
|
||||
// CHECK: bb0([[ARRAY:%[0-9]+]] : $Array<AnyObject>):
|
||||
func testArrayDowncastBridgedConditional(array: AnyObject[]) -> BridgedSwift[]?{
|
||||
func testArrayDowncastBridgedConditional(array: [AnyObject]) -> [BridgedSwift]?{
|
||||
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFSs37_arrayBridgeFromObjectiveCConditionalU___FGSaQ__GSqGSaQ0___ : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
|
||||
// CHECK-NEXT: apply [[BRIDGE_FN]]<AnyObject, BridgedSwift>([[ARRAY]]) : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
|
||||
return array as? BridgedSwift[]
|
||||
return array as? [BridgedSwift]
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast19testArrayIsaBridged
|
||||
// CHECK: bb0([[ARRAY:%[0-9]+]] : $Array<AnyObject>)
|
||||
func testArrayIsaBridged(array: AnyObject[]) -> Bool {
|
||||
func testArrayIsaBridged(array: [AnyObject]) -> Bool {
|
||||
// CHECK: [[DOWNCAST_FN:%[0-9]+]] = function_ref @_TFSs37_arrayBridgeFromObjectiveCConditionalU___FGSaQ__GSqGSaQ0___ : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
|
||||
// CHECK: apply [[DOWNCAST_FN]]<AnyObject, BridgedSwift>([[ARRAY]]) : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
|
||||
return array is BridgedSwift[] ? true : false
|
||||
return array is [BridgedSwift] ? true : false
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF19collection_downcast32testDictionaryDowncastFromObject
|
||||
|
||||
@@ -27,18 +27,18 @@ func == (x: BridgedSwift, y: BridgedSwift) -> Bool { return true }
|
||||
|
||||
// CHECK-LABEL: sil @_TF17collection_upcast15testArrayUpcast
|
||||
// CHECK-NEXT: bb0([[ARRAY:%[0-9]+]] : $Array<BridgedObjC>):
|
||||
func testArrayUpcast(array: BridgedObjC[]) {
|
||||
func testArrayUpcast(array: [BridgedObjC]) {
|
||||
// CHECK: [[UPCAST_FN:%[0-9]+]] = function_ref @_TFSs12_arrayUpCastU___FGSaQ__GSaQ0__ : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
|
||||
// CHECK-NEXT: apply [[UPCAST_FN]]<BridgedObjC, AnyObject>([[ARRAY]]) : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
|
||||
let anyObjectArr: AnyObject[] = array
|
||||
let anyObjectArr: [AnyObject] = array
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF17collection_upcast22testArrayUpcastBridged
|
||||
// CHECK-NEXT: bb0([[ARRAY:%[0-9]+]] : $Array<BridgedSwift>):
|
||||
func testArrayUpcastBridged(array: BridgedSwift[]) {
|
||||
func testArrayUpcastBridged(array: [BridgedSwift]) {
|
||||
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFSs24_arrayBridgeToObjectiveCU___FGSaQ__GSaQ0__ : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
|
||||
// CHECK-NEXT: apply [[BRIDGE_FN]]<BridgedSwift, AnyObject>([[ARRAY]]) : $@thin <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
|
||||
let anyObjectArr: AnyObject[] = array
|
||||
let anyObjectArr: [AnyObject] = array
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF17collection_upcast20testDictionaryUpcast
|
||||
|
||||
@@ -158,7 +158,7 @@ func scalar_to_tuple() {
|
||||
|
||||
// CHECK-LABEL: sil @_TF11expressions11array_alloc
|
||||
func array_alloc(n: Int) {
|
||||
var a: Int[] = new Int[n]
|
||||
var a: [Int] = new Int[n]
|
||||
}
|
||||
|
||||
struct SomeStruct {
|
||||
@@ -354,7 +354,7 @@ struct Spoon : Runcible, Mincible {
|
||||
}
|
||||
|
||||
struct Hat<T> : Runcible {
|
||||
typealias U = T[]
|
||||
typealias U = [T]
|
||||
var free: Int { return 1 }
|
||||
var associated: U { get {} }
|
||||
|
||||
@@ -426,7 +426,7 @@ func tuple_element(var x: (Int, Float)) {
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF11expressions10containers
|
||||
func containers() -> (Int[], Dictionary<String, Int>) {
|
||||
func containers() -> ([Int], Dictionary<String, Int>) {
|
||||
return ([1, 2, 3], ["Ankeny": 1, "Burnside": 2, "Couch": 3])
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ func testAddressOnlyLet<T>(a : T) {
|
||||
}
|
||||
|
||||
|
||||
func produceSubscriptableRValue() -> String[] {}
|
||||
func produceSubscriptableRValue() -> [String] {}
|
||||
|
||||
// CHECK-LABEL: sil @{{.*}}subscriptRValue
|
||||
func subscriptRValue() {
|
||||
|
||||
@@ -20,7 +20,7 @@ func Pročprostěnemluvíčesky() { }
|
||||
// non-variadic tuples.
|
||||
|
||||
// CHECK-LABEL: sil @_TF8mangling9r13757744FT1xGSaSi__T_
|
||||
func r13757744(#x: Int[]) {}
|
||||
func r13757744(#x: [Int]) {}
|
||||
// CHECK-LABEL: sil @_TF8mangling9r13757744Ft1xGSaSi__T_
|
||||
func r13757744(#x: Int...) {}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ class Bas : NSObject {
|
||||
// CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC13objc_bridging3Bas{{.*}} : $@cc(method) @thin (@owned Array<AnyObject>, @owned Bas) -> ()
|
||||
// CHECK: [[RESULT:%[0-9]+]] = apply [[SWIFT_FN]]([[ARRAY]], [[SELF]]) : $@cc(method) @thin (@owned Array<AnyObject>, @owned Bas) -> ()
|
||||
// CHECK: return [[RESULT]] : $()
|
||||
func arrayArg(array: AnyObject[]) { }
|
||||
func arrayArg(array: [AnyObject]) { }
|
||||
|
||||
// CHECK-LABEL: sil @_TToFC13objc_bridging3Bas11arrayResult{{.*}} : $@cc(objc_method) @thin (Bas) -> @autoreleased NSArray
|
||||
// CHECK: bb0([[SELF:%[0-9]+]] : $Bas):
|
||||
@@ -318,11 +318,11 @@ class Bas : NSObject {
|
||||
// CHECK: [[ARRAY:%[0-9]+]] = apply [[SWIFT_FN]]([[SELF]]) : $@cc(method) @thin (@owned Bas) -> @owned Array<AnyObject>
|
||||
// CHECK: [[CONV_FN:%[0-9]+]] = function_ref @_TF10Foundation22_convertArrayToNSArray{{.*}} : $@thin <τ_0_0> (@owned Array<τ_0_0>) -> @owned NSArray
|
||||
// CHECK: [[NSARRAY:%[0-9]+]] = apply [[CONV_FN]]<AnyObject>([[ARRAY]]) : $@thin <τ_0_0> (@owned Array<τ_0_0>) -> @owned NSArray
|
||||
func arrayResult() -> AnyObject[] { return [] }
|
||||
func arrayResult() -> [AnyObject] { return [] }
|
||||
|
||||
// CHECK-LABEL: sil [transparent] @_TToFC13objc_bridging3Basg9arrayPropGSaSS_ : $@cc(objc_method) @thin (Bas) -> @autoreleased NSArray
|
||||
// CHECK-LABEL: sil [transparent] @_TToFC13objc_bridging3Bass9arrayPropGSaSS_ : $@cc(objc_method) @thin (NSArray, Bas) -> ()
|
||||
var arrayProp: String[] = []
|
||||
var arrayProp: [String] = []
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @_TF13objc_bridging16applyStringBlock
|
||||
|
||||
@@ -271,7 +271,7 @@ func tuple_element(x: (Int, Float)) {
|
||||
|
||||
}
|
||||
|
||||
func containers() -> (Int[], Dictionary<String, Int>) {
|
||||
func containers() -> ([Int], Dictionary<String, Int>) {
|
||||
return ([1, 2, 3], ["Ankeny": 1, "Burnside": 2, "Couch": 3])
|
||||
// CHECK-LABEL: sil @_TF13sil_locations10containers
|
||||
// CHECK: string_literal utf16 "Ankeny" {{.*}} line:[[@LINE-2]]:23
|
||||
|
||||
@@ -190,7 +190,7 @@ class C {}
|
||||
|
||||
func use(c: C) {}
|
||||
|
||||
func for_each_loop(x: C[]) {
|
||||
func for_each_loop(x: [C]) {
|
||||
for i in x {
|
||||
use(i)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func bridgedIs(obj: AnyObject) {
|
||||
|
||||
// CHECK: [[ARRAY_BRIDGE_FN:%[0-9]+]] = function_ref @_TFSa20bridgeFromObjectiveCU__fMGSaQ__FCSo7NSArrayGSaQ__
|
||||
// CHECK: apply [[ARRAY_BRIDGE_FN]]<NSString>
|
||||
case is NSString[]:
|
||||
case is [NSString]:
|
||||
()
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// RUN: %swift %s -O3 -emit-sil
|
||||
// Make sure we are not crashing on this one.
|
||||
|
||||
var a : String[] = ["foo"]
|
||||
var a : [String] = ["foo"]
|
||||
|
||||
_preconditionFailure("unreachable")
|
||||
for i in 0...a.count {
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
// As a workaround the devirtualizer checks that the array size match as
|
||||
// expected an bail if this is not the case.
|
||||
|
||||
func asHex(a: UInt8[]) -> String {
|
||||
func asHex(a: [UInt8]) -> String {
|
||||
return "".join(a.map { "0x" + String($0, radix: 16)})
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import SwiftShims
|
||||
|
||||
class MD5 {
|
||||
init()
|
||||
@final var w: UInt32[]
|
||||
@final var w: [UInt32]
|
||||
}
|
||||
|
||||
// CHECK-LABEL:sil @test_unique_check_arc : $@cc(method) @thin (@owned MD5) -> ()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//CHECK-NOT: strong_retain
|
||||
//CHECK-NOT: strong_release
|
||||
//CHECK: return
|
||||
func swapByIndex(inout A : Int8[], x : Int, y : Int) {
|
||||
func swapByIndex(inout A : [Int8], x : Int, y : Int) {
|
||||
swap(&A[x],&A[y])
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ extension Int {
|
||||
typealias EspeciallyMagicalInt = Int64
|
||||
}
|
||||
|
||||
typealias IntSlice = Int[]
|
||||
typealias IntSlice = [Int]
|
||||
|
||||
|
||||
struct Base {
|
||||
|
||||
@@ -14,7 +14,7 @@ func useNested((x: Int, y: Int), #n: Int) {}
|
||||
|
||||
func variadic(#x: Double, y: Int...) {}
|
||||
|
||||
func slice(#x: Int[]) {}
|
||||
func slice(#x: [Int]) {}
|
||||
func optional(#x: Int?) {}
|
||||
|
||||
func overloaded(#x: Int) {}
|
||||
|
||||
@@ -11,7 +11,7 @@ extension CodePoints {
|
||||
func print(x: CodePoints) { print(String(x._base)) }
|
||||
func println(x: CodePoints) { println(String(x._base)) }
|
||||
|
||||
func println(x: CodePoints[]) {
|
||||
func println(x: [CodePoints]) {
|
||||
print("[ ")
|
||||
var prefix=""
|
||||
for s in x {
|
||||
@@ -53,7 +53,7 @@ testSplit()
|
||||
// generic algorithms that work on Sequences, so need a lightweight
|
||||
// way to get Streams out of them.
|
||||
operator prefix ^ {}
|
||||
@prefix func ^ (x: Int[]) -> Array<Int>.GeneratorType
|
||||
@prefix func ^ (x: [Int]) -> Array<Int>.GeneratorType
|
||||
{ return x.generate() }
|
||||
|
||||
// FIXME: This class is a temporary workaround for
|
||||
@@ -61,7 +61,7 @@ operator prefix ^ {}
|
||||
struct VecIntStream : Generator, Sequence {
|
||||
typealias Element = Int
|
||||
|
||||
init(_ owner: Int[]) {
|
||||
init(_ owner: [Int]) {
|
||||
self.owner = owner
|
||||
self.value = owner.generate()
|
||||
}
|
||||
@@ -71,12 +71,12 @@ struct VecIntStream : Generator, Sequence {
|
||||
func generate() -> VecIntStream {
|
||||
return self
|
||||
}
|
||||
var owner: Int[]
|
||||
var owner: [Int]
|
||||
var value: Array<Int>.GeneratorType
|
||||
}
|
||||
|
||||
operator prefix ^^ {}
|
||||
@prefix func ^^ (x: Int[]) -> VecIntStream
|
||||
@prefix func ^^ (x: [Int]) -> VecIntStream
|
||||
{
|
||||
var result = Array<Int>()
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func testTakeActualArray() {
|
||||
for x in primes0 { primes1.append(x) }
|
||||
|
||||
// Take the elements of primes1 in an Array
|
||||
var primes2 : Int[] = primes1
|
||||
var primes2 : [Int] = primes1
|
||||
|
||||
// Check that the copy worked
|
||||
// CHECK-NEXT: <2> <3> <5> <7> <11> .
|
||||
|
||||
@@ -136,12 +136,12 @@ class Thunks : NSObject {
|
||||
return BridgedObjC(value)
|
||||
}
|
||||
|
||||
@objc func acceptBridgedObjCArray(x: BridgedObjC[]) {
|
||||
@objc func acceptBridgedObjCArray(x: [BridgedObjC]) {
|
||||
println("acceptBridgedObjCArray(\(x))")
|
||||
}
|
||||
|
||||
@objc func produceBridgedObjCArray(numItems: Int) -> BridgedObjC[] {
|
||||
var array: BridgedObjC[] = []
|
||||
@objc func produceBridgedObjCArray(numItems: Int) -> [BridgedObjC] {
|
||||
var array: [BridgedObjC] = []
|
||||
for i in 0..<numItems {
|
||||
array.append(BridgedObjC(i))
|
||||
}
|
||||
@@ -149,12 +149,12 @@ class Thunks : NSObject {
|
||||
return array
|
||||
}
|
||||
|
||||
@objc func acceptBridgedSwiftArray(x: BridgedSwift[]) {
|
||||
@objc func acceptBridgedSwiftArray(x: [BridgedSwift]) {
|
||||
println("acceptBridgedSwiftArray(\(x))")
|
||||
}
|
||||
|
||||
@objc func produceBridgedSwiftArray(numItems: Int) -> BridgedSwift[] {
|
||||
var array: BridgedSwift[] = []
|
||||
@objc func produceBridgedSwiftArray(numItems: Int) -> [BridgedSwift] {
|
||||
var array: [BridgedSwift] = []
|
||||
for i in 0..<numItems {
|
||||
array.append(BridgedSwift(i))
|
||||
}
|
||||
@@ -169,7 +169,7 @@ class Thunks : NSObject {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func testBridgedVerbatim() {
|
||||
let bases: Base[] = [Base(100), Base(200), Base(300)]
|
||||
let bases: [Base] = [Base(100), Base(200), Base(300)]
|
||||
|
||||
//===--- Implicit conversion to/from NSArray ------------------------------===//
|
||||
|
||||
@@ -180,8 +180,8 @@ func testBridgedVerbatim() {
|
||||
// Create an ordinary NSArray, not a native one
|
||||
let nsArrayOfBase: NSArray = NSArray(object: Base(42))
|
||||
|
||||
// NSArray converts implicitly to AnyObject[]...
|
||||
let nsArrayOfBaseConvertedToAnyObjectArray: AnyObject[] = nsArrayOfBase
|
||||
// NSArray converts implicitly to [AnyObject]...
|
||||
let nsArrayOfBaseConvertedToAnyObjectArray: [AnyObject] = nsArrayOfBase
|
||||
|
||||
// Capture the representation of the first element
|
||||
// CHECK-NEXT: [[base42:Base.*42]]
|
||||
@@ -192,12 +192,12 @@ func testBridgedVerbatim() {
|
||||
println(nsArrayOfBaseConvertedToAnyObjectArray[0] as Base)
|
||||
|
||||
//===--- Up- and Down-casts -----------------------------------------------===//
|
||||
var derived: Derived[] = [Derived(11), Derived(22)]
|
||||
var derived: [Derived] = [Derived(11), Derived(22)]
|
||||
// CHECK-NEXT: [[derived0:\[Derived#[0-9]+\(11\), Derived#[0-9]+\(22\)\]{1}]]
|
||||
println(derived)
|
||||
|
||||
// upcast is implicit
|
||||
let derivedAsBases: Base[] = derived
|
||||
let derivedAsBases: [Base] = derived
|
||||
|
||||
// CHECK-NEXT: [[derived0]]
|
||||
println(derivedAsBases)
|
||||
@@ -211,7 +211,7 @@ func testBridgedVerbatim() {
|
||||
println(derivedAsBases)
|
||||
|
||||
// CHECK-NEXT: [[derived0]]
|
||||
if let roundTripDerived = derivedAsBases as? Derived[] {
|
||||
if let roundTripDerived = derivedAsBases as? [Derived] {
|
||||
println(roundTripDerived)
|
||||
}
|
||||
else {
|
||||
@@ -219,11 +219,11 @@ func testBridgedVerbatim() {
|
||||
}
|
||||
|
||||
// CHECK-NEXT: [[derived2:\[Derived#[0-9]+\(44\), Derived#[0-9]+\(55\)\]{1}]]
|
||||
let derivedInBaseBuffer: Base[] = [Derived(44), Derived(55)]
|
||||
let derivedInBaseBuffer: [Base] = [Derived(44), Derived(55)]
|
||||
println(derivedInBaseBuffer)
|
||||
|
||||
// CHECK-NEXT: Explicit downcast-ability is based on element type, not buffer type
|
||||
if let downcastBaseBuffer = derivedInBaseBuffer as? Derived[] {
|
||||
if let downcastBaseBuffer = derivedInBaseBuffer as? [Derived] {
|
||||
println("Explicit downcast-ability is based on element type, not buffer type")
|
||||
}
|
||||
else {
|
||||
@@ -232,11 +232,11 @@ func testBridgedVerbatim() {
|
||||
|
||||
// We can up-cast to array of AnyObject
|
||||
// CHECK-NEXT: [[derived2]]
|
||||
let derivedAsAnyObjectArray: AnyObject[] = derivedInBaseBuffer
|
||||
let derivedAsAnyObjectArray: [AnyObject] = derivedInBaseBuffer
|
||||
println(derivedAsAnyObjectArray)
|
||||
|
||||
// CHECK-NEXT: downcastBackToBase = [[derived2]]
|
||||
if let downcastBackToBase = derivedAsAnyObjectArray as? Base[] {
|
||||
if let downcastBackToBase = derivedAsAnyObjectArray as? [Base] {
|
||||
println("downcastBackToBase = \(downcastBackToBase)")
|
||||
}
|
||||
else {
|
||||
@@ -244,7 +244,7 @@ func testBridgedVerbatim() {
|
||||
}
|
||||
|
||||
// CHECK-NEXT: downcastBackToDerived = [[derived2]]
|
||||
if let downcastBackToDerived = derivedAsAnyObjectArray as? Derived[] {
|
||||
if let downcastBackToDerived = derivedAsAnyObjectArray as? [Derived] {
|
||||
println("downcastBackToDerived = \(downcastBackToDerived)")
|
||||
}
|
||||
else {
|
||||
@@ -252,28 +252,28 @@ func testBridgedVerbatim() {
|
||||
}
|
||||
|
||||
// CHECK-NEXT: downcastToProtocols = [[derived2]]
|
||||
if let downcastToProtocols = derivedAsAnyObjectArray as? Fooable[] {
|
||||
if let downcastToProtocols = derivedAsAnyObjectArray as? [Fooable] {
|
||||
println("downcastToProtocols = \(downcastToProtocols)")
|
||||
} else {
|
||||
println("downcastToProtocols failed")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: downcastToProtocols = [[derived2]]
|
||||
if let downcastToProtocols = derivedAsAnyObjectArray as? Barable[] {
|
||||
if let downcastToProtocols = derivedAsAnyObjectArray as? [Barable] {
|
||||
println("downcastToProtocols = \(downcastToProtocols)")
|
||||
} else {
|
||||
println("downcastToProtocols failed")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: downcastToProtocols = [[derived2]]
|
||||
if let downcastToProtocols = derivedAsAnyObjectArray as? protocol<Barable, Fooable>[] {
|
||||
if let downcastToProtocols = derivedAsAnyObjectArray as? [protocol<Barable, Fooable>] {
|
||||
println("downcastToProtocols = \(downcastToProtocols)")
|
||||
} else {
|
||||
println("downcastToProtocols failed")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: downcastToProtocols failed
|
||||
if let downcastToProtocols = derivedAsAnyObjectArray as? protocol<Barable, Bazable>[] {
|
||||
if let downcastToProtocols = derivedAsAnyObjectArray as? [protocol<Barable, Bazable>] {
|
||||
println("downcastToProtocols = \(downcastToProtocols)")
|
||||
} else {
|
||||
println("downcastToProtocols failed")
|
||||
@@ -303,11 +303,11 @@ func testExplicitlyBridged() {
|
||||
|
||||
let bridgedSwiftsAsNSArray: NSArray = bridgedSwifts
|
||||
// CHECK-NEXT: [BridgedObjC#{{[0-9]+}}(42), BridgedObjC#{{[0-9]+}}(17)]
|
||||
println("bridgedSwiftsAsNSArray = \(bridgedSwiftsAsNSArray as AnyObject[]))")
|
||||
println("bridgedSwiftsAsNSArray = \(bridgedSwiftsAsNSArray as [AnyObject]))")
|
||||
|
||||
// Make sure we can bridge back.
|
||||
let roundTripBridgedSwifts
|
||||
= BridgedSwift[].bridgeFromObjectiveC(bridgedSwiftsAsNSArray)
|
||||
= [BridgedSwift].bridgeFromObjectiveC(bridgedSwiftsAsNSArray)
|
||||
// CHECK-NEXT-NOT: [BridgedSwift#[[id00]](42), BridgedSwift#[[id01]](17)]
|
||||
// CHECK-NEXT: [BridgedSwift#[[id10:[0-9]+]](42), BridgedSwift#[[id11:[0-9]+]](17)]
|
||||
println("roundTripBridgedSwifts = \(roundTripBridgedSwifts))")
|
||||
@@ -317,7 +317,7 @@ func testExplicitlyBridged() {
|
||||
|
||||
// ...and bridge *that* back
|
||||
let bridgedBackSwifts
|
||||
= BridgedSwift[].bridgeFromObjectiveC(cocoaBridgedSwifts)
|
||||
= [BridgedSwift].bridgeFromObjectiveC(cocoaBridgedSwifts)
|
||||
// CHECK-NEXT-NOT: [BridgedSwift#[[id00]](42), BridgedSwift#[[id01]](17)]
|
||||
// CHECK-NEXT-NOT: [BridgedSwift#[[id10]](42), BridgedSwift#[[id11]](17)]
|
||||
// CHECK-NEXT: [BridgedSwift#{{[0-9]+}}(42), BridgedSwift#{{[0-9]+}}(17)]
|
||||
@@ -325,23 +325,23 @@ func testExplicitlyBridged() {
|
||||
|
||||
// all: verbatim, not, and doesn't bridge
|
||||
// implicit conversions to/from NSArray
|
||||
// Base[] -> Derived[] and Derived[] -> Base[] where Base can be AnyObject
|
||||
// defining @objc method taking T[] and returning T[]
|
||||
// [Base] -> [Derived] and [Derived] -> [Base] where Base can be AnyObject
|
||||
// defining @objc method taking [T] and returning [T]
|
||||
|
||||
// Up-casts.
|
||||
let bridgedSwiftsAsBridgedObjCs: BridgedObjC[] = bridgedSwifts
|
||||
let bridgedSwiftsAsBridgedObjCs: [BridgedObjC] = bridgedSwifts
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(bridgedSwiftsAsBridgedObjCs[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
println(bridgedSwiftsAsBridgedObjCs[1])
|
||||
|
||||
let bridgedSwiftsAsBases: Base[] = bridgedSwifts
|
||||
let bridgedSwiftsAsBases: [Base] = bridgedSwifts
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(bridgedSwiftsAsBases[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
println(bridgedSwiftsAsBases[1])
|
||||
|
||||
let bridgedSwiftsAsAnyObjects: AnyObject[] = bridgedSwifts
|
||||
let bridgedSwiftsAsAnyObjects: [AnyObject] = bridgedSwifts
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(bridgedSwiftsAsAnyObjects[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
@@ -349,7 +349,7 @@ func testExplicitlyBridged() {
|
||||
|
||||
// Downcasts of non-verbatim bridged value types to objects.
|
||||
if true {
|
||||
let downcasted = bridgedSwifts as BridgedObjC[]
|
||||
let downcasted = bridgedSwifts as [BridgedObjC]
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
@@ -357,7 +357,7 @@ func testExplicitlyBridged() {
|
||||
}
|
||||
|
||||
if true {
|
||||
let downcasted = bridgedSwifts as Base[]
|
||||
let downcasted = bridgedSwifts as [Base]
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
@@ -365,7 +365,7 @@ func testExplicitlyBridged() {
|
||||
}
|
||||
|
||||
if true {
|
||||
let downcasted = bridgedSwifts as AnyObject[]
|
||||
let downcasted = bridgedSwifts as [AnyObject]
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
@@ -373,67 +373,67 @@ func testExplicitlyBridged() {
|
||||
}
|
||||
|
||||
// Downcasts of up-casted arrays.
|
||||
if let downcasted = bridgedSwiftsAsAnyObjects as? BridgedObjC[] {
|
||||
if let downcasted = bridgedSwiftsAsAnyObjects as? [BridgedObjC] {
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
println(downcasted[1])
|
||||
} else {
|
||||
println("Could not downcast AnyObject[] to BridgedObjC[]?")
|
||||
println("Could not downcast [AnyObject] to [BridgedObjC]?")
|
||||
}
|
||||
|
||||
if let downcasted = bridgedSwiftsAsAnyObjects as? Base[] {
|
||||
if let downcasted = bridgedSwiftsAsAnyObjects as? [Base] {
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
println(downcasted[1])
|
||||
} else {
|
||||
println("Could not downcast AnyObject[] to Base[]?")
|
||||
println("Could not downcast [AnyObject] to [Base]?")
|
||||
}
|
||||
|
||||
// Downcast of Cocoa array to an array of classes.
|
||||
let wrappedCocoaBridgedSwifts: AnyObject[] = cocoaBridgedSwifts
|
||||
if let downcasted = wrappedCocoaBridgedSwifts as? BridgedObjC[] {
|
||||
let wrappedCocoaBridgedSwifts: [AnyObject] = cocoaBridgedSwifts
|
||||
if let downcasted = wrappedCocoaBridgedSwifts as? [BridgedObjC] {
|
||||
// CHECK-NEXT: BridgedObjC#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedObjC#[[ID1:[0-9]+]](17)
|
||||
println(downcasted[1])
|
||||
} else {
|
||||
println("Could not downcast AnyObject[] to BridgedObjC[]?")
|
||||
println("Could not downcast [AnyObject] to [BridgedObjC]?")
|
||||
}
|
||||
|
||||
// Downcast of Cocoa array to an array of values.
|
||||
if let downcasted = wrappedCocoaBridgedSwifts as? BridgedSwift[] {
|
||||
if let downcasted = wrappedCocoaBridgedSwifts as? [BridgedSwift] {
|
||||
// CHECK-NEXT: BridgedSwift#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedSwift#[[ID1:[0-9]+]](17)
|
||||
println(downcasted[1])
|
||||
} else {
|
||||
println("Could not downcast AnyObject[] to BridgedSwift[]?")
|
||||
println("Could not downcast [AnyObject] to [BridgedSwift]?")
|
||||
}
|
||||
|
||||
// Downcast of Cocoa array to an array of strings (which should fail)
|
||||
// CHECK-NEXT: Could not downcast AnyObject[] to String[]
|
||||
if let downcasted = wrappedCocoaBridgedSwifts as? String[] {
|
||||
// CHECK-NEXT: Could not downcast [AnyObject] to [String]
|
||||
if let downcasted = wrappedCocoaBridgedSwifts as? [String] {
|
||||
println("Shouldn't be able to downcast to an array of strings")
|
||||
} else {
|
||||
println("Could not downcast AnyObject[] to String[]")
|
||||
println("Could not downcast [AnyObject] to [String]")
|
||||
}
|
||||
|
||||
// Downcast from an implicitly unwrapped optional array of AnyObjects.
|
||||
var wrappedCocoaBridgedSwiftsIUO: AnyObject[]! = wrappedCocoaBridgedSwifts
|
||||
if let downcasted = wrappedCocoaBridgedSwiftsIUO as? BridgedSwift[] {
|
||||
var wrappedCocoaBridgedSwiftsIUO: [AnyObject]! = wrappedCocoaBridgedSwifts
|
||||
if let downcasted = wrappedCocoaBridgedSwiftsIUO as? [BridgedSwift] {
|
||||
// CHECK-NEXT: BridgedSwift#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedSwift#[[ID1:[0-9]+]](17)
|
||||
println(downcasted[1])
|
||||
} else {
|
||||
println("Could not downcast AnyObject[]! to BridgedSwift[]")
|
||||
println("Could not downcast [AnyObject]! to [BridgedSwift]")
|
||||
}
|
||||
|
||||
// Downcast from a nil implicitly unwrapped optional array of AnyObjects.
|
||||
wrappedCocoaBridgedSwiftsIUO = nil
|
||||
if let downcasted = wrappedCocoaBridgedSwiftsIUO as? BridgedSwift[] {
|
||||
if let downcasted = wrappedCocoaBridgedSwiftsIUO as? [BridgedSwift] {
|
||||
println("Cannot downcast from a nil array!")
|
||||
} else {
|
||||
// CHECK-NEXT: Correctly rejected downcast of nil array
|
||||
@@ -441,19 +441,19 @@ func testExplicitlyBridged() {
|
||||
}
|
||||
|
||||
// Downcast from an optional array of AnyObjects.
|
||||
var wrappedCocoaBridgedSwiftsOpt: AnyObject[]? = wrappedCocoaBridgedSwifts
|
||||
if let downcasted = wrappedCocoaBridgedSwiftsOpt as? BridgedSwift[] {
|
||||
var wrappedCocoaBridgedSwiftsOpt: [AnyObject]? = wrappedCocoaBridgedSwifts
|
||||
if let downcasted = wrappedCocoaBridgedSwiftsOpt as? [BridgedSwift] {
|
||||
// CHECK-NEXT: BridgedSwift#[[ID0:[0-9]+]](42)
|
||||
println(downcasted[0])
|
||||
// CHECK-NEXT: BridgedSwift#[[ID1:[0-9]+]](17)
|
||||
println(downcasted[1])
|
||||
} else {
|
||||
println("Could not downcast AnyObject[]! to BridgedSwift[]")
|
||||
println("Could not downcast [AnyObject]! to [BridgedSwift]")
|
||||
}
|
||||
|
||||
// Downcast from a nil optional array of AnyObjects.
|
||||
wrappedCocoaBridgedSwiftsOpt = nil
|
||||
if let downcasted = wrappedCocoaBridgedSwiftsOpt as? BridgedSwift[] {
|
||||
if let downcasted = wrappedCocoaBridgedSwiftsOpt as? [BridgedSwift] {
|
||||
println("Cannot downcast from a nil array!")
|
||||
} else {
|
||||
// CHECK-NEXT: Correctly rejected downcast of nil array
|
||||
|
||||
@@ -37,7 +37,7 @@ if arg == "OutOfBounds3" {
|
||||
}
|
||||
|
||||
if arg == "OutOfBounds4" {
|
||||
var a: Int[] = []
|
||||
var a: [Int] = []
|
||||
println("OK")
|
||||
a.removeLast()
|
||||
}
|
||||
@@ -46,23 +46,23 @@ class Base { }
|
||||
class Derived : Base { }
|
||||
|
||||
if arg == "Downcast1" {
|
||||
let ba: Base[] = [Derived(), Base()]
|
||||
let ba: [Base] = [Derived(), Base()]
|
||||
// <rdar://problem/17340393> Array downcast should do deferred checking
|
||||
// FIXME: The "OK" should be moved after "let d0 = da[0]" when we
|
||||
// get deferred checking.
|
||||
println("OK")
|
||||
let da: Derived[] = _arrayDownCast(ba)
|
||||
let da: [Derived] = _arrayDownCast(ba)
|
||||
let d0 = da[0]
|
||||
let d1 = da[1]
|
||||
}
|
||||
|
||||
if arg == "Downcast2" {
|
||||
let a: AnyObject[] = ["String", 1]
|
||||
let a: [AnyObject] = ["String", 1]
|
||||
// <rdar://problem/17340393> Array downcast should do deferred checking
|
||||
// FIXME: The "OK" should be moved after "let s0 = sa[0]" when we
|
||||
// get deferred checking.
|
||||
println("OK")
|
||||
let sa: NSString[] = _arrayBridgeFromObjectiveC(a)
|
||||
let sa: [NSString] = _arrayBridgeFromObjectiveC(a)
|
||||
let s0 = sa[0]
|
||||
let s1 = sa[1]
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func testScope() {
|
||||
|
||||
// Because the elements come back at +0, we really don't want to
|
||||
// treat them as objects, or we'll get double deletion
|
||||
let objects: Word[] = [0, 0]
|
||||
let objects: [Word] = [0, 0]
|
||||
|
||||
objects.withUnsafePointerToElements {
|
||||
nsx.getObjects(
|
||||
|
||||
@@ -1170,7 +1170,7 @@ func uniformRandom(max: Int) -> Int {
|
||||
return random() % max
|
||||
}
|
||||
|
||||
func pickRandom<T>(a: T[]) -> T {
|
||||
func pickRandom<T>(a: [T]) -> T {
|
||||
return a[uniformRandom(a.count)]
|
||||
}
|
||||
|
||||
@@ -1201,7 +1201,7 @@ func testDeleteChainCollisionRandomized() {
|
||||
|
||||
let chainLength = 7
|
||||
|
||||
var knownKeys: TestKeyTy[] = []
|
||||
var knownKeys: [TestKeyTy] = []
|
||||
func getKey(value: Int) -> TestKeyTy {
|
||||
for k in knownKeys {
|
||||
if k.value == value {
|
||||
@@ -2783,7 +2783,7 @@ func test_BridgedFromObjC_Verbatim_ArrayOfDictionaries() {
|
||||
getAsNSDictionary([ 10: 1010 + i, 20: 1020 + i, 30: 1030 + i ]))
|
||||
}
|
||||
|
||||
var a = nsa as AnyObject[] as Dictionary<NSObject, AnyObject>[]
|
||||
var a = nsa as [AnyObject] as [Dictionary<NSObject, AnyObject>]
|
||||
for i in 0..<3 {
|
||||
var d = a[i]
|
||||
var gen = d.generate()
|
||||
@@ -2807,7 +2807,7 @@ func test_BridgedFromObjC_Nonverbatim_ArrayOfDictionaries() {
|
||||
getAsNSDictionary([ 10: 1010 + i, 20: 1020 + i, 30: 1030 + i ]))
|
||||
}
|
||||
|
||||
var a = nsa as AnyObject[] as Dictionary<TestBridgedKeyTy, TestBridgedValueTy>[]
|
||||
var a = nsa as [AnyObject] as [Dictionary<TestBridgedKeyTy, TestBridgedValueTy>]
|
||||
for i in 0..<3 {
|
||||
var d = a[i]
|
||||
var gen = d.generate()
|
||||
|
||||
@@ -15,7 +15,7 @@ struct Print<T : Printable> : Sink {
|
||||
|
||||
var z = [ 1, 2, 3 ]
|
||||
|
||||
func printArray<T : Printable>(x: T[]) {
|
||||
func printArray<T : Printable>(x: [T]) {
|
||||
pipe(SequenceOf(x), SinkOf(Print<T>()))
|
||||
println()
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ struct Bundle {
|
||||
locations = Array()
|
||||
}
|
||||
var name = String()
|
||||
var locations: String[]
|
||||
var locations: [String]
|
||||
}
|
||||
|
||||
var a = HeapBuffer<Bundle,Int>(HeapBufferStorage<Bundle,Int>.self, Bundle(), 10)
|
||||
|
||||
@@ -23,37 +23,37 @@ JoinTestCase.test("${ArrayType}") {
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[]]
|
||||
let seq: [ArrayType] = [[]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[], []]
|
||||
let seq: [ArrayType] = [[], []]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[], [], []]
|
||||
let seq: [ArrayType] = [[], [], []]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ]]
|
||||
let seq: [ArrayType] = [[ 1 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ], [ 2 ]]
|
||||
let seq: [ArrayType] = [[ 1 ], [ 2 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 2 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ], [ 2 ], [ 3 ]]
|
||||
let seq: [ArrayType] = [[ 1 ], [ 2 ], [ 3 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 2, 3 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]
|
||||
let seq: [ArrayType] = [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 2, 3, 4, 5, 6 ], r)
|
||||
}
|
||||
@@ -63,42 +63,42 @@ JoinTestCase.test("${ArrayType}") {
|
||||
if true {
|
||||
let separator: ArrayType = [ 42 ]
|
||||
if true {
|
||||
let seq: ArrayType[] = []
|
||||
let seq: [ArrayType] = []
|
||||
let r = join(separator, seq)
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[]]
|
||||
let seq: [ArrayType] = [[]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[], []]
|
||||
let seq: [ArrayType] = [[], []]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 42 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[], [], []]
|
||||
let seq: [ArrayType] = [[], [], []]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 42, 42 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ]]
|
||||
let seq: [ArrayType] = [[ 1 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ], [ 2 ]]
|
||||
let seq: [ArrayType] = [[ 1 ], [ 2 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 42, 2 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ], [ 2 ], [ 3 ]]
|
||||
let seq: [ArrayType] = [[ 1 ], [ 2 ], [ 3 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 42, 2, 42, 3 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]
|
||||
let seq: [ArrayType] = [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 2, 42, 3, 4, 42, 5, 6 ], r)
|
||||
}
|
||||
@@ -108,42 +108,42 @@ JoinTestCase.test("${ArrayType}") {
|
||||
if true {
|
||||
let separator: ArrayType = [ 42, 4242 ]
|
||||
if true {
|
||||
let seq: ArrayType[] = []
|
||||
let seq: [ArrayType] = []
|
||||
let r = join(separator, seq)
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[]]
|
||||
let seq: [ArrayType] = [[]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[], []]
|
||||
let seq: [ArrayType] = [[], []]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 42, 4242 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[], [], []]
|
||||
let seq: [ArrayType] = [[], [], []]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 42, 4242, 42, 4242 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ]]
|
||||
let seq: [ArrayType] = [[ 1 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ], [ 2 ]]
|
||||
let seq: [ArrayType] = [[ 1 ], [ 2 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 42, 4242, 2 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1 ], [ 2 ], [ 3 ]]
|
||||
let seq: [ArrayType] = [[ 1 ], [ 2 ], [ 3 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 42, 4242, 2, 42, 4242, 3 ], r)
|
||||
}
|
||||
if true {
|
||||
let seq: ArrayType[] = [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]
|
||||
let seq: [ArrayType] = [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]
|
||||
let r = join(separator, seq)
|
||||
expectEqual([ 1, 2, 42, 4242, 3, 4, 42, 4242, 5, 6 ], r)
|
||||
}
|
||||
@@ -155,7 +155,7 @@ JoinTestCase.test("${ArrayType}") {
|
||||
|
||||
if true {
|
||||
let separator: ArrayType = [ 42, 4242 ]
|
||||
let seq: ArrayType[] = [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]
|
||||
let seq: [ArrayType] = [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]
|
||||
let r = separator.join(seq)
|
||||
expectEqual([ 1, 2, 42, 4242, 3, 4, 42, 4242, 5, 6 ], r)
|
||||
}
|
||||
@@ -300,131 +300,131 @@ struct MinimalCollection : Collection {
|
||||
JoinTestCase.test("OperatorPlus") {
|
||||
// ExtensibleCollection + Sequence
|
||||
if true {
|
||||
var ec: Int[] = []
|
||||
var s = SequenceOf(Int[]())
|
||||
var r: Int[] = ec + s
|
||||
var ec: [Int] = []
|
||||
var s = SequenceOf([Int]())
|
||||
var r: [Int] = ec + s
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
var ec: Int[] = []
|
||||
var ec: [Int] = []
|
||||
var s = SequenceOf([ 4, 5, 6, 7 ])
|
||||
var r: Int[] = ec + s
|
||||
var r: [Int] = ec + s
|
||||
expectEqual([ 4, 5, 6, 7 ], r)
|
||||
}
|
||||
if true {
|
||||
var ec: Int[] = [ 1, 2, 3 ]
|
||||
var s = SequenceOf(Int[]())
|
||||
var r: Int[] = ec + s
|
||||
var ec: [Int] = [ 1, 2, 3 ]
|
||||
var s = SequenceOf([Int]())
|
||||
var r: [Int] = ec + s
|
||||
expectEqual([ 1, 2, 3 ], r)
|
||||
}
|
||||
if true {
|
||||
var ec: Int[] = [ 1, 2, 3 ]
|
||||
var ec: [Int] = [ 1, 2, 3 ]
|
||||
var s = SequenceOf([ 4, 5, 6, 7 ])
|
||||
var r: Int[] = ec + s
|
||||
var r: [Int] = ec + s
|
||||
expectEqual([ 1, 2, 3, 4, 5, 6, 7 ], r)
|
||||
}
|
||||
|
||||
// Sequence + ExtensibleCollection
|
||||
if true {
|
||||
var s = SequenceOf(Int[]())
|
||||
var ec: Int[] = []
|
||||
var r: Int[] = s + ec
|
||||
var s = SequenceOf([Int]())
|
||||
var ec: [Int] = []
|
||||
var r: [Int] = s + ec
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
var s = SequenceOf(Int[]())
|
||||
var ec: Int[] = [ 4, 5, 6, 7 ]
|
||||
var r: Int[] = s + ec
|
||||
var s = SequenceOf([Int]())
|
||||
var ec: [Int] = [ 4, 5, 6, 7 ]
|
||||
var r: [Int] = s + ec
|
||||
expectEqual([ 4, 5, 6, 7 ], r)
|
||||
}
|
||||
if true {
|
||||
var s = SequenceOf([ 1, 2, 3 ])
|
||||
var ec: Int[] = []
|
||||
var r: Int[] = s + ec
|
||||
var ec: [Int] = []
|
||||
var r: [Int] = s + ec
|
||||
expectEqual([ 1, 2, 3 ], r)
|
||||
}
|
||||
if true {
|
||||
var s = SequenceOf([ 1, 2, 3 ])
|
||||
var ec: Int[] = [ 4, 5, 6, 7]
|
||||
var r: Int[] = s + ec
|
||||
var ec: [Int] = [ 4, 5, 6, 7]
|
||||
var r: [Int] = s + ec
|
||||
expectEqual([ 1, 2, 3, 4, 5, 6, 7 ], r)
|
||||
}
|
||||
|
||||
// ExtensibleCollection + Collection
|
||||
if true {
|
||||
var ec: Int[] = []
|
||||
var c = MinimalCollection(Int[]())
|
||||
var r: Int[] = ec + c
|
||||
var ec: [Int] = []
|
||||
var c = MinimalCollection([Int]())
|
||||
var r: [Int] = ec + c
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
var ec: Int[] = []
|
||||
var ec: [Int] = []
|
||||
var c = MinimalCollection([ 4, 5, 6, 7 ])
|
||||
var r: Int[] = ec + c
|
||||
var r: [Int] = ec + c
|
||||
expectEqual([ 4, 5, 6, 7 ], r)
|
||||
}
|
||||
if true {
|
||||
var ec: Int[] = [ 1, 2, 3 ]
|
||||
var c = MinimalCollection(Int[]())
|
||||
var r: Int[] = ec + c
|
||||
var ec: [Int] = [ 1, 2, 3 ]
|
||||
var c = MinimalCollection([Int]())
|
||||
var r: [Int] = ec + c
|
||||
expectEqual([ 1, 2, 3 ], r)
|
||||
}
|
||||
if true {
|
||||
var ec: Int[] = [ 1, 2, 3 ]
|
||||
var ec: [Int] = [ 1, 2, 3 ]
|
||||
var c = MinimalCollection([ 4, 5, 6, 7 ])
|
||||
var r: Int[] = ec + c
|
||||
var r: [Int] = ec + c
|
||||
expectEqual([ 1, 2, 3, 4, 5, 6, 7 ], r)
|
||||
}
|
||||
|
||||
// ExtensibleCollection + same ExtensibleCollection
|
||||
if true {
|
||||
var ec1: Int[] = []
|
||||
var ec2: Int[] = []
|
||||
var r: Int[] = ec1 + ec2
|
||||
var ec1: [Int] = []
|
||||
var ec2: [Int] = []
|
||||
var r: [Int] = ec1 + ec2
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
var ec1: Int[] = []
|
||||
var ec2: Int[] = [ 4, 5, 6, 7 ]
|
||||
var r: Int[] = ec1 + ec2
|
||||
var ec1: [Int] = []
|
||||
var ec2: [Int] = [ 4, 5, 6, 7 ]
|
||||
var r: [Int] = ec1 + ec2
|
||||
expectEqual([ 4, 5, 6, 7 ], r)
|
||||
}
|
||||
if true {
|
||||
var ec1: Int[] = [ 1, 2, 3 ]
|
||||
var ec2: Int[] = []
|
||||
var r: Int[] = ec1 + ec2
|
||||
var ec1: [Int] = [ 1, 2, 3 ]
|
||||
var ec2: [Int] = []
|
||||
var r: [Int] = ec1 + ec2
|
||||
expectEqual([ 1, 2, 3 ], r)
|
||||
}
|
||||
if true {
|
||||
var ec1: Int[] = [ 1, 2, 3 ]
|
||||
var ec2: Int[] = [ 4, 5, 6, 7 ]
|
||||
var r: Int[] = ec1 + ec2
|
||||
var ec1: [Int] = [ 1, 2, 3 ]
|
||||
var ec2: [Int] = [ 4, 5, 6, 7 ]
|
||||
var r: [Int] = ec1 + ec2
|
||||
expectEqual([ 1, 2, 3, 4, 5, 6, 7 ], r)
|
||||
}
|
||||
|
||||
// ExtensibleCollection + other ExtensibleCollection
|
||||
if true {
|
||||
var ec1: Int[] = []
|
||||
var ec2 = MockExtensibleCollection(Int[]())
|
||||
var r: Int[] = ec1 + ec2
|
||||
var ec1: [Int] = []
|
||||
var ec2 = MockExtensibleCollection([Int]())
|
||||
var r: [Int] = ec1 + ec2
|
||||
expectEqual([], r)
|
||||
}
|
||||
if true {
|
||||
var ec1: Int[] = []
|
||||
var ec1: [Int] = []
|
||||
var ec2 = MockExtensibleCollection([ 4, 5, 6, 7 ])
|
||||
var r: Int[] = ec1 + ec2
|
||||
var r: [Int] = ec1 + ec2
|
||||
expectEqual([ 4, 5, 6, 7 ], r)
|
||||
}
|
||||
if true {
|
||||
var ec1: Int[] = [ 1, 2, 3 ]
|
||||
var ec2 = MockExtensibleCollection(Int[]())
|
||||
var r: Int[] = ec1 + ec2
|
||||
var ec1: [Int] = [ 1, 2, 3 ]
|
||||
var ec2 = MockExtensibleCollection([Int]())
|
||||
var r: [Int] = ec1 + ec2
|
||||
expectEqual([ 1, 2, 3 ], r)
|
||||
}
|
||||
if true {
|
||||
var ec1: Int[] = [ 1, 2, 3 ]
|
||||
var ec1: [Int] = [ 1, 2, 3 ]
|
||||
var ec2 = MockExtensibleCollection([ 4, 5, 6, 7 ])
|
||||
var r: Int[] = ec1 + ec2
|
||||
var r: [Int] = ec1 + ec2
|
||||
expectEqual([ 1, 2, 3, 4, 5, 6, 7 ], r)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import Foundation
|
||||
var NSStringAPIs = TestCase("NSStringAPIs")
|
||||
|
||||
NSStringAPIs.test("Encodings") {
|
||||
let availableEncodings: NSStringEncoding[] = String.availableStringEncodings()
|
||||
let availableEncodings: [NSStringEncoding] = String.availableStringEncodings()
|
||||
expectNotEqual(0, availableEncodings.count)
|
||||
|
||||
let defaultCStringEncoding = String.defaultCStringEncoding()
|
||||
@@ -250,7 +250,7 @@ NSStringAPIs.test("completePathIntoString(_:caseSensitive:matchesIntoArray:filte
|
||||
|
||||
if true {
|
||||
var outputName = "None Found"
|
||||
var outputArray: String[] = [ "foo", "bar" ]
|
||||
var outputArray: [String] = [ "foo", "bar" ]
|
||||
var count = nonExistentPath.completePathIntoString(
|
||||
&outputName, caseSensitive: false, matchesIntoArray: &outputArray)
|
||||
|
||||
@@ -275,7 +275,7 @@ NSStringAPIs.test("completePathIntoString(_:caseSensitive:matchesIntoArray:filte
|
||||
|
||||
if true {
|
||||
var outputName = "None Found"
|
||||
var outputArray: String[] = [ "foo", "bar" ]
|
||||
var outputArray: [String] = [ "foo", "bar" ]
|
||||
var count = existingPath.completePathIntoString(
|
||||
&outputName, caseSensitive: false, matchesIntoArray: &outputArray)
|
||||
|
||||
@@ -308,8 +308,8 @@ NSStringAPIs.test("componentsSeparatedByString(_:)") {
|
||||
NSStringAPIs.test("cStringUsingEncoding(_:)") {
|
||||
expectEmpty("абв".cStringUsingEncoding(NSASCIIStringEncoding))
|
||||
|
||||
let expectedBytes: UInt8[] = [ 0xd0, 0xb0, 0xd0, 0xb1, 0xd0, 0xb2, 0 ]
|
||||
var expectedStr: CChar[] = expectedBytes.map { $0.asSigned() }
|
||||
let expectedBytes: [UInt8] = [ 0xd0, 0xb0, 0xd0, 0xb1, 0xd0, 0xb2, 0 ]
|
||||
var expectedStr: [CChar] = expectedBytes.map { $0.asSigned() }
|
||||
expectEqual(expectedStr,
|
||||
"абв".cStringUsingEncoding(NSUTF8StringEncoding)!)
|
||||
}
|
||||
@@ -321,7 +321,7 @@ NSStringAPIs.test("dataUsingEncoding(_:allowLossyConversion:)") {
|
||||
let data = "あいう".dataUsingEncoding(NSUTF8StringEncoding)
|
||||
let bytes = Array(UnsafeArray(
|
||||
start: UnsafePointer<UInt8>(data!.bytes), length: data!.length))
|
||||
let expectedBytes: UInt8[] = [
|
||||
let expectedBytes: [UInt8] = [
|
||||
0xe3, 0x81, 0x82, 0xe3, 0x81, 0x84, 0xe3, 0x81, 0x86
|
||||
]
|
||||
expectTrue(equal(expectedBytes, bytes))
|
||||
@@ -340,7 +340,7 @@ NSStringAPIs.test("decomposedStringWithCompatibilityMapping") {
|
||||
}
|
||||
|
||||
NSStringAPIs.test("enumerateLines(_:)") {
|
||||
var lines: String[] = []
|
||||
var lines: [String] = []
|
||||
"abc\n\ndefghi\njklm".enumerateLines {
|
||||
(line: String, inout stop: Bool)
|
||||
in
|
||||
@@ -356,9 +356,9 @@ NSStringAPIs.test("enumerateLinguisticTagsInRange(_:scheme:options:orthography:_
|
||||
let s = "Абв. Глокая куздра штеко будланула бокра и кудрячит бокрёнка. Абв."
|
||||
let startIndex = advance(s.startIndex, 5)
|
||||
let endIndex = advance(s.startIndex, 62)
|
||||
var tags: String[] = []
|
||||
var tokens: String[] = []
|
||||
var sentences: String[] = []
|
||||
var tags: [String] = []
|
||||
var tokens: [String] = []
|
||||
var sentences: [String] = []
|
||||
s.enumerateLinguisticTagsInRange(startIndex..<endIndex,
|
||||
scheme: NSLinguisticTagSchemeTokenType,
|
||||
options: NSLinguisticTaggerOptions(0),
|
||||
@@ -387,7 +387,7 @@ NSStringAPIs.test("enumerateSubstringsInRange(_:options:_:)") {
|
||||
// FIXME: this might need to be adjusted to 5 when we implement
|
||||
// grapheme clusters properly.
|
||||
let endIndex = advance(s.startIndex, 7)
|
||||
var substrings: String[] = []
|
||||
var substrings: [String] = []
|
||||
s.enumerateSubstringsInRange(startIndex..<endIndex,
|
||||
options: NSStringEnumerationOptions.ByComposedCharacterSequences) {
|
||||
(substring: String, substringRange: Range<String.Index>,
|
||||
@@ -401,20 +401,20 @@ NSStringAPIs.test("enumerateSubstringsInRange(_:options:_:)") {
|
||||
}
|
||||
|
||||
NSStringAPIs.test("fastestEncoding") {
|
||||
let availableEncodings: NSStringEncoding[] = String.availableStringEncodings()
|
||||
let availableEncodings: [NSStringEncoding] = String.availableStringEncodings()
|
||||
expectTrue(contains(availableEncodings, "abc".fastestEncoding))
|
||||
}
|
||||
|
||||
NSStringAPIs.test("fileSystemRepresentation()") {
|
||||
if true {
|
||||
let expectedStr: CChar[] = Array(map("abc\0".utf8) { $0.asSigned() })
|
||||
let expectedStr: [CChar] = Array(map("abc\0".utf8) { $0.asSigned() })
|
||||
expectEqual(expectedStr, "abc".fileSystemRepresentation())
|
||||
}
|
||||
|
||||
// On OSX file system representation is Unicode NFD.
|
||||
// This test might need to be adjusted for other systems.
|
||||
if true {
|
||||
let expectedStr: CChar[] =
|
||||
let expectedStr: [CChar] =
|
||||
Array(map("\u305f\u3099くてん\0".utf8) { $0.asSigned() })
|
||||
expectEqual(expectedStr, "だくてん".fileSystemRepresentation())
|
||||
}
|
||||
@@ -427,11 +427,11 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
if true {
|
||||
// 'maxLength' is limiting.
|
||||
let bufferLength = 100
|
||||
var expectedStr: UInt8[] = Array("def где ".utf8)
|
||||
var expectedStr: [UInt8] = Array("def где ".utf8)
|
||||
while (expectedStr.count != bufferLength) {
|
||||
expectedStr += 0xff
|
||||
}
|
||||
var buffer = UInt8[](count: bufferLength, repeatedValue: 0xff)
|
||||
var buffer = [UInt8](count: bufferLength, repeatedValue: 0xff)
|
||||
var usedLength = 0
|
||||
var remainingRange = startIndex..<endIndex
|
||||
var result = s.getBytes(&buffer, maxLength: 11, usedLength: &usedLength,
|
||||
@@ -448,11 +448,11 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
// 'bufferLength' is limiting. Note that the buffer is not filled
|
||||
// completely, since doing that would break a UTF sequence.
|
||||
let bufferLength = 5
|
||||
var expectedStr: UInt8[] = Array("def ".utf8)
|
||||
var expectedStr: [UInt8] = Array("def ".utf8)
|
||||
while (expectedStr.count != bufferLength) {
|
||||
expectedStr += 0xff
|
||||
}
|
||||
var buffer = UInt8[](count: bufferLength, repeatedValue: 0xff)
|
||||
var buffer = [UInt8](count: bufferLength, repeatedValue: 0xff)
|
||||
var usedLength = 0
|
||||
var remainingRange = startIndex..<endIndex
|
||||
var result = s.getBytes(&buffer, maxLength: 11, usedLength: &usedLength,
|
||||
@@ -468,11 +468,11 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
if true {
|
||||
// 'range' is converted completely.
|
||||
let bufferLength = 100
|
||||
var expectedStr: UInt8[] = Array("def где gh жз ".utf8)
|
||||
var expectedStr: [UInt8] = Array("def где gh жз ".utf8)
|
||||
while (expectedStr.count != bufferLength) {
|
||||
expectedStr += 0xff
|
||||
}
|
||||
var buffer = UInt8[](count: bufferLength, repeatedValue: 0xff)
|
||||
var buffer = [UInt8](count: bufferLength, repeatedValue: 0xff)
|
||||
var usedLength = 0
|
||||
var remainingRange = startIndex..<endIndex
|
||||
var result = s.getBytes(&buffer, maxLength: bufferLength,
|
||||
@@ -488,11 +488,11 @@ NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remain
|
||||
if true {
|
||||
// Inappropriate encoding.
|
||||
let bufferLength = 100
|
||||
var expectedStr: UInt8[] = Array("def ".utf8)
|
||||
var expectedStr: [UInt8] = Array("def ".utf8)
|
||||
while (expectedStr.count != bufferLength) {
|
||||
expectedStr += 0xff
|
||||
}
|
||||
var buffer = UInt8[](count: bufferLength, repeatedValue: 0xff)
|
||||
var buffer = [UInt8](count: bufferLength, repeatedValue: 0xff)
|
||||
var usedLength = 0
|
||||
var remainingRange = startIndex..<endIndex
|
||||
var result = s.getBytes(&buffer, maxLength: bufferLength,
|
||||
@@ -511,18 +511,18 @@ NSStringAPIs.test("getCString(_:maxLength:encoding:)") {
|
||||
var s = "abc あかさた"
|
||||
if true {
|
||||
let bufferLength = 16
|
||||
var buffer = CChar[](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var buffer = [CChar](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var result = s.getCString(&buffer, maxLength: 100,
|
||||
encoding: NSUTF8StringEncoding)
|
||||
expectFalse(result)
|
||||
}
|
||||
if true {
|
||||
let bufferLength = 17
|
||||
var expectedStr: CChar[] = Array(map("abc あかさた\0".utf8) { $0.asSigned() })
|
||||
var expectedStr: [CChar] = Array(map("abc あかさた\0".utf8) { $0.asSigned() })
|
||||
while (expectedStr.count != bufferLength) {
|
||||
expectedStr += (0xff).asSigned()
|
||||
}
|
||||
var buffer = CChar[](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var buffer = [CChar](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var result = s.getCString(&buffer, maxLength: 100,
|
||||
encoding: NSUTF8StringEncoding)
|
||||
expectTrue(result)
|
||||
@@ -530,7 +530,7 @@ NSStringAPIs.test("getCString(_:maxLength:encoding:)") {
|
||||
}
|
||||
if true {
|
||||
let bufferLength = 100
|
||||
var buffer = CChar[](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var buffer = [CChar](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var result = s.getCString(&buffer, maxLength: 8,
|
||||
encoding: NSUTF8StringEncoding)
|
||||
expectFalse(result)
|
||||
@@ -543,18 +543,18 @@ NSStringAPIs.test("getFileSystemRepresentation(_:maxLength:)") {
|
||||
var s = "abc だくてん"
|
||||
if true {
|
||||
let bufferLength = 16
|
||||
var buffer = CChar[](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var buffer = [CChar](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var result = s.getFileSystemRepresentation(&buffer, maxLength: 100)
|
||||
expectFalse(result)
|
||||
}
|
||||
if true {
|
||||
let bufferLength = 100
|
||||
var expectedStr: CChar[] =
|
||||
var expectedStr: [CChar] =
|
||||
Array(map("abc \u305f\u3099くてん\0".utf8) { $0.asSigned() })
|
||||
while (expectedStr.count != bufferLength) {
|
||||
expectedStr += (0xff).asSigned()
|
||||
}
|
||||
var buffer = CChar[](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
var buffer = [CChar](count: bufferLength, repeatedValue: (0xff).asSigned())
|
||||
expectTrue(s.getFileSystemRepresentation(&buffer, maxLength: bufferLength))
|
||||
expectTrue(equal(expectedStr, buffer))
|
||||
}
|
||||
@@ -600,7 +600,7 @@ NSStringAPIs.test("hash") {
|
||||
|
||||
NSStringAPIs.test("stringWithBytes(_:length:encoding:)") {
|
||||
var s: String = "abc あかさた"
|
||||
var bytes: UInt8[] = Array(s.utf8)
|
||||
var bytes: [UInt8] = Array(s.utf8)
|
||||
expectOptionalEqual(s, String.stringWithBytes(bytes, length: bytes.count,
|
||||
encoding: NSUTF8StringEncoding))
|
||||
|
||||
@@ -617,7 +617,7 @@ NSStringAPIs.test("stringWithBytes(_:length:encoding:)") {
|
||||
|
||||
NSStringAPIs.test("stringWithBytesNoCopy(_:length:encoding:freeWhenDone:)") {
|
||||
var s: String = "abc あかさた"
|
||||
var bytes: UInt8[] = Array(s.utf8)
|
||||
var bytes: [UInt8] = Array(s.utf8)
|
||||
expectOptionalEqual(s, String.stringWithBytesNoCopy(&bytes,
|
||||
length: bytes.count, encoding: NSUTF8StringEncoding,
|
||||
freeWhenDone: false))
|
||||
@@ -635,14 +635,14 @@ NSStringAPIs.test("stringWithBytesNoCopy(_:length:encoding:freeWhenDone:)") {
|
||||
|
||||
NSStringAPIs.test("init(utf16CodeUnits:count:)") {
|
||||
let expected = "abc абв \U0001F60A"
|
||||
let chars: unichar[] = Array(expected.utf16)
|
||||
let chars: [unichar] = Array(expected.utf16)
|
||||
|
||||
expectEqual(expected, String(utf16CodeUnits: chars, count: chars.count))
|
||||
}
|
||||
|
||||
NSStringAPIs.test("init(utf16CodeUnitsNoCopy:count:freeWhenDone:)") {
|
||||
let expected = "abc абв \U0001F60A"
|
||||
let chars: unichar[] = Array(expected.utf16)
|
||||
let chars: [unichar] = Array(expected.utf16)
|
||||
|
||||
expectEqual(expected, String(utf16CodeUnitsNoCopy: chars,
|
||||
count: chars.count, freeWhenDone: false))
|
||||
@@ -656,7 +656,7 @@ NSStringAPIs.test("init(format:_:...)") {
|
||||
|
||||
NSStringAPIs.test("init(format:arguments:)") {
|
||||
let world: NSString = "world"
|
||||
let args: CVarArg[] = [ world, 42 ]
|
||||
let args: [CVarArg] = [ world, 42 ]
|
||||
expectEqual("Hello, world!%42",
|
||||
String(format: "Hello, %@!%%%ld", arguments: args))
|
||||
}
|
||||
@@ -671,7 +671,7 @@ NSStringAPIs.test("init(format:locale:_:...)") {
|
||||
|
||||
NSStringAPIs.test("init(format:locale:arguments:)") {
|
||||
let world: NSString = "world"
|
||||
let args: CVarArg[] = [ world, 42 ]
|
||||
let args: [CVarArg] = [ world, 42 ]
|
||||
expectEqual("Hello, world!%42", String(format: "Hello, %@!%%%ld",
|
||||
locale: nil, arguments: args))
|
||||
expectEqual("Hello, world!%42", String(format: "Hello, %@!%%%ld",
|
||||
@@ -706,7 +706,7 @@ NSStringAPIs.test("linguisticTagsInRange(_:scheme:options:orthography:tokenRange
|
||||
let s = "Абв. Глокая куздра штеко будланула бокра и кудрячит бокрёнка. Абв."
|
||||
let startIndex = advance(s.startIndex, 5)
|
||||
let endIndex = advance(s.startIndex, 17)
|
||||
var tokenRanges: Range<String.Index>[] = []
|
||||
var tokenRanges: [Range<String.Index>] = []
|
||||
var tags = s.linguisticTagsInRange(startIndex..<endIndex,
|
||||
scheme: NSLinguisticTagSchemeTokenType,
|
||||
options: NSLinguisticTaggerOptions(0),
|
||||
@@ -816,7 +816,7 @@ NSStringAPIs.test("precomposedStringWithCompatibilityMapping") {
|
||||
|
||||
NSStringAPIs.test("propertyList()") {
|
||||
expectEqual([ "foo", "bar" ],
|
||||
"(\"foo\", \"bar\")".propertyList() as String[])
|
||||
"(\"foo\", \"bar\")".propertyList() as [String])
|
||||
}
|
||||
|
||||
NSStringAPIs.test("propertyListFromStringsFileFormat()") {
|
||||
@@ -1066,7 +1066,7 @@ func getIllFormedUTF8String2() -> (CString, dealloc: ()->()) {
|
||||
return (CString(up), { up.dealloc(100) })
|
||||
}
|
||||
|
||||
func asCCharArray(a: UInt8[]) -> CChar[] {
|
||||
func asCCharArray(a: [UInt8]) -> [CChar] {
|
||||
return a.map { $0.asSigned() }
|
||||
}
|
||||
|
||||
|
||||
@@ -455,7 +455,7 @@ testSingleElementModifiers${A}()
|
||||
|
||||
//===--- Regression Tests -------------------------------------------------===//
|
||||
func rdar16958865() {
|
||||
var a: Int[] = []
|
||||
var a: [Int] = []
|
||||
a += SequenceOf([ 42, 4242 ])
|
||||
// CHECK-NEXT: [42, 4242]
|
||||
println(a)
|
||||
@@ -465,7 +465,7 @@ rdar16958865()
|
||||
import SpriteKit
|
||||
|
||||
class Rdar16914909 : NSObject {
|
||||
var basicColorSet = SKColor[]()
|
||||
var basicColorSet = [SKColor]()
|
||||
|
||||
func doColorStuff() {
|
||||
basicColorSet.append(SKColor.lightGrayColor())
|
||||
|
||||
@@ -84,7 +84,7 @@ println("forced extraction use: \(x!.successor()).")
|
||||
func testRelation(p: (Int?, Int?) -> Bool) {
|
||||
typealias optPair = (Int?, Int?)
|
||||
|
||||
let relationships: optPair[] = [
|
||||
let relationships: [optPair] = [
|
||||
(1, 1), (1, 2), (2, 1), (1, .None), (.None, 1), (.None, .None)
|
||||
]
|
||||
|
||||
|
||||
@@ -506,7 +506,7 @@ test_ObjectPrinting()
|
||||
// CHECK: test_ObjectPrinting done
|
||||
|
||||
func test_ArrayPrinting() {
|
||||
var arrayOfInts: Int[] = []
|
||||
var arrayOfInts: [Int] = []
|
||||
printedIs(arrayOfInts, "[]")
|
||||
|
||||
printedIs([ 1 ], "[1]")
|
||||
|
||||
@@ -587,7 +587,7 @@ struct Pear<T, U> { let fst: T; let snd: U }
|
||||
class SubScene: SKScene {
|
||||
let foo = 12_131_415
|
||||
let bar = "boom"
|
||||
let bas: Pear<Int, Any?[]> = Pear(fst: 219, snd: ["boom", 123, 456.0])
|
||||
let bas: Pear<Int, [Any?]> = Pear(fst: 219, snd: ["boom", 123, 456.0])
|
||||
let zim = 20721
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ StringTests.test("sizeof") {
|
||||
}
|
||||
|
||||
func checkUnicodeScalarViewIteration(
|
||||
expectedScalars: UInt32[], str: String) -> AssertionResult {
|
||||
expectedScalars: [UInt32], str: String) -> AssertionResult {
|
||||
if true {
|
||||
var us = str.unicodeScalars
|
||||
var i = us.startIndex
|
||||
var end = us.endIndex
|
||||
var decoded: UInt32[] = []
|
||||
var decoded: [UInt32] = []
|
||||
while i != end {
|
||||
decoded += us[i].value
|
||||
i = i.successor()
|
||||
@@ -30,7 +30,7 @@ func checkUnicodeScalarViewIteration(
|
||||
var us = str.unicodeScalars
|
||||
var start = us.startIndex
|
||||
var i = us.endIndex
|
||||
var decoded: UInt32[] = []
|
||||
var decoded: [UInt32] = []
|
||||
while i != start {
|
||||
i = i.predecessor()
|
||||
decoded += us[i].value
|
||||
@@ -123,7 +123,7 @@ func testStringToInt() {
|
||||
// then print if the new String is or is not still an Int.
|
||||
func testConvertabilityOfStringWithModification(
|
||||
initialValue: Int,
|
||||
modification: (inout chars: UTF8.CodeUnit[]) -> () )
|
||||
modification: (inout chars: [UTF8.CodeUnit]) -> () )
|
||||
{
|
||||
var chars = Array(String(initialValue).utf8)
|
||||
modification(chars: &chars)
|
||||
@@ -135,7 +135,7 @@ func testStringToInt() {
|
||||
var minChars = String(Int.min).utf8
|
||||
|
||||
testConvertabilityOfStringWithModification(Int.min) {
|
||||
(inout chars: UTF8.CodeUnit[]) in ()
|
||||
(inout chars: [UTF8.CodeUnit]) in ()
|
||||
}
|
||||
// CHECK-NEXT: {{-9223372036854775808|-2147483648}} is an Int
|
||||
|
||||
@@ -161,7 +161,7 @@ func testStringToInt() {
|
||||
|
||||
|
||||
testConvertabilityOfStringWithModification(Int.max) {
|
||||
(inout chars: UTF8.CodeUnit[]) in ()
|
||||
(inout chars: [UTF8.CodeUnit]) in ()
|
||||
}
|
||||
// CHECK-NEXT: {{9223372036854775807|2147483647}} is an Int
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ extension UTF32 : TestableUnicodeCodec {
|
||||
var _unicodeScalarRanges = Array<Range<UInt32>>()
|
||||
|
||||
// The valid ranges of Unicode scalar values
|
||||
var unicodeScalarRanges : Range<UInt32>[] {
|
||||
var unicodeScalarRanges : [Range<UInt32>] {
|
||||
if _unicodeScalarRanges.count == 0 {
|
||||
for r in [UInt32(0)..<0xD800, 0xE000..<0xFDD0, 0xFDF0..<0xFFFE] {
|
||||
_unicodeScalarRanges.append(r)
|
||||
@@ -75,7 +75,7 @@ func nthUnicodeScalar(n: UInt32) -> UnicodeScalar {
|
||||
func nsEncode<CodeUnit>(
|
||||
var c: UInt32,
|
||||
encoding: NSStringEncoding,
|
||||
inout buffer: CodeUnit[],
|
||||
inout buffer: [CodeUnit],
|
||||
inout used: Int
|
||||
) {
|
||||
var s = NSString(
|
||||
@@ -131,7 +131,7 @@ class ArraySink<T: IntegerLiteralConvertible> : Sink {
|
||||
return storage[0..<count]
|
||||
}
|
||||
var count = 0
|
||||
var storage: T[] = Array()
|
||||
var storage: [T] = Array()
|
||||
}
|
||||
|
||||
@asmname("random") func random() -> UInt32
|
||||
@@ -161,7 +161,7 @@ else {
|
||||
class CodecTest<Codec: TestableUnicodeCodec> {
|
||||
var used = 0
|
||||
typealias CodeUnit = Codec.CodeUnit
|
||||
var nsEncodeBuffer: CodeUnit[] = Array(count: 4, repeatedValue: 0)
|
||||
var nsEncodeBuffer: [CodeUnit] = Array(count: 4, repeatedValue: 0)
|
||||
var encodeBuffer = ArraySink<CodeUnit>(capacity: 4)
|
||||
|
||||
func testOne(scalar: UnicodeScalar)
|
||||
@@ -219,7 +219,7 @@ CodecTest<UTF16>().run()
|
||||
// CHECK-NEXT: done.
|
||||
CodecTest<UTF32>().run()
|
||||
|
||||
func println(a: UTF8.CodeUnit[]) {
|
||||
func println(a: [UTF8.CodeUnit]) {
|
||||
print("[ ")
|
||||
var prefix = ""
|
||||
for x in a {
|
||||
@@ -229,7 +229,7 @@ func println(a: UTF8.CodeUnit[]) {
|
||||
println(" ]")
|
||||
}
|
||||
|
||||
func println(a: UTF16.CodeUnit[]) {
|
||||
func println(a: [UTF16.CodeUnit]) {
|
||||
print("[ ")
|
||||
var prefix = ""
|
||||
for x in a {
|
||||
@@ -254,8 +254,8 @@ func additionalUtf16Tests() {
|
||||
// CHECK-NEXT: true
|
||||
println(UTF16.trailSurrogate("𝄞") == 0xDD1E)
|
||||
|
||||
var u8: UTF8.CodeUnit[] = [ 0, 1, 2, 3, 4, 5 ]
|
||||
var u16: UTF16.CodeUnit[] = [ 6, 7, 8, 9, 10, 11 ]
|
||||
var u8: [UTF8.CodeUnit] = [ 0, 1, 2, 3, 4, 5 ]
|
||||
var u16: [UTF16.CodeUnit] = [ 6, 7, 8, 9, 10, 11 ]
|
||||
|
||||
u16.withUnsafePointerToElements {
|
||||
(p16)->() in
|
||||
@@ -301,11 +301,11 @@ additionalUtf16Tests()
|
||||
import StdlibUnittest
|
||||
|
||||
class EOFCountingGenerator<T> : Generator {
|
||||
var array: T[]
|
||||
var array: [T]
|
||||
var index: Int = 0
|
||||
var numTimesReturnedEOF: Int = 0
|
||||
|
||||
init(_ array: T[]) {
|
||||
init(_ array: [T]) {
|
||||
self.array = array
|
||||
}
|
||||
|
||||
@@ -319,11 +319,11 @@ class EOFCountingGenerator<T> : Generator {
|
||||
}
|
||||
|
||||
func checkDecodeUTF<Codec : UnicodeCodec>(
|
||||
codec: Codec.Type, expectedHead: UInt32[],
|
||||
expectedRepairedTail: UInt32[], utfStr: Codec.CodeUnit[]
|
||||
codec: Codec.Type, expectedHead: [UInt32],
|
||||
expectedRepairedTail: [UInt32], utfStr: [Codec.CodeUnit]
|
||||
) -> AssertionResult {
|
||||
if true {
|
||||
var decoded: UInt32[] = []
|
||||
var decoded: [UInt32] = []
|
||||
var g = EOFCountingGenerator(utfStr)
|
||||
transcode(codec, UTF32.self, g,
|
||||
SinkOf {
|
||||
@@ -343,7 +343,7 @@ func checkDecodeUTF<Codec : UnicodeCodec>(
|
||||
var expected = expectedHead
|
||||
expected += expectedRepairedTail
|
||||
|
||||
var decoded: UInt32[] = []
|
||||
var decoded: [UInt32] = []
|
||||
var g = EOFCountingGenerator(utfStr)
|
||||
transcode(codec, UTF32.self, g,
|
||||
SinkOf {
|
||||
@@ -363,30 +363,30 @@ func checkDecodeUTF<Codec : UnicodeCodec>(
|
||||
}
|
||||
|
||||
func checkDecodeUTF8(
|
||||
expectedHead: UInt32[],
|
||||
expectedRepairedTail: UInt32[], utf8Str: UInt8[]
|
||||
expectedHead: [UInt32],
|
||||
expectedRepairedTail: [UInt32], utf8Str: [UInt8]
|
||||
) -> AssertionResult {
|
||||
return checkDecodeUTF(UTF8.self, expectedHead, expectedRepairedTail, utf8Str)
|
||||
}
|
||||
|
||||
func checkDecodeUTF16(
|
||||
expectedHead: UInt32[],
|
||||
expectedRepairedTail: UInt32[], utf16Str: UInt16[]
|
||||
expectedHead: [UInt32],
|
||||
expectedRepairedTail: [UInt32], utf16Str: [UInt16]
|
||||
) -> AssertionResult {
|
||||
return checkDecodeUTF(UTF16.self, expectedHead, expectedRepairedTail,
|
||||
utf16Str)
|
||||
}
|
||||
|
||||
func checkDecodeUTF32(
|
||||
expectedHead: UInt32[],
|
||||
expectedRepairedTail: UInt32[], utf32Str: UInt32[]
|
||||
expectedHead: [UInt32],
|
||||
expectedRepairedTail: [UInt32], utf32Str: [UInt32]
|
||||
) -> AssertionResult {
|
||||
return checkDecodeUTF(UTF32.self, expectedHead, expectedRepairedTail,
|
||||
utf32Str)
|
||||
}
|
||||
|
||||
func checkEncodeUTF8(expected: UInt8[], scalars: UInt32[]) -> AssertionResult {
|
||||
var encoded: UInt8[] = []
|
||||
func checkEncodeUTF8(expected: [UInt8], scalars: [UInt32]) -> AssertionResult {
|
||||
var encoded: [UInt8] = []
|
||||
var g = EOFCountingGenerator(scalars)
|
||||
let hadError = transcode(UTF32.self, UTF8.self, g,
|
||||
SinkOf {
|
||||
@@ -406,11 +406,11 @@ func checkEncodeUTF8(expected: UInt8[], scalars: UInt32[]) -> AssertionResult {
|
||||
}
|
||||
|
||||
struct UTF8Test {
|
||||
let scalars: UInt32[]
|
||||
let encoded: UInt8[]
|
||||
let scalars: [UInt32]
|
||||
let encoded: [UInt8]
|
||||
let loc: SourceLoc
|
||||
|
||||
init(_ scalars: UInt32[], _ encoded: UInt8[],
|
||||
init(_ scalars: [UInt32], _ encoded: [UInt8],
|
||||
file: String = __FILE__, line: UWord = __LINE__) {
|
||||
self.scalars = scalars
|
||||
self.encoded = encoded
|
||||
@@ -611,13 +611,13 @@ let UTF8TestsSmokeTest = [
|
||||
]
|
||||
|
||||
struct UTF16Test {
|
||||
let scalarsHead: UInt32[]
|
||||
let scalarsRepairedTail: UInt32[]
|
||||
let encoded: UInt16[]
|
||||
let scalarsHead: [UInt32]
|
||||
let scalarsRepairedTail: [UInt32]
|
||||
let encoded: [UInt16]
|
||||
let loc: SourceLoc
|
||||
|
||||
init(_ scalarsHead: UInt32[], _ scalarsRepairedTail: UInt32[],
|
||||
_ encoded: UInt16[],
|
||||
init(_ scalarsHead: [UInt32], _ scalarsRepairedTail: [UInt32],
|
||||
_ encoded: [UInt16],
|
||||
file: String = __FILE__, line: UWord = __LINE__) {
|
||||
self.scalarsHead = scalarsHead
|
||||
self.scalarsRepairedTail = scalarsRepairedTail
|
||||
@@ -2254,8 +2254,8 @@ import Foundation
|
||||
// The most simple subclass of NSString that CoreFoundation does not know
|
||||
// about.
|
||||
class NonContiguousNSString : NSString {
|
||||
convenience init(_ scalars: UInt8[]) {
|
||||
var encoded: UInt16[] = []
|
||||
convenience init(_ scalars: [UInt8]) {
|
||||
var encoded: [UInt16] = []
|
||||
var g = scalars.generate()
|
||||
let hadError = transcode(UTF8.self, UTF16.self, g,
|
||||
SinkOf {
|
||||
@@ -2266,13 +2266,13 @@ class NonContiguousNSString : NSString {
|
||||
self.init(encoded)
|
||||
}
|
||||
|
||||
init(_ value: UInt16[]) {
|
||||
init(_ value: [UInt16]) {
|
||||
_value = value
|
||||
super.init()
|
||||
}
|
||||
|
||||
convenience init(_ scalars: UInt32[]) {
|
||||
var encoded: UInt16[] = []
|
||||
convenience init(_ scalars: [UInt32]) {
|
||||
var encoded: [UInt16] = []
|
||||
var g = scalars.generate()
|
||||
let hadError = transcode(UTF32.self, UTF16.self, g,
|
||||
SinkOf {
|
||||
@@ -2297,19 +2297,19 @@ class NonContiguousNSString : NSString {
|
||||
return _value[index]
|
||||
}
|
||||
|
||||
var _value: UInt16[]
|
||||
var _value: [UInt16]
|
||||
}
|
||||
|
||||
func checkUTF8View(expected: UInt8[], stringUnderTest: String) {
|
||||
let utf8Bytes: UInt8[] = Array(stringUnderTest.utf8)
|
||||
func checkUTF8View(expected: [UInt8], stringUnderTest: String) {
|
||||
let utf8Bytes: [UInt8] = Array(stringUnderTest.utf8)
|
||||
expectEqual(expected, utf8Bytes)
|
||||
}
|
||||
|
||||
func checkUTF16View(expected: UInt16[], stringUnderTest: String,
|
||||
func checkUTF16View(expected: [UInt16], stringUnderTest: String,
|
||||
extraLoc: SourceLoc) {
|
||||
if true {
|
||||
// Test .generate() method.
|
||||
var utf16Words: UInt16[] = []
|
||||
var utf16Words: [UInt16] = []
|
||||
var g = stringUnderTest.utf16.generate()
|
||||
while let u = g.next() {
|
||||
utf16Words += u
|
||||
@@ -2319,7 +2319,7 @@ func checkUTF16View(expected: UInt16[], stringUnderTest: String,
|
||||
|
||||
if true {
|
||||
// Test subscript(Int).
|
||||
var utf16Words: UInt16[] = []
|
||||
var utf16Words: [UInt16] = []
|
||||
var view = stringUnderTest.utf16
|
||||
for var i = view.startIndex; i != view.endIndex; ++i {
|
||||
utf16Words += view[i]
|
||||
@@ -2331,7 +2331,7 @@ func checkUTF16View(expected: UInt16[], stringUnderTest: String,
|
||||
// Test subscript(Range<Int>).
|
||||
for start in 0...expected.count {
|
||||
for end in start...expected.count {
|
||||
var utf16Words: UInt16[] = []
|
||||
var utf16Words: [UInt16] = []
|
||||
var view = stringUnderTest.utf16[start..<end]
|
||||
for var i = view.startIndex; i != view.endIndex; ++i {
|
||||
utf16Words += view[i]
|
||||
@@ -2376,8 +2376,8 @@ StringCookedViews.test("UTF8ForContiguousUTF16") {
|
||||
// CoreFoundation off the ASCII fast path.
|
||||
//
|
||||
// U+0283 LATIN SMALL LETTER ESH
|
||||
var backingStorage: UInt16[] = [ 0x0283 ]
|
||||
let expected: UInt8[] = [ 0xca, 0x83 ] + test.encoded
|
||||
var backingStorage: [UInt16] = [ 0x0283 ]
|
||||
let expected: [UInt8] = [ 0xca, 0x83 ] + test.encoded
|
||||
|
||||
var g = test.scalars.generate()
|
||||
transcode(UTF32.self, UTF16.self, g,
|
||||
@@ -2400,7 +2400,7 @@ StringCookedViews.test("UTF8ForContiguousUTF16") {
|
||||
|
||||
forStringsWithUnpairedSurrogates {
|
||||
(test: UTF16Test, subject: String) -> () in
|
||||
var expected: UInt8[] = []
|
||||
var expected: [UInt8] = []
|
||||
var expectedScalars = test.scalarsHead + test.scalarsRepairedTail
|
||||
var g = expectedScalars.generate()
|
||||
transcode(UTF32.self, UTF8.self, g,
|
||||
@@ -2444,7 +2444,7 @@ StringCookedViews.test("UTF8ForNonContiguousUTF16") {
|
||||
for (name, batch) in UTF16Tests {
|
||||
println("Batch: \(name)")
|
||||
for test in batch {
|
||||
var expected: UInt8[] = []
|
||||
var expected: [UInt8] = []
|
||||
var expectedScalars = test.scalarsHead + test.scalarsRepairedTail
|
||||
var g = expectedScalars.generate()
|
||||
transcode(UTF32.self, UTF8.self, g,
|
||||
@@ -2464,7 +2464,7 @@ StringCookedViews.test("UTF8ForNonContiguousUTF16Extra") {
|
||||
// These tests don't add much additional value as long as tests above
|
||||
// actually test the code path we care about.
|
||||
if true {
|
||||
var bytes: UInt8[] = [ 97, 98, 99 ]
|
||||
var bytes: [UInt8] = [ 97, 98, 99 ]
|
||||
var cfstring: CFString = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
|
||||
bytes, bytes.count, CFStringBuiltInEncodings.MacRoman.toRaw(), 0, kCFAllocatorNull)
|
||||
|
||||
@@ -2483,7 +2483,7 @@ StringCookedViews.test("UTF8ForNonContiguousUTF16Extra") {
|
||||
}
|
||||
|
||||
if true {
|
||||
var bytes: UInt8[] = [ 97, 98, 99 ]
|
||||
var bytes: [UInt8] = [ 97, 98, 99 ]
|
||||
var cfstring: CFString = CFStringCreateWithBytes(kCFAllocatorDefault,
|
||||
bytes, bytes.count, CFStringBuiltInEncodings.MacRoman.toRaw(), 0)
|
||||
|
||||
@@ -2506,7 +2506,7 @@ StringCookedViews.test("UTF8ForNonContiguousUTF16Extra") {
|
||||
|
||||
StringCookedViews.test("UTF16") {
|
||||
for test in UTF8TestsSmokeTest {
|
||||
var expected: UInt16[] = []
|
||||
var expected: [UInt16] = []
|
||||
var expectedScalars = test.scalars
|
||||
var g = expectedScalars.generate()
|
||||
transcode(UTF32.self, UTF16.self, g,
|
||||
@@ -2521,7 +2521,7 @@ StringCookedViews.test("UTF16") {
|
||||
|
||||
forStringsWithUnpairedSurrogates {
|
||||
(test: UTF16Test, subject: String) -> () in
|
||||
var expected: UInt16[] = []
|
||||
var expected: [UInt16] = []
|
||||
var expectedScalars = test.scalarsHead + test.scalarsRepairedTail
|
||||
var g = expectedScalars.generate()
|
||||
transcode(UTF32.self, UTF16.self, g,
|
||||
@@ -2538,7 +2538,7 @@ StringCookedViews.test("UnicodeScalars") {
|
||||
forStringsWithUnpairedSurrogates {
|
||||
(test: UTF16Test, subject: String) -> () in
|
||||
let expected = test.scalarsHead + test.scalarsRepairedTail
|
||||
let actual: UInt32[] = Array(map(subject.unicodeScalars) { $0.value })
|
||||
let actual: [UInt32] = Array(map(subject.unicodeScalars) { $0.value })
|
||||
expectEqual(expected, actual)
|
||||
}
|
||||
}
|
||||
@@ -2553,7 +2553,7 @@ StringTests.test("StreamableConformance") {
|
||||
(test: UTF16Test, subject: String) -> () in
|
||||
let expected = test.scalarsHead + test.scalarsRepairedTail
|
||||
let printedSubject = toString(subject)
|
||||
let actual: UInt32[] =
|
||||
let actual: [UInt32] =
|
||||
Array(map(printedSubject.unicodeScalars) { $0.value })
|
||||
expectEqual(expected, actual)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// Generate all possible permutes.
|
||||
func _permuteInternal(
|
||||
elem: Int, size : Int,
|
||||
inout perm : Int[], inout visited : Bool[],
|
||||
verify : (Int[]) -> ()
|
||||
inout perm : [Int], inout visited : [Bool],
|
||||
verify : ([Int]) -> ()
|
||||
) {
|
||||
if (elem == size) {
|
||||
verify(perm)
|
||||
@@ -23,16 +23,16 @@ func _permuteInternal(
|
||||
}
|
||||
|
||||
// Convenience wrapper for the permute method.
|
||||
func permute(size : Int, verify : (Int[]) -> ()) {
|
||||
var perm = Int[](count: size, repeatedValue: 0)
|
||||
var visited = Bool[](count: size, repeatedValue: false)
|
||||
func permute(size : Int, verify : ([Int]) -> ()) {
|
||||
var perm = [Int](count: size, repeatedValue: 0)
|
||||
var visited = [Bool](count: size, repeatedValue: false)
|
||||
_permuteInternal(0, size, &perm, &visited, verify)
|
||||
}
|
||||
|
||||
|
||||
// A simple random number generator.
|
||||
func randomize(size : Int, verify : (Int[]) -> ()) {
|
||||
var arr : Int[] = []
|
||||
func randomize(size : Int, verify : ([Int]) -> ()) {
|
||||
var arr : [Int] = []
|
||||
var N = 1
|
||||
var M = 1
|
||||
for i in 0..<size {
|
||||
@@ -47,7 +47,7 @@ func randomize(size : Int, verify : (Int[]) -> ()) {
|
||||
}
|
||||
|
||||
// Verify the permute method itself:
|
||||
let printer : (Int[]) -> () = {
|
||||
let printer : ([Int]) -> () = {
|
||||
println($0)
|
||||
}
|
||||
//CHECK: [0, 1, 2]
|
||||
@@ -59,7 +59,7 @@ let printer : (Int[]) -> () = {
|
||||
permute(3, printer)
|
||||
|
||||
// Now, let's verify the sort.
|
||||
let sort_verifier : (Int[]) -> () = {
|
||||
let sort_verifier : ([Int]) -> () = {
|
||||
var y = sorted($0)
|
||||
for i in 0..<y.count - 1 {
|
||||
if (y[i] > y[i+1]) {
|
||||
@@ -77,7 +77,7 @@ permute(7, sort_verifier)
|
||||
println("Test1 - Done")
|
||||
|
||||
// Now, let's verify the sort.
|
||||
let partition_verifier : (Int[]) -> () = {
|
||||
let partition_verifier : ([Int]) -> () = {
|
||||
var y = $0
|
||||
// Partition() returns the index to the pivot value.
|
||||
let idx = partition(&y, 0..<y.count)
|
||||
|
||||
Reference in New Issue
Block a user