Browse Source

add test cases

master
CismonX 1 year ago
parent
commit
991002a952
No known key found for this signature in database GPG Key ID: 315D6652268C5007
  1. 3
      .gitignore
  2. 2
      tests/default/cat.exp
  3. 49
      tests/default/quines.exp
  4. 2
      tests/default/square.exp
  5. 3
      tests/u6a_run

3
.gitignore

@ -36,6 +36,9 @@ u6a
*.sum
site.*
# tests
unlambda-2.0.0*
# gcov
*.gcov
*.gcda

2
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 {

49
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 <admin@cismon.net>
#
# 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 <https://www.gnu.org/licenses/>.
#
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"

2
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 {

3
tests/u6a_run

@ -18,7 +18,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
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 -

Loading…
Cancel
Save