Skip to content

Commit 68910da

Browse files
authored
Merge pull request #69574 from tshortli/subset-parse-enum-tests
NFC: Subset out floating point raw value enum parsing tests
2 parents a8d29e4 + a10fcfa commit 68910da

File tree

2 files changed

+101
-101
lines changed

2 files changed

+101
-101
lines changed

test/Parse/enum.swift

Lines changed: 4 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
// FIXME: this test only passes on platforms which have Float80.
4-
// <rdar://problem/19508460> Floating point enum raw values are not portable
5-
6-
// REQUIRES: CPU=i386 || CPU=x86_64
7-
8-
// Windows does not support FP80
9-
// XFAIL: OS=windows-msvc
10-
113
enum Empty {}
124

135
enum Boolish {
@@ -207,12 +199,6 @@ enum RawTypeWithCharacterValues_Error1 : Character { // expected-error {{'RawTyp
207199
case First = "abc" // expected-error {{cannot convert value of type 'String' to raw type 'Character'}}
208200
}
209201

210-
enum RawTypeWithFloatValues : Float { // expected-error {{'RawTypeWithFloatValues' declares raw type 'Float', but does not conform to RawRepresentable and conformance could not be synthesized}}
211-
case Northrup = 1.5
212-
case Overton // expected-error {{enum case must declare a raw value when the preceding raw value is not an integer}}
213-
case Pettygrove = 2.25
214-
}
215-
216202
enum RawTypeWithStringValues : String {
217203
case Primrose // okay
218204
case Quimby = "Lucky Lab"
@@ -229,86 +215,22 @@ enum RawTypeWithRepeatValues : Int {
229215
case Wilson = 22 // expected-error {{raw value for enum case is not unique}}
230216
}
231217

232-
enum RawTypeWithRepeatValues2 : Double {
233-
case Vaughn = 22 // expected-note {{raw value previously used here}}
234-
case Wilson = 22.0 // expected-error {{raw value for enum case is not unique}}
235-
}
236-
237-
enum RawTypeWithRepeatValues3 : Double {
238-
// 2^63-1
239-
case Vaughn = 9223372036854775807 // expected-note {{raw value previously used here}}
240-
case Wilson = 9223372036854775807.0 // expected-error {{raw value for enum case is not unique}}
241-
}
242-
243-
enum RawTypeWithRepeatValues4 : Double {
244-
// 2^64-1
245-
case Vaughn = 18446744073709551615 // expected-note {{raw value previously used here}}
246-
case Wilson = 18446744073709551615.0 // expected-error {{raw value for enum case is not unique}}
247-
}
248-
249-
enum RawTypeWithRepeatValues5 : Double {
250-
// FIXME: should reject.
251-
// 2^65-1
252-
case Vaughn = 36893488147419103231
253-
case Wilson = 36893488147419103231.0
254-
}
255-
256-
enum RawTypeWithRepeatValues6 : Double {
257-
// FIXME: should reject.
258-
// 2^127-1
259-
case Vaughn = 170141183460469231731687303715884105727
260-
case Wilson = 170141183460469231731687303715884105727.0
261-
}
262-
263-
enum RawTypeWithRepeatValues7 : Double {
264-
// FIXME: should reject.
265-
// 2^128-1
266-
case Vaughn = 340282366920938463463374607431768211455
267-
case Wilson = 340282366920938463463374607431768211455.0
268-
}
269-
270-
enum RawTypeWithRepeatValues8 : String {
218+
enum RawTypeWithRepeatValuesString : String {
271219
case Vaughn = "XYZ" // expected-note {{raw value previously used here}}
272220
case Wilson = "XYZ" // expected-error {{raw value for enum case is not unique}}
273221
}
274222

275-
enum RawTypeWithNonRepeatValues : Double {
276-
case SantaClara = 3.7
277-
case SanFernando = 7.4
278-
case SanAntonio = -3.7
279-
case SanCarlos = -7.4
280-
}
281-
282-
283-
enum RawTypeWithRepeatValuesAutoInc : Double {
284-
case Vaughn = 22 // expected-note {{raw value auto-incremented from here}}
285-
case Wilson // expected-note {{raw value previously used here}}
286-
case Yeon = 23 // expected-error {{raw value for enum case is not unique}}
287-
}
288-
289-
enum RawTypeWithRepeatValuesAutoInc2 : Double {
290-
case Vaughn = 23 // expected-note {{raw value previously used here}}
291-
case Wilson = 22 // expected-note {{raw value auto-incremented from here}}
292-
case Yeon // expected-error {{raw value for enum case is not unique}}
293-
}
294-
295-
enum RawTypeWithRepeatValuesAutoInc3 : Double {
296-
case Vaughn // expected-note {{raw value implicitly auto-incremented from zero}}
297-
case Wilson // expected-note {{raw value previously used here}}
298-
case Yeon = 1 // expected-error {{raw value for enum case is not unique}}
299-
}
300-
301-
enum RawTypeWithRepeatValuesAutoInc4 : String {
223+
enum RawTypeWithRepeatValuesAutoInc1 : String {
302224
case A = "B" // expected-note {{raw value previously used here}}
303225
case B // expected-error {{raw value for enum case is not unique}}
304226
}
305227

306-
enum RawTypeWithRepeatValuesAutoInc5 : String {
228+
enum RawTypeWithRepeatValuesAutoInc2 : String {
307229
case A // expected-note {{raw value previously used here}}
308230
case B = "A" // expected-error {{raw value for enum case is not unique}}
309231
}
310232

311-
enum RawTypeWithRepeatValuesAutoInc6 : String {
233+
enum RawTypeWithRepeatValuesAutoInc3 : String {
312234
case A
313235
case B // expected-note {{raw value previously used here}}
314236
case C = "B" // expected-error {{raw value for enum case is not unique}}
@@ -440,25 +362,6 @@ enum ManyLiteralC : ManyLiteralable {
440362
case B = "0"
441363
}
442364

443-
// rdar://problem/22476643
444-
public protocol RawValueA: RawRepresentable
445-
{
446-
var rawValue: Double { get }
447-
}
448-
449-
enum RawValueATest: Double, RawValueA {
450-
case A, B
451-
}
452-
453-
public protocol RawValueB
454-
{
455-
var rawValue: Double { get }
456-
}
457-
458-
enum RawValueBTest: Double, RawValueB {
459-
case A, B
460-
}
461-
462365
enum foo : String { // expected-error {{'foo' declares raw type 'String', but does not conform to RawRepresentable and conformance could not be synthesized}}
463366
case bar = nil // expected-error {{cannot convert 'nil' to raw type 'String'}}
464367
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// FIXME: this test only passes on platforms which have Float80.
4+
// <rdar://problem/19508460> Floating point enum raw values are not portable
5+
6+
// REQUIRES: CPU=i386 || CPU=x86_64
7+
8+
// Windows does not support FP80
9+
// XFAIL: OS=windows-msvc
10+
11+
enum RawTypeWithFloatValues : Float { // expected-error {{'RawTypeWithFloatValues' declares raw type 'Float', but does not conform to RawRepresentable and conformance could not be synthesized}}
12+
case Northrup = 1.5
13+
case Overton // expected-error {{enum case must declare a raw value when the preceding raw value is not an integer}}
14+
case Pettygrove = 2.25
15+
}
16+
17+
enum RawTypeWithRepeatValues2 : Double {
18+
case Vaughn = 22 // expected-note {{raw value previously used here}}
19+
case Wilson = 22.0 // expected-error {{raw value for enum case is not unique}}
20+
}
21+
22+
enum RawTypeWithRepeatValues3 : Double {
23+
// 2^63-1
24+
case Vaughn = 9223372036854775807 // expected-note {{raw value previously used here}}
25+
case Wilson = 9223372036854775807.0 // expected-error {{raw value for enum case is not unique}}
26+
}
27+
28+
enum RawTypeWithRepeatValues4 : Double {
29+
// 2^64-1
30+
case Vaughn = 18446744073709551615 // expected-note {{raw value previously used here}}
31+
case Wilson = 18446744073709551615.0 // expected-error {{raw value for enum case is not unique}}
32+
}
33+
34+
enum RawTypeWithRepeatValues5 : Double {
35+
// FIXME: should reject.
36+
// 2^65-1
37+
case Vaughn = 36893488147419103231
38+
case Wilson = 36893488147419103231.0
39+
}
40+
41+
enum RawTypeWithRepeatValues6 : Double {
42+
// FIXME: should reject.
43+
// 2^127-1
44+
case Vaughn = 170141183460469231731687303715884105727
45+
case Wilson = 170141183460469231731687303715884105727.0
46+
}
47+
48+
enum RawTypeWithRepeatValues7 : Double {
49+
// FIXME: should reject.
50+
// 2^128-1
51+
case Vaughn = 340282366920938463463374607431768211455
52+
case Wilson = 340282366920938463463374607431768211455.0
53+
}
54+
55+
enum RawTypeWithNonRepeatValues : Double {
56+
case SantaClara = 3.7
57+
case SanFernando = 7.4
58+
case SanAntonio = -3.7
59+
case SanCarlos = -7.4
60+
}
61+
62+
enum RawTypeWithRepeatValuesAutoInc : Double {
63+
case Vaughn = 22 // expected-note {{raw value auto-incremented from here}}
64+
case Wilson // expected-note {{raw value previously used here}}
65+
case Yeon = 23 // expected-error {{raw value for enum case is not unique}}
66+
}
67+
68+
enum RawTypeWithRepeatValuesAutoInc2 : Double {
69+
case Vaughn = 23 // expected-note {{raw value previously used here}}
70+
case Wilson = 22 // expected-note {{raw value auto-incremented from here}}
71+
case Yeon // expected-error {{raw value for enum case is not unique}}
72+
}
73+
74+
enum RawTypeWithRepeatValuesAutoInc3 : Double {
75+
case Vaughn // expected-note {{raw value implicitly auto-incremented from zero}}
76+
case Wilson // expected-note {{raw value previously used here}}
77+
case Yeon = 1 // expected-error {{raw value for enum case is not unique}}
78+
}
79+
80+
// rdar://problem/22476643
81+
public protocol RawValueA: RawRepresentable
82+
{
83+
var rawValue: Double { get }
84+
}
85+
86+
enum RawValueATest: Double, RawValueA {
87+
case A, B
88+
}
89+
90+
public protocol RawValueB
91+
{
92+
var rawValue: Double { get }
93+
}
94+
95+
enum RawValueBTest: Double, RawValueB {
96+
case A, B
97+
}

0 commit comments

Comments
 (0)