add simple test suite
This commit is contained in:
parent
6e9448bdbb
commit
1c79cf3cbf
|
|
@ -1,2 +1,3 @@
|
||||||
*.o
|
*.o
|
||||||
bin
|
bin
|
||||||
|
*.d.out
|
||||||
|
|
|
||||||
2
makefile
2
makefile
|
|
@ -6,3 +6,5 @@ FLAGS := -g -w $(INCLUDE_PATHS)
|
||||||
all: $(SRC)
|
all: $(SRC)
|
||||||
$(COMPILER) $(FLAGS) $(SRC) -ofbin/dfmt
|
$(COMPILER) $(FLAGS) $(SRC) -ofbin/dfmt
|
||||||
|
|
||||||
|
test: bin/dfmt
|
||||||
|
cd tests && ./test.sh
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
import std.stdio; void main() { writeln("Hello, world without explicit compilations!"); }
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import std.stdio;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
writeln("Hello, world without explicit compilations!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue