aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-04-11 21:22:18 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-04-11 21:22:18 -0700
commit3dd49d281145d457bf8fa834418c2a7ff38250bd (patch)
tree97bf9c847e20c342a261180caa958af851855314
parent97294a20f0121b5edd0e709375a5c18d013d258e (diff)
downloadegawk-3dd49d281145d457bf8fa834418c2a7ff38250bd.tar.gz
egawk-3dd49d281145d457bf8fa834418c2a7ff38250bd.tar.bz2
egawk-3dd49d281145d457bf8fa834418c2a7ff38250bd.zip
@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.
-rw-r--r--test/let1.awk33
1 files changed, 33 insertions, 0 deletions
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
+ }
+ }
+}