Skip to content

Commit 60da3b4

Browse files
authored
Merge pull request #9322 from augusto2112/test-protocol-comp-expr
[lldb] Test evaluation of protocol composition existentials
2 parents 5f77bb9 + 78f4b56 commit 60da3b4

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
include Makefile.rules
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
5+
6+
7+
class TestSwiftProtocolComposition(lldbtest.TestBase):
8+
@swiftTest
9+
def test(self):
10+
"""Test that expression evaluation can call functions in protocol composition existentials"""
11+
12+
self.build()
13+
filespec = lldb.SBFileSpec("main.swift")
14+
target, process, thread, breakpoint1 = lldbutil.run_to_source_breakpoint(
15+
self, "break here", filespec
16+
)
17+
self.expect("expr c.foo()", substrs=["In class foo"])
18+
self.expect("expr c.bar()", substrs=["In class bar"])
19+
20+
self.expect("expr s.foo()", substrs=["In struct foo"])
21+
self.expect("expr s.bar()", substrs=["In struct bar"])
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
protocol P1 {
2+
func foo() -> String
3+
}
4+
5+
protocol P2 {
6+
func bar() -> String
7+
}
8+
9+
class C: P1, P2 {
10+
let i = 42
11+
12+
func foo() -> String {
13+
"In class foo"
14+
}
15+
16+
func bar() -> String {
17+
"In class bar"
18+
}
19+
}
20+
21+
struct S: P1, P2 {
22+
let str = "Hello"
23+
24+
func foo() -> String {
25+
"In struct foo"
26+
}
27+
28+
func bar() -> String {
29+
"In struct bar"
30+
}
31+
}
32+
33+
func f() {
34+
let c: any P1 & P2 = C()
35+
let s: any P1 & P2 = S()
36+
print("break here")
37+
}
38+
39+
f()
40+

0 commit comments

Comments
 (0)