2005-02-19 20:13:45 +01:00
|
|
|
function run_test()
|
|
|
|
test_files = {
|
2008-09-25 14:10:12 +02:00
|
|
|
'.' 'ramst';
|
|
|
|
'.' 'ramst_a';
|
2005-02-19 20:13:45 +01:00
|
|
|
'.' 'example1';
|
2008-09-25 14:10:12 +02:00
|
|
|
%'.' 'example2';
|
|
|
|
'.' 't_sgu_ex1';
|
|
|
|
'arima' 'mod1';
|
|
|
|
'arima' 'mod1a';
|
|
|
|
'arima' 'mod1b';
|
|
|
|
'arima' 'mod1c';
|
|
|
|
'arima' 'mod2';
|
|
|
|
'arima' 'mod2a';
|
|
|
|
'arima' 'mod2b';
|
|
|
|
'arima' 'mod2c';
|
|
|
|
'fs2000' 'fs2000';
|
|
|
|
'fs2000' 'fs2000a';
|
|
|
|
'estimation_options','fs2000A';
|
|
|
|
'estimation_options','fs2000B';
|
|
|
|
}
|
2005-02-19 20:13:45 +01:00
|
|
|
|
|
|
|
results = cell(length(test_files),1);
|
|
|
|
|
|
|
|
for i=1:length(test_files)
|
2008-09-25 14:10:12 +02:00
|
|
|
tic;
|
|
|
|
rand('state',1);
|
|
|
|
randn('state',1);
|
2005-02-19 20:13:45 +01:00
|
|
|
results{i}= run_test1(test_files{i,1},test_files{i,2});
|
2008-09-25 14:10:12 +02:00
|
|
|
|
|
|
|
toc;
|
|
|
|
|
2005-02-19 20:13:45 +01:00
|
|
|
end
|
|
|
|
|
2008-09-25 14:10:12 +02:00
|
|
|
|
2005-02-19 20:13:45 +01:00
|
|
|
for i=1:length(test_files)
|
|
|
|
disp(test_files{i,2})
|
|
|
|
disp(results{i})
|
2008-09-25 14:10:12 +02:00
|
|
|
disp(toc)
|
|
|
|
end
|
|
|
|
|
2005-02-19 20:13:45 +01:00
|
|
|
end
|
2008-09-25 14:10:12 +02:00
|
|
|
|
2005-02-19 20:13:45 +01:00
|
|
|
function msg=run_test1(path1,mod_file)
|
2008-09-25 14:10:12 +02:00
|
|
|
global options_ oo_
|
|
|
|
options_=struct('trick',1);
|
|
|
|
oo_=struct('trick',1);
|
2005-02-19 20:13:45 +01:00
|
|
|
old_path = pwd;
|
|
|
|
cd(path1);
|
|
|
|
msg = 'OK';
|
|
|
|
expr = ['disp(''error in ' mod_file ''');msg=lasterr;disp(msg)'];
|
2008-09-25 14:10:12 +02:00
|
|
|
|
|
|
|
try
|
|
|
|
old_results=load([mod_file '_results']);
|
|
|
|
catch
|
|
|
|
eval(['dynare ' mod_file ' noclearall'],'eval(expr)');
|
|
|
|
msg = 'no previous results'
|
|
|
|
cd(old_path)
|
|
|
|
return
|
|
|
|
end
|
2005-02-19 20:13:45 +01:00
|
|
|
eval(['dynare ' mod_file ' noclearall'],'eval(expr)');
|
2008-09-25 14:10:12 +02:00
|
|
|
msg = strvcat(msg, comparison(oo_,old_results.oo_,0, 'oo_'));
|
2005-02-19 20:13:45 +01:00
|
|
|
cd(old_path)
|
2008-09-25 14:10:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function msg=comparison(A,B,tol,parent)
|
|
|
|
|
|
|
|
msg = '';
|
|
|
|
mca = my_class(A);
|
|
|
|
mcb = my_class(B);
|
|
|
|
if size(mca,2) ~= size(mcb,2) || any(mca ~= mcb)
|
|
|
|
msg = ['Types differ in ' parent];
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
switch my_class(A)
|
|
|
|
case 'numeric'
|
|
|
|
if size(A)==size(B)
|
|
|
|
if ~all(all(abs(A-B)<tol))
|
|
|
|
msg = ['Difference greater than tolerance in ' parent];
|
|
|
|
end
|
|
|
|
else
|
|
|
|
msg = ['Sizes differ in ' parent];
|
|
|
|
end
|
|
|
|
case 'char'
|
|
|
|
if A~=B
|
|
|
|
msg = ['Strings differ in ' parent];
|
|
|
|
end
|
|
|
|
case 'cell'
|
|
|
|
if size(A) == size(B)
|
|
|
|
[M,N] = size(A);
|
|
|
|
for i = 1:M
|
|
|
|
for j = 1:N
|
|
|
|
msg = strvcat(msg, comparison(A{i,j}, B{i,j}, tol, sprintf('%s{%d,%d}', parent, i, j)))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
msg = [ 'Cell sizes differ in ' parent ];
|
|
|
|
end
|
|
|
|
case 'struct'
|
|
|
|
|
|
|
|
namesA=fieldnames(A);
|
|
|
|
namesB=fieldnames(B);
|
|
|
|
|
|
|
|
if length(namesA)~=length(namesB)
|
|
|
|
msg = [ 'Number of fields differ in ' parent ]
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
namesA = sort(namesA);
|
|
|
|
namesB = sort(namesB);
|
|
|
|
|
|
|
|
for i=1:length(namesA)
|
|
|
|
if namesA{i}==namesB{i}
|
|
|
|
msg = strvcat(msg, comparison(A.(namesA{i}),B.(namesB{i}),tol, sprintf('%s.%s', parent, namesA{i})));
|
|
|
|
else
|
|
|
|
msg = strvcat(msg, sprintf('Field %s.%s in 1st arg does not exist in 2nd arg', parent, namesA{i}));
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
otherwise
|
|
|
|
msg = ['Unsupported type in ' parent ];
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function t = my_class(a)
|
|
|
|
c = class(a);
|
|
|
|
if isequal(c, 'double') | isequal(c, 'single') | isequal(c, 'int8')| isequal(c, 'uint8') | ...
|
|
|
|
isequal(c, 'int16') | isequal(c, 'uint16') | isequal(c, 'int32') | isequal(c, 'uint32') | ...
|
|
|
|
isequal(c, 'int64') | isequal(c, 'uint64')
|
|
|
|
t = 'numeric';
|
|
|
|
else
|
|
|
|
t = c;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-02-19 20:13:45 +01:00
|
|
|
|