-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathreflect_Enum_values2.swift
74 lines (54 loc) · 1.98 KB
/
reflect_Enum_values2.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Enum_values2
// RUN: %target-codesign %t/reflect_Enum_values2
// RUN: %target-run %target-swift-reflection-test %t/reflect_Enum_values2 | tee /dev/stderr | %FileCheck %s --check-prefix=CHECK%target-ptrsize --check-prefix=CHECKALL --dump-input=fail %add_num_extra_inhabitants
// REQUIRES: objc_interop
// REQUIRES: executable_test
// REQUIRES: reflection_test_support
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: asan
import SwiftReflectionTest
enum EnumB {
case a
case b(Int8)
case c(Int8)
case d(Void)
case e(Void)
case RIGHT(Int8)
case f(Int8)
case g(Void)
case LEFT(Int8, Int64)
}
class PlaceSummaryUnit {
let t: EnumB
init(t: EnumB) { self.t = t }
}
reflect(object: PlaceSummaryUnit(t: .RIGHT(5)))
// CHECKALL: Reflecting an object.
// CHECKALL-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECKALL-NEXT: Type reference:
// CHECKALL-NEXT: (class reflect_Enum_values2.PlaceSummaryUnit)
// CHECKALL: Type info
// TODO: Check the type layout for 64- and 32-bit targets
reflect(enumValue: PlaceSummaryUnit(t: .RIGHT(5)).t)
// CHECKALL: Reflecting an enum value.
// CHECKALL-NEXT: Type reference:
// CHECKALL-NEXT: (enum reflect_Enum_values2.EnumB)
// CHECKALL-NEXT: Value: .RIGHT(_)
reflect(enumValue: PlaceSummaryUnit(t: .a).t)
// CHECKALL: Reflecting an enum value.
// CHECKALL-NEXT: Type reference:
// CHECKALL-NEXT: (enum reflect_Enum_values2.EnumB)
// CHECKALL-NEXT: Value: .a
reflect(enumValue: PlaceSummaryUnit(t: .LEFT(1,2)).t)
// CHECKALL: Reflecting an enum value.
// CHECKALL-NEXT: Type reference:
// CHECKALL-NEXT: (enum reflect_Enum_values2.EnumB)
// CHECKALL-NEXT: Value: .LEFT(_)
reflect(enumValue: PlaceSummaryUnit(t: .d(())).t)
// CHECKALL: Reflecting an enum value.
// CHECKALL-NEXT: Type reference:
// CHECKALL-NEXT: (enum reflect_Enum_values2.EnumB)
// CHECKALL-NEXT: Value: .d(_)
doneReflecting()
// CHECKALL: Done.