Thu Mar 31 16:19:52 2016 UTC ()
Don't confuse more capable shells by writing operator combinations
that could be interpreted as something different. That is, for our
shell +4++3 is just (+4)+(+3) and works fine. But others treat ++
as the increment operator.  Same for --. Sprinkle spaces to taste.
(from kre@)


(christos)
diff -r1.2 -r1.3 src/tests/bin/sh/t_arith.sh

cvs diff -r1.2 -r1.3 src/tests/bin/sh/t_arith.sh (expand / switch to unified diff)

--- src/tests/bin/sh/t_arith.sh 2016/03/16 17:39:12 1.2
+++ src/tests/bin/sh/t_arith.sh 2016/03/31 16:19:52 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: t_arith.sh,v 1.2 2016/03/16 17:39:12 christos Exp $ 1# $NetBSD: t_arith.sh,v 1.3 2016/03/31 16:19:52 christos Exp $
2# 2#
3# Copyright (c) 2016 The NetBSD Foundation, Inc. 3# Copyright (c) 2016 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# Redistribution and use in source and binary forms, with or without 6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions 7# modification, are permitted provided that the following conditions
8# are met: 8# are met:
9# 1. Redistributions of source code must retain the above copyright 9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer. 10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright 11# 2. Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the 12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution. 13# documentation and/or other materials provided with the distribution.
14# 14#
@@ -270,29 +270,29 @@ elementary_add_body() @@ -270,29 +270,29 @@ elementary_add_body()
270 atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ 270 atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \
271 'echo $(( 1 + 1 ))' 271 'echo $(( 1 + 1 ))'
272 atf_check -s exit:0 -o inline:'10\n' -e empty ${TEST_SH} -c \ 272 atf_check -s exit:0 -o inline:'10\n' -e empty ${TEST_SH} -c \
273 'echo $(( 4 + 6 ))' 273 'echo $(( 4 + 6 ))'
274 atf_check -s exit:0 -o inline:'10\n' -e empty ${TEST_SH} -c \ 274 atf_check -s exit:0 -o inline:'10\n' -e empty ${TEST_SH} -c \
275 'echo $(( 6 + 4 ))' 275 'echo $(( 6 + 4 ))'
276 atf_check -s exit:0 -o inline:'5555\n' -e empty ${TEST_SH} -c \ 276 atf_check -s exit:0 -o inline:'5555\n' -e empty ${TEST_SH} -c \
277 'echo $(( 1234 + 4321 ))' 277 'echo $(( 1234 + 4321 ))'
278 atf_check -s exit:0 -o inline:'3333\n' -e empty ${TEST_SH} -c \ 278 atf_check -s exit:0 -o inline:'3333\n' -e empty ${TEST_SH} -c \
279 'echo $((1111+2222))' 279 'echo $((1111+2222))'
280 atf_check -s exit:0 -o inline:'5555\n' -e empty ${TEST_SH} -c \ 280 atf_check -s exit:0 -o inline:'5555\n' -e empty ${TEST_SH} -c \
281 'echo $((+3333+2222))' 281 'echo $((+3333+2222))'
282 atf_check -s exit:0 -o inline:'7777\n' -e empty ${TEST_SH} -c \ 282 atf_check -s exit:0 -o inline:'7777\n' -e empty ${TEST_SH} -c \
283 'echo $((+3333++4444))' 283 'echo $((+3333 + +4444))'
284 atf_check -s exit:0 -o inline:'-7777\n' -e empty ${TEST_SH} -c \ 284 atf_check -s exit:0 -o inline:'-7777\n' -e empty ${TEST_SH} -c \
285 'echo -$((+4125++3652))' 285 'echo -$((+4125+ +3652))'
286} 286}
287 287
288atf_test_case elementary_sub 288atf_test_case elementary_sub
289elementary_sub_head() 289elementary_sub_head()
290{ 290{
291 atf_set "descr" "Tests that simple subtraction works as expected" 291 atf_set "descr" "Tests that simple subtraction works as expected"
292} 292}
293elementary_sub_body() 293elementary_sub_body()
294{ 294{
295 atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ 295 atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \
296 'echo $(( 0 - 0 ))' 296 'echo $(( 0 - 0 ))'
297 atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ 297 atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \
298 'echo $(( 1 - 0 ))' 298 'echo $(( 1 - 0 ))'
@@ -301,27 +301,27 @@ elementary_sub_body() @@ -301,27 +301,27 @@ elementary_sub_body()
301 atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ 301 atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \
302 'echo $(( 0 - 1 ))' 302 'echo $(( 0 - 1 ))'
303 atf_check -s exit:0 -o inline:'488\n' -e empty ${TEST_SH} -c \ 303 atf_check -s exit:0 -o inline:'488\n' -e empty ${TEST_SH} -c \
304 'echo $(( 1066 - 578 ))' 304 'echo $(( 1066 - 578 ))'
305 atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \ 305 atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \
306 'echo $(( 2016-5678 ))' 306 'echo $(( 2016-5678 ))'
307 atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \ 307 atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \
308 'echo $(( 2016+-5678 ))' 308 'echo $(( 2016+-5678 ))'
309 atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \ 309 atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \
310 'echo $(( 2016-+5678 ))' 310 'echo $(( 2016-+5678 ))'
311 atf_check -s exit:0 -o inline:'-7694\n' -e empty ${TEST_SH} -c \ 311 atf_check -s exit:0 -o inline:'-7694\n' -e empty ${TEST_SH} -c \
312 'echo $(( -2016-5678 ))' 312 'echo $(( -2016-5678 ))'
313 atf_check -s exit:0 -o inline:'--1\n' -e empty ${TEST_SH} -c \ 313 atf_check -s exit:0 -o inline:'--1\n' -e empty ${TEST_SH} -c \
314 'echo -$(( -1018--1017 ))' 314 'echo -$(( -1018 - -1017 ))'
315} 315}
316 316
317atf_test_case elementary_mul 317atf_test_case elementary_mul
318elementary_mul_head() 318elementary_mul_head()
319{ 319{
320 atf_set "descr" "Tests that simple multiplication works as expected" 320 atf_set "descr" "Tests that simple multiplication works as expected"
321} 321}
322elementary_mul_body() 322elementary_mul_body()
323{ 323{
324 atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ 324 atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \
325 'echo $(( 0 * 0 ))' 325 'echo $(( 0 * 0 ))'
326 atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ 326 atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \
327 'echo $(( 1 * 0 ))' 327 'echo $(( 1 * 0 ))'