File tree Expand file tree Collapse file tree 2 files changed +29
-19
lines changed
Inputs/report_dead_method_call Expand file tree Collapse file tree 2 files changed +29
-19
lines changed Original file line number Diff line number Diff line change
1
+ // The StdlibUnittest test suite is placed here because it contains
2
+ // expressions that are only allowed at the top level in files named
3
+ // "main.swift".
1
4
5
+ import StdlibUnittest
2
6
3
7
@inline ( never)
4
8
func testProto( _ c: Container ) {
@@ -27,16 +31,22 @@ func testPublicClass(_ c: PublicBase) {
27
31
c. ghi ( )
28
32
}
29
33
30
- switch Process . argc {
31
- case 1 :
32
- callClass ( )
34
+ let ReportDeadMethodCallTestSuite = TestSuite ( " ReportDeadMethodCall " )
33
35
34
- case 2 :
35
- callProto ( )
36
+ ReportDeadMethodCallTestSuite . test ( " Call class " ) {
37
+ expectCrashLater ( )
38
+ callClass ( )
39
+ }
36
40
37
- case 3 :
38
- callPublicClass ( )
41
+ ReportDeadMethodCallTestSuite . test ( " Call proto " ) {
42
+ expectCrashLater ( )
43
+ callProto ( )
44
+ }
39
45
40
- default :
41
- break
46
+ ReportDeadMethodCallTestSuite . test ( " Call public class " ) {
47
+ expectCrashLater ( )
48
+ callPublicClass ( )
42
49
}
50
+
51
+ runAllTests ( )
52
+
Original file line number Diff line number Diff line change 1
- // RUN: rm -rf %t && mkdir -p %t
2
- // RUN: %target-build-swift %S/Inputs/report_dead_method_call/main.swift %s -O -Xfrontend -disable-access-control -o %t/a.out
3
- // RUN: %target-run %t/a.out 2> %t/err1.log; FileCheck %s < %t/err1.log
4
- // RUN: %target-run %t/a.out p1 2> %t/err2.log; FileCheck %s < %t/err2.log
5
- // RUN: %target-run %t/a.out p1 p2 2> %t/err3.log; FileCheck %s < %t/err3.log
6
- // REQUIRES: executable_test
7
-
1
+ // RUN: rm -rf %t
2
+ // RUN: mkdir -p %t
8
3
9
- // The -disable-access-control option let us "call" methods, which are removed
10
- // by dead method elimination.
4
+ // We compile with -O (optimizations) and -disable-access-control (which
5
+ // allows use to "call" methods that are removed by dead code elimination).
6
+ // RUN: %target-build-swift %S/Inputs/report_dead_method_call/main.swift %s -O -Xfrontend -disable-access-control -o %t/report_dead_method_call
11
7
12
- // CHECK: fatal error: call of deleted method
8
+ // The private, unused methods are optimized away. The test calls these
9
+ // methods anyway (since it has overridden the access control), so we
10
+ // expect them to produce "fatal error: call of deleted method" when run.
11
+ // RUN: %target-run %t/report_dead_method_call
12
+ // REQUIRES: executable_test
13
13
14
14
private protocol PrivateProto {
15
15
func abc( )
You can’t perform that action at this time.
0 commit comments