|
1 |
| -// RUN: %target-run-simple-swift | FileCheck %s |
| 1 | +// RUN: %target-run-simple-swift |
2 | 2 | // REQUIRES: executable_test
|
3 | 3 |
|
| 4 | +import StdlibUnittest |
| 5 | + |
4 | 6 | struct StructWithMembers {
|
5 | 7 | var a = 1
|
6 | 8 | var b = "Hello World"
|
7 | 9 | }
|
8 | 10 |
|
9 |
| -print(_PrintForDebugger.printForDebugger(value: StructWithMembers())) |
10 |
| -// CHECK: StructWithMembers |
11 |
| -// CHECK: a : 1 |
12 |
| -// CHECK: b : "Hello World" |
13 |
| - |
14 | 11 | class ClassWithMembers {
|
15 | 12 | var a = 1
|
16 | 13 | var b = "Hello World"
|
17 | 14 | }
|
18 | 15 |
|
19 |
| -print(_PrintForDebugger.printForDebugger(value: ClassWithMembers())) |
20 |
| -// CHECK: <ClassWithMembers: 0x |
21 |
| - |
22 | 16 | class ClassWithMirror: CustomReflectable {
|
23 | 17 | var customMirror: Mirror {
|
24 | 18 | return Mirror(self, children: ["a" : 1, "b" : "Hello World"])
|
25 | 19 | }
|
26 | 20 | }
|
27 | 21 |
|
28 |
| -print(_PrintForDebugger.printForDebugger(value: ClassWithMirror())) |
29 |
| -// CHECK: ClassWithMirror |
30 |
| -// CHECK: a : 1 |
31 |
| -// CHECK: b : "Hello World" |
| 22 | +let PrintForDebuggerTests = TestSuite("PrintForDebugger") |
| 23 | +PrintForDebuggerTests.test("StructWithMembers") { |
| 24 | + let printed = _PrintForDebugger.printForDebugger(value: StructWithMembers()) |
| 25 | + expectEqual(printed, "▿ StructWithMembers\n - a : 1\n - b : \"Hello World\"\n") |
| 26 | +} |
| 27 | + |
| 28 | +PrintForDebuggerTests.test("ClassWithMembers") { |
| 29 | + let printed = _PrintForDebugger.printForDebugger(value: ClassWithMembers()) |
| 30 | + expectTrue(printed.hasPrefix("<ClassWithMembers: 0x")) |
| 31 | +} |
| 32 | + |
| 33 | +PrintForDebuggerTests.test("ClassWithMirror") { |
| 34 | + let printed = _PrintForDebugger.printForDebugger(value: ClassWithMirror()) |
| 35 | + expectEqual(printed, "▿ ClassWithMirror\n - a : 1\n - b : \"Hello World\"\n") |
| 36 | +} |
32 | 37 |
|
33 |
| -print(_PrintForDebugger.printForDebugger(value: [1,2,3,4])) |
34 |
| -// CHECK: 4 elements |
35 |
| -// CHECK: - 0 : 1 |
36 |
| -// CHECK: - 1 : 2 |
37 |
| -// CHECK: - 2 : 3 |
38 |
| -// CHECK: - 3 : 4 |
| 38 | +PrintForDebuggerTests.test("Array") { |
| 39 | + let printed = _PrintForDebugger.printForDebugger(value: [1,2,3,4]) |
| 40 | + expectEqual(printed, "▿ 4 elements\n - 0 : 1\n - 1 : 2\n - 2 : 3\n - 3 : 4\n") |
| 41 | +} |
39 | 42 |
|
40 |
| -print(_PrintForDebugger.printForDebugger(value: [1:2, 3:4])) |
41 |
| -// CHECK: 2 elements |
42 |
| -// CHECK: 0 : 2 elements |
43 |
| -// CHECK: 1 : 2 elements |
| 43 | +PrintForDebuggerTests.test("Dictionary") { |
| 44 | + let printed = _PrintForDebugger.printForDebugger(value: [1:2]) |
| 45 | + expectEqual(printed, "▿ 1 elements\n ▿ 0 : 2 elements\n - .0 : 1\n - .1 : 2\n") |
| 46 | +} |
44 | 47 |
|
45 |
| -print(_PrintForDebugger.printForDebugger(value: nil as Int?)) |
46 |
| -// CHECK: nil |
| 48 | +PrintForDebuggerTests.test("NilOptional") { |
| 49 | + let printed = _PrintForDebugger.printForDebugger(value: nil as Int?) |
| 50 | + expectTrue(printed.hasPrefix("nil")) |
| 51 | +} |
47 | 52 |
|
48 |
| -print(_PrintForDebugger.printForDebugger(value: 3 as Int?)) |
49 |
| -// CHECK: Optional<Int> |
50 |
| -// CHECK: - some : 3 |
| 53 | +PrintForDebuggerTests.test("SomeOptional") { |
| 54 | + let printed = _PrintForDebugger.printForDebugger(value: 3 as Int?) |
| 55 | + expectEqual(printed, "▿ Optional<Int>\n - some : 3\n") |
| 56 | +} |
51 | 57 |
|
| 58 | +runAllTests() |
0 commit comments