Mercurial > hg > octave-nkf
annotate test/test_eval-catch.m @ 13197:6db186dfdeaa
Refactor sprandn/sprand code, move common code to common function (bug #34352)
* __sprand_impl__.m: New file
* module.mk: Add new file
* sprand.m: Remove comment in docstring about inaccuracy of density.
Put sprandsym in @seealso. Refactor repeated code into
__sprand_impl__.m
* sprandn.m: Ditto. Also enable test for exact density.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Fri, 23 Sep 2011 02:40:05 -0500 |
parents | fd0a3ac60b0e |
children | c3309e1ec50d |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2006-2011 John W. Eaton |
7016 | 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 | |
5590 | 19 %% test/octave.test/eval-catch/eval-catch-1.m |
20 %!test | |
21 %! eval ("clear a; a;", ""); | |
22 | |
23 %% test/octave.test/eval-catch/eval-catch-2.m | |
24 %!test | |
25 %! eval ("", "error('Shouldn't get here');"); | |
26 | |
27 %% test/octave.test/eval-catch/eval-catch-3.m | |
28 %!test | |
29 %! eval ("clear a; a; x = 0;", "x = 1;"); | |
30 %! assert (x, 1); | |
31 | |
5775 | 32 %% FIXME This is redundant with the changes to the above |
5590 | 33 %% test/octave.test/eval-catch/eval-catch-4.m |
34 | |
35 %% test/octave.test/eval-catch/eval-catch-5.m | |
36 %!test | |
37 %! eval ("clear a; a; str = '';", "str=lasterr;"); | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
38 %! assert(lasterr()(1:13),"`a' undefined"); |
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
39 %! assert(str(1:13),"`a' undefined"); |
5590 | 40 |
41 %% test/octave.test/eval-catch/eval-catch-6.m | |
42 %!test | |
43 %! eval ("error (\"user-defined error\"); str = '';", "str = lasterr;"); | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
44 %! assert(lasterr()(1:18),"user-defined error"); |
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
45 %! assert(str(1:18),"user-defined error"); |
5590 | 46 |
47 %% test/octave.test/eval-catch/eval-catch-7.m | |
48 %!function ms = mangle (s) | |
49 %! ## Wrap angle brackets around S. | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
50 %! ms = cstrcat ("<", s, ">"); |
5590 | 51 %!test |
52 %! eval ("clear a; a; str='';", "str = mangle (lasterr);"); | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
53 %! assert(mangle(lasterr)(1:14),"<`a' undefined"); |
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
54 %! assert(str(1:14),"<`a' undefined"); |
5590 | 55 |
56 %% test/octave.test/eval-catch/eval-catch-8.m | |
57 %!test | |
58 %! eval ("eval (\"clear a; a;str1='';\", \"str1=lasterr;\"); clear b; b; str2='';", | |
59 %! "str2 = lasterr;"); | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
60 %! assert(str1(1:13),"`a' undefined"); |
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
61 %! assert(str2(1:13),"`b' undefined"); |
5590 | 62 |
63 %% test/octave.test/eval-catch/eval-catch-9.m | |
64 %!test | |
65 %! eval ("clear a; a; str1='';", | |
66 %! "eval (\"clear b; b; str2='';\", \"str2=lasterr;\"); str1=lasterr;"); | |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
67 %! assert(str1(1:13),"`b' undefined"); |
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
68 %! assert(str2(1:13),"`b' undefined"); |
5590 | 69 |
70 %% test/octave.test/eval-catch/eval-catch-10.m | |
71 %!test | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
72 %! eval ("eval (\"clear a; a; str='';\",\"error (cstrcat (\\\"rethrow: \\\", lasterr));str='';\");", |
5590 | 73 %! "str=lasterr;"); |
7883
3092dd54ad95
fix expected output from lasterr in tests; fix fail tests in ismember.m
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
74 %! assert(str(1:22),"rethrow: `a' undefined"); |