Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/bin/sh Add a new test case "nested_arith" (that is, th...



details:   https://anonhg.NetBSD.org/src/rev/0148f75328e1
branches:  trunk
changeset: 824339:0148f75328e1
user:      kre <kre%NetBSD.org@localhost>
date:      Fri Jun 02 01:50:48 2017 +0000

description:
Add a new test case "nested_arith" (that is, things like $(( 1 + $(( 2 )) ))
which will currently fail (some of the sub-tests, but this one stops on
first failure, so the test simply fails.)  This will be corrected later today.

diffstat:

 tests/bin/sh/t_arith.sh |  27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diffs (48 lines):

diff -r 9e7b43bd91cd -r 0148f75328e1 tests/bin/sh/t_arith.sh
--- a/tests/bin/sh/t_arith.sh   Fri Jun 02 01:48:13 2017 +0000
+++ b/tests/bin/sh/t_arith.sh   Fri Jun 02 01:50:48 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_arith.sh,v 1.6 2017/03/20 11:32:51 kre Exp $
+# $NetBSD: t_arith.sh,v 1.7 2017/06/02 01:50:48 kre Exp $
 #
 # Copyright (c) 2016 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -818,6 +818,30 @@
                'echo $(( 0x33 || 0xF0F0 ))'
 }
 
+atf_test_case nested_arith
+nested_arith_head()
+{
+       atf_set "descr" 'Test nested arithmetic $(( $(( )) ))'
+}
+nested_arith_body()
+{
+       atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \
+               'echo $(( $(( 0 )) ))'
+       atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \
+               'echo $(( 1 + $(( 2 - 2 )) ))'
+       atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \
+               'echo $(( $(( 3 / 3 )) + $((1*1*1)) - $(( 7 % 6 ))))'
+       atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \
+               'echo $(($(($(($(($((1))))))))))'
+
+       atf_check -s exit:0 -o inline:'246\n' -e empty ${TEST_SH} -c \
+               'echo $(( 2$((2 * 2))6 ))'
+       atf_check -s exit:0 -o inline:'291117\n' -e empty ${TEST_SH} -c \
+               'echo $(( $((1 + 1))$((3 * 3))$(( 99-88 ))$(( 17))))'
+       atf_check -s exit:0 -o inline:'123456789\n' -e empty ${TEST_SH} -c \
+         'echo $(( 1$((2$((1+2))4$((2 + 2 + 1))6))7$((4 * 2))$(($((81/9))))))'
+}
+
 atf_test_case make_selection
 make_selection_head()
 {
@@ -1082,6 +1106,7 @@
        atf_add_test_case logical_and
        atf_add_test_case logical_or
        atf_add_test_case make_selection
+       atf_add_test_case nested_arith
        atf_add_test_case operator_precedence
        atf_add_test_case parentheses
        # atf_add_test_case progressive                 # build up big expr



Home | Main Index | Thread Index | Old Index