add packaging
[platform/upstream/m4.git] / checks / 073.shift
1 dnl @ ../doc/m4.texi:2978: Origin of test
2 dnl @ expected status: 0
3 dnl @ extra options: 
4 dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software
5 dnl @ Foundation, Inc.
6 dnl @ This file is free software; the Free Software Foundation
7 dnl @ gives unlimited permission to copy and/or distribute it
8 dnl @ with or without modifications, as long as this notice
9 dnl @ is preserved.
10 define(`cond',
11 `ifelse(`$#', `1', `$1',
12         `ifelse($1, `$2', `$3',
13                 `$0(shift(shift(shift($@))))')')')dnl
14 define(`side', `define(`counter', incr(counter))$1')dnl
15 define(`example1',
16 `define(`counter', `0')dnl
17 ifelse(side(`$1'), `yes', `one comparison: ',
18        side(`$1'), `no', `two comparisons: ',
19        side(`$1'), `maybe', `three comparisons: ',
20        `side(`default answer: ')')counter')dnl
21 define(`example2',
22 `define(`counter', `0')dnl
23 cond(`side(`$1')', `yes', `one comparison: ',
24      `side(`$1')', `no', `two comparisons: ',
25      `side(`$1')', `maybe', `three comparisons: ',
26      `side(`default answer: ')')counter')dnl
27 example1(`yes')
28 dnl @result{}one comparison: 3
29 example1(`no')
30 dnl @result{}two comparisons: 3
31 example1(`maybe')
32 dnl @result{}three comparisons: 3
33 example1(`feeling rather indecisive today')
34 dnl @result{}default answer: 4
35 example2(`yes')
36 dnl @result{}one comparison: 1
37 example2(`no')
38 dnl @result{}two comparisons: 2
39 example2(`maybe')
40 dnl @result{}three comparisons: 3
41 example2(`feeling rather indecisive today')
42 dnl @result{}default answer: 4