mirror of https://github.com/aamine/cbc
* test/test.sh: compile command by myself before run it.
* test/shunit.sh (assert_status, assert_error, assert_stdout): allow any number of arguments for command. * test/Makefile: remove task "cbprograms". * test/Makefile (clean): clean programs depending on svn:ignore list. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3799 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
67442a4801
commit
57b38c5a86
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Sat Jan 5 08:00:26 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* test/test.sh: compile command by myself before run it.
|
||||
|
||||
* test/shunit.sh (assert_status, assert_error, assert_stdout):
|
||||
allow any number of arguments for command.
|
||||
|
||||
* test/Makefile: remove task "cbprograms".
|
||||
|
||||
* test/Makefile (clean): clean programs depending on svn:ignore
|
||||
list.
|
||||
|
||||
Sat Jan 5 07:36:43 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* test/cast2.cb: test cast from long* to int*.
|
||||
|
|
|
@ -1,47 +1,19 @@
|
|||
CC = gcc
|
||||
CFLAGS = -Wall -O -fno-omit-frame-pointer
|
||||
CBC = ./cbc
|
||||
CBPROGS = zero one hello hello2 hello3 hello4 integer string \
|
||||
funcall0 funcall1 funcall2 funcall3 funcall4 funcall5 \
|
||||
param lvar1 lvar2 comm scomm gvar sgvar slvar slcomm \
|
||||
add sub mul div mod bitand bitor bitxor bitnot lshift rshift \
|
||||
logicalnot unaryplus unaryminus \
|
||||
eq neq gt lt gteq lteq \
|
||||
assign opassign inc dec \
|
||||
if1 if2 condexpr logicaland logicalor \
|
||||
while1 while2 while3 while-break while-continue \
|
||||
dowhile1 dowhile2 dowhile3 dowhile-break dowhile-continue \
|
||||
for1 for-break for-continue \
|
||||
array array2 \
|
||||
struct struct-semcheck union union-semcheck \
|
||||
usertype \
|
||||
pointer pointer2 pointer3 ptrmemb funcptr funcptr2 \
|
||||
charops shortops intops longops \
|
||||
ucharops ushortops uintops ulongops \
|
||||
block cast cast2 defvar mbc assoc \
|
||||
|
||||
ANT = jant
|
||||
|
||||
# immscope cast
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cb .
|
||||
.cb:
|
||||
$(CBC) $<
|
||||
|
||||
default: cbprograms
|
||||
|
||||
test: cbprograms
|
||||
test:
|
||||
./test.sh
|
||||
|
||||
cbprograms: $(CBPROGS)
|
||||
|
||||
clean:
|
||||
rm -f $(CBPROGS) *.s *.o
|
||||
|
||||
recompile:
|
||||
cd .. && $(ANT) clean && $(ANT) compile
|
||||
|
||||
clean-test: recompile
|
||||
$(MAKE) clean
|
||||
$(MAKE) test
|
||||
comptest: recompile
|
||||
./test.sh
|
||||
|
||||
clean:
|
||||
rm -f *.s *.o `svn pget svn:ignore .`
|
||||
|
|
|
@ -44,13 +44,12 @@ test_failed() {
|
|||
assert_status() {
|
||||
begin_test
|
||||
expected=$1; shift
|
||||
mycmd=$1; shift
|
||||
eval "$mycmd" >/dev/null 2>&1
|
||||
"$@" >/dev/null 2>&1
|
||||
really=$?
|
||||
assert_not_coredump || return
|
||||
if [ "$really" != "$expected" ]
|
||||
then
|
||||
echo "shunit[$mycmd]: status $expected expected but was: $really"
|
||||
echo "shunit[$@]: status $expected expected but was: $really"
|
||||
test_failed
|
||||
return 1
|
||||
fi
|
||||
|
@ -59,13 +58,12 @@ assert_status() {
|
|||
|
||||
assert_error() {
|
||||
begin_test
|
||||
mycmd=$1; shift
|
||||
eval "$mycmd" >/dev/null 2>&1
|
||||
"$@" >/dev/null 2>&1
|
||||
really=$?
|
||||
assert_not_coredump || return
|
||||
if [ "$really" = "0" ]
|
||||
then
|
||||
echo "shunit[$mycmd]: non-zero status expected but was: $really"
|
||||
echo "shunit[$@]: non-zero status expected but was: $really"
|
||||
test_failed
|
||||
return 1
|
||||
fi
|
||||
|
@ -74,8 +72,8 @@ assert_error() {
|
|||
|
||||
assert_eq() {
|
||||
begin_test
|
||||
expected="$1"; shift
|
||||
really="$1"; shift
|
||||
expected="$1"
|
||||
really="$2"
|
||||
if [ "$really" != "$expected" ]
|
||||
then
|
||||
echo "shunit: <$expected> expected but is: <$really>"
|
||||
|
@ -88,8 +86,8 @@ assert_eq() {
|
|||
assert_equal() {
|
||||
begin_test
|
||||
_f="no"
|
||||
excmd=$1; shift
|
||||
mycmd=$1; shift
|
||||
excmd=$1
|
||||
mycmd=$2
|
||||
eval "$excmd" >tc.out.expected 2>tc.err.expected
|
||||
eval "$mycmd" >tc.out.real 2>tc.err.real
|
||||
assert_not_coredump || return
|
||||
|
@ -139,14 +137,13 @@ assert_equal_stdout() {
|
|||
assert_stdout() {
|
||||
begin_test
|
||||
expected=$1; shift
|
||||
mycmd=$1; shift
|
||||
echo "$expected" > tc.out.expected
|
||||
eval "$mycmd" >tc.out.real 2>/dev/null
|
||||
"$@" >tc.out.real 2>/dev/null
|
||||
assert_not_coredump || return
|
||||
cmp tc.out.expected tc.out.real >/dev/null 2>&1
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
echo "stdout differ: string \"$expected\" and cmd \"$mycmd\""
|
||||
echo "stdout differ: string \"$expected\" and cmd \"$@\""
|
||||
diff -u tc.out.expected tc.out.real
|
||||
echo "----"
|
||||
test_failed
|
||||
|
|
38
test/test.sh
38
test/test.sh
|
@ -4,14 +4,24 @@ CBC=./cbc
|
|||
|
||||
. ./shunit.sh
|
||||
|
||||
assert_ok() {
|
||||
assert_stdout "OK" $1
|
||||
assert_status 0 $1
|
||||
assert_compile() {
|
||||
assert_status 0 $CBC "$@"
|
||||
}
|
||||
|
||||
assert_stat() {
|
||||
st=$1; shift
|
||||
assert_compile "$1.cb" &&
|
||||
assert_status $st "$@"
|
||||
}
|
||||
|
||||
assert_out() {
|
||||
assert_stdout "$1" $2
|
||||
assert_status 0 $2
|
||||
msg="$1"; shift
|
||||
assert_compile "$1.cb" &&
|
||||
assert_stdout "$msg" "$@"
|
||||
}
|
||||
|
||||
assert_ok() {
|
||||
assert_out "OK" "$@"
|
||||
}
|
||||
|
||||
symbol_visibility() {
|
||||
|
@ -47,19 +57,19 @@ assert_compile_error() {
|
|||
return 0
|
||||
}
|
||||
|
||||
assert_status 0 ./zero
|
||||
assert_status 1 ./one
|
||||
assert_stat 0 ./zero
|
||||
assert_stat 1 ./one
|
||||
|
||||
assert_out "Hello, World!" ./hello
|
||||
assert_out "Hello, World!" ./hello2
|
||||
assert_out "Hello, World!" ./hello3
|
||||
assert_out "Hello, World!" ./hello4
|
||||
|
||||
assert_status 0 ./funcall0
|
||||
assert_status 0 ./funcall1
|
||||
assert_status 0 ./funcall2
|
||||
assert_status 0 ./funcall3
|
||||
assert_status 0 ./funcall4
|
||||
assert_stat 0 ./funcall0
|
||||
assert_stat 0 ./funcall1
|
||||
assert_stat 0 ./funcall2
|
||||
assert_stat 0 ./funcall3
|
||||
assert_stat 0 ./funcall4
|
||||
assert_out "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36;37;38;39;40;41;42;43;44;45;46;47;48;49;50;51;52;53;54;55" ./funcall5
|
||||
|
||||
assert_out "$(/bin/echo -e ';;a;aa;b;";'\'';\a\b\0033\f\n\r\t\v;ABCabc')" ./string
|
||||
|
@ -139,7 +149,7 @@ assert_compile_error aref-semcheck.cb
|
|||
assert_compile_error array-semcheck1.cb
|
||||
|
||||
assert_out "11;22" ./struct
|
||||
assert_status 0 ./struct-semcheck
|
||||
assert_stat 0 ./struct-semcheck
|
||||
assert_compile_error struct-semcheck2.cb
|
||||
assert_compile_error struct-semcheck3.cb
|
||||
assert_compile_error struct-semcheck4.cb
|
||||
|
@ -151,7 +161,7 @@ assert_compile_error struct-semcheck9.cb
|
|||
assert_compile_error struct-semcheck10.cb
|
||||
|
||||
assert_out "1;2;513" ./union # little endian
|
||||
assert_status 0 ./union-semcheck
|
||||
assert_stat 0 ./union-semcheck
|
||||
assert_compile_error union-semcheck2.cb
|
||||
assert_compile_error union-semcheck3.cb
|
||||
assert_compile_error union-semcheck4.cb
|
||||
|
|
Loading…
Reference in New Issue