123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #!/bin/bash
- #shellcheck disable=SC1090
-
- . "$TF_DIR/include/subtest.sh"
- . "$TF_DIR/include/tools.sh"
-
- . "$(sfpath)" || tf_exit_error "failed to init shellfu"
- export PRETTY=plain
- shellfu import isa || tf_exit_error "failed to import isa"
-
-
- tf_enum_subtests() {
- local sut
- local ttype
- #
- # isa_
- #
- for sut in isa__bool isa__false isa__int isa__name isa__posint isa__true; do
- for ttype in ok empty none pfx sfx nota; do
- echo "${sut},$ttype"
- done
- done
- }
-
- mkfact() {
- #
- # Make artifact or oracle $what for $TestName
- #
- local what=$1
- case $TestName:$what in
-
- isa__bool,ok:arg) echo true ;;
- isa__bool,pfx:arg) echo xtrue ;;
- isa__bool,sfx:arg) echo truex ;;
- isa__bool,nota:arg) echo hello ;;
- isa__bool,tricky:arg) echo True ;;
- isa__bool,ok:o_es) echo 0 ;;
- isa__bool,*:o_es) echo 1 ;;
-
- isa__false,ok:arg) echo false ;;
- isa__false,pfx:arg) echo xfalse ;;
- isa__false,sfx:arg) echo falsex ;;
- isa__false,nota:arg) echo true ;;
- isa__false,tricky:arg) echo False ;;
- isa__false,ok:o_es) echo 0 ;;
- isa__false,*:o_es) echo 1 ;;
-
- isa__true,ok:arg) echo true ;;
- isa__true,pfx:arg) echo xtrue ;;
- isa__true,sfx:arg) echo truex ;;
- isa__true,nota:arg) echo True ;;
- isa__true,tricky:arg) echo 0 ;;
- isa__true,ok:o_es) echo 0 ;;
- isa__true,*:o_es) echo 1 ;;
-
- isa__int,ok:arg) echo 42 ;;
- isa__int,pfx:arg) echo x42 ;;
- isa__int,sfx:arg) echo 42x ;;
- isa__int,nota:arg) echo 22.2 ;;
- isa__int,tricky:arg) echo \ 42 ;;
- isa__int,ok:o_es) echo 0 ;;
- isa__int,*:o_es) echo 1 ;;
-
- isa__posint,ok:arg) echo 42 ;;
- isa__posint,pfx:arg) echo x42 ;;
- isa__posint,sfx:arg) echo 42x ;;
- isa__posint,nota:arg) echo -42 ;;
- isa__posint,tricky:arg) echo 42 + 55 ;;
- isa__posint,ok:o_es) echo 0 ;;
- isa__posint,*:o_es) echo 1 ;;
-
- isa__name,ok:arg) echo foo5az ;;
- isa__name,pfx:arg) echo .foo5az ;;
- isa__name,sfx:arg) echo foo5az/ ;;
- isa__name,nota:arg) echo 55zoos ;;
- isa__name,tricky:arg) echo foo bar ;;
- isa__name,ok:o_es) echo 0 ;;
- isa__name,*:o_es) echo 1 ;;
-
- esac
- }
-
- mkresult() {
- local sut
- local ttype
- local args=()
- ttype=${TestName##*,}
- sut=${TestName%,$ttype}
- type -t "$sut" >/dev/null || {
- tf_exit_error "no such function: $sut"
- }
- #shellcheck disable=SC2046
- case $ttype in
- none) : ;;
- empty) args=("") ;;
- more) args=(foo bar) ;;
- *) readarray -t args <<<"$(mkfact arg)" ;;
- esac
- "$sut" "${args[@]}"
- }
-
- tf_do_subtest() {
- local TestName=$1
- local o_es
- o_es=$(mkfact o_es)
- tf_testflt -n "$TestName" -S "$o_es" "mkresult"
- }
-
- tf_do_subtests
|