[PATCH] tests: add test for ternary precedence

Natanael Copa ncopa at alpinelinux.org
Tue May 21 12:48:32 UTC 2024


This tests a regression introduced by commit 0256e00a9d07 (awk: fix
precedence of = relative to ==).

Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
---
 testsuite/awk.tests | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/testsuite/awk.tests b/testsuite/awk.tests
index 063084a1c..a56232d02 100755
--- a/testsuite/awk.tests
+++ b/testsuite/awk.tests
@@ -552,6 +552,11 @@ testing "awk = has higher precedence than == (despite what gawk manpage claims)"
 	'0\n1\n2\n1\n3\n' \
 	'' ''
 
+testing 'awk ternary precedence' \
+	"awk 'BEGIN { a = 0 ? \"yes\": \"no\"; print a }'" \
+	'no\n' \
+	'' ''
+
 sq="'"
 testing 'awk gensub backslashes \' \
 	'awk '$sq'BEGIN { s="\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
-- 
2.45.1



More information about the busybox mailing list