comparison test/recursion.tst @ 16030:1af8d21608b7

rename all test files in the test directory from test_X.m to X.tst * Use - instead of _ for .tst file names. Fix all file lists in module.mk and Makefile.am files. * __run_test_suite__.m: Adapt to new naming convention.
author John W. Eaton <jwe@octave.org>
date Sat, 09 Feb 2013 21:35:55 -0500
parents test/test_recursion.m@72c96de7a403
children b1283d4c06c2
comparison
equal deleted inserted replaced
16029:b8157404614f 16030:1af8d21608b7
1 ## Copyright (C) 2006-2012 John W. Eaton
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 %% test/octave.test/recursion/recursion-1.m
20 %!function y = f (x)
21 %! if (x == 1)
22 %! y = x;
23 %! return;
24 %! else
25 %! y = x * f (x-1);
26 %! endif
27 %!endfunction
28 %!
29 %!assert(f (5), 120);
30
31 %% test/octave.test/recursion/recursion-2.m
32 %!function y = f (x)
33 %! if (x == 1)
34 %! y = x;
35 %! return;
36 %! else
37 %! y = f (x-1) * x;
38 %! endif
39 %!endfunction
40 %!
41 %!assert(f (5), 120);
42
43 %%FIXME: Need test for maximum recursion depth