shell script testing (im not a shell sripter)
yea this is bare bones, i wrote it on the commute home
i will expand it with more tests and what not later on
This commit is contained in:
Kitty-Cricket Piapiac 2023-04-13 20:29:27 -07:00
parent f25f1b8176
commit 2571884392
4 changed files with 33 additions and 40 deletions

4
t/as/ref-abs.kmm Normal file
View File

@ -0,0 +1,4 @@
{absolute references}
:a @a ; :b @b ;
{-8<-}
#00000000 #00000004

4
t/as/ref-rel.kmm Normal file
View File

@ -0,0 +1,4 @@
{relative references}
^a ^a ^a ^a :a ; ^a ^a ^a ^a
{-8<-}
#04030201 #00fffefd

25
t/t.sh Executable file
View File

@ -0,0 +1,25 @@
#/bin/sh
AS=../b/as
echo "Testing assembler..."
for f in as/*.kmm; do
n="${f%%.*}"; txt=$(cat $f)
echo -n " $n? "
inpbuf="${txt%%\{-8<-\}*}" expbuf="${txt#*\{-8<-\}}"
inpinf="$n.inp.kmm"; expinf="$n.exp.kmm"
inpouf="$n.inp.rom"; expouf="$n.exp.rom"
inphex="$n.inp.hex"; exphex="$n.exp.hex"
inplog="$n.inp.log"; outlog="$n.out.log"
echo "$inpbuf" > $inpinf; echo "$expbuf" > $expinf
$AS $inpinf $inpouf > $inplog; $AS $expinf $expouf > $outlog
inpres=$(hexdump -C $inpouf); expres=$(hexdump -C $expouf)
echo "$inpres" > $inphex; echo "$expres" > $exphex
if [ "$inpres" == "$expres" ]
then echo "OK"
else echo "FAIL"; diff --color "$inphex" "$exphex"
fi
rm $inpinf $expinf $inpouf $expouf $inphex $exphex $inplog $outlog
done
echo "Assembler OK"

40
t/u.c
View File

@ -1,40 +0,0 @@
#include"../u.h"
#define AEQ(a,b)Q((a)!=(b),die("assertion failed at line %d\n",__LINE__))
V tsl(V){
AEQ(4,Sl("meow").l);}
V tseql(V){
AEQ(0,seql(Sl("meow"),Sl("rewr")));
AEQ(1,seql(Sl("meow"),Sl("meow")));}
V tsnxt(V){
S n=Sl("meow/rewr/:3");
AEQ(1,seql(Sl("meow"),snxt(n,'/')))
AEQ(1,seql(Sl("rewr"),snxt(S0,'/')))
AEQ(1,seql(Sl(":3"),snxt(S0,'/')))
AEQ(0,snxt(S0,'/').l)}
V thputgetgrw(V){Ht h;
hini(&h,1,SZ(W));
*(W*)hput(&h,Sl("meow"))=1;
*(W*)hput(&h,Sl("rewr"))=2;
AEQ(1,*Hget(W,h,Sl("meow")));
AEQ(2,*Hget(W,h,Sl("rewr")));}
V thgetnul(V){Ht h;
hini(&h,4,SZ(W));
AEQ(0,Hget(W,h,Sl("meow")));}
V thgrw(V){Ht h;
hini(&h,2,SZ(W));
*(W*)hput(&h,Sl("meow"))=1;
hgrw(&h,8);
AEQ(1,*Hget(W,h,Sl("meow"))); }
I main(V){
/*S*/
tsl();
tseql();
tsnxt();
/*Ht*/
thputgetgrw();
thgetnul();
thgrw();
}