Skip to content

tests: Parenthesize concatenations to avoid ambiguity

Currently, tests fail for mawk, which is the default implementation of AWK in Debian and its derivatives. Indeed, POSIX leaves the behavior of unparenthesized operators in expression | getline unspecified and strongly recommends parenthesizing to avoid ambiguity:

The getline operator can form ambiguous constructs when there are unparenthesized operators (including concatenate) to the left of the '|' (to the beginning of the expression containing getline). In the context of the '' operator, '|' shall behave as if it had a lower precedence than ''. The result of evaluating other operators is unspecified, and conforming applications shall parenthesize properly all such usages.

gawk allows constructs like "echo " string | getline var and concatenates the whole expression correctly. However, it's not the default implementation on many systems. Therefore, adding parentheses around the left expression allows for maximum portability and helps avoid ambiguity.

Testsuite summary after changes:

PASS: test-simple-expr.awk
PASS: test-minus.awk
PASS: test-modulo.awk
PASS: test-e-notation.awk
PASS: test-abs.awk
PASS: test-sqrt.awk
PASS: test-sqrt-minus-one.awk
PASS: test-hex.awk
PASS: test-cube-root.awk
PASS: test-log10.awk
PASS: test-log10-zero.awk
PASS: test-log10-negative.awk
PASS: test-log.awk
PASS: test-log2.awk
PASS: test-exp.awk
PASS: test-div-zero.awk
PASS: test-div-zero-negative.awk
PASS: test-div-zero-zero.awk
PASS: test-pi.awk
PASS: test-sin.awk
PASS: test-cos.awk
PASS: test-tan.awk
PASS: test-asin.awk
PASS: test-acos.awk
PASS: test-atan.awk
PASS: test-pow.awk
============================================================================
Testsuite summary for xfce4-calculator-plugin 0.7.1git-UNKNOWN
============================================================================
# TOTAL: 26
# PASS:  26
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================

Merge request reports