Skip to content

Commit 950a344

Browse files
committed
Cutback and Adjust tests
1 parent 6f508a5 commit 950a344

File tree

7 files changed

+24
-43
lines changed

7 files changed

+24
-43
lines changed

stdlib/private/StdlibUnicodeUnittest/StdlibUnicodeUnittest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ public struct UTFTest {
142142
public let loc: SourceLoc
143143

144144
public var utf32: [UInt32] {
145-
return unicodeScalars.map({ s in UInt32(s) })
145+
return unicodeScalars.map { UInt32($0) }
146146
}
147147

148148
public var utf32RepairedTail: [UInt32] {
149-
return unicodeScalarsRepairedTail.map({ s in UInt32(s) })
149+
return unicodeScalarsRepairedTail.map { UInt32($0) }
150150
}
151151

152152
public init(

stdlib/public/core/IntegerTypes.swift.gyb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,14 +1786,6 @@ ${operatorComment(x.operator, True)}
17861786
}
17871787
}
17881788

1789-
extension ${Self} {
1790-
/// Construct with value `v.value`.
1791-
@inlinable @_alwaysEmitIntoClient
1792-
public init(unicode v: Unicode.Scalar) {
1793-
self = ${Self}(v.value)
1794-
}
1795-
}
1796-
17971789

17981790
extension ${Self}: Sendable { }
17991791

stdlib/public/core/UnicodeScalar.swift

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -380,51 +380,42 @@ extension UInt64 {
380380
}
381381
}
382382

383+
extension FixedWidthInteger {
384+
/// Construct with value `v.value`.
385+
@inlinable @_alwaysEmitIntoClient
386+
public init(unicode v: Unicode.Scalar) {
387+
_precondition(v.value <= Self.max,
388+
"Code point value does not fit into type")
389+
self = Self(v.value)
390+
}
391+
}
392+
383393
/// Allows direct comparisons between UInt8 and double quoted literals.
384394
extension UInt8 {
385-
/// Basic comparison operators
395+
/// Basic equality operator
386396
@_transparent @_alwaysEmitIntoClient
387397
public static func == (i: Self, s: Unicode.Scalar) -> Bool {
388398
return i == UInt8(ascii: s)
389399
}
400+
/// Basic inequality operator
390401
@_transparent @_alwaysEmitIntoClient
391402
public static func != (i: Self, s: Unicode.Scalar) -> Bool {
392403
return i != UInt8(ascii: s)
393404
}
394-
@_transparent @_alwaysEmitIntoClient
395-
public static func <= (i: Self, s: Unicode.Scalar) -> Bool {
396-
return i <= UInt8(ascii: s)
397-
}
398-
@_transparent @_alwaysEmitIntoClient
399-
public static func >= (i: Self, s: Unicode.Scalar) -> Bool {
400-
return i >= UInt8(ascii: s)
401-
}
402-
@_transparent @_alwaysEmitIntoClient
403-
public static func < (i: Self, s: Unicode.Scalar) -> Bool {
404-
return i < UInt8(ascii: s)
405-
}
406-
@_transparent @_alwaysEmitIntoClient
407-
public static func > (i: Self, s: Unicode.Scalar) -> Bool {
408-
return i > UInt8(ascii: s)
409-
}
410405
/// Used in switch statements
411406
@_transparent @_alwaysEmitIntoClient
412407
public static func ~= (s: Unicode.Scalar, i: Self) -> Bool {
413408
return i == UInt8(ascii: s)
414409
}
415-
/// Useful now and then
416-
@_transparent @_alwaysEmitIntoClient
417-
public static func - (i: Self, s: Unicode.Scalar) -> Self {
418-
return i - UInt8(ascii: s)
419-
}
420410
}
421411

422412
extension UInt8? {
423-
/// Basic equality operators
413+
/// Optional equality operator
424414
@_transparent @_alwaysEmitIntoClient
425415
public static func == (i: Self, s: Unicode.Scalar) -> Bool {
426416
return i == UInt8(ascii: s)
427417
}
418+
/// Optional inequality operator
428419
@_transparent @_alwaysEmitIntoClient
429420
public static func != (i: Self, s: Unicode.Scalar) -> Bool {
430421
return i != UInt8(ascii: s)

test/Constraints/patterns.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,7 @@ func testExprPatternIsolation() {
631631
}
632632
for case 0 in nil {} // expected-error {{'nil' requires a contextual type}}
633633
for case 0 in [nil] {}
634-
// expected-error@-1 {{type 'Any' cannot conform to 'Equatable'}}
635-
// expected-note@-2 {{only concrete types such as structs, enums and classes can conform to protocols}}
636-
// expected-note@-3 {{requirement from conditional conformance of 'Any?' to 'Equatable'}}
634+
// expected-error@-1 {{expression pattern of type 'Int' cannot match values of type 'Any?'}}
637635

638636
// Though we will try Double for an integer literal...
639637
let d: Double = 0
@@ -679,7 +677,7 @@ func testExprPatternIsolation() {
679677

680678
// FIXME: Bad error (https://github.com/apple/swift/issues/64279)
681679
if case .e(nil, 0) = produceMultiPayload() {}
682-
// expected-error@-1 {{expression pattern of type 'String' cannot match values of type 'Substring'}}
680+
// expected-error@-1 {{expression pattern of type 'Unicode.Scalar' cannot match values of type 'UInt8'}}
683681
// expected-note@-2 {{overloads for '~=' exist with these partially matching parameter lists}}
684682

685683
if case .e(5, nil) = produceMultiPayload() as MultiPayload<Int?> {}

test/Constraints/rdar105782480.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ func foo(value: MyEnum) {
1111
takeClosure {
1212
switch value {
1313
case .second(let drag).invalid:
14-
// expected-error@-1 {{value of type 'MyEnum' has no member 'invalid'}}
15-
// expected-error@-2 {{'let' binding pattern cannot appear in an expression}}
14+
// expected-error@-1 {{expression pattern of type 'Unicode.Scalar' cannot match values of type 'MyEnum'}}
15+
// expected-error@-2 {{type 'Unicode.Scalar' has no member 'second'}}
1616
break
1717
}
1818
}

test/Prototypes/UnicodeDecoders.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,11 @@ public struct UTFTest {
650650
public let loc: SourceLoc
651651

652652
public var utf32: [UInt32] {
653-
return unicodeScalars.map(UInt32.init)
653+
return unicodeScalars.map { UInt32($0) }
654654
}
655655

656656
public var utf32RepairedTail: [UInt32] {
657-
return unicodeScalarsRepairedTail.map(UInt32.init)
657+
return unicodeScalarsRepairedTail.map { UInt32($0) }
658658
}
659659

660660
public init(

test/stmt/typed_throws.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ func testDoCatchMultiErrorType() {
8080
do {
8181
try doSomething()
8282
try doHomework()
83-
} catch .failed { // expected-error{{type 'any Error' has no member 'failed'}}
84-
83+
} catch .failed { // expected-error{{expression pattern of type 'Unicode.Scalar' cannot match values of type 'any Error}}
84+
// expected-error@-1{{type 'Unicode.Scalar' has no member 'failed'}}
8585
} catch {
8686
let _: Int = error // expected-error{{cannot convert value of type 'any Error' to specified type 'Int'}}
8787
}

0 commit comments

Comments
 (0)