-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathfor.swift
70 lines (65 loc) · 2.61 KB
/
for.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
// RUN: %empty-directory(%t)
// RUN: cp %s %t/main.swift
// RUN: %target-build-swift -whole-module-optimization -module-name PlaygroundSupport -emit-module-path %t/PlaygroundSupport.swiftmodule -parse-as-library -c -o %t/PlaygroundSupport.o %S/Inputs/PCMacroRuntime.swift %S/Inputs/SilentPlaygroundsRuntime.swift
// RUN: %target-build-swift -Xfrontend -pc-macro -o %t/main -I=%t %t/PlaygroundSupport.o %t/main.swift
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s
// RUN: %target-build-swift -Xfrontend -pc-macro -Xfrontend -playground -Xfrontend -debugger-support -o %t/main2 -I=%t %t/PlaygroundSupport.o %t/main.swift
// RUN: %target-codesign %t/main2
// RUN: %target-run %t/main2 | %FileCheck %s
// REQUIRES: executable_test
// FIXME: rdar://problem/30234450 PCMacro tests fail on linux in optimized mode
// UNSUPPORTED: OS=linux-gnu
import PlaygroundSupport
#sourceLocation(file: "main.swift", line: 8)
for i in 0..<3 /* comments won't confuse pc macro! */ {
i // check it is hitting the loop conditional between each iteration.
}
// CHECK: [8:1-8:15] pc before
// CHECK-NEXT: [8:1-8:15] pc after
// CHECK-NEXT: [9:3-9:4] pc before
// CHECK-NEXT: [9:3-9:4] pc after
// CHECK-NEXT: [8:1-8:15] pc before
// CHECK-NEXT: [8:1-8:15] pc after
// CHECK-NEXT: [9:3-9:4] pc before
// CHECK-NEXT: [9:3-9:4] pc after
// CHECK-NEXT: [8:1-8:15] pc before
// CHECK-NEXT: [8:1-8:15] pc after
// CHECK-NEXT: [9:3-9:4] pc before
// CHECK-NEXT: [9:3-9:4] pc after
for i in 0..<3 { // comments here shouldn't confuse it
i
continue // checking it includes the continue
}
// CHECK-NEXT: [24:1-24:15] pc before
// CHECK-NEXT: [24:1-24:15] pc after
// CHECK-NEXT: [25:3-25:4] pc before
// CHECK-NEXT: [25:3-25:4] pc after
// CHECK-NEXT: [26:3-26:11] pc before
// CHECK-NEXT: [26:3-26:11] pc after
// CHECK-NEXT: [24:1-24:15] pc before
// CHECK-NEXT: [24:1-24:15] pc after
// CHECK-NEXT: [25:3-25:4] pc before
// CHECK-NEXT: [25:3-25:4] pc after
// CHECK-NEXT: [26:3-26:11] pc before
// CHECK-NEXT: [26:3-26:11] pc after
// CHECK-NEXT: [24:1-24:15] pc before
// CHECK-NEXT: [24:1-24:15] pc after
// CHECK-NEXT: [25:3-25:4] pc before
// CHECK-NEXT: [25:3-25:4] pc after
// CHECK-NEXT: [26:3-26:11] pc before
// CHECK-NEXT: [26:3-26:11] pc after
for i in 0..<3 {
i
break // check it only happens once and includes the break
}
// CHECK-NEXT: [47:1-47:15] pc before
// CHECK-NEXT: [47:1-47:15] pc after
// CHECK-NEXT: [48:3-48:4] pc before
// CHECK-NEXT: [48:3-48:4] pc after
// CHECK-NEXT: [49:3-49:8] pc before
// CHECK-NEXT: [49:3-49:8] pc after
1
// check the file is finished
// CHECK-NEXT: [57:1-57:2] pc before
// CHECK-NEXT: [57:1-57:2] pc after