diff --git a/.gitignore b/.gitignore index 9e9683a..9c07130 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,9 @@ u6a *.sum site.* +# tests +unlambda-2.0.0* + # gcov *.gcov *.gcda diff --git a/tests/default/cat.exp b/tests/default/cat.exp index 8ad633e..ae1f982 100644 --- a/tests/default/cat.exp +++ b/tests/default/cat.exp @@ -31,7 +31,7 @@ for { set i 0 } { $i < [ llength $rand_str_list ] } { incr i } { set rand_str [ lindex $rand_str_list $i ] send -- "$rand_str\r" expect { - $rand_str { + -ex "$rand_str" { pass "case $i ok!" } default { diff --git a/tests/default/quines.exp b/tests/default/quines.exp new file mode 100644 index 0000000..73490fe --- /dev/null +++ b/tests/default/quines.exp @@ -0,0 +1,49 @@ +## + # quines.exp - Test whether quines programs from CUAN works on this u6a build + # + # Copyright (C) 2020 CismonX + # + # This program is free software: you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation, either version 3 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + # + +set tool "default" +set timeout 20 + +puts "Downloading files..." +exec wget --quiet "http://www.eleves.ens.fr:8080/home/madore/unlambda-2.0.0.tar.gz" +puts "Extracting archive..." +exec tar -zxvf "unlambda-2.0.0.tar.gz" + +set pwd [ pwd ] +set quines [ glob -directory "$pwd/unlambda-2.0.0/CUAN/quine/" "*.unl" ] +foreach filename $quines { + set fp [ open $filename r ] + set data [ read $fp ] + close $fp + u6a_run "$filename" - "-p5000000" 0 + match_max [ string length $data ] + expect { + -ex "$data" { + pass "$filename ok!" + } + default { + fail "$filename fails!" + } + } + u6a_stop 0 +} + +puts "Cleaning up..." +file delete "$pwd/unlambda-2.0.0.tar.gz" +file delete -force "$pwd/unlambda-2.0.0" diff --git a/tests/default/square.exp b/tests/default/square.exp index 25ab8a1..a0541d6 100644 --- a/tests/default/square.exp +++ b/tests/default/square.exp @@ -32,7 +32,7 @@ for { set i 0 } { $i < 20 } { incr i } { set expected "$expected\n$square" u6a_run [ format $src_stub $src_segment ] - - 0 expect { - $expected { + -ex "$expected" { pass "case $i ok!" } default { diff --git a/tests/u6a_run b/tests/u6a_run index 0d21182..d0aee12 100755 --- a/tests/u6a_run +++ b/tests/u6a_run @@ -18,7 +18,8 @@ # along with this program. If not, see . # -U6A_BYTECODE=`echo $5 | $1 - | base64 $3` +CMD=`[[ "$5" == "/"* ]] && echo 'cat' || echo 'echo'` +U6A_BYTECODE=`$CMD $5 | $1 - | base64 $3` test -z $U6A_BYTECODE && exit -1 cat <(echo $U6A_BYTECODE | base64 $4) <(test $6 && cat $6) | $2 -