Mercurial > octave-nkf
annotate test/build_bc_overload_tests.sh @ 10090:655ab6f6c369
add tests for built-in class overloads
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 13 Jan 2010 08:44:24 +0100 |
parents | |
children | ffc5426c85a4 |
rev | line source |
---|---|
10090
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
1 #!/bin/sh |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
2 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
3 # Copyright (C) 2010 VZLU Prague |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
4 # |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
5 # This file is part of Octave. |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 # |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
7 # Octave is free software; you can redistribute it and/or modify it |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
8 # under the terms of the GNU General Public License as published by the |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
9 # Free Software Foundation; either version 3 of the License, or (at |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
10 # your option) any later version. |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 # |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
12 # Octave is distributed in the hope that it will be useful, but WITHOUT |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
15 # for more details. |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
16 # |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU General Public License |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 # along with Octave; see the file COPYING. If not, see |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
19 # <http://www.gnu.org/licenses/>. |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
20 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
21 CLASSES="double single char logical int8 int16 int32 int64 \ |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
22 uint8 uint16 uint32 uint64 struct cell function_handle" |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
23 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
24 for class in $CLASSES ; do |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
25 DIR=\@$class |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
26 test -d $DIR || mkdir $DIR || { echo "error: could not create $DIR" ; exit ; } |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
27 cat > $DIR/tbcover.m <<end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
28 % DO NOT EDIT - generated automatically |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
29 function s = tbcover (x, y) |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
30 s = '$class'; |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
31 end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
32 done |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
33 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 cat > tbcover.m <<end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
35 % DO NOT EDIT - generated automatically |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
36 function s = tbcover (x, y) |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
37 s = 'none'; |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
38 end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
39 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
40 if test "$1" == "overloads_only" ; then |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
41 exit |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
42 fi |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
43 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
44 cat > test_bc_overloads.m <<end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
45 ## THIS IS AN AUTOMATICALLY GENERATED FILE --- DO NOT EDIT --- |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
46 ## instead modify build_bc_overload_tests.sh to generate the tests that you want. |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
47 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
48 %!shared ex |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
49 %! ex.double = 1; |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
50 %! ex.single = single(1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
51 %! ex.logical = true; |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
52 %! ex.char = 'char'; |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
53 %! ex.int8 = int8 (1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
54 %! ex.int16 = int16 (1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
55 %! ex.int32 = int32 (1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
56 %! ex.int64 = int64 (1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
57 %! ex.uint8 = uint8 (1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
58 %! ex.uint16 = uint16 (1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
59 %! ex.uint32 = uint32 (1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
60 %! ex.uint64 = uint64 (1); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
61 %! ex.cell = {}; |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
62 %! ex.struct = struct (); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
63 %! ex.function_handle = @numel; |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
64 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
65 end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
66 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
67 cat bc_overloads_expected |\ |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
68 while read cl1 cl2 clr ; do |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
69 cat >> test_bc_overloads.m <<end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
70 %% Name call |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
71 %!assert (tbcover (ex.$cl1, ex.$cl2), "$clr") |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
72 %% Handle call |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
73 %!assert ((@tbcover) (ex.$cl1, ex.$cl2), "$clr") |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
74 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
75 end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
76 done |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
77 |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
78 cat >> test_bc_overloads.m <<end |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
79 %%test handles through cellfun |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
80 %!test |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
81 %! f = fieldnames (ex); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
82 %! n = numel (f); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
83 %! s = c1 = c2 = cell (n); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
84 %! for i = 1:n |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
85 %! for j = 1:n |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
86 %! c1{i,j} = ex.(f{i}); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
87 %! c2{i,j} = ex.(f{j}); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
88 %! s{i,j} = tbcover (ex.(f{i}), ex.(f{j})); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
89 %! endfor |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
90 %! endfor |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
91 %! assert (cellfun (@tbcover, c1, c2, "uniformoutput", false), s); |
655ab6f6c369
add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
92 end |