From 2571884392b1fe4f869dfb45769ff3374f02d9e4 Mon Sep 17 00:00:00 2001 From: Kitty-Cricket Piapiac Date: Thu, 13 Apr 2023 20:29:27 -0700 Subject: [PATCH] t/t.sh 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 --- t/as/ref-abs.kmm | 4 ++++ t/as/ref-rel.kmm | 4 ++++ t/t.sh | 25 +++++++++++++++++++++++++ t/u.c | 40 ---------------------------------------- 4 files changed, 33 insertions(+), 40 deletions(-) create mode 100644 t/as/ref-abs.kmm create mode 100644 t/as/ref-rel.kmm create mode 100755 t/t.sh delete mode 100644 t/u.c diff --git a/t/as/ref-abs.kmm b/t/as/ref-abs.kmm new file mode 100644 index 0000000..e00a57b --- /dev/null +++ b/t/as/ref-abs.kmm @@ -0,0 +1,4 @@ +{absolute references} +:a @a ; :b @b ; +{-8<-} +#00000000 #00000004 diff --git a/t/as/ref-rel.kmm b/t/as/ref-rel.kmm new file mode 100644 index 0000000..904ec4e --- /dev/null +++ b/t/as/ref-rel.kmm @@ -0,0 +1,4 @@ +{relative references} +^a ^a ^a ^a :a ; ^a ^a ^a ^a +{-8<-} +#04030201 #00fffefd diff --git a/t/t.sh b/t/t.sh new file mode 100755 index 0000000..76a67ed --- /dev/null +++ b/t/t.sh @@ -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" diff --git a/t/u.c b/t/u.c deleted file mode 100644 index 13c35f6..0000000 --- a/t/u.c +++ /dev/null @@ -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(); -}