MCPcopy Create free account
hub / github.com/KDE/kdevelop / testVariablesAttributes

Method testVariablesAttributes

plugins/debuggercommon/tests/debuggertestbase.cpp:1987–2075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1985}
1986
1987void DebuggerTestBase::testVariablesAttributes()
1988{
1989 auto* const session = createTestDebugSession();
1990 TestLaunchConfiguration cfg;
1991
1992 variableCollection()->variableWidgetShown();
1993
1994 addDebugeeBreakpoint(24);
1995 addDebugeeBreakpoint(29);
1996 ActiveStateSessionSpy sessionSpy(session);
1997 START_DEBUGGING_AND_WAIT_FOR_PAUSED_STATE_E(session, cfg, sessionSpy);
1998
1999 auto* const jVariable = variableCollection()->watches()->add("j");
2000 QVERIFY(jVariable);
2001 QCOMPARE(jVariable->canSetFormat(), true);
2002 // Verify initialization of attributes in the constructor of a variable.
2003 QCOMPARE(jVariable->expression(), "j");
2004 QCOMPARE(jVariable->showError(), false);
2005 QCOMPARE(jVariable->format(), Variable::Natural);
2006
2007 // Wait for the results of an MI command -var-create.
2008 WAIT_FOR_STATE_AND_IDLE(session, IDebugSession::PausedState);
2009 QCOMPARE(currentMiLine(session), 29);
2010 // There is no variable named `j` in the scope of main().
2011 QCOMPARE(jVariable->showError(), true);
2012
2013 // Setting format of a not yet attached variable succeeds but does not modify the value of the variable.
2014 jVariable->setFormat(Variable::Octal);
2015 QCOMPARE(jVariable->format(), Variable::Octal);
2016
2017 CONTINUE_AND_WAIT_FOR_PAUSED_STATE(session, sessionSpy);
2018 QCOMPARE(currentMiLine(session), 24);
2019 // A variable named `j` is present in the scope of foo().
2020 QCOMPARE(jVariable->showError(), false);
2021 QCOMPARE(jVariable->inScope(), true);
2022 QCOMPARE(jVariable->type(), "int");
2023 QCOMPARE(jVariable->format(), Variable::Octal);
2024 QCOMPARE(jVariable->value(), "01");
2025
2026 CONTINUE_AND_WAIT_FOR_PAUSED_STATE(session, sessionSpy);
2027 QCOMPARE(currentMiLine(session), 24);
2028 QCOMPARE(jVariable->showError(), false);
2029 QCOMPARE(jVariable->inScope(), true);
2030 QCOMPARE(jVariable->type(), "int");
2031 QCOMPARE(jVariable->format(), Variable::Octal);
2032 QCOMPARE(jVariable->value(), "02");
2033
2034 jVariable->setFormat(Variable::Binary);
2035 // Wait for the results of an MI command -var-set-format.
2036 WAIT_FOR_STATE_AND_IDLE(session, IDebugSession::PausedState);
2037 QCOMPARE(jVariable->showError(), false);
2038 QCOMPARE(jVariable->inScope(), true);
2039 QCOMPARE(jVariable->type(), "int");
2040 QCOMPARE(jVariable->format(), Variable::Binary);
2041 QCOMPARE(jVariable->value(), adjustedVariableValueInBinaryFormat("10"));
2042
2043 STEP_OUT_AND_WAIT_FOR_PAUSED_STATE(session, sessionSpy);
2044 QCOMPARE(currentMiLine(session), 32);

Callers

nothing calls this directly

Calls 13

variableCollectionFunction · 0.85
currentMiLineFunction · 0.85
variableWidgetShownMethod · 0.80
canSetFormatMethod · 0.80
formatMethod · 0.80
inScopeMethod · 0.80
addMethod · 0.45
expressionMethod · 0.45
showErrorMethod · 0.45
setFormatMethod · 0.45
typeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected