Fri 09 Apr 2010 09:01:33 AM UTC, original submission:
When running the following (modified code from MUnit framework)
file CollectTests.m
function ts = CollectTests(files,recursive,name)
if isa(files,'char')
ts = CollectTests({},recursive,name);
else
tests = cell(1,numel(files));
disp(tests);
ts = testset(name,name,tests); % fails when using this line
% ts = makeTS(name,name,tests); % works when using this line
end
end
function ts = makeTS(name,id,tests)
ts = testset(name,id,tests);
end
=======
I get:
octave:3> CollectTests('hello',true,'hello')
{}(1x0)
error: `tests' undefined near line 7 column 28
error: evaluating argument list element number 3
error: called from:
error: D:\tests\libs\MUnit\tools\CollectTests.m at line 7, column 8
error: D:\tests\libs\MUnit\tools\CollectTests.m at line 3, column 8
Note that 'tests' is displayed a line above where it is used, it is not undefined but {}(1x0) instead.
The call works correctly, when the construction of the testset class is deferred to another function in the same file (uncomment line 8 and comment line 7)
The recursion one CollectTests seems to be important: calling directly works:
octave:3> CollectTests({},true,'hello')
{}(1x0)
Unit test "hello" of class "testset",
hello
Both tests are made right after clean start of octave, while only the path has been set.
testset is the unmodified testset class from MUnit (full code attached) which takes a vararg as input.
|