From 3dd49d281145d457bf8fa834418c2a7ff38250bd Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 11 Apr 2022 21:22:18 -0700 Subject: @let: tests for variable clearing. * test/let1.awk: Add tests confirming that let variables without initializers are set to the correct initial value that makes them appear unassigned. --- test/let1.awk | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/let1.awk b/test/let1.awk index c7e98468..94a1a681 100644 --- a/test/let1.awk +++ b/test/let1.awk @@ -37,3 +37,36 @@ BEGIN { @let (x = x + 1, x = x + 1) print "b3", l3 "-" x } + +# test clearing uninitialized variables + +function f4() +{ + @let (i) for (i = 0; i < 2; i++) { + @let (a, b, c) { + if (a != 0 || a != "") + exit 1 + if (b != 0 || b != "") + exit 1 + if (c != 0 || c != "") + exit 1 + a = b = c = 1 + } + } +} + +BEGIN { f4() } + +BEGIN { + @let (i) for (i = 0; i < 2; i++) { + @let (a, b, c) { + if (a != 0 || a != "") + exit 1 + if (b != 0 || b != "") + exit 1 + if (c != 0 || c != "") + exit 1 + a = b = c = 1 + } + } +} -- cgit v1.2.3