shithub: mc

ref: cc563f86c280dfe8ced50f804fed9b8ac607db0f
dir: /test/runtest.rc/

View raw version
#!/bin/rc

rfork e
MYR_MC=../6/6.out
MYR_MUSE=../muse/6.out
fn build {
	rm -f $1 $1^.6 $1^.use
	../obj/mbld/mbld -Bnone -o 'out' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.6 $1^.myr
}

fn pass {
	echo '!}>> ok'
}

fn fail {
	echo '!}>> fail '
}

fn expectstatus {
	st='*'^$2
	if(~ $2 0)
		st=''''''
	./out/$1 $3
	if(eval '~ $status '$st)
		pass $1
	if not
		fail $1
}

fn expectprint {
	ifs='
'
	if(~ `{./out/$1 $3} $2)
		pass $1
	if not
		fail $1
}

fn expectcmp {
	t=/tmp/myrtest-^$1
	rm -f $t
	./out/$1 $3 > $t
	if (cmp $t data/$1-expected)
		pass $1
	if not
		fail $1
}

fn expectfcmp {
	t=/tmp/myrtest-^$1
	rm -f $t
	./out/$1 $3
	if (cmp $2 data/$1-expected)
		pass $1
	if not
		fail $1
}

fn B {
	test=$1; shift
	type=$1; shift
	res=$1; shift

	echo 'test' $test '<<{!'
	build $test
	switch($type) {
	case E
		expectstatus $test $res
	case P
		expectprint $test $res
	case C
		expectcmp $test $res
	case F
		expectfcmp $test $res
	}
}

fn F {
	echo 'test ' ^ $1 '<<{!'
	@{ build $1 } >[2=1]
	if (~ $status '')
		fail $1
	if not
		pass $1
}

echo 'MTEST ' `{grep '^[BF]' tests | wc -l}

. tests