summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2014-02-01 21:01:27 +0200
committerOrgad Shaneh <orgads@gmail.com>2014-02-05 13:46:44 +0100
commit408901273500a64438bd168864300f7877877a6b (patch)
tree9969dbd0e71a88aa660cc922dd37e94a80d7dbdb /tests
parentddab33545ce769c27fb4d7483ab534688fd8f875 (diff)
downloadqt-creator-408901273500a64438bd168864300f7877877a6b.tar.gz
GenericHighligher: Preserve whole context on LineContinue
Task-number: QTCREATORBUG-11063 Change-Id: I5f23a2a1f1db370e732c1a101a6581fa5c493085 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/generichighlighter/highlighterengine/tst_highlighterengine.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/generichighlighter/highlighterengine/tst_highlighterengine.cpp b/tests/auto/generichighlighter/highlighterengine/tst_highlighterengine.cpp
index 54b26aa42d..dd2fa87b6d 100644
--- a/tests/auto/generichighlighter/highlighterengine/tst_highlighterengine.cpp
+++ b/tests/auto/generichighlighter/highlighterengine/tst_highlighterengine.cpp
@@ -187,6 +187,13 @@ void tst_HighlighterEngine::createContexts()
nestedComment->setLineEndContext("#stay");
nestedComment->setDefinition(m_definition);
+ // SimpleNestedComment context
+ QSharedPointer<Context> simpleNestedComment =
+ m_definition->createContext("SimpleNestedComment", false);
+ simpleNestedComment->setItemData("Comment");
+ simpleNestedComment->setLineEndContext("#pop");
+ simpleNestedComment->setDefinition(m_definition);
+
// Dummy context
QSharedPointer<Context> dummy = m_definition->createContext("Dummy", false);
dummy->setItemData("Dummy");
@@ -433,6 +440,22 @@ void tst_HighlighterEngine::createContexts()
r27->setFirstNonSpace("true");
r27->setDefinition(m_definition);
normal->addRule(QSharedPointer<Rule>(r27));
+
+ Detect2CharsRule *r28 = new Detect2CharsRule;
+ r28->setChar("#");
+ r28->setChar1("#");
+ r28->setItemData("Comment");
+ r28->setContext("SimpleNestedComment");
+ r28->setDefinition(m_definition);
+ QSharedPointer<Rule> sr28(r28);
+ multiComment->addRule(sr28);
+ nestedComment->addRule(sr28);
+
+ LineContinueRule *r29 = new LineContinueRule;
+ r29->setItemData("Comment");
+ r29->setContext("#stay");
+ r29->setDefinition(m_definition);
+ simpleNestedComment->addRule(QSharedPointer<Rule>(r29));
}
void tst_HighlighterEngine::createItemDatas()
@@ -699,6 +722,12 @@ void tst_HighlighterEngine::testLineContinue_data()
seqe.add(3, 8);
seqe.add(8, 9, Formats::instance().baseNFormat());
seqe.add(9, 10);
+ HighlightSequence seqf(0, 9, Formats::instance().commentFormat());
+ seqf.add(9, 18, Formats::instance().errorFormat());
+ HighlightSequence seqg(0, 7, Formats::instance().commentFormat());
+ HighlightSequence seqh(0, 5, Formats::instance().commentFormat());
+ HighlightSequence seqi(0, 5, Formats::instance().errorFormat());
+ seqi.add(5, 8, Formats::instance().commentFormat());
states << 1 << 2;
sequences << seqa << seqb;
@@ -722,6 +751,12 @@ void tst_HighlighterEngine::testLineContinue_data()
sequences << seqa << seqc << seqd << seqe;
lines = "#define max\\\n 100\\\n000\nint i = 0;";
QTest::newRow("case 3") << states << sequences << lines;
+
+ clear(&states, &sequences);
+ states << 4 << 1 << 1 << 2 << 3 << 0 << 1;
+ sequences << seqf << seqg << seqh << seqh << seqi << seqh;
+ lines = "/*int i; /# int j;\n##foo \\\nbar \\\nbaz \nxxx#/yyy\nzzz*/";
+ QTest::newRow("case 4") << states << sequences << lines;
}
void tst_HighlighterEngine::setupForEditingLineContinue()