Skip to content

Commit a0a3aec

Browse files
committed
[move-only] Add some execution tests that use generics.
1 parent 6a7dc26 commit a0a3aec

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

test/Interpreter/moveonly.swift

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Tests.test("global destroyed once") {
4545
do {
4646
global = FD()
4747
}
48-
expectEqual(0, LifetimeTracked.instances)
48+
expectEqual(0, LifetimeTracked.instances)
4949
}
5050

5151
@_moveOnly
@@ -104,3 +104,31 @@ Tests.test("empty struct") {
104104
let _ = consume e
105105
}
106106
}
107+
108+
protocol P {
109+
var name: String { get }
110+
}
111+
112+
Tests.test("AddressOnly") {
113+
class Klass : P {
114+
var name: String { "myName" }
115+
}
116+
117+
@_moveOnly
118+
struct S<T : P> {
119+
var t: T
120+
}
121+
122+
let e = S(t: Klass())
123+
expectEqual(e.t.name, "myName")
124+
125+
func testGeneric<T : P>(_ x: borrowing S<T>) {
126+
expectEqual(x.t.name, "myName")
127+
}
128+
testGeneric(e)
129+
130+
if e.t.name.count == 5 {
131+
let _ = consume e
132+
}
133+
}
134+

0 commit comments

Comments
 (0)