forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoverage_exceptions.swift
64 lines (52 loc) · 1.51 KB
/
coverage_exceptions.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
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_catch %s | FileCheck %s
enum SomeErr : ErrorType {
case Err1
case Err2
}
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.bar
func bar() throws {
// CHECK-NEXT: [[@LINE-1]]:19 -> [[@LINE+2]]:2 : 0
throw SomeErr.Err2
} // CHECK-NEXT: }
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.baz
func baz(fn: () throws -> ()) rethrows {
do {
try fn()
} catch SomeErr.Err1 { // CHECK: [[@LINE]]:24 -> {{[0-9]+}}:4 : 2
return
} // CHECK-NEXT: [[@LINE]]:4 -> {{[0-9]+}}:2 : 1
try fn()
} // CHECK-NEXT: }
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.foo
func foo() -> Int32 {
var x : Int32 = 0
do {
throw SomeErr.Err1
x += 2 // [[@LINE]]:5 -> [[@LINE+1]]:4 : zero
} catch SomeErr.Err1 {
// CHECK: [[@LINE-1]]:24 -> [[@LINE+1]]:4 : 2
} catch _ {
// CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:4 : 3
} // CHECK: [[@LINE]]:4 -> {{[0-9:]+}} : 1
do {
try baz(bar)
} catch _ {
// CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:4 : 5
} // CHECK: [[@LINE]]:4 -> {{[0-9:]+}} : 4
do {
try baz { () throws -> () in throw SomeErr.Err1 }
} catch _ {}
try! baz { () throws -> () in return }
return x
}
struct S {
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.S.init
init() {
do {
throw SomeErr.Err1
} catch {
// CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:6 : 2
} // CHECK: [[@LINE]]:6 -> [[@LINE+1]]:4 : 1
}
}
foo()