mirror of
https://github.com/dlang-community/dfmt.git
synced 2025-04-25 21:00:03 +03:00
add simple test suite
This commit is contained in:
parent
6e9448bdbb
commit
1c79cf3cbf
7 changed files with 49 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
*.o
|
||||
bin
|
||||
*.d.out
|
||||
|
|
2
makefile
2
makefile
|
@ -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
15
tests/frontpage.d
Normal 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
15
tests/frontpage.d.ref
Normal 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
1
tests/hello.d
Normal file
|
@ -0,0 +1 @@
|
|||
import std.stdio; void main() { writeln("Hello, world without explicit compilations!"); }
|
7
tests/hello.d.ref
Normal file
7
tests/hello.d.ref
Normal file
|
@ -0,0 +1,7 @@
|
|||
import std.stdio;
|
||||
|
||||
void main()
|
||||
{
|
||||
writeln("Hello, world without explicit compilations!");
|
||||
}
|
||||
|
8
tests/test.sh
Executable file
8
tests/test.sh
Executable 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
|
Loading…
Add table
Add a link
Reference in a new issue