aboutsummaryrefslogtreecommitdiff
path: root/tests/value
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-12-14 14:18:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-12-14 14:18:44 +0200
commit0aa7a94e1032a96a2a72cb6a82824f9fe970d412 (patch)
tree412ab1e9da30c708b616ae6fda1663b8169fc55c /tests/value
parent218a739b33325c5dd6baa5cf6291dad849ad2441 (diff)
Improve empty simple value to empty list of names reduction heuristics
Specifically, do not reduce typed RHS empty simple values for prepend/append and additionally for assignment provided LHS is typed and is a container.
Diffstat (limited to 'tests/value')
-rw-r--r--tests/value/reverse.testscript55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/value/reverse.testscript b/tests/value/reverse.testscript
index 9f73981..921d14b 100644
--- a/tests/value/reverse.testscript
+++ b/tests/value/reverse.testscript
@@ -89,3 +89,58 @@
EOO
}
}
+
+: reduce
+:
+: Test empty simple value reduction heuristics.
+:
+{
+ : typed
+ :
+ $* <<EOI >>"EOO"
+ x = [string]
+ n = [string,null]
+ y = [strings] $x
+ y += $x
+ y += $n
+ print $size($y)
+
+ file{*}: y += $x
+ file{x}:
+ print $size($(file{x}: y))
+
+ for i: $x
+ print iteration
+
+ print $null($x[0])
+ EOI
+ 2
+ 3
+ iteration
+ false
+ EOO
+
+ : untyped
+ :
+ $* <<EOI >>"EOO"
+ x =
+ n = [null]
+ y = $x
+ y += $x
+ y += $n
+ print $size($y)
+
+ file{*}: y += $x
+ file{x}:
+ print $size($(file{x}: y))
+
+ for i: $x
+ print iteration
+
+ print $null($x[0])
+ EOI
+ 0
+ 0
+ true
+ EOO
+}