From 8c15651c0372b8dc9c399d8e222cf4bf0566adcd Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 2 Jun 2014 11:24:25 -0400 Subject: [PATCH] Bug 436349 - JUnit test for step-return for a method returning void Change-Id: Ia449c9f599e6c5c3af9e26b4014ade6a12ae58c3 Signed-off-by: Marc Khouzam Reviewed-on: https://git.eclipse.org/r/27735 Tested-by: Hudson CI --- .../data/launch/src/ExpressionTestApp.cc | 7 ++++++ .../dsf/gdb/tests/MIExpressionsTest.java | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc index 8a4c0ee1673..7037087b009 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc @@ -365,6 +365,12 @@ int testRTTI() { } // End of bug 376901 RTTI tests +void noReturnValue() { + int a = 0; + a++; + return; +} + int testSimpleReturn(int a) { int b = 0; b = a; @@ -384,6 +390,7 @@ void testReturn() { testSimpleReturn(6); testComplexReturn(); + noReturnValue(); a = 0; } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java index 9c67ea49cb3..ab7bab201d0 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java @@ -4105,6 +4105,29 @@ public class MIExpressionsTest extends BaseTestCase { assertEquals("b", result[0].getName()); } + /** + * This test verifies that we properly display variables after a step-return operation + * from a method returning void. + */ + @Test + public void testNoReturnValueForEmptyStepReturn() throws Throwable { + SyncUtil.runToLocation("noReturnValue"); + MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_RETURN); + + // Check no return value is shown when looking at the first frame + final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + IVariableDMData[] result = SyncUtil.getLocals(frameDmc); + + assertEquals(2, result.length); // Two variables and one return value + + // first variable + assertEquals("a", result[0].getName()); + assertEquals("10", result[0].getValue()); + // Second variable + assertEquals("b", result[1].getName()); + assertEquals("false", result[1].getValue()); + } + /** * This tests verifies that we can obtain a child even though * is was already created directly.