|
|
@@ -4,7 +4,8 @@ |
|
|
|
|
|
function assertStringContains(text, subtext)
|
|
|
assert(~isempty(strfind(text, subtext)), ...
|
|
|
- 'String ''%s'' should contain ''%s'', but it doesn''t.', text, subtext);
|
|
|
+ 'String ''%s'' should contain ''%s'', but it doesn''t.', ...
|
|
|
+ text, subtext);
|
|
|
end
|
|
|
|
|
|
function filepath = create_tempfile(filename, contents)
|
|
|
@@ -32,12 +33,12 @@ function assertStringContains(text, subtext) |
|
|
' end\n', ...
|
|
|
' methods\n', ...
|
|
|
' function self = ', classname, ' \n', ...
|
|
|
- ' fprintf(0, ''hello world!'');\n', ...
|
|
|
+ ' abs(1);\n', ...
|
|
|
' end\n', ...
|
|
|
' end\n', ...
|
|
|
' methods (Access = public)\n', ...
|
|
|
' function x = aMethod(self)\n', ...
|
|
|
- ' fprintf(0, ''hello world!'');\n', ...
|
|
|
+ ' abs(2);\n', ...
|
|
|
' end\n', ...
|
|
|
' end\n', ...
|
|
|
'end\n' ...
|
|
|
@@ -89,7 +90,7 @@ function assertStringContains(text, subtext) |
|
|
method_lines = [10, 15];
|
|
|
|
|
|
for n = method_lines
|
|
|
- assertStringContains(lines{n}, 'fprintf');
|
|
|
+ assertStringContains(lines{n}, 'abs(');
|
|
|
assert(executable_lines(n), ...
|
|
|
'`%s` line is wrongly classified as non-executable', lines{n});
|
|
|
end
|
|
|
@@ -132,9 +133,9 @@ function assertStringContains(text, subtext) |
|
|
classname = ['AClass', char(64 + ceil(26*rand(1, 20)))];
|
|
|
tempfile = create_classdef(classname);
|
|
|
teardown = onCleanup(@() delete(tempfile));
|
|
|
- % a valid decorator
|
|
|
+ % a valid decorator (which does nothing)
|
|
|
decorator = @(line_number) ...
|
|
|
- sprintf('fprintf(0, ''%s:%d'');', tempfile, line_number);
|
|
|
+ sprintf('abs(3);');
|
|
|
|
|
|
% When: the decorated file is generated
|
|
|
mfile = MOcovMFile(tempfile);
|
|
|
@@ -151,7 +152,8 @@ function assertStringContains(text, subtext) |
|
|
aObject = constructor();
|
|
|
aObject.aMethod();
|
|
|
catch
|
|
|
- assert(false, ['Problems when running the decorated file: `%s` ', ...
|
|
|
- 'please check for syntax errors.'], decorated);
|
|
|
+ assert(false, ['Problems when running the decoated file: ', ...
|
|
|
+ '%s - please check for syntax errors.'], tempfile);
|
|
|
end
|
|
|
end
|
|
|
+
|
0 comments on commit
04ae980