replace individual test with equivalent with custom .args files
This commit is contained in:
parent
1a8221fc53
commit
0c63b758e3
|
@ -106,7 +106,7 @@ dfmt_space_before_function_parameters | `true`, `false` | `false` | Insert space
|
|||
dfmt_selective_import_space | `true`, `false` | `true` | Insert space after the module name and before the `:` for selective imports.
|
||||
dfmt_compact_labeled_statements | `true`, `false` | `true` | Place labels on the same line as the labeled `switch`, `for`, `foreach`, or `while` statement.
|
||||
dfmt_template_constraint_style | `conditional_newline_indent` `conditional_newline` `always_newline` `always_newline_indent` | `conditional_newline_indent` | Control the formatting of template constraints.
|
||||
dfmt_single_template_constraint_indent | `true`, `false` | `false` | Set if the constraints are indented by a single tab instead of two. Has only an effect for certain indentation styles.
|
||||
dfmt_single_template_constraint_indent | `true`, `false` | `false` | Set if the constraints are indented by a single tab instead of two. Has only an effect for if indentation style if set to `always_newline_indent` or `conditional_newline_indent`.
|
||||
|
||||
## Terminology
|
||||
* Braces - `{` and `}`
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
void foo()()
|
||||
if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees
|
||||
&& cows && sheeps && monkeys && whales)
|
||||
{
|
||||
}
|
||||
|
||||
void foo()() if (dogs && pigs && birds)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
void foo()()
|
||||
if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees
|
||||
&& cows && sheeps && monkeys && whales)
|
||||
{
|
||||
}
|
||||
|
||||
void foo()()
|
||||
if (dogs && pigs && birds)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
--template_constraint_style=conditional_newline_indent
|
||||
--single_template_constraint_indent=true
|
|
@ -0,0 +1,4 @@
|
|||
void foo()() if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees && cows && sheeps && monkeys && whales)
|
||||
{}
|
||||
|
||||
void foo()() if (dogs && pigs && birds) {}
|
|
@ -0,0 +1,2 @@
|
|||
--template_constraint_style=always_newline_indent
|
||||
--single_template_constraint_indent=true
|
|
@ -0,0 +1,4 @@
|
|||
void foo()() if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees && cows && sheeps && monkeys && whales)
|
||||
{}
|
||||
|
||||
void foo()() if (dogs && pigs && birds) {}
|
|
@ -1,4 +0,0 @@
|
|||
# DFMT individual tests
|
||||
|
||||
Each D source file in this folder gets only compiled and executed with DMD.
|
||||
Each must contain its own functions to call and test particular features.
|
|
@ -1,73 +0,0 @@
|
|||
module single_constraint_indent;
|
||||
|
||||
private string dfmt_name;
|
||||
|
||||
static this()
|
||||
{
|
||||
import std.path : dirName;
|
||||
dfmt_name = __FILE_FULL_PATH__.dirName ~ "/../../bin/dfmt";
|
||||
}
|
||||
|
||||
private immutable input1 = q{
|
||||
void foo()() if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees && cows && sheeps && monkeys && whales)
|
||||
{}};
|
||||
private immutable expected1 = q{
|
||||
void foo()()
|
||||
if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees
|
||||
&& cows && sheeps && monkeys && whales)
|
||||
{
|
||||
}};
|
||||
private immutable input2 = q{
|
||||
void foo()() if (dogs && pigs && birds)
|
||||
{}};
|
||||
private immutable expected21 = q{
|
||||
void foo()() if (dogs && pigs && birds)
|
||||
{
|
||||
}};
|
||||
private immutable expected22 = q{
|
||||
void foo()()
|
||||
if (dogs && pigs && birds)
|
||||
{
|
||||
}};
|
||||
|
||||
private void test(string input, string expected, string[] dfmt_args)
|
||||
{
|
||||
import std.array : array, join;
|
||||
import std.conv : to;
|
||||
import std.process : ProcessPipes, pipeProcess, wait;
|
||||
import std.stdio : stderr;
|
||||
|
||||
ProcessPipes pp = pipeProcess(([dfmt_name] ~ dfmt_args));
|
||||
pp.stdin.write(input);
|
||||
pp.stdin.close;
|
||||
const r = wait(pp.pid);
|
||||
const e = pp.stderr.byLineCopy.array.join("\n");
|
||||
if (r == 0)
|
||||
{
|
||||
assert(e.length == 0, "unexpected stderr content: \n" ~ e);
|
||||
const auto formatted_output = "\n" ~ pp.stdout.byLineCopy.array.join("\n");
|
||||
assert(formatted_output == expected, formatted_output);
|
||||
}
|
||||
else assert(false, "abnormal dfmt termination : " ~ to!string(r) ~ "\n" ~ e);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
input1.test(expected1, [
|
||||
"--template_constraint_style=always_newline_indent",
|
||||
"--single_template_constraint_indent=true",
|
||||
]);
|
||||
input1.test(expected1, [
|
||||
"--template_constraint_style=conditional_newline_indent",
|
||||
"--single_template_constraint_indent=true",
|
||||
]);
|
||||
input2.test(expected21, [
|
||||
"--template_constraint_style=conditional_newline_indent",
|
||||
"--single_template_constraint_indent=true",
|
||||
]);
|
||||
input2.test(expected22, [
|
||||
"--template_constraint_style=always_newline_indent",
|
||||
"--single_template_constraint_indent=true",
|
||||
]);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
void foo()()
|
||||
if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees
|
||||
&& cows && sheeps && monkeys && whales) {
|
||||
}
|
||||
|
||||
void foo()() if (dogs && pigs && birds) {
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
void foo()()
|
||||
if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees
|
||||
&& cows && sheeps && monkeys && whales) {
|
||||
}
|
||||
|
||||
void foo()()
|
||||
if (dogs && pigs && birds) {
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# main test suite
|
||||
for braceStyle in allman otbs
|
||||
do
|
||||
for source in *.d
|
||||
|
@ -17,17 +16,3 @@ do
|
|||
diff -u "${braceStyle}/${source}.ref" "${braceStyle}/${source}.out"
|
||||
done
|
||||
done
|
||||
|
||||
# individual tests
|
||||
cd individual
|
||||
for source in *.d
|
||||
do
|
||||
echo "testing indiviual ${source}"
|
||||
test_name="${source}_test"
|
||||
$DC ${source} -of${test_name}
|
||||
if [ -f ${test_name} ]; then
|
||||
./${test_name}
|
||||
rm -f "${test_name}"
|
||||
echo "tested indiviual ${source}"
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue