diff --git a/t/Makefile.am b/t/Makefile.am index f3ac5bc..602f20c 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -16,14 +16,6 @@ check_ERRORS = \ do-5001.err \ do-5002.err \ feed-5001.err \ - feed-5002.err \ - feed-5003.err \ - feed-5004.err \ - feed-5005.err \ - feed-5006.err \ - feed-5007.err \ - feed-5008.err \ - feed-5009.err \ mlist-5001.err \ var-5001.err \ var-5002.err \ diff --git a/t/Makefile.in b/t/Makefile.in index 9145492..a1e844f 100644 --- a/t/Makefile.in +++ b/t/Makefile.in @@ -487,14 +487,6 @@ check_ERRORS = \ do-5001.err \ do-5002.err \ feed-5001.err \ - feed-5002.err \ - feed-5003.err \ - feed-5004.err \ - feed-5005.err \ - feed-5006.err \ - feed-5007.err \ - feed-5008.err \ - feed-5009.err \ mlist-5001.err \ var-5001.err \ var-5002.err \ diff --git a/t/err.sh b/t/err.sh index 23b1a34..951d51c 100644 --- a/t/err.sh +++ b/t/err.sh @@ -3,22 +3,73 @@ for i in $@; do :; done script="$i" -expected_errinfo=$(grep -n -o -E "##ERROR: .+" "$script" 2>/dev/null) -[ -z "$expected_errinfo" ] && { - echo "INVALID TESTER - $script contains no ERROR information" - exit 1 +run_partfile() { + l_cmd=""; + l_nargs=$# + + while [ $# -gt 3 ] + do + l_cmd="$l_cmd $1" + shift + done + + l_script="$1" + shift ## skip the original script. + l_partno="$1" + shift ## partno + + l_partfile="$1" + l_cmd="$l_cmd $l_partfile" + + l_expected_errinfo=$(grep -n -o -E "##ERROR: .+" "$l_partfile" 2>/dev/null) + [ -z "$l_expected_errinfo" ] && { + echo "ERROR: INVALID TESTER - $l_script($l_partno) contains no ERROR information" + return 1 + } + + l_expected_errline=$(echo $l_expected_errinfo | cut -d: -f1) + l_xlen=$(echo $l_expected_errline | wc -c) + l_xlen=$(expr $l_xlen + 10) + l_expected_errmsg=$(echo $l_expected_errinfo | cut -c${l_xlen}-) + l_output=`$l_cmd 2>&1` + ## the regular expression is not escaped properly. the error information must not + ## include specifial regex characters to avoid problems. + echo "$l_output" | grep -E "ERROR:.+${l_partfile}\[${l_expected_errline},[[:digit:]]+\] ${l_expected_errmsg}" >/dev/null 2>&1 || { + echo "ERROR: error not raised - $l_script($l_partno) - $l_output" + return 1 + } + + echo "OK" + return 0 } -expected_errline=$(echo $expected_errinfo | cut -d: -f1) -xlen=$(echo $expected_errline | wc -c) -xlen=$(expr $xlen + 10) -expected_errmsg=$(echo $expected_errinfo | cut -c${xlen}-) -output=$($@ 2>&1) -## the regular expression is not escaped properly. the error information must not -## include specifial regex characters to avoid problems. -echo "$output" | grep -E "ERROR:.+${script}\[${expected_errline},[[:digit:]]+\] ${expected_errmsg}" || { - echo "$script - $output" - exit 1 +ever_failed=0 +partfile=`mktemp` +partno=0 +partlines=0 +> "$partfile" + +## TODO: don't use while read line.. +while IFS= read -r line +do + if [ "$line" = "---" ] + then + [ $partlines -gt 0 ] && { + run_partfile "$@" "$partno" "$partfile" || ever_failed=1 + } + partno=`expr $partno + 1` + partlines=0 + > "$partfile" + else + echo "$line" >> "$partfile" + partlines=`expr $partlines + 1` + fi +done < "$script" + +[ $partlines -gt 0 ] && { + run_partfile "$@" "$partno" "$partfile" || ever_failed=1 } -exit 0 + +rm -f "$partfile" +exit $ever_failed diff --git a/t/feed-5001.err b/t/feed-5001.err index b8c4a56..071df03 100644 --- a/t/feed-5001.err +++ b/t/feed-5001.err @@ -1,2 +1,69 @@ ## you can't have another colon before the method.. (obj: :method) ##ERROR: syntax error - : disallowed + +--- + +## while EOL is ignored in explicitly parenthesized XLIST, a semicolon must not be. +(printf + "hello, world\n" +) + +(printf; ##ERROR: syntax error - unexpected semicolon + "hello, world\n" +) + +--- + +## semicolon inside #{} must raise a syntax error + +a := #{ + "k1": + "hello k1\n", + "k2": + "hello k2\n"; ##ERROR: syntax error - unexpected semicolon +}; + +--- + +{ + ;;; + +(do + (printf "hello\n") + (printf "hello\n") +);; + +k := [10 ; 20 ]; ##ERROR: syntax error - unexpected semicolon + +} + +--- + +## a code point greater than 255 is illegal in the character literal prefix fixed with b. + +printf "[%c] [#x%x] [%d]\n" '★' '★' #x2605; +printf "[%c]\n" b'★'; ##ERROR: syntax error - wrong character literal + +--- + +## #b can be followed by [ or binary digits. + +printf "%O\n" #b[ 10 20 30 ]; +printf "%010b\n" #b0101; +printf "%O\n" #bxy; ##ERROR: syntax error - neither valid radixed number nor valid directive #bxy + +--- + +printf :*; ##ERROR: syntax error - prohibited in this context + +--- + +defun :: fun1() { ##ERROR: syntax error - function name not symbol in defun + return 10; +}; + +--- + +defun :* fun1() { ##ERROR: syntax error - function name not symbol in defun + return 10; +}; diff --git a/t/feed-5002.err b/t/feed-5002.err deleted file mode 100644 index 20f5ca7..0000000 --- a/t/feed-5002.err +++ /dev/null @@ -1,8 +0,0 @@ -## while EOL is ignored in explicitly parenthesized XLIST, a semicolon must not be. -(printf - "hello, world\n" -) - -(printf; ##ERROR: syntax error - unexpected semicolon - "hello, world\n" -) diff --git a/t/feed-5003.err b/t/feed-5003.err deleted file mode 100644 index b80eaf3..0000000 --- a/t/feed-5003.err +++ /dev/null @@ -1,9 +0,0 @@ -## semicolon inside #{} must raise a syntax error - -a := #{ - "k1": - "hello k1\n", - "k2": - "hello k2\n"; ##ERROR: syntax error - unexpected semicolon -}; - diff --git a/t/feed-5004.err b/t/feed-5004.err deleted file mode 100644 index 348825b..0000000 --- a/t/feed-5004.err +++ /dev/null @@ -1,11 +0,0 @@ -{ - ;;; - -(do - (printf "hello\n") - (printf "hello\n") -);; - -k := [10 ; 20 ]; ##ERROR: syntax error - unexpected semicolon - -} diff --git a/t/feed-5005.err b/t/feed-5005.err deleted file mode 100644 index 85ec90f..0000000 --- a/t/feed-5005.err +++ /dev/null @@ -1,4 +0,0 @@ -## a code point greater than 255 is illegal in the character literal prefix fixed with b. - -printf "[%c] [#x%x] [%d]\n" '★' '★' #x2605; -printf "[%c]\n" b'★'; ##ERROR: syntax error - wrong character literal diff --git a/t/feed-5006.err b/t/feed-5006.err deleted file mode 100644 index e173b86..0000000 --- a/t/feed-5006.err +++ /dev/null @@ -1,6 +0,0 @@ -## #b can be followed by [ or binary digits. - -printf "%O\n" #b[ 10 20 30 ]; -printf "%010b\n" #b0101; -printf "%O\n" #bxy; ##ERROR: syntax error - neither valid radixed number nor valid directive #bxy - diff --git a/t/feed-5007.err b/t/feed-5007.err deleted file mode 100644 index 7d5dfe6..0000000 --- a/t/feed-5007.err +++ /dev/null @@ -1 +0,0 @@ -printf :*; ##ERROR: syntax error - prohibited in this context diff --git a/t/feed-5008.err b/t/feed-5008.err deleted file mode 100644 index 7070959..0000000 --- a/t/feed-5008.err +++ /dev/null @@ -1,3 +0,0 @@ -defun :: fun1() { ##ERROR: syntax error - function name not symbol in defun - return 10; -}; diff --git a/t/feed-5009.err b/t/feed-5009.err deleted file mode 100644 index b745f7e..0000000 --- a/t/feed-5009.err +++ /dev/null @@ -1,3 +0,0 @@ -defun :* fun1() { ##ERROR: syntax error - function name not symbol in defun - return 10; -}; diff --git a/t/insta-02.hcl b/t/insta-02.hcl index e25b362..f2a0594 100644 --- a/t/insta-02.hcl +++ b/t/insta-02.hcl @@ -1,6 +1,6 @@ set t ( class | x | { - defun :* make() { set x 1234; return self; }; + defun :* make() { x := 1234; return self; }; defun get-x() { return x }; } ); @@ -16,11 +16,11 @@ if (nqv? t 1234) { printf "ERROR: t must be 1234\n" } \ else { printf "OK: t is %d\n" t }; -set j #{ ((X:make):get-x): 9999, 4512: ((X: make): get-x) }; -set v (dic.get j 1234); +j := #{ ((X:make):get-x): 9999, 4512: ((X: make): get-x) }; +v := (dic.get j 1234); if (nqv? v 9999) { printf "ERROR: v is not 9999\n" } \ else { printf "OK: value is %d\n" v }; -set v (dic.get j 4512); +v := (dic.get j 4512); if (nqv? v 1234) { printf "ERROR: v is not 1234\n" } \ else { printf "OK: value is %d\n" v };