Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
np committed Nov 29, 2010
1 parent 2323733 commit 6d0ca84
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build:
ocamlbuild pplex.byte
test:
@PPLEX=$(PWD)/_build/pplex.byte cmdcheck tests/*.t
find tests -path '*.t/*' \( -name stdin -o -name '*.ml' \) -exec ./tests/check-roundtrip -f -w {} \;
42 changes: 42 additions & 0 deletions tests/char-crlf.t/TESTRECIPE
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

testname='char-crlf.t'
command="$PPLEX"
args=( '-s' 'input.ml' )
exit_code='0'
stdin_file='/dev/null'
stdout_file='stdout'
stderr_file='/dev/null'
sources=( 'input.ml' )
products=( )

# Environment variables:
env_vars=( )

setup(){
: Perform here actions to be run before the tested program
}

munge(){
: Munge here the results of the tested program to ease the check
}

check(){
check_exit_code &&
check_stderr &&
check_stdout &&
check_products &&
: Perform here extra checks on the tested program
}

explain(){
explain_exit_code
explain_stdout
explain_stderr
explain_products
: Explain here more potential differences
}

teardown(){
: Undo here the actions of setup
}
2 changes: 2 additions & 0 deletions tests/char-crlf.t/input.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'
'
2 changes: 2 additions & 0 deletions tests/char-crlf.t/stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHAR "\r\n"
NEWLINE "\n"
42 changes: 42 additions & 0 deletions tests/char-esc-overflow.t/TESTRECIPE
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

testname='char-esc-overflow.t'
command="$PPLEX"
args=( '-f' '-s' 'input.ml' )
exit_code='0'
stdin_file='/dev/null'
stdout_file='stdout'
stderr_file='/dev/null'
sources=( 'input.ml' )
products=( )

# Environment variables:
env_vars=( )

setup(){
: Perform here actions to be run before the tested program
}

munge(){
: Munge here the results of the tested program to ease the check
}

check(){
check_exit_code &&
check_stderr &&
check_stdout &&
check_products &&
: Perform here extra checks on the tested program
}

explain(){
explain_exit_code
explain_stdout
explain_stderr
explain_products
: Explain here more potential differences
}

teardown(){
: Undo here the actions of setup
}
1 change: 1 addition & 0 deletions tests/char-esc-overflow.t/input.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'\705'
2 changes: 2 additions & 0 deletions tests/char-esc-overflow.t/stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ERROR "'\\705'" "Illegal_escape" "\\705"
NEWLINE "\n"
13 changes: 12 additions & 1 deletion tests/check-rand-roundtrip
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#!/bin/bash -e
prefix=''
count='100'
while [ $# -gt 0 ]; do
case "$1" in
-p|--prefix) shift; prefix="$1"; shift;;
-c|--count) shift; count="$1"; shift;;
-*) echo usage; exit 1;;
*) break;;
esac
done
input="$(mktemp --suffix .ml)"
dd if=/dev/urandom of="$input" count=1 bs="$1" 2>/dev/null
echo -n "$prefix" > "$input"
dd if=/dev/urandom of="$input" oflag=append count=1 bs="$count" 2>/dev/null
lex=${PPLEX:-$(dirname $0)/../pplex.byte}
if "$lex" -f "$input" | cmp "$input" /dev/stdin; then
rm "$input"
Expand Down
42 changes: 42 additions & 0 deletions tests/string-esc-overflow.t/TESTRECIPE
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

testname='string-esc-overflow.t'
command="$PPLEX"
args=( '-f' '-s' 'input.ml' )
exit_code='0'
stdin_file='/dev/null'
stdout_file='stdout'
stderr_file='/dev/null'
sources=( 'input.ml' )
products=( )

# Environment variables:
env_vars=( )

setup(){
: Perform here actions to be run before the tested program
}

munge(){
: Munge here the results of the tested program to ease the check
}

check(){
check_exit_code &&
check_stderr &&
check_stdout &&
check_products &&
: Perform here extra checks on the tested program
}

explain(){
explain_exit_code
explain_stdout
explain_stderr
explain_products
: Explain here more potential differences
}

teardown(){
: Undo here the actions of setup
}
1 change: 1 addition & 0 deletions tests/string-esc-overflow.t/input.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"\705"
2 changes: 2 additions & 0 deletions tests/string-esc-overflow.t/stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ERROR "\"\\705\"" "Illegal_escape" "\\705"
NEWLINE "\n"

0 comments on commit 6d0ca84

Please sign in to comment.