Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,56 @@ public void dispose() {
tester.close();
}

@Test
public void testSuperSourceSections() throws Throwable {
assertSuperSourceSections("super().value", "super(Derived, self).method(value)");
}

@Test
public void testGenericSuperSourceSections() throws Throwable {
assertSuperSourceSections("alias(Derived, self).value", "alias(Derived, self).method(value)");
}

private void assertSuperSourceSections(String valueLookup, String methodCall) throws Throwable {
Source source = Source.newBuilder("python", """
class Base:
@property
def value(self):
return 21
def method(self, value):
return value * 2
class Derived(Base):
def run(self):
value = %s
return %s
alias = super
for _ in range(10):
Derived().run()
""".formatted(valueLookup, methodCall), "super_sections.py").buildLiteral();
try (DebuggerSession session = tester.startSession()) {
session.install(Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(4).build());
session.install(Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(6).build());
tester.startEval(source);
// The default session instruments statements, so caller locations cover the enclosing
// assignment/return. Check both uncached and cached execution, as for ordinary calls.
for (int i = 0; i < 10; i++) {
expectSuspended(event -> {
var frames = event.getStackFrames().iterator();
assertEquals(4, frames.next().getSourceSection().getStartLine());
assertEquals("value = " + valueLookup, frames.next().getSourceSection().getCharacters().toString());
event.prepareContinue();
});
expectSuspended(event -> {
var frames = event.getStackFrames().iterator();
assertEquals(6, frames.next().getSourceSection().getStartLine());
assertEquals("return " + methodCall, frames.next().getSourceSection().getCharacters().toString());
event.prepareContinue();
});
}
tester.expectDone();
}
}

@Test
public void testSteppingAsExpected() throws Throwable {
// test that various elements step as expected, including generators, statement level atomic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import sys
import types
import unittest
import builtins

if sys.implementation.name == "graalpy" and not __graalpython__.is_forced_uncached_interpreter:

Expand Down
Loading
Loading