mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[stdlib] String internal API review changes
I had to XFAIL test/ClangModules/cf.swift, which is failing for reasons I can't understand. <rdar://problem/16911496> Swift SVN r18071
This commit is contained in:
@@ -99,8 +99,7 @@ extension String {
|
|||||||
func withCString<Result>(
|
func withCString<Result>(
|
||||||
f: (CString)->Result
|
f: (CString)->Result
|
||||||
) -> Result {
|
) -> Result {
|
||||||
var u8 = self.nulTerminatedUTF8()
|
return self.nulTerminatedUTF8.withUnsafePointerToElements {
|
||||||
return u8.buffer.withUnsafePointerToElements {
|
|
||||||
f(CString($0))
|
f(CString($0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,8 +110,7 @@ extension String {
|
|||||||
func withCString<Result>(
|
func withCString<Result>(
|
||||||
f: (UnsafePointer<CChar>)->Result
|
f: (UnsafePointer<CChar>)->Result
|
||||||
) -> Result {
|
) -> Result {
|
||||||
var u8 = self.nulTerminatedUTF8()
|
return self.nulTerminatedUTF8.withUnsafePointerToElements {
|
||||||
return u8.buffer.withUnsafePointerToElements {
|
|
||||||
f(UnsafePointer($0))
|
f(UnsafePointer($0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ extension String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
// FIXME: Locales make this interesting
|
var uppercaseString : String {
|
||||||
var uppercase : String {
|
|
||||||
let end = utf8.endIndex
|
let end = utf8.endIndex
|
||||||
var resultArray = NativeArray<UTF8.CodeUnit>(count: countElements(utf8),
|
var resultArray = NativeArray<UTF8.CodeUnit>(count: countElements(utf8),
|
||||||
value: 0)
|
value: 0)
|
||||||
@@ -112,7 +111,7 @@ extension String {
|
|||||||
return String(UTF8.self, input: resultArray)
|
return String(UTF8.self, input: resultArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
var lowercase : String {
|
var lowercaseString : String {
|
||||||
let end = utf8.endIndex
|
let end = utf8.endIndex
|
||||||
var resultArray = NativeArray<UTF8.CodeUnit>(count: countElements(utf8),
|
var resultArray = NativeArray<UTF8.CodeUnit>(count: countElements(utf8),
|
||||||
value: 0)
|
value: 0)
|
||||||
@@ -158,17 +157,17 @@ extension String {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func startsWith(prefix: String) -> Bool {
|
func hasPrefix(prefix: String) -> Bool {
|
||||||
return Swift.startsWith(self, prefix)
|
return Swift.startsWith(self, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func endsWith(suffix: String) -> Bool {
|
func hasSuffix(suffix: String) -> Bool {
|
||||||
return Swift.startsWith(Reverse(self), Reverse(suffix))
|
return Swift.startsWith(Reverse(self), Reverse(suffix))
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAlpha() -> Bool { return _isAll({ $0.isAlpha() }) }
|
func _isAlpha() -> Bool { return _isAll({ $0.isAlpha() }) }
|
||||||
func isDigit() -> Bool { return _isAll({ $0.isDigit() }) }
|
func _isDigit() -> Bool { return _isAll({ $0.isDigit() }) }
|
||||||
func isSpace() -> Bool { return _isAll({ $0.isSpace() }) }
|
func _isSpace() -> Bool { return _isAll({ $0.isSpace() }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Represent a positive integer value in the given radix,
|
/// \brief Represent a positive integer value in the given radix,
|
||||||
@@ -215,9 +214,9 @@ func _formatSignedInteger(
|
|||||||
// Conversions to string from other types.
|
// Conversions to string from other types.
|
||||||
extension String {
|
extension String {
|
||||||
|
|
||||||
init(_ v: Int64, radix: Int = 10, uppercase: Bool = false) {
|
init(_ v: Int64, radix: Int = 10, _uppercase: Bool = false) {
|
||||||
var format = _formatSignedInteger(v, UInt64(radix),
|
var format = _formatSignedInteger(v, UInt64(radix),
|
||||||
ten: uppercase ? "A" : "a")
|
ten: _uppercase ? "A" : "a")
|
||||||
var asciiCount = 0
|
var asciiCount = 0
|
||||||
format(stream: { _ in ++asciiCount;() })
|
format(stream: { _ in ++asciiCount;() })
|
||||||
var buffer = _StringBuffer(
|
var buffer = _StringBuffer(
|
||||||
@@ -228,9 +227,9 @@ extension String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This function assumes UTF16
|
// FIXME: This function assumes UTF16
|
||||||
init(_ v: UInt64, radix: Int = 10, uppercase: Bool = false) {
|
init(_ v: UInt64, radix: Int = 10, _uppercase: Bool = false) {
|
||||||
var format = _formatPositiveInteger(v, UInt64(radix),
|
var format = _formatPositiveInteger(v, UInt64(radix),
|
||||||
ten: uppercase ? "A" : "a")
|
ten: _uppercase ? "A" : "a")
|
||||||
var asciiCount = v == 0 ? 1 : 0
|
var asciiCount = v == 0 ? 1 : 0
|
||||||
format(stream: { _ in ++asciiCount;() })
|
format(stream: { _ in ++asciiCount;() })
|
||||||
var buffer = _StringBuffer(
|
var buffer = _StringBuffer(
|
||||||
@@ -243,40 +242,44 @@ extension String {
|
|||||||
self = String(buffer)
|
self = String(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
init(_ v : Int8, radix : Int = 10, uppercase : Bool = false) {
|
init(_ v : Int8, radix : Int = 10, _uppercase : Bool = false) {
|
||||||
self = String(Int64(v), radix: radix, uppercase: uppercase)
|
self = String(Int64(v), radix: radix, _uppercase: _uppercase)
|
||||||
}
|
}
|
||||||
init(_ v : Int16, radix : Int = 10, uppercase : Bool = false) {
|
init(_ v : Int16, radix : Int = 10, _uppercase : Bool = false) {
|
||||||
self = String(Int64(v), radix: radix, uppercase: uppercase)
|
self = String(Int64(v), radix: radix, _uppercase: _uppercase)
|
||||||
}
|
}
|
||||||
init(_ v : Int32, radix : Int = 10, uppercase : Bool = false) {
|
init(_ v : Int32, radix : Int = 10, _uppercase : Bool = false) {
|
||||||
self = String(Int64(v), radix: radix, uppercase: uppercase)
|
self = String(Int64(v), radix: radix, _uppercase: _uppercase)
|
||||||
}
|
}
|
||||||
init(_ v : Int, radix : Int = 10, uppercase : Bool = false) {
|
init(_ v : Int, radix : Int = 10, _uppercase : Bool = false) {
|
||||||
self = String(Int64(v), radix: radix, uppercase: uppercase)
|
self = String(Int64(v), radix: radix, _uppercase: _uppercase)
|
||||||
}
|
}
|
||||||
init(_ v : UInt8, radix : Int = 10, uppercase : Bool = false) {
|
init(_ v : UInt8, radix : Int = 10, _uppercase : Bool = false) {
|
||||||
self = String(UInt64(v), radix: radix, uppercase: uppercase)
|
self = String(UInt64(v), radix: radix, _uppercase: _uppercase)
|
||||||
}
|
}
|
||||||
init(_ v : UInt16, radix : Int = 10, uppercase : Bool = false) {
|
init(_ v : UInt16, radix : Int = 10, _uppercase : Bool = false) {
|
||||||
self = String(UInt64(v), radix: radix, uppercase: uppercase)
|
self = String(UInt64(v), radix: radix, _uppercase: _uppercase)
|
||||||
}
|
}
|
||||||
init(_ v : UInt32, radix : Int = 10, uppercase : Bool = false) {
|
init(_ v : UInt32, radix : Int = 10, _uppercase : Bool = false) {
|
||||||
self = String(UInt64(v), radix: radix, uppercase: uppercase)
|
self = String(UInt64(v), radix: radix, _uppercase: _uppercase)
|
||||||
}
|
}
|
||||||
init(_ v : UInt, radix : Int = 10, uppercase : Bool = false) {
|
init(_ v : UInt, radix : Int = 10, _uppercase : Bool = false) {
|
||||||
self = String(UInt64(v), radix: radix, uppercase: uppercase)
|
self = String(UInt64(v), radix: radix, _uppercase: _uppercase)
|
||||||
}
|
}
|
||||||
|
|
||||||
init(_ v : Double) {
|
typealias _Double = Double
|
||||||
|
typealias _Float = Float
|
||||||
|
typealias _Bool = Bool
|
||||||
|
|
||||||
|
init(_ v : _Double) {
|
||||||
self = _doubleToString(v)
|
self = _doubleToString(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
init(_ v : Float) {
|
init(_ v : _Float) {
|
||||||
self = String(Double(v))
|
self = String(Double(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
init(_ b : Bool) {
|
init(_ b : _Bool) {
|
||||||
if b {
|
if b {
|
||||||
self = "true"
|
self = "true"
|
||||||
} else {
|
} else {
|
||||||
@@ -344,7 +347,7 @@ extension String {
|
|||||||
extension String {
|
extension String {
|
||||||
/// \brief Produce a substring of the given string from the given character
|
/// \brief Produce a substring of the given string from the given character
|
||||||
/// index to the end of the string.
|
/// index to the end of the string.
|
||||||
func substr(start: Int) -> String {
|
func _substr(start: Int) -> String {
|
||||||
var rng = unicodeScalars
|
var rng = unicodeScalars
|
||||||
var startIndex = rng.startIndex
|
var startIndex = rng.startIndex
|
||||||
for i in 0..start {
|
for i in 0..start {
|
||||||
@@ -356,7 +359,7 @@ extension String {
|
|||||||
/// \brief Split the given string at the given delimiter character, returning
|
/// \brief Split the given string at the given delimiter character, returning
|
||||||
/// the strings before and after that character (neither includes the character
|
/// the strings before and after that character (neither includes the character
|
||||||
/// found) and a boolean value indicating whether the delimiter was found.
|
/// found) and a boolean value indicating whether the delimiter was found.
|
||||||
func splitFirst(delim: UnicodeScalar)
|
func _splitFirst(delim: UnicodeScalar)
|
||||||
-> (before: String, after: String, wasFound : Bool)
|
-> (before: String, after: String, wasFound : Bool)
|
||||||
{
|
{
|
||||||
var rng = unicodeScalars
|
var rng = unicodeScalars
|
||||||
@@ -372,7 +375,7 @@ extension String {
|
|||||||
/// predicate returns true. Returns the string before that character, the
|
/// predicate returns true. Returns the string before that character, the
|
||||||
/// character that matches, the string after that character, and a boolean value
|
/// character that matches, the string after that character, and a boolean value
|
||||||
/// indicating whether any character was found.
|
/// indicating whether any character was found.
|
||||||
func splitFirstIf(pred: (UnicodeScalar) -> Bool)
|
func _splitFirstIf(pred: (UnicodeScalar) -> Bool)
|
||||||
-> (before: String, found: UnicodeScalar, after: String, wasFound: Bool)
|
-> (before: String, found: UnicodeScalar, after: String, wasFound: Bool)
|
||||||
{
|
{
|
||||||
var rng = unicodeScalars
|
var rng = unicodeScalars
|
||||||
@@ -387,7 +390,7 @@ extension String {
|
|||||||
/// \brief Split the given string at each occurrence of a character for which
|
/// \brief Split the given string at each occurrence of a character for which
|
||||||
/// the given predicate evaluates true, returning an array of strings that
|
/// the given predicate evaluates true, returning an array of strings that
|
||||||
/// before/between/after those delimiters.
|
/// before/between/after those delimiters.
|
||||||
func splitIf(pred: (UnicodeScalar) -> Bool) -> String[] {
|
func _splitIf(pred: (UnicodeScalar) -> Bool) -> String[] {
|
||||||
var scalarSlices = Swift.split(unicodeScalars, pred)
|
var scalarSlices = Swift.split(unicodeScalars, pred)
|
||||||
return scalarSlices.map { $0 as String }
|
return scalarSlices.map { $0 as String }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ extension String {
|
|||||||
return core.elementWidth == 1 ? core.startASCII : nil
|
return core.elementWidth == 1 ? core.startASCII : nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func nulTerminatedUTF8() -> NativeArray<UTF8.CodeUnit> {
|
var nulTerminatedUTF8: NativeArray<UTF8.CodeUnit> {
|
||||||
var result = NativeArray<UTF8.CodeUnit>()
|
var result = NativeArray<UTF8.CodeUnit>()
|
||||||
result.reserve(countElements(utf8) + 1)
|
result.reserve(countElements(utf8) + 1)
|
||||||
result += utf8
|
result += utf8
|
||||||
|
|||||||
@@ -10,11 +10,12 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
func ==(lhs: UnicodeScalarView.IndexType, rhs: UnicodeScalarView.IndexType) -> Bool {
|
func ==(lhs: String.UnicodeScalarView.IndexType, rhs: String.UnicodeScalarView.IndexType) -> Bool {
|
||||||
return lhs._position == rhs._position
|
return lhs._position == rhs._position
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UnicodeScalarView : Sliceable, Sequence {
|
extension String {
|
||||||
|
struct UnicodeScalarView : Sliceable, Sequence {
|
||||||
init(_ _base: _StringCore) {
|
init(_ _base: _StringCore) {
|
||||||
self._base = _base
|
self._base = _base
|
||||||
}
|
}
|
||||||
@@ -162,6 +163,7 @@ struct UnicodeScalarView : Sliceable, Sequence {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _base: _StringCore
|
var _base: _StringCore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
|
|||||||
@@ -738,25 +738,6 @@ extension String {
|
|||||||
return _ns.hash
|
return _ns.hash
|
||||||
}
|
}
|
||||||
|
|
||||||
// - (BOOL)hasPrefix:(NSString *)aString
|
|
||||||
|
|
||||||
/// \brief Returns a Boolean value that indicates whether a given
|
|
||||||
/// string matches the beginning characters of the receiver.
|
|
||||||
|
|
||||||
func hasPrefix(aString: String) -> Bool {
|
|
||||||
return _ns.hasPrefix(aString)
|
|
||||||
}
|
|
||||||
|
|
||||||
// - (BOOL)hasSuffix:(NSString *)aString
|
|
||||||
|
|
||||||
/// \brief Returns a Boolean value that indicates whether a given
|
|
||||||
/// string matches the ending characters of the receiver.
|
|
||||||
|
|
||||||
func hasSuffix(aString: String) -> Bool {
|
|
||||||
return _ns.hasSuffix(aString)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Nothing to do here; already provided for String
|
Nothing to do here; already provided for String
|
||||||
|
|
||||||
@@ -1075,13 +1056,6 @@ extension String {
|
|||||||
return self.longLongValue
|
return self.longLongValue
|
||||||
}
|
}
|
||||||
|
|
||||||
// @property NSString * lowercaseString
|
|
||||||
|
|
||||||
/// \brief Returns lowercased representation of the receiver.
|
|
||||||
var lowercaseString: String {
|
|
||||||
return _ns.lowercaseString
|
|
||||||
}
|
|
||||||
|
|
||||||
// - (NSString *)lowercaseStringWithLocale:(NSLocale *)locale
|
// - (NSString *)lowercaseStringWithLocale:(NSLocale *)locale
|
||||||
|
|
||||||
/// \brief Returns a version of the string with all letters
|
/// \brief Returns a version of the string with all letters
|
||||||
@@ -1481,12 +1455,6 @@ extension String {
|
|||||||
return _ns.substringWithRange(aRange)
|
return _ns.substringWithRange(aRange)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @property NSString* uppercaseString;
|
|
||||||
|
|
||||||
/// \brief Returns a uppercased representation of the receiver.
|
|
||||||
var uppercaseString: String {
|
|
||||||
return _ns.uppercaseString
|
|
||||||
}
|
|
||||||
|
|
||||||
// - (NSString *)uppercaseStringWithLocale:(NSLocale *)locale
|
// - (NSString *)uppercaseStringWithLocale:(NSLocale *)locale
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ extension Selector : Equatable, Hashable {
|
|||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
/// \brief Construct the C string representation of an Objective-C selector.
|
/// \brief Construct the C string representation of an Objective-C selector.
|
||||||
init(_ sel: Selector) {
|
init(_sel: Selector) {
|
||||||
// FIXME: This misses the ASCII optimization.
|
// FIXME: This misses the ASCII optimization.
|
||||||
self = String.fromCString(sel_getName(sel))
|
self = String.fromCString(sel_getName(_sel))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// RUN: rm -rf %t/clang-module-cache
|
// RUN: rm -rf %t/clang-module-cache
|
||||||
// RUN: %swift -parse -verify -import-cf-types -module-cache-path %t/clang-module-cache -I %S/Inputs/custom-modules -target x86_64-apple-darwin13 %s
|
// RUN: %swift -parse -verify -import-cf-types -module-cache-path %t/clang-module-cache -I %S/Inputs/custom-modules -target x86_64-apple-darwin13 %s
|
||||||
|
// XFAIL: *
|
||||||
|
|
||||||
import CoreCooling
|
import CoreCooling
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ var sub1Result : String = obj[5]!
|
|||||||
var sub2Result : Int = obj[A()]!
|
var sub2Result : Int = obj[A()]!
|
||||||
|
|
||||||
// Subscript then call without the '!'
|
// Subscript then call without the '!'
|
||||||
var sub1ResultNE = obj[5].startsWith("foo")
|
var sub1ResultNE = obj[5].hasPrefix("foo")
|
||||||
var sub2ResultNE = obj[A()].hashValue
|
var sub2ResultNE = obj[A()].hashValue
|
||||||
|
|
||||||
// Property/function ambiguities.
|
// Property/function ambiguities.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ yf.f1(i, y: 1)
|
|||||||
Swift.print(3)
|
Swift.print(3)
|
||||||
|
|
||||||
var format : String
|
var format : String
|
||||||
format.splitFirstIf({ $0.isAlpha() })
|
format._splitFirstIf({ $0.isAlpha() })
|
||||||
|
|
||||||
// Archetypes
|
// Archetypes
|
||||||
func doGetLogicValue<T : LogicValue>(t: T) {
|
func doGetLogicValue<T : LogicValue>(t: T) {
|
||||||
@@ -80,7 +80,7 @@ struct GZ<T> {
|
|||||||
// Members of literals
|
// Members of literals
|
||||||
// FIXME: Crappy diagnostic
|
// FIXME: Crappy diagnostic
|
||||||
"foo".lower() // expected-error{{could not find member 'lower'}}
|
"foo".lower() // expected-error{{could not find member 'lower'}}
|
||||||
var tmp = "foo".lowercase
|
var tmp = "foo".lowercaseString
|
||||||
|
|
||||||
// Members of modules
|
// Members of modules
|
||||||
var myTrue = Swift.true
|
var myTrue = Swift.true
|
||||||
|
|||||||
@@ -28,6 +28,6 @@ println(xxx)
|
|||||||
|
|
||||||
// FIXME: compilation fails without the temporary yyy
|
// FIXME: compilation fails without the temporary yyy
|
||||||
var yyy = sort(["apple", "Banana", "cherry"],
|
var yyy = sort(["apple", "Banana", "cherry"],
|
||||||
{ $0.lowercase > $1.lowercase })
|
{ $0.lowercaseString > $1.lowercaseString })
|
||||||
println(yyy)
|
println(yyy)
|
||||||
// CHECK-NEXT: [cherry, Banana, apple]
|
// CHECK-NEXT: [cherry, Banana, apple]
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ println("Nested \"\(HW)\" with Pi = \(pi)!")
|
|||||||
|
|
||||||
// CHECK: value = 1099226349619 hex = 0xFFEEFF0033 oct = 0o17775677600063
|
// CHECK: value = 1099226349619 hex = 0xFFEEFF0033 oct = 0o17775677600063
|
||||||
var someval = 0xFFeeFF0033
|
var someval = 0xFFeeFF0033
|
||||||
println("value = \(someval) hex = 0x\(someval, radix:16, uppercase : true) oct = 0o\(someval, radix:8)")
|
println("value = \(someval) hex = 0x\(someval, radix:16, _uppercase : true) oct = 0o\(someval, radix:8)")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// String Splits
|
// String Splits
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
if true {
|
if true {
|
||||||
var (before, after, found) = "foo.bar".splitFirst(".")
|
var (before, after, found) = "foo.bar"._splitFirst(".")
|
||||||
assert(found)
|
assert(found)
|
||||||
assert(before == "foo")
|
assert(before == "foo")
|
||||||
assert(after == "bar")
|
assert(after == "bar")
|
||||||
@@ -18,7 +18,7 @@ println("OKAY")
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
if true {
|
if true {
|
||||||
// CHECK-NEXT: {{^}}FOOBAR.WIBBLE{{$}}
|
// CHECK-NEXT: {{^}}FOOBAR.WIBBLE{{$}}
|
||||||
println("FooBar.Wibble".uppercase)
|
println("FooBar.Wibble".uppercaseString)
|
||||||
// CHECK-NEXT: {{^}}foobar.wibble{{$}}
|
// CHECK-NEXT: {{^}}foobar.wibble{{$}}
|
||||||
println("FooBar.Wibble".lowercase)
|
println("FooBar.Wibble".lowercaseString)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// RUN: %target-run-simple-swift | FileCheck %s
|
// RUN: %target-run-simple-swift | FileCheck %s
|
||||||
|
|
||||||
typealias CodePoints = UnicodeScalarView
|
typealias CodePoints = String.UnicodeScalarView
|
||||||
|
|
||||||
extension CodePoints {
|
extension CodePoints {
|
||||||
init(_ x: String) {
|
init(_ x: String) {
|
||||||
@@ -39,7 +39,7 @@ func testSplit() {
|
|||||||
|
|
||||||
// FIXME: Disabled pending <rdar://problem/15736729> and <rdar://problem/15733855>
|
// FIXME: Disabled pending <rdar://problem/15736729> and <rdar://problem/15733855>
|
||||||
// CHECK-NEXT-DISABLED: [ "", "", "foo bar baz " ]
|
// CHECK-NEXT-DISABLED: [ "", "", "foo bar baz " ]
|
||||||
// println(split(CodePoints(" foo bar baz "), { $0.isSpace() }, true, maxSplit:2))
|
// println(split(CodePoints(" foo bar baz "), { $0._isSpace() }, true, maxSplit:2))
|
||||||
|
|
||||||
println("done.")
|
println("done.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,9 +208,11 @@ println("so < tocks => \(so < tocks)")
|
|||||||
// CHECK-NEXT: true
|
// CHECK-NEXT: true
|
||||||
println("sox < tocks => \(sox < tocks)")
|
println("sox < tocks => \(sox < tocks)")
|
||||||
|
|
||||||
|
let qqq = nonASCIILiteral.hasPrefix("🏂☃")
|
||||||
|
let rrr = nonASCIILiteral.hasPrefix("☃")
|
||||||
let zz = (
|
let zz = (
|
||||||
nonASCIILiteral.startsWith("🏂☃"), nonASCIILiteral.startsWith("☃"),
|
nonASCIILiteral.hasPrefix("🏂☃"), nonASCIILiteral.hasPrefix("☃"),
|
||||||
nonASCIILiteral.endsWith("⛄️❄️"), nonASCIILiteral.endsWith("☃"))
|
nonASCIILiteral.hasSuffix("⛄️❄️"), nonASCIILiteral.hasSuffix("☃"))
|
||||||
|
|
||||||
// CHECK-NEXT: <true, false, true, false>
|
// CHECK-NEXT: <true, false, true, false>
|
||||||
println("<\(zz.0), \(zz.1), \(zz.2), \(zz.3)>")
|
println("<\(zz.0), \(zz.1), \(zz.2), \(zz.3)>")
|
||||||
|
|||||||
Reference in New Issue
Block a user