annotate test/build-bc-overload-tests.sh @ 20614:10ec79b47808

use new string_value method to handle value extraction errors * __voronoi__.cc, chol.cc, colamd.cc, fftw.cc: Use new string_value method.
author John W. Eaton <jwe@octave.org>
date Thu, 08 Oct 2015 18:15:56 -0400
parents bacaec9b5535
children
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
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19627
diff changeset
3 # Copyright (C) 2010-2015 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.
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
6 #
10090
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.
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
11 #
10090
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.
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
16 #
10090
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
20343
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
39 if [ $# -eq 2 ]; then
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
40 output_dir="$1"
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
41 shift
16019
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
42 case "$1" in
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
43 --list-files)
20343
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
44 echo $output_dir/tbcover.m
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
45 echo $output_dir/bc-overloads.tst
16019
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
46 for class in $CLASSES; do
20343
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
47 echo $output_dir/@$class/tbcover.m
16019
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
48 done
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
49 exit
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
50 ;;
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
51 --list-dirs)
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
52 for class in $CLASSES; do
20343
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
53 echo $output_dir/@$class
16019
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
54 done
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
55 exit
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
56 ;;
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
57 --list-classes)
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
58 echo $CLASSES
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
59 exit
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
60 ;;
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
61 *)
20343
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
62 expected_results_file="$1"
16019
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
63 ;;
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
64 esac
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
65 else
20343
bacaec9b5535 eliminate recursive make invocation in test directory tree
John W. Eaton <jwe@octave.org>
parents: 20340
diff changeset
66 echo "usage: build-bc-overload-tests.sh output_dir option" 1>&2
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
67 exit 1
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
68 fi
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
69
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
70 for class in $CLASSES; do
20340
4f911b4e012b allow bc-overload tests to be written to an arbitrary directory
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
71 DIR="$output_dir/@$class"
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
72 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
73 cat > $DIR/tbcover.m << EOF
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
74 % !!! DO NOT EDIT !!!
20340
4f911b4e012b allow bc-overload tests to be written to an arbitrary directory
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
75 % generated automatically by build-bc-overload-tests.sh
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
76 function s = tbcover (x, y)
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
77 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
78 EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
79 done
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
80
20340
4f911b4e012b allow bc-overload tests to be written to an arbitrary directory
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
81 cat > $output_dir/tbcover.m << EOF
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
82 % !!! DO NOT EDIT !!!
20340
4f911b4e012b allow bc-overload tests to be written to an arbitrary directory
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
83 % generated automatically by build-bc-overload-tests.sh
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
84 function s = tbcover (x, y)
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
85 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
86 EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
87
10097
462fa695a565 Correct sh test syntax in build_bc_overload_tests.sh
Rik <rdrider0-list@yahoo.com>
parents: 10096
diff changeset
88 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
89 exit
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
90 fi
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
91
20340
4f911b4e012b allow bc-overload tests to be written to an arbitrary directory
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
92 cat > $output_dir/bc-overloads.tst << EOF
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
93 ## !!! DO NOT EDIT !!!
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
94 ## THIS IS AN AUTOMATICALLY GENERATED FILE
20340
4f911b4e012b allow bc-overload tests to be written to an arbitrary directory
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
95 ## modify build-bc-overload-tests.sh to generate the tests you need.
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
96
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
97 %!shared ex
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
98 %! ex.double = 1;
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
99 %! ex.single = single (1);
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
100 %! ex.logical = true;
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
101 %! ex.char = 'char';
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
102 %! ex.int8 = int8 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
103 %! ex.int16 = int16 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
104 %! ex.int32 = int32 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
105 %! ex.int64 = int64 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
106 %! ex.uint8 = uint8 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
107 %! ex.uint16 = uint16 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
108 %! ex.uint32 = uint32 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
109 %! ex.uint64 = uint64 (1);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
110 %! ex.cell = {};
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
111 %! ex.struct = struct ();
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
112 %! ex.function_handle = @numel;
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
113
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
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
115
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
116 cat $expected_results_file | \
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
117 while read cl1 cl2 clr ; do
20340
4f911b4e012b allow bc-overload tests to be written to an arbitrary directory
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
118 cat >> $output_dir/bc-overloads.tst << EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
119 %% Name call
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
120 %!assert (tbcover (ex.$cl1, ex.$cl2), "$clr")
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
121 %% Handle call
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
122 %!assert ((@tbcover) (ex.$cl1, ex.$cl2), "$clr")
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
123
10096
ffc5426c85a4 build_bc_overload_tests.sh: accept expected results file as argument
John W. Eaton <jwe@octave.org>
parents: 10090
diff changeset
124 EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
125 done
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
126
20340
4f911b4e012b allow bc-overload tests to be written to an arbitrary directory
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
127 cat >> $output_dir/bc-overloads.tst << EOF
10090
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
128 %%test handles through cellfun
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
129 %!test
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
130 %! f = fieldnames (ex);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
131 %! n = numel (f);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
132 %! s = c1 = c2 = cell (n);
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
133 %! for i = 1:n
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
134 %! for j = 1:n
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
135 %! c1{i,j} = ex.(f{i});
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
136 %! c2{i,j} = ex.(f{j});
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
137 %! 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
138 %! endfor
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
139 %! endfor
655ab6f6c369 add tests for built-in class overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
140 %! 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
141 EOF