Closed RaniAgus closed 2 months ago
Nevermind, I've configured clang-format like this:
ForEachMacros: [describe, it, before, after, skip]
Macros: ["end=/*end*/"]
And it works:
context(example) {
describe ("Hello world") {
it ("true should be true") {
should_bool(true) be equal to(true);
} end
it ("true shouldn't be false") {
should_bool(true) not be equal to(false);
} end
it ("this test will fail because 10 is not equal to 11") {
should_int(10) be equal to(11);
} end
skip ("this test will fail because \"Hello\" is not \"Bye\"") {
should_string("Hello") be equal to("Bye");
} end
} end
}
Most C/C++ code formatters (like
clang-format
) are not able to understand the{} end
syntax, so they end up formatting CSpec code like this:In a custom branch I've tried getting rid of
end
macro and moving the curly braces inside parenthesis:And it indents almost as expected (it doesn't work for single-line blocks, even though I've set every
AllowShort*OnASingleLine
option to false/Never/None):But, I find this syntax much more easier to understand and use, and also more beginner friendly. What do you think?