diff --git a/lib/comp.c b/lib/comp.c index da06681..fcb3819 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -2311,7 +2311,7 @@ static int compile_if (hcl_t* hcl, hcl_cnode_t* src) if (!obj) { /* no value */ - hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(src), HCL_NULL, "no conditional expression after %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); + hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(src), HCL_NULL, "no conditional expression after '%.*js'", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); return -1; } else if (!HCL_CNODE_IS_CONS(obj)) @@ -2412,7 +2412,7 @@ static HCL_INLINE int compile_elif (hcl_t* hcl) if (!obj) { /* no value */ - hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(src), HCL_NULL, "no conditional expression after %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); + hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(src), HCL_NULL, "no conditional expression after '%.*js'", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); return -1; } else if (!HCL_CNODE_IS_CONS(obj)) diff --git a/t/call-5001.err b/t/call-5001.err index 308d0a0..61d5ddf 100644 --- a/t/call-5001.err +++ b/t/call-5001.err @@ -15,7 +15,7 @@ while(i < 20) { --- -if ##ERROR: syntax error - no conditional expression after if +if ##ERROR: syntax error - no conditional expression after 'if' --- diff --git a/t/err.sh b/t/err.sh index 4cfbc70..9a77222 100644 --- a/t/err.sh +++ b/t/err.sh @@ -27,14 +27,19 @@ run_partfile() { return 1 } - l_expected_errline=$(echo $l_expected_errinfo | cut -d: -f1) - l_xlen=$(echo $l_expected_errline | wc -c) + 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_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 || { + + ## the checks using grep may not be 100% accurate depending on message patterns. + ## but it's unlikely such a case really happens + echo "$l_output" | grep -q -E "^ERROR:.+${l_partfile}\[${l_expected_errline},[[:digit:]]+\] .+" 2>&1 || { + echo "ERROR: error not raised at line $l_expected_errline - $l_script($l_partno) - $l_output" + return 1 + } + echo "$l_output" | grep -q -F " ${l_expected_errmsg}" 2>&1 || { echo "ERROR: error not raised at line $l_expected_errline - $l_script($l_partno) - $l_output" return 1 } diff --git a/t/var-5001.err b/t/var-5001.err index f3d40f6..7807475 100644 --- a/t/var-5001.err +++ b/t/var-5001.err @@ -49,5 +49,5 @@ class A [ a + ] { ##ERROR: syntax error - prohibited binary operator - + ## TODO: This check is supposed to fail. + must be treated as a binop symbol ##--- -##class A [ + ] { ##ERROR: syntax error - prohibited binary operator - + +##class A [ + ] { ## ERROR: syntax error - prohibited binary operator - + ##}