Files
swift-mirror/test/Profiler/coverage_toplevel.swift
Vedant Kumar c3f4d99e57 Group the the code coverage, profiling, and pgo tests together (#16070)
* Group tests for profiling instrumentation together, NFC

This will make it easier to test changes to the code coverage logic.

There are a handful of tests which relate to profiling which I have not
moved. These include tests for the driver and for the SIL optimizer. It
makes more sense to keep those tests where they are.

* Rename a test file, NFC

This file tests code coverage of primary files, so I've changed the name
of the file to reflect that.

* Simplify the check lines in a test, NFC

This file tests code coverage of closures. It had several check lines
which obscured the meaning of the test, and its check lines were in a
strange order.

Remove the extra checks and disable -emit-sorted-sil.
2018-04-20 15:15:52 -07:00

54 lines
1.1 KiB
Swift

// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_toplevel %s | %FileCheck %s
// CHECK: sil_coverage_map{{.*}}__tlcd_line:[[@LINE+2]]:1
// CHECK: [[@LINE+1]]:1 -> [[@LINE+1]]:11
print("a")
// CHECK: sil_coverage_map{{.*}}// coverage_toplevel.f1
func f1() {}
var i : Int32 = 0
// CHECK: sil_coverage_map{{.*}}__tlcd_line:[[@LINE+2]]:1
// CHECK: [[@LINE+1]]:7 -> [[@LINE+1]]:15 : (0 + 1)
while (i < 10) {
i += 1
}
// CHECK: sil_coverage_map{{.*}}__tlcd_line:[[@LINE+3]]:1
// CHECK-NEXT: [[@LINE+2]]:17 -> [[@LINE+2]]:18 : 1
// CHECK-NEXT: [[@LINE+1]]:21 -> [[@LINE+1]]:22 : (0 - 1)
var i2 = true ? 1 : 0;
// CHECK: sil_coverage_map{{.*}}__tlcd_line:[[@LINE+4]]:1
// CHECK-NEXT: [[@LINE+3]]:11 -> [[@LINE+5]]:2 : 1
// CHECK-NEXT: [[@LINE+2]]:1 -> [[@LINE+4]]:2 : 0
// CHECK-NEXT: [[@LINE+3]]:2 -> [[@LINE+3]]:2 : 0
if (true) {
i2 = 2
}
// Crash tests:
if (true) {
i2 = 3
} else {
i2 = 4
}
while (i2 > 0) {
if (true) {
i2 -= 1
continue
} else {
i2 -= 1
break
}
}
switch (1) {
case 0: fallthrough
case 1: break
default: break
}