[DEV] add block check
This commit is contained in:
parent
16b9c3f17e
commit
bfc351e2a4
@ -544,6 +544,13 @@ int32_t estyle::Generator::process(int32_t _startId,
|
||||
continue;
|
||||
}
|
||||
if (elem == estyle::lexer::BRACE_IN) {
|
||||
typePush("block");
|
||||
int32_t subGenerationStart = iii+1;
|
||||
int32_t subGenerationStop = endOfSection(iii);
|
||||
iii = generateBrace(subGenerationStart, subGenerationStop, true, false);
|
||||
iii--;
|
||||
typePop();
|
||||
/*
|
||||
addNewLineIfSemiColon();
|
||||
m_urrentStack.pushBack(stack::BLOCK);
|
||||
addNewLine();
|
||||
@ -551,19 +558,13 @@ int32_t estyle::Generator::process(int32_t _startId,
|
||||
m_output += "{";
|
||||
m_output += getEndOfLine();
|
||||
indentationPush();
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
if (elem == estyle::lexer::BRACE_OUT) {
|
||||
addNewLineIfSemiColon();
|
||||
indentationPop();
|
||||
if (m_urrentStack.size() == 0) {
|
||||
ESTYLE_ERROR("Get '}' without a '{' element");
|
||||
continue;
|
||||
} else if (m_urrentStack.back() != stack::BLOCK) {
|
||||
ESTYLE_ERROR("Get '}' without other than a '{' element in stack of type ...");
|
||||
} else {
|
||||
m_urrentStack.popBack();
|
||||
}
|
||||
ESTYLE_ERROR("Get '}' without other than a '{' element in stack of type ...");
|
||||
addNewLine();
|
||||
addSpace();
|
||||
m_output += "}";
|
||||
|
@ -0,0 +1,257 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#include <estyle/estyle.hpp>
|
||||
#include <estyle/Generator.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
|
||||
static etk::String sourceBlock = "action_A;{action_B;}action_D;";
|
||||
|
||||
|
||||
TEST(testBlock, brace_0000) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-in-space-before", "true");
|
||||
//interface.properties.set("brace-block-in-space-after", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-out-space-before", "true");
|
||||
//interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;{action_B;}action_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_1000) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-in-space-before", "true");
|
||||
//interface.properties.set("brace-block-in-space-after", "true");
|
||||
interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-out-space-before", "true");
|
||||
//interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\n{action_B;\n}action_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_1010) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
interface.properties.set("brace-block-in-space-before", "true");
|
||||
//interface.properties.set("brace-block-in-space-after", "true");
|
||||
interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
interface.properties.set("brace-block-out-space-before", "true");
|
||||
//interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\n{action_B;\n}action_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_1011) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
interface.properties.set("brace-block-in-space-before", "true");
|
||||
interface.properties.set("brace-block-in-space-after", "true");
|
||||
interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
interface.properties.set("brace-block-out-space-before", "true");
|
||||
interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\n{ action_B;\n} action_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_1100) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-in-space-before", "true");
|
||||
//interface.properties.set("brace-block-in-space-after", "true");
|
||||
interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-out-space-before", "true");
|
||||
//interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_1101) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-in-space-before", "true");
|
||||
interface.properties.set("brace-block-in-space-after", "true");
|
||||
interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-out-space-before", "true");
|
||||
interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_1110) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
interface.properties.set("brace-block-in-space-before", "true");
|
||||
//interface.properties.set("brace-block-in-space-after", "true");
|
||||
interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
interface.properties.set("brace-block-out-space-before", "true");
|
||||
//interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_1111) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
interface.properties.set("brace-block-in-space-before", "true");
|
||||
interface.properties.set("brace-block-in-space-after", "true");
|
||||
interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
interface.properties.set("brace-block-out-space-before", "true");
|
||||
interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_1001) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-in-space-before", "true");
|
||||
interface.properties.set("brace-block-in-space-after", "true");
|
||||
interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-out-space-before", "true");
|
||||
interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\n{ action_B;\n} action_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
||||
TEST(testBlock, brace_0100) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-in-space-before", "true");
|
||||
//interface.properties.set("brace-block-in-space-after", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-out-space-before", "true");
|
||||
//interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;{\n\taction_B;}\naction_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_0101) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-in-space-before", "true");
|
||||
interface.properties.set("brace-block-in-space-after", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-out-space-before", "true");
|
||||
interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;{\n\taction_B;}\naction_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_0110) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
interface.properties.set("brace-block-in-space-before", "true");
|
||||
//interface.properties.set("brace-block-in-space-after", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
interface.properties.set("brace-block-out-space-before", "true");
|
||||
//interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A; {\n\taction_B; }\naction_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_0010) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
interface.properties.set("brace-block-in-space-before", "true");
|
||||
//interface.properties.set("brace-block-in-space-after", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
interface.properties.set("brace-block-out-space-before", "true");
|
||||
//interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A; {action_B; }action_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_0011) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
interface.properties.set("brace-block-in-space-before", "true");
|
||||
interface.properties.set("brace-block-in-space-after", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
interface.properties.set("brace-block-out-space-before", "true");
|
||||
interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A; { action_B; } action_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_0111) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
interface.properties.set("brace-block-in-space-before", "true");
|
||||
interface.properties.set("brace-block-in-space-after", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
interface.properties.set("brace-block-out-space-before", "true");
|
||||
interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A; {\n\taction_B; }\naction_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testBlock, brace_0001) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-block-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-in-space-before", "true");
|
||||
interface.properties.set("brace-block-in-space-after", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-block-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-block-out-space-before", "true");
|
||||
interface.properties.set("brace-block-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;{ action_B;} action_D;";
|
||||
etk::String output = interface.process(sourceBlock);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user