annotate test/build_bc_overload_tests.sh @ 11523:fd0a3ac60b0e

update copyright notices
author John W. Eaton <jwe@octave.org>
date Fri, 14 Jan 2011 05:47:45 -0500
parents 462fa695a565
children c3309e1ec50d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
1 #! /bin/sh
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
2
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10097
diff changeset
3 # Copyright (C) 2010-2011 VZLU Prague
10090
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
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
21 CLASSES="
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
22 double
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
23 single
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
24 char
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
25 logical
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
26 int8
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
27 int16
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
28 int32
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
29 int64
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
30 uint8
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
31 uint16
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
32 uint32
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
33 uint64
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
34 struct
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
35 cell
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
36 function_handle
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
37 "
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
39 if [ $# -eq 1 ]; then
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
40 expected_results_file="$1"
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
41 else
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
42 echo "usage: build_bc_overload_tests.sh expected-results-file" 1>&2
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
43 exit 1
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
44 fi
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
45
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
46 for class in $CLASSES; do
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
47 DIR="@$class"
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
48 test -d $DIR || mkdir $DIR || { echo "error: could not create $DIR"; exit; }
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
49 cat > $DIR/tbcover.m << EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50 % DO NOT EDIT - generated automatically
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
51 function s = tbcover (x, y)
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 s = '$class';
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
53 EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 done
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
56 cat > tbcover.m << EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57 % DO NOT EDIT - generated automatically
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
58 function s = tbcover (x, y)
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
59 s = 'none';
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
60 EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
61
10097
462fa695a565 Correct sh test syntax in build_bc_overload_tests.sh
Rik <rdrider0-list@yahoo.com>
parents: 10096
diff changeset
62 if test "$1" = "overloads_only" ; then
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
63 exit
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
64 fi
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
65
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
66 cat > test_bc_overloads.m << EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
67 ## 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
68 ## 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
69
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
70 %!shared ex
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
71 %! ex.double = 1;
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
72 %! ex.single = single(1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
73 %! ex.logical = true;
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
74 %! ex.char = 'char';
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
75 %! ex.int8 = int8 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
76 %! ex.int16 = int16 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
77 %! ex.int32 = int32 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
78 %! ex.int64 = int64 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
79 %! ex.uint8 = uint8 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
80 %! ex.uint16 = uint16 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
81 %! ex.uint32 = uint32 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
82 %! ex.uint64 = uint64 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
83 %! ex.cell = {};
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
84 %! ex.struct = struct ();
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
85 %! ex.function_handle = @numel;
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
86
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
87 EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
88
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
89 cat $expected_results_file | \
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
90 while read cl1 cl2 clr ; do
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
91 cat >> test_bc_overloads.m << EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
92 %% Name call
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
93 %!assert (tbcover (ex.$cl1, ex.$cl2), "$clr")
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
94 %% Handle call
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
95 %!assert ((@tbcover) (ex.$cl1, ex.$cl2), "$clr")
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
96
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
97 EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
98 done
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
99
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
100 cat >> test_bc_overloads.m << EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
101 %%test handles through cellfun
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
102 %!test
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
103 %! f = fieldnames (ex);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
104 %! n = numel (f);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
105 %! s = c1 = c2 = cell (n);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
106 %! for i = 1:n
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
107 %! for j = 1:n
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
108 %! c1{i,j} = ex.(f{i});
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
109 %! c2{i,j} = ex.(f{j});
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
110 %! 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
111 %! endfor
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
112 %! endfor
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
113 %! assert (cellfun (@tbcover, c1, c2, "uniformoutput", false), s);
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
114 EOF