diff options
| author | kre <kre@NetBSD.org> | 2017-06-02 01:50:48 +0000 |
|---|---|---|
| committer | kre <kre@NetBSD.org> | 2017-06-02 01:50:48 +0000 |
| commit | 6d5af52ef90ca5969edc6c0eaeef8ee218e4e2ec (patch) | |
| tree | b5397fa2b248d6ac1148300ea544687aebeff08c /tests/bin | |
| parent | 7fe376f2d496c8903b5016dc9af49d4adae9d672 (diff) | |
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 (limited to 'tests/bin')
| -rw-r--r-- | tests/bin/sh/t_arith.sh | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/bin/sh/t_arith.sh b/tests/bin/sh/t_arith.sh index fbf5585dfe6..63d08f52476 100644 --- a/tests/bin/sh/t_arith.sh +++ b/tests/bin/sh/t_arith.sh @@ -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 @@ logical_or_body() '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_init_test_cases() { 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 |
