Skip to content

Commit be804aa

Browse files
committed
better test suite for older matlab
1 parent c93bedd commit be804aa

File tree

8 files changed

+24
-34
lines changed

8 files changed

+24
-34
lines changed

+stdlib/filename.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
% filename (including suffix) without directory
77

88
function f = filename(p, backend)
9-
arguments
10-
p
11-
backend = 'fileparts'
9+
if nargin < 2
10+
backend = 'fileparts';
1211
end
1312

1413
% fileparts is 5x to 10x faster than regexp and pattern

private/releaseTestTags.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
end
1111

1212
releasesKnown = [
13-
"R2019b", "R2020a", "R2020b", "R2021a", "R2021b", ...
14-
"R2022a", "R2022b", "R2023a", "R2023b", "R2024a", ...
15-
"R2024b", "R2025a", "R2025b"];
13+
"R2019a", "R2019b", "R2020a", "R2020b", ...
14+
"R2021a", "R2021b", "R2022a", "R2022b", ...
15+
"R2023a", "R2023b", "R2024a", "R2024b", ...
16+
"R2025a", "R2025b"];
1617

1718
% takes releases not newer than this release
1819
idx = find(releasesKnown >= r, 1, 'first');

test/TestAbsolute.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2019b', 'impure'}) ...
2+
TestTags = {'R2019a', 'impure'}) ...
33
TestAbsolute < matlab.unittest.TestCase
44

55
properties (TestParameter)

test/TestFilename.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2019b', 'pure'}) ...
2+
TestTags = {'R2019a', 'pure'}) ...
33
TestFilename < matlab.unittest.TestCase
44

55
properties (TestParameter)

test/TestIsAbsolute.m

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2019b', 'pure'}) ...
2+
TestTags = {'R2019a', 'pure'}) ...
33
TestIsAbsolute < matlab.unittest.TestCase
44

55
properties (TestParameter)
6-
p = {{"", false}, {"x", false}, {"x:", false}}
7-
pu = {{"x:/foo", false}, {"/foo", true}}
8-
pw = {{"x:/foo", true}, {"/foo", false}}
6+
p = init_p()
97
end
108

119

@@ -17,27 +15,16 @@ function test_is_absolute(tc, p)
1715
end
1816

1917
end
20-
21-
22-
methods (Test, TestTags={'unix'})
23-
24-
function test_is_absolute_unix(tc, pu)
25-
tc.assumeTrue(isunix())
26-
ok = stdlib.is_absolute(pu{1});
27-
tc.verifyEqual(ok, pu{2}, pu{1})
2818
end
2919

30-
end
3120

21+
function p = init_p()
22+
p = {{"", false}, {"x", false}, {"x:", false}};
3223

33-
methods (Test, TestTags={'windows'})
34-
35-
function test_is_absolute_windows(tc, pw)
36-
tc.assumeTrue(ispc())
37-
ok = stdlib.is_absolute(pw{1});
38-
tc.verifyEqual(ok, pw{2}, pw{1})
39-
end
40-
24+
if ispc()
25+
p = [p, {{"x:/foo", true}, {"/foo", false}}];
26+
else
27+
p = [p, {{"x:/foo", false}, {"/foo", true}}];
4128
end
4229

4330
end

test/TestStem.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'pure'}) ...
2+
TestTags = {'R2019a', 'pure'}) ...
33
TestStem < matlab.unittest.TestCase
44

55
properties (TestParameter)
@@ -19,7 +19,7 @@
1919
end
2020

2121

22-
methods (Test, TestTags={'R2019b'})
22+
methods (Test)
2323

2424
function test_stem(tc, p)
2525
tc.verifyEqual(stdlib.stem(p{1}), p{2})

test/TestSuffix.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'pure'}) ...
2+
TestTags = {'R2019a', 'pure'}) ...
33
TestSuffix < matlab.unittest.TestCase
44

55
properties (TestParameter)
@@ -14,7 +14,7 @@
1414
end
1515

1616

17-
methods (Test, TestTags={'R2019b'})
17+
methods (Test)
1818

1919
function test_suffix(tc, p)
2020
r = stdlib.suffix(p{1});

test_main.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ function test_main(context, sel)
3131
suite = testsuite(test_root, 'Tag', tags);
3232
catch e
3333
if e.identifier == "MATLAB:expectedScalartext"
34-
suite = testsuite(test_root, 'Tag', "R2019b");
34+
suite = testsuite(test_root);
35+
for t = tags
36+
sel = sel | HasTag(t);
37+
end
3538
else
3639
rethrow(e)
3740
end

0 commit comments

Comments
 (0)