Skip to content

Commit

Permalink
Merge pull request #290 from gnu-octave/oct9
Browse files Browse the repository at this point in the history
draft: porting to Octave 9
  • Loading branch information
cbm755 authored Mar 5, 2024
2 parents e9b364e + 03af49d commit 28fad67
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
10 changes: 7 additions & 3 deletions inst/private/doctest_collect.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
%%
% Copyright (c) 2010 Thomas Grenfell Smith
% Copyright (c) 2015 Michael Walter
% Copyright (c) 2015-2019, 2022-2023 Colin B. Macdonald
% Copyright (c) 2015-2019, 2022-2024 Colin B. Macdonald
% Copyright (c) 2015 Oliver Heimlich
% Copyright (C) 2018 Mike Miller
% SPDX-License-Identifier: BSD-3-Clause
Expand Down Expand Up @@ -309,10 +309,14 @@
for i=1:numel(meths)
target = struct();
if is_octave()
if compare_versions (OCTAVE_VERSION, '7.0.0', '>=') && exist (w, "class") == 8
if compare_versions (OCTAVE_VERSION, '9.0.0', '>=') && exist (w, "class") == 8
% classdef on newish Octave: use cls.method
target.name = sprintf ('%s.%s', w, meths{i});
target.link = '';
elseif compare_versions (OCTAVE_VERSION, '7.0.0', '>=') && exist (w, "class") == 8
% use cls.method, use cls.method, but skip cls.cls
if strcmp (meths{i}, w)
% TODO: gathering the ctor help fails https://savannah.gnu.org/bugs/?62803
% gathering the ctor help fails https://savannah.gnu.org/bugs/?62803
continue
end
target.name = sprintf ('%s.%s', w, meths{i});
Expand Down
40 changes: 33 additions & 7 deletions test/bist.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,40 @@ function bist()
%! end

%!xtest
%! % complicated classdef has correct number of tests and targets
%! % https://github.com/gnu-octave/octave-doctest/issues/268
%! if (compare_versions (OCTAVE_VERSION(), '7.0.0', '>='))
%! [nump, numt, summ] = doctest ('classdef_infile');
%! % Now on Octave 9, #268 fixed but it fails in new way:
%! % https://github.com/gnu-octave/octave-doctest/issues/288
%! % (these issues test separately elsewhere)
%! if (compare_versions (OCTAVE_VERSION(), '9.0.0', '>='))
%! [nump, numt, summ] = doctest ('test_classdef');
%! assert (nump == numt && numt == 5)
%! assert (summ.num_targets == 4)
%! end

%!test
%! % https://github.com/gnu-octave/octave-doctest/issues/268
%! if (compare_versions (OCTAVE_VERSION(), '9.0.0', '>='))
%! [nump, numt, summ] = doctest ('classdef_infile.classdef_infile');
%! assert (nump == numt && numt == 1)
%! assert (summ.num_targets == 1)
%! end

%!test
%! % https://github.com/gnu-octave/octave-doctest/issues/268
%! if (compare_versions (OCTAVE_VERSION(), '9.0.0', '>='))
%! [nump, numt, summ] = doctest ('test_classdef.test_classdef');
%! assert (nump == numt && numt == 1)
%! assert (summ.num_targets == 1)
%! end

%!test
%! %% Issue #220, Issue #261, clear and w/o special order or workarounds
%! if (compare_versions (OCTAVE_VERSION(), '7.0.0', '>='))
%! clear classes
%! % doctest ('test_classdef')
%! [numpass, numtest, summary] = doctest ('test_classdef');
%! assert (numpass == numtest)
%! assert (summary.num_targets_without_tests == 0)
%! assert (summary.num_targets >= 3)
%! end

%!test
Expand Down Expand Up @@ -141,9 +160,9 @@ function bist()
%! assert (summ.num_targets >= 2)
%! end

%!xtest
%!test
%! % https://github.com/gnu-octave/octave-doctest/issues/268
%! if (compare_versions (OCTAVE_VERSION(), '7.0.0', '>='))
%! if (compare_versions (OCTAVE_VERSION(), '9.0.0', '>='))
%! [nump, numt, summ] = doctest ('classdef_infile');
%! assert (summ.num_targets == 3)
%! assert (nump == numt && numt == 4)
Expand Down Expand Up @@ -244,11 +263,18 @@ function bist()

%!test
%! % classdef.method, where method is external file
%! if (compare_versions (OCTAVE_VERSION(), '6.0.0', '>='))
%! if ((compare_versions (OCTAVE_VERSION(), '6.0.0', '>=')) && ...
%! (compare_versions (OCTAVE_VERSION(), '9.0.0', '<')))
%! [n, t, summary] = doctest ("test_classdef.amethod");
%! assert (n == t)
%! assert (n == 1)
%! end
%!xtest
%! % classdef.method, where method is external file
%! % https://github.com/gnu-octave/octave-doctest/issues/288
%! [n, t, summary] = doctest ("test_classdef.amethod");
%! assert (n == t)
%! assert (n == 1)

%!test
%! % classdef.method
Expand Down
20 changes: 10 additions & 10 deletions test_extra/run_tests.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%% Copyright (c) 2022 Markus Mützel
%% Copyright (c) 2022-2023 Colin B. Macdonald
%% Copyright (c) 2022-2024 Colin B. Macdonald
%%
%% SPDX-License-Identifier: BSD-3-Clause
%%
Expand Down Expand Up @@ -37,12 +37,12 @@
save_enc = feature ('DefaultCharacterSet');
meh = feature ('DefaultCharacterSet', 'CP1252');
chdir ('test_encoding')
ok1 = doctest ('test_matlab_style_CP1252.m');
ok1 = doctest ('test_matlab_style_CP1252');
chdir ('..')

meh = feature ('DefaultCharacterSet', 'UTF-8');
chdir ('test_encoding_utf8')
ok2 = doctest ('test_matlab_style_utf8.m');
ok2 = doctest ('test_matlab_style_utf8');
chdir ('..')

meh = feature ('DefaultCharacterSet', save_enc);
Expand All @@ -62,7 +62,7 @@
%! warn_orig = warning ('off', 'octave:get_input:invalid_utf8');
%! unwind_protect
%! addpath (canonicalize_file_name ('test_encoding'));
%! assert (doctest ('test_CP1252.m', '-quiet'));
%! assert (doctest ('test_CP1252', '-quiet'));
%! unwind_protect_cleanup
%! path (path_orig)
%! warning (warn_orig)
Expand All @@ -76,8 +76,8 @@
%! path_orig = path ();
%! unwind_protect
%! addpath (canonicalize_file_name ('test_encoding'));
%! assert (doctest ('test_bytecount_CP1252.m', '-quiet'));
%! assert (doctest ('test_matlab_style_CP1252.m', '-quiet'));
%! assert (doctest ('test_bytecount_CP1252', '-quiet'));
%! assert (doctest ('test_matlab_style_CP1252', '-quiet'));
%! unwind_protect_cleanup
%! path (path_orig)
%! end
Expand All @@ -89,8 +89,8 @@
%! d = pwd ();
%! unwind_protect
%! cd ('test_encoding');
%! assert (doctest ('test_bytecount_CP1252.m', '-quiet'));
%! assert (doctest ('test_matlab_style_CP1252.m', '-quiet'));
%! assert (doctest ('test_bytecount_CP1252', '-quiet'));
%! assert (doctest ('test_matlab_style_CP1252', '-quiet'));
%! unwind_protect_cleanup
%! cd (d)
%! end
Expand All @@ -103,7 +103,7 @@
%! path_orig = path ();
%! unwind_protect
%! addpath (canonicalize_file_name ('test_encoding_utf8'));
%! assert (doctest ('test_matlab_style_utf8.m', '-quiet'));
%! assert (doctest ('test_matlab_style_utf8', '-quiet'));
%! unwind_protect_cleanup
%! path (path_orig)
%! end
Expand All @@ -115,7 +115,7 @@
%! d = pwd ();
%! unwind_protect
%! cd ('test_encoding_utf8');
%! assert (doctest ('test_matlab_style_utf8.m', '-quiet'));
%! assert (doctest ('test_matlab_style_utf8', '-quiet'));
%! unwind_protect_cleanup
%! cd (d)
%! end
Expand Down

0 comments on commit 28fad67

Please sign in to comment.