mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[tests] Update tests as String.CharacterView is deprecated
This commit is contained in:
@@ -418,7 +418,7 @@ extension Array where Element: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
func rdar29633747(characters: String.CharacterView) {
|
||||
func rdar29633747(characters: String) {
|
||||
let _ = Array(characters).trimmed(["("])
|
||||
}
|
||||
|
||||
|
||||
@@ -396,7 +396,6 @@ func resyncParserB11() {}
|
||||
// rdar://21346928
|
||||
func optStr() -> String? { return nil }
|
||||
let x = (optStr() ?? "autoclosure").#^TOP_LEVEL_AUTOCLOSURE_1^#
|
||||
// AUTOCLOSURE_STRING: Decl[InstanceVar]/CurrNominal: characters[#String.CharacterView#]
|
||||
// AUTOCLOSURE_STRING: Decl[InstanceVar]/CurrNominal: unicodeScalars[#String.UnicodeScalarView#]
|
||||
// AUTOCLOSURE_STRING: Decl[InstanceVar]/CurrNominal: utf16[#String.UTF16View#]
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ func giveMeAString() -> Int {
|
||||
return "Here's a string".#^LITERAL5^# // try .characters.count here
|
||||
}
|
||||
|
||||
// LITERAL5-DAG: Decl[InstanceVar]/CurrNominal: characters[#String.CharacterView#]{{; name=.+$}}
|
||||
// LITERAL5-DAG: Decl[InstanceVar]/CurrNominal: endIndex[#String.Index#]{{; name=.+$}}
|
||||
// LITERAL5-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: reserveCapacity({#(n): Int#})[#Void#]{{; name=.+$}}
|
||||
// LITERAL5-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: append({#(c): Character#})[#Void#]{{; name=.+$}}
|
||||
|
||||
@@ -1730,7 +1730,6 @@ func testThrows006() {
|
||||
|
||||
// rdar://21346928
|
||||
// Just sample some String API to sanity check.
|
||||
// AUTOCLOSURE_STRING: Decl[InstanceVar]/CurrNominal: characters[#String.CharacterView#]
|
||||
// AUTOCLOSURE_STRING: Decl[InstanceVar]/CurrNominal: unicodeScalars[#String.UnicodeScalarView#]
|
||||
// AUTOCLOSURE_STRING: Decl[InstanceVar]/CurrNominal: utf16[#String.UTF16View#]
|
||||
func testWithAutoClosure1(_ x: String?) {
|
||||
|
||||
@@ -1127,7 +1127,7 @@ func test22436880() {
|
||||
|
||||
// sr-184
|
||||
let x: String? // expected-note 2 {{constant defined here}}
|
||||
print(x?.characters.count as Any) // expected-error {{constant 'x' used before being initialized}}
|
||||
print(x?.count as Any) // expected-error {{constant 'x' used before being initialized}}
|
||||
print(x!) // expected-error {{constant 'x' used before being initialized}}
|
||||
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ func _String<S : Sequence>(s: S, sep: String) where S.Iterator.Element == String
|
||||
_ = s.joinWithSeparator(sep) // expected-error {{'joinWithSeparator' has been renamed to 'joined(separator:)'}} {{9-26=joined}} {{27-27=separator: }} {{none}}
|
||||
}
|
||||
|
||||
func _StringCharacterView<S, C>(x: String.CharacterView, s: S, c: C, i: String.CharacterView.Index)
|
||||
func _StringCharacterView<S, C>(x: String, s: S, c: C, i: String.Index)
|
||||
where S : Sequence, S.Iterator.Element == Character, C : Collection, C.Iterator.Element == Character {
|
||||
var x = x
|
||||
x.replaceRange(i..<i, with: c) // expected-error {{'replaceRange(_:with:)' has been renamed to 'replaceSubrange'}} {{5-17=replaceSubrange}} {{none}}
|
||||
|
||||
@@ -82,7 +82,7 @@ func testStringCollectionTypes(s: String) {
|
||||
acceptsBidirectionalCollection(s.unicodeScalars)
|
||||
acceptsRandomAccessCollection(s.unicodeScalars) // expected-error{{argument type 'String.UnicodeScalarView' does not conform to expected type 'RandomAccessCollection'}}
|
||||
|
||||
acceptsCollection(s.characters)
|
||||
acceptsBidirectionalCollection(s.characters)
|
||||
acceptsRandomAccessCollection(s.characters) // expected-error{{argument type 'String.CharacterView' does not conform to expected type 'RandomAccessCollection'}}
|
||||
acceptsCollection(s)
|
||||
acceptsBidirectionalCollection(s)
|
||||
acceptsRandomAccessCollection(s) // expected-error{{argument type 'String' does not conform to expected type 'RandomAccessCollection'}}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ func testStringCollectionTypes(s: String) {
|
||||
acceptsBidirectionalCollection(s.unicodeScalars)
|
||||
acceptsRandomAccessCollection(s.unicodeScalars) // expected-error{{argument type 'String.UnicodeScalarView' does not conform to expected type 'RandomAccessCollection'}}
|
||||
|
||||
acceptsCollection(s.characters)
|
||||
acceptsBidirectionalCollection(s.characters)
|
||||
acceptsRandomAccessCollection(s.characters) // expected-error{{argument type 'String.CharacterView' does not conform to expected type 'RandomAccessCollection'}}
|
||||
acceptsCollection(s)
|
||||
acceptsBidirectionalCollection(s)
|
||||
acceptsRandomAccessCollection(s) // expected-error{{argument type 'String' does not conform to expected type 'RandomAccessCollection'}}
|
||||
}
|
||||
|
||||
struct NotLosslessStringConvertible {}
|
||||
|
||||
@@ -48,7 +48,7 @@ func test_UnicodeScalarView(s: String.UnicodeScalarView, i: String.UnicodeScalar
|
||||
_ = s.distance(from: i, to: i) // OK
|
||||
}
|
||||
|
||||
func test_CharacterView(s: String.CharacterView, i: String.CharacterView.Index, d: Int) {
|
||||
func test_CharacterView(s: String, i: String.Index, d: Int) {
|
||||
_ = s.index(after: i) // OK
|
||||
_ = s.index(before: i) // OK
|
||||
_ = s.index(i, offsetBy: d) // OK
|
||||
|
||||
Reference in New Issue
Block a user