Mercurial > hg > octave-nkf
diff test/test_args.m @ 14131:c3309e1ec50d stable
test: Use Octave coding and spacing conventions for fixed test scripts
* build_bc_overload_tests.sh, build_bc_overloads_expected.m,
build_sparse_tests.sh, test_args.m, test_contin.m, test_diag_perm.m,
test_error.m, test_eval-catch.m, test_for.m, test_func.m, test_global.m,
test_if.m, test_index.m, test_io.m, test_logical_index.m, test_null_assign.m,
test_parser.m, test_prefer.m, test_range.m, test_recursion.m, test_return.m,
test_slice.m, test_struct.m, test_switch.m, test_system.m, test_transpose.m,
test_try.m, test_unwind.m, test_while.m:
Use Octave coding and spacing conventions for fixed test scripts.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 01 Jan 2012 20:04:52 -0800 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/test/test_args.m +++ b/test/test_args.m @@ -23,6 +23,7 @@ %!function f () %! assert (nargin, 0); %! assert (nargout, 0); +%!endfunction %!test %! f; @@ -30,6 +31,7 @@ %!function f (x, y) %! assert (nargin, 1); %! assert (nargout, 0); +%!endfunction %!test %! f (1); @@ -38,6 +40,7 @@ %! assert (nargin, 0); %! assert (nargout, 1); %! x = 2; +%!endfunction %!test %! assert (f (), 2); @@ -46,6 +49,7 @@ %! assert (nargin, 1); %! assert (nargout, 1); %! x = a; +%!endfunction %!test %! assert (f (1), 1); @@ -56,6 +60,7 @@ %!function [varargout] = f (varargin) %! assert (nargin, 0); %! assert (nargout, 0); +%!endfunction %!test %! f; @@ -63,6 +68,7 @@ %!function [varargout] = f (x, varargin) %! assert (nargin, 1); %! assert (nargout, 0); +%!endfunction %!test %! f (1); @@ -71,6 +77,7 @@ %! assert (nargin, 0); %! assert (nargout, 1); %! x = 2; +%!endfunction %!test %! assert (f (), 2); @@ -79,6 +86,7 @@ %! assert (nargin, 1); %! assert (nargout, 1); %! varargout{1} = varargin{1}; +%!endfunction %!test %! assert (f (1), 1); @@ -91,9 +99,10 @@ %! assert (nargout, 2); %! x = a; %! y = b; +%!endfunction %!test %! [s, t] = f (1, 2, 3, 4); -%! assert([s t], [1 2]); +%! assert ([s t], [1 2]); ## Fully used varargin and varargout %!function [varargout] = f (varargin) @@ -103,92 +112,107 @@ %! varargout{2} = varargin{2}; %! varargout{3} = varargin{3}; %! varargout{4} = 4; +%!endfunction %!test %! [s, t, u, v] = f (1, 2, 3); -%! assert([s t u v], [1 2 3 4]); +%! assert ([s t u v], [1 2 3 4]); ## Test default arguments ## numeric %!function f (x = 0) -%! assert (x, 0) +%! assert (x, 0); +%!endfunction %!test %! f() ## numeric vector (spaces) %!function f (x = [0 1 2]) -%! assert (x, [0 1 2]) +%! assert (x, [0 1 2]); +%!endfunction %!test %! f() ## numeric vector (range) %!function f (x = 1:3) -%! assert (x, 1:3) +%! assert (x, 1:3); +%!endfunction %!test %! f() ## numeric vector (commas) %!function f (x = [0,1,2]) -%! assert (x, [0 1 2]) +%! assert (x, [0 1 2]); +%!endfunction %!test %! f() ## numeric vector (commas and spaces) %!function f (x = [0, 1, 2]) -%! assert (x, [0 1 2]) +%! assert (x, [0 1 2]); +%!endfunction %!test %! f() ## numeric matrix %!function f (x = [0, 1, 2;3, 4, 5]) -%! assert (x, [0 1 2;3 4 5]) +%! assert (x, [0 1 2;3 4 5]); +%!endfunction %!test %! f() ## empty cell %!function f (x = {}) -%! assert (x, {}) +%! assert (x, {}); +%!endfunction %!test %! f() ## full cell %!function f (x = {1}) -%! assert (x, {1}) +%! assert (x, {1}); +%!endfunction %!test %! f() ## many cells %!function f (x = {1 'a' "b" 2.0 struct("a", 3)}) -%! assert (x, {1 'a' "b" 2.0 struct("a", 3)}) +%! assert (x, {1 'a' "b" 2.0 struct("a", 3)}); +%!endfunction %!test %! f() ## struct %!function f (x = struct("a", 3)) -%! assert (x, struct ("a", 3)) +%! assert (x, struct ("a", 3)); +%!endfunction %!test %! f() ## char (double quotes) %!function f (x = "a") -%! assert (x, "a") +%! assert (x, "a"); +%!endfunction %!test %! f() ## char (single quotes) %!function f (x = 'a') -%! assert (x, "a") +%! assert (x, "a"); +%!endfunction %!test %! f() ## char (string, double quotes) %!function f (x = "abc123") -%! assert (x, "abc123") +%! assert (x, "abc123"); +%!endfunction %!test %! f() ## char (string, double quotes, punctuation) %!function f (x = "abc123`1234567890-=~!@#$%^&*()_+[]{}|;':\",./<>?\\") -%! assert (x, "abc123`1234567890-=~!@#$%^&*()_+[]{}|;':\",./<>?\\") +%! assert (x, "abc123`1234567890-=~!@#$%^&*()_+[]{}|;':\",./<>?\\"); +%!endfunction %!test %! f() @@ -197,6 +221,7 @@ %! finfo = functions (x); %! fname = finfo.function; %! assert (isa (x, "function_handle") && strcmp (fname, "sin")); +%!endfunction %!test %! f() @@ -205,5 +230,7 @@ %! finfo = functions (x); %! ftype = finfo.type; %! assert (isa (x, "function_handle") && strcmp (ftype, "anonymous")); +%!endfunction %!test %! f() +