aboutsummaryrefslogtreecommitdiff
path: root/shell/ash_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-06-16 19:43:53 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-06-16 19:51:01 +0200
commite1279858394a6079be6816cbedaa3f10e74057cc (patch)
tree7a7a032ea71978437c8888c9f508db1d4fdf4fe3 /shell/ash_test
parentf8263528cd44ac5dc95778556c6fd3feea14742e (diff)
downloadbusybox-w32-e1279858394a6079be6816cbedaa3f10e74057cc.tar.gz
busybox-w32-e1279858394a6079be6816cbedaa3f10e74057cc.tar.bz2
busybox-w32-e1279858394a6079be6816cbedaa3f10e74057cc.zip
shell/math: fix ?: to not evaluate not-taken branches
This fixes ash-arith-arith-ternary1/2.tests function old new delta evaluate_string 1271 1432 +161 arith_apply 968 1000 +32 arith 22 36 +14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 207/0) Total: 207 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test')
-rw-r--r--shell/ash_test/ash-arith/arith-ternary-assign.right1
-rwxr-xr-xshell/ash_test/ash-arith/arith-ternary-assign.tests3
-rw-r--r--shell/ash_test/ash-arith/arith-ternary-comma.right1
-rwxr-xr-xshell/ash_test/ash-arith/arith-ternary-comma.tests3
-rw-r--r--shell/ash_test/ash-arith/arith-ternary-preincr.right1
-rwxr-xr-xshell/ash_test/ash-arith/arith-ternary-preincr.tests3
-rw-r--r--shell/ash_test/ash-arith/arith-ternary3.right1
-rwxr-xr-xshell/ash_test/ash-arith/arith-ternary3.tests4
-rw-r--r--shell/ash_test/ash-arith/arith-ternary_nested3.right2
-rwxr-xr-xshell/ash_test/ash-arith/arith-ternary_nested3.tests6
10 files changed, 25 insertions, 0 deletions
diff --git a/shell/ash_test/ash-arith/arith-ternary-assign.right b/shell/ash_test/ash-arith/arith-ternary-assign.right
new file mode 100644
index 000000000..6644d86bf
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary-assign.right
@@ -0,0 +1 @@
42:42
diff --git a/shell/ash_test/ash-arith/arith-ternary-assign.tests b/shell/ash_test/ash-arith/arith-ternary-assign.tests
new file mode 100755
index 000000000..fa18fe7b9
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary-assign.tests
@@ -0,0 +1,3 @@
1exec 2>&1
2a='@'
3echo 42:$((a=1?42:3,a))
diff --git a/shell/ash_test/ash-arith/arith-ternary-comma.right b/shell/ash_test/ash-arith/arith-ternary-comma.right
new file mode 100644
index 000000000..6644d86bf
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary-comma.right
@@ -0,0 +1 @@
42:42
diff --git a/shell/ash_test/ash-arith/arith-ternary-comma.tests b/shell/ash_test/ash-arith/arith-ternary-comma.tests
new file mode 100755
index 000000000..5e05b58c4
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary-comma.tests
@@ -0,0 +1,3 @@
1exec 2>&1
2x='@'
3echo 42:$((1?4:x,20*2+2))
diff --git a/shell/ash_test/ash-arith/arith-ternary-preincr.right b/shell/ash_test/ash-arith/arith-ternary-preincr.right
new file mode 100644
index 000000000..6644d86bf
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary-preincr.right
@@ -0,0 +1 @@
42:42
diff --git a/shell/ash_test/ash-arith/arith-ternary-preincr.tests b/shell/ash_test/ash-arith/arith-ternary-preincr.tests
new file mode 100755
index 000000000..3985c7079
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary-preincr.tests
@@ -0,0 +1,3 @@
1exec 2>&1
2x='@'
3echo 42:$((1?42:++x))
diff --git a/shell/ash_test/ash-arith/arith-ternary3.right b/shell/ash_test/ash-arith/arith-ternary3.right
new file mode 100644
index 000000000..6644d86bf
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary3.right
@@ -0,0 +1 @@
42:42
diff --git a/shell/ash_test/ash-arith/arith-ternary3.tests b/shell/ash_test/ash-arith/arith-ternary3.tests
new file mode 100755
index 000000000..0bf9f3002
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary3.tests
@@ -0,0 +1,4 @@
1exec 2>&1
2# "EXPR ?..." should check _evaluated_ EXPR,
3# not its last value
4echo 42:$((1 < 1 ? -1 : 1 > 1 ? 1 : 42))
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested3.right b/shell/ash_test/ash-arith/arith-ternary_nested3.right
new file mode 100644
index 000000000..1a34fde65
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary_nested3.right
@@ -0,0 +1,2 @@
142:42
2a=2:2
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested3.tests b/shell/ash_test/ash-arith/arith-ternary_nested3.tests
new file mode 100755
index 000000000..b69dcc6e9
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary_nested3.tests
@@ -0,0 +1,6 @@
1exec 2>&1
2x='@'
3a=2
4# After processing nested ?:, outermost ?: should still rememeber to NOT evaluate a*=2
5echo 42:$((1?0?41:42:(a*=2)))
6echo "a=2:$a"