Module Name:    src
Committed By:   kre
Date:           Fri Jun  2 01:50:48 UTC 2017

Modified Files:
        src/tests/bin/sh: t_arith.sh

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/bin/sh/t_arith.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/bin/sh/t_arith.sh
diff -u src/tests/bin/sh/t_arith.sh:1.6 src/tests/bin/sh/t_arith.sh:1.7
--- src/tests/bin/sh/t_arith.sh:1.6	Mon Mar 20 11:32:51 2017
+++ src/tests/bin/sh/t_arith.sh	Fri Jun  2 01:50:48 2017
@@ -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

Reply via email to