add simple test suite

This commit is contained in:
Andreas Zwinkau 2015-01-13 18:10:15 +01:00
parent 6e9448bdbb
commit 1c79cf3cbf
7 changed files with 49 additions and 0 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*.o
bin
*.d.out

View file

@ -6,3 +6,5 @@ FLAGS := -g -w $(INCLUDE_PATHS)
all: $(SRC)
$(COMPILER) $(FLAGS) $(SRC) -ofbin/dfmt
test: bin/dfmt
cd tests && ./test.sh

15
tests/frontpage.d Normal file
View file

@ -0,0 +1,15 @@
// Computes average line length for standard input.
import std.stdio;
void main()
{
ulong lines = 0;
double sumLength = 0;
foreach (line; stdin.byLine())
{
++lines;
sumLength += line.length;
}
writeln("Average line length: ",
lines ? sumLength / lines : 0);
}

15
tests/frontpage.d.ref Normal file
View file

@ -0,0 +1,15 @@
// Computes average line length for standard input.
import std.stdio;
void main()
{
ulong lines = 0;
double sumLength = 0;
foreach (line; stdin.byLine())
{
++lines;
sumLength += line.length;
}
writeln("Average line length: ", lines ? sumLength / lines:0);
}

1
tests/hello.d Normal file
View file

@ -0,0 +1 @@
import std.stdio; void main() { writeln("Hello, world without explicit compilations!"); }

7
tests/hello.d.ref Normal file
View file

@ -0,0 +1,7 @@
import std.stdio;
void main()
{
writeln("Hello, world without explicit compilations!");
}

8
tests/test.sh Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e
for source in *.d
do
../bin/dfmt "${source}" >"${source}.out"
diff -u "${source}.ref" "${source}.out" || echo "fail ${source}"
done