From 8ccb3f7b1375862f8ef82cd9d225da986b80f054 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 13 Jun 2023 15:17:14 +0200 Subject: shell: add a few yet-failing arithmentic tests Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-arith/arith-assign-in-varexp.right | 3 +++ shell/ash_test/ash-arith/arith-assign-in-varexp.tests | 8 ++++++++ shell/ash_test/ash-arith/arith-comma1.right | 3 +++ shell/ash_test/ash-arith/arith-comma1.tests | 6 ++++++ shell/ash_test/ash-arith/arith-precedence1.right | 1 + shell/ash_test/ash-arith/arith-precedence1.tests | 2 ++ shell/ash_test/ash-arith/arith-ternary1.right | 5 +++++ shell/ash_test/ash-arith/arith-ternary1.tests | 12 ++++++++++++ shell/ash_test/ash-arith/arith-ternary2.right | 1 + shell/ash_test/ash-arith/arith-ternary2.tests | 2 ++ 10 files changed, 43 insertions(+) create mode 100644 shell/ash_test/ash-arith/arith-assign-in-varexp.right create mode 100755 shell/ash_test/ash-arith/arith-assign-in-varexp.tests create mode 100644 shell/ash_test/ash-arith/arith-comma1.right create mode 100755 shell/ash_test/ash-arith/arith-comma1.tests create mode 100644 shell/ash_test/ash-arith/arith-precedence1.right create mode 100755 shell/ash_test/ash-arith/arith-precedence1.tests create mode 100644 shell/ash_test/ash-arith/arith-ternary1.right create mode 100755 shell/ash_test/ash-arith/arith-ternary1.tests create mode 100644 shell/ash_test/ash-arith/arith-ternary2.right create mode 100755 shell/ash_test/ash-arith/arith-ternary2.tests diff --git a/shell/ash_test/ash-arith/arith-assign-in-varexp.right b/shell/ash_test/ash-arith/arith-assign-in-varexp.right new file mode 100644 index 0000000..06ac80a --- /dev/null +++ b/shell/ash_test/ash-arith/arith-assign-in-varexp.right @@ -0,0 +1,3 @@ +20:20 +a=b=10 +b=10 diff --git a/shell/ash_test/ash-arith/arith-assign-in-varexp.tests b/shell/ash_test/ash-arith/arith-assign-in-varexp.tests new file mode 100755 index 0000000..920aaa7 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-assign-in-varexp.tests @@ -0,0 +1,8 @@ +exec 2>&1 +a='b=10' +b=3 +# The variables should evaluate left-to-right, +# thus b is set to 10 _before_ addition +echo 20:$((a + b)) +echo "a=$a" +echo "b=$b" diff --git a/shell/ash_test/ash-arith/arith-comma1.right b/shell/ash_test/ash-arith/arith-comma1.right new file mode 100644 index 0000000..be1264c --- /dev/null +++ b/shell/ash_test/ash-arith/arith-comma1.right @@ -0,0 +1,3 @@ +10:10 +a=b=10 +b=10 diff --git a/shell/ash_test/ash-arith/arith-comma1.tests b/shell/ash_test/ash-arith/arith-comma1.tests new file mode 100755 index 0000000..f863043 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-comma1.tests @@ -0,0 +1,6 @@ +exec 2>&1 +a='b=10' +b=3 +echo 10:$((a,b)) +echo "a=$a" +echo "b=$b" diff --git a/shell/ash_test/ash-arith/arith-precedence1.right b/shell/ash_test/ash-arith/arith-precedence1.right new file mode 100644 index 0000000..7f407b5 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-precedence1.right @@ -0,0 +1 @@ +4:4 diff --git a/shell/ash_test/ash-arith/arith-precedence1.tests b/shell/ash_test/ash-arith/arith-precedence1.tests new file mode 100755 index 0000000..964ae4e --- /dev/null +++ b/shell/ash_test/ash-arith/arith-precedence1.tests @@ -0,0 +1,2 @@ +exec 2>&1 +echo 4:"$((0 ? 1,2 : 3,4))" diff --git a/shell/ash_test/ash-arith/arith-ternary1.right b/shell/ash_test/ash-arith/arith-ternary1.right new file mode 100644 index 0000000..c968f11 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary1.right @@ -0,0 +1,5 @@ +42:42 +a=0 +6:6 +a=b=+err+ +b=6 diff --git a/shell/ash_test/ash-arith/arith-ternary1.tests b/shell/ash_test/ash-arith/arith-ternary1.tests new file mode 100755 index 0000000..5a54e34 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary1.tests @@ -0,0 +1,12 @@ +exec 2>&1 +a=0 +# The not-taken branch should not evaluate +echo 42:$((1 ? 42 : (a+=2))) +echo "a=$a" + +a='b=+err+' +b=5 +# The not-taken branch should not even parse variables +echo 6:$((0 ? a : ++b)) +echo "a=$a" +echo "b=$b" diff --git a/shell/ash_test/ash-arith/arith-ternary2.right b/shell/ash_test/ash-arith/arith-ternary2.right new file mode 100644 index 0000000..aa54bd9 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary2.right @@ -0,0 +1 @@ +5:5 diff --git a/shell/ash_test/ash-arith/arith-ternary2.tests b/shell/ash_test/ash-arith/arith-ternary2.tests new file mode 100755 index 0000000..eefc8e7 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary2.tests @@ -0,0 +1,2 @@ +exec 2>&1 +echo 5:$((1?2?3?4?5:6:7:8:9)) -- cgit v1.1