Skip to content

Commit 14efe18

Browse files
committed
Add Swift specific test
1 parent 6ad660e commit 14efe18

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Test controlling `expression` result variables are persistent.
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.lldbtest import *
7+
from lldbsuite.test.decorators import *
8+
from lldbsuite.test import lldbutil
9+
10+
11+
class TestCase(TestBase):
12+
def setUp(self):
13+
TestBase.setUp(self)
14+
self.build()
15+
lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.swift"))
16+
17+
def test_enable_persistent_result(self):
18+
"""Test explicitly enabling result variables persistence."""
19+
self.expect("expression --persistent-result on -- i", startstr="(Int) $R0 = 30")
20+
# Verify the lifetime of $R0 extends beyond the `expression` it was created in.
21+
self.expect("expression $R0", startstr="(Int) $R1 = 30")
22+
23+
def test_disable_persistent_result(self):
24+
"""Test explicitly disabling persistent result variables."""
25+
self.expect("expression --persistent-result off -- i", startstr="(Int) 30")
26+
# Verify a persistent result was not silently created.
27+
self.expect("expression $R0", error=True)
28+
29+
def test_expression_persists_result(self):
30+
"""Test `expression`'s default behavior is to persist a result variable."""
31+
self.expect("expression i", startstr="(Int) $R0 = 30")
32+
self.expect("expression $R0", startstr="(Int) $R1 = 30")
33+
34+
def test_p_does_not_persist_results(self):
35+
"""Test `p` does not persist a result variable."""
36+
self.expect("p i", startstr="(Int) 30")
37+
self.expect("p $R0", error=True)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
func main() {
2+
var i = 30
3+
print("break here")
4+
}
5+
6+
main()

0 commit comments

Comments
 (0)