Skip to content

Commit 99c8fc3

Browse files
committed
[Utils] add test cases for swift-function-caller-generator
1 parent ce80641 commit 99c8fc3

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
// RUN: %swift-function-caller-generator Test %t/test.swift > %t/out.swift
4+
// RUN: %diff %t/out.swift %t/out.swift.expected
5+
6+
//--- test.swift
7+
func foo(x: Int) -> Int
8+
9+
func bar(_ y: UnsafePointer<CInt>)
10+
11+
@_lifetime(borrow z)
12+
func baz(_ z: Span<CInt>) -> Span<CInt>
13+
14+
@_lifetime(`func`: copy `func`)
15+
func qux(_ func: inout MutableSpan<CInt>)
16+
17+
//--- out.swift.expected
18+
import Test
19+
20+
func call_foo(x: Int) -> Int {
21+
return foo(x: x)
22+
}
23+
24+
25+
func call_bar(_ y: UnsafePointer<CInt>) {
26+
return unsafe bar(y)
27+
}
28+
29+
30+
@_lifetime(borrow z)
31+
func call_baz(_ z: Span<CInt>) -> Span<CInt> {
32+
return baz(z)
33+
}
34+
35+
36+
@_lifetime(`func`: copy `func`)
37+
func call_qux(_ func: inout MutableSpan<CInt>) {
38+
return qux(&`func`)
39+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-build-swift -emit-module %s -enable-experimental-feature Lifetimes -enable-experimental-feature LifetimeDependence -o %t/%target-library-name(Test) -module-name Test -emit-library
4+
5+
// RUN: %target-swift-emit-module-interface(%t/Test.swiftinterface) %s -enable-experimental-feature Lifetimes -enable-experimental-feature LifetimeDependence
6+
// RUN: %swift-function-caller-generator Test %t/Test.swiftinterface > %t/out.swift
7+
8+
// RUN: %target-swift-frontend -typecheck -verify %t/out.swift -I %t
9+
10+
func foo(x: Int) -> Int {
11+
return x
12+
}
13+
14+
func bar(_ y: UnsafePointer<CInt>) {}
15+
16+
@_lifetime(borrow z)
17+
func baz(_ z: Span<CInt>) -> Span<CInt> {
18+
return z
19+
}
20+
21+
@_lifetime(`func`: copy `func`)
22+
func qux(_ func: inout MutableSpan<CInt>) {}
23+

0 commit comments

Comments
 (0)