Skip to content

Commit fb9fc5b

Browse files
authored
Revert "Improve attr_implements_fp.swift test."
1 parent f4a2b8f commit fb9fc5b

File tree

2 files changed

+33
-70
lines changed

2 files changed

+33
-70
lines changed

test/attr/attr_implements_fp.swift

Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: echo 'main()' >%t/main.swift
3-
// RUN: %target-build-swift -o %t/a.out %s %t/main.swift -Xfrontend -enable-operator-designated-types -Xfrontend -solver-enable-operator-designated-types
3+
// RUN: %target-swiftc_driver -o %t/a.out %s %t/main.swift
44
// RUN: %target-codesign %t/a.out
55
// RUN: %target-run %t/a.out | %FileCheck %s
66
// REQUIRES: executable_test
@@ -10,33 +10,25 @@
1010
// when only known to be comparable".
1111

1212
// Could calls to the different comparison operators.
13-
public var comparedAsCauxmparablesCount : Int = 0
13+
public var comparedAsComparablesCount : Int = 0
1414
public var comparedAsFauxtsCount : Int = 0
1515

16-
infix operator .< : ComparisonPrecedence, BinaryFauxtingPoint, Cauxmparable
17-
18-
public protocol Cauxmparable {
19-
static func .< (lhs: Self, rhs: Self) -> Bool
20-
}
21-
22-
public protocol FauxtingPoint : Cauxmparable {
16+
public protocol FauxtingPoint : Comparable {
2317
static var nan: Self { get }
2418
static var one: Self { get }
2519
static var two: Self { get }
2620
}
2721

2822
public protocol BinaryFauxtingPoint: FauxtingPoint {
29-
@_nonoverride static func .< (lhs: Self, rhs: Self) -> Bool
30-
3123
var bitPattern: UInt8 { get }
3224
}
3325

3426
public extension BinaryFauxtingPoint {
35-
// This version of .< will be called in a context that only knows it has a Cauxmparable.
36-
@_implements(Cauxmparable, .<(_:_:))
37-
static func _CauxmparableLessThan(_ lhs: Fauxt, _ rhs: Fauxt) -> Bool {
38-
print("compared as Cauxmparables")
39-
comparedAsCauxmparablesCount += 1
27+
// This version of < will be called in a context that only knows it has a Comparable.
28+
@_implements(Comparable, <(_:_:))
29+
static func _ComparableLessThan(_ lhs: Fauxt, _ rhs: Fauxt) -> Bool {
30+
print("compared as Comparables")
31+
comparedAsComparablesCount += 1
4032
return lhs.bitPattern < rhs.bitPattern
4133
}
4234
}
@@ -78,11 +70,11 @@ extension Fauxt: BinaryFauxtingPoint {
7870
}
7971

8072
public extension Fauxt {
81-
// This version of .< will be called in a context that knows it has a Fauxt.
73+
// This version of < will be called in a context that knows it has a Fauxt.
8274
// It is inside an extension of Fauxt rather than the declaration of Fauxt
8375
// itself in order to avoid a warning about near-matches with the defaulted
84-
// requirement from Cauxmparable..< up above.
85-
static func .<(_ lhs: Fauxt, _ rhs: Fauxt) -> Bool {
76+
// requirement from Comparable.< up above.
77+
static func <(_ lhs: Fauxt, _ rhs: Fauxt) -> Bool {
8678
print("compared as Fauxts")
8779
comparedAsFauxtsCount += 1
8880
if lhs.state == .Nan || rhs.state == .Nan {
@@ -93,42 +85,24 @@ public extension Fauxt {
9385
}
9486
}
9587

96-
public func compare_Cauxmparables<T:Cauxmparable>(_ x: T, _ y: T) -> Bool {
97-
return x .< y
98-
}
99-
100-
public func compare_FauxtingPoint<T:FauxtingPoint>(_ x: T, _ y: T) -> Bool {
101-
return x .< y
102-
}
103-
104-
public func compare_BinaryFauxtingPoint<T:BinaryFauxtingPoint>(_ x: T, _ y: T) -> Bool {
105-
return x .< y
88+
public func compare_Comparables<T:Comparable>(_ x: T, _ y: T) -> Bool {
89+
return x < y
10690
}
10791

10892
public func compare_Fauxts(_ x: Fauxt, _ y: Fauxt) -> Bool {
109-
return x .< y
93+
return x < y
11094
}
11195

11296
public func main() {
113-
assert(compare_Cauxmparables(Fauxt.one, Fauxt.two))
114-
assert(comparedAsCauxmparablesCount == 1)
115-
// CHECK: compared as Cauxmparables
116-
assert(compare_Cauxmparables(Fauxt.one, Fauxt.nan))
117-
assert(comparedAsCauxmparablesCount == 2)
118-
// CHECK: compared as Cauxmparables
119-
assert(!compare_Cauxmparables(Fauxt.nan, Fauxt.one))
120-
assert(comparedAsCauxmparablesCount == 3)
121-
// CHECK: compared as Cauxmparables
122-
123-
assert(compare_FauxtingPoint(Fauxt.one, Fauxt.two))
124-
assert(comparedAsCauxmparablesCount == 4)
125-
// CHECK: compared as Cauxmparables
126-
assert(compare_FauxtingPoint(Fauxt.one, Fauxt.nan))
127-
assert(comparedAsCauxmparablesCount == 5)
128-
// CHECK: compared as Cauxmparables
129-
assert(!compare_FauxtingPoint(Fauxt.nan, Fauxt.one))
130-
assert(comparedAsCauxmparablesCount == 6)
131-
// CHECK: compared as Cauxmparables
97+
assert(compare_Comparables(Fauxt.one, Fauxt.two))
98+
assert(comparedAsComparablesCount == 1)
99+
// CHECK: compared as Comparables
100+
assert(compare_Comparables(Fauxt.one, Fauxt.nan))
101+
assert(comparedAsComparablesCount == 2)
102+
// CHECK: compared as Comparables
103+
assert(!compare_Comparables(Fauxt.nan, Fauxt.one))
104+
assert(comparedAsComparablesCount == 3)
105+
// CHECK: compared as Comparables
132106

133107
assert(compare_Fauxts(Fauxt.one, Fauxt.two))
134108
assert(comparedAsFauxtsCount == 1)
@@ -139,15 +113,4 @@ public func main() {
139113
assert(!compare_Fauxts(Fauxt.nan, Fauxt.one))
140114
assert(comparedAsFauxtsCount == 3)
141115
// CHECK: compared as Fauxts
142-
143-
assert(compare_BinaryFauxtingPoint(Fauxt.one, Fauxt.two))
144-
assert(comparedAsFauxtsCount == 4)
145-
// CHECK: compared as Fauxts
146-
assert(!compare_BinaryFauxtingPoint(Fauxt.one, Fauxt.nan))
147-
assert(comparedAsFauxtsCount == 5)
148-
// CHECK: compared as Fauxts
149-
assert(!compare_BinaryFauxtingPoint(Fauxt.nan, Fauxt.one))
150-
assert(comparedAsFauxtsCount == 6)
151-
// CHECK: compared as Fauxts
152-
153116
}

test/attr/attr_implements_serial.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: echo 'client()' >%t/main.swift
3-
// RUN: %target-build-swift-dylib(%t/libAttrImplFP.%target-dylib-extension) -module-name AttrImplFP -emit-module -emit-module-path %t/AttrImplFP.swiftmodule %S/attr_implements_fp.swift -Xfrontend -enable-operator-designated-types -Xfrontend -solver-enable-operator-designated-types
3+
// RUN: %target-build-swift-dylib(%t/libAttrImplFP.%target-dylib-extension) -module-name AttrImplFP -emit-module -emit-module-path %t/AttrImplFP.swiftmodule %S/attr_implements_fp.swift
44
// RUN: %target-build-swift -I %t -o %t/a.out %s %t/main.swift -L %t -Xlinker -rpath -Xlinker %t -lAttrImplFP
55
// RUN: %target-codesign %t/a.out
66
// RUN: %target-codesign %t/libAttrImplFP.%target-dylib-extension
@@ -13,15 +13,15 @@
1313
import AttrImplFP
1414

1515
public func client() {
16-
precondition(compare_Cauxmparables(Fauxt.one, Fauxt.two))
17-
precondition(comparedAsCauxmparablesCount == 1)
18-
// CHECK: compared as Cauxmparables
19-
precondition(compare_Cauxmparables(Fauxt.one, Fauxt.nan))
20-
precondition(comparedAsCauxmparablesCount == 2)
21-
// CHECK: compared as Cauxmparables
22-
precondition(!compare_Cauxmparables(Fauxt.nan, Fauxt.one))
23-
precondition(comparedAsCauxmparablesCount == 3)
24-
// CHECK: compared as Cauxmparables
16+
precondition(compare_Comparables(Fauxt.one, Fauxt.two))
17+
precondition(comparedAsComparablesCount == 1)
18+
// CHECK: compared as Comparables
19+
precondition(compare_Comparables(Fauxt.one, Fauxt.nan))
20+
precondition(comparedAsComparablesCount == 2)
21+
// CHECK: compared as Comparables
22+
precondition(!compare_Comparables(Fauxt.nan, Fauxt.one))
23+
precondition(comparedAsComparablesCount == 3)
24+
// CHECK: compared as Comparables
2525

2626
precondition(compare_Fauxts(Fauxt.one, Fauxt.two))
2727
precondition(comparedAsFauxtsCount == 1)

0 commit comments

Comments
 (0)