diff --git a/matlab/@dynDate/colon.m b/matlab/@dynDate/colon.m index 5c6e22f66..9f794b1b1 100644 --- a/matlab/@dynDate/colon.m +++ b/matlab/@dynDate/colon.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function sp = colon(a,b) %@info: diff --git a/matlab/@dynDate/dynDate.m b/matlab/@dynDate/dynDate.m index e6af26bb5..22c1f71d2 100644 --- a/matlab/@dynDate/dynDate.m +++ b/matlab/@dynDate/dynDate.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function date = dynDate(a,b) %@info: diff --git a/matlab/@dynDate/eq.m b/matlab/@dynDate/eq.m index 64367e1d9..82edfb527 100644 --- a/matlab/@dynDate/eq.m +++ b/matlab/@dynDate/eq.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = eq(a,b) %@info: diff --git a/matlab/@dynDate/format.m b/matlab/@dynDate/format.m index df403148a..5258ba0ba 100644 --- a/matlab/@dynDate/format.m +++ b/matlab/@dynDate/format.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function p = format(date) %@info: diff --git a/matlab/@dynDate/ge.m b/matlab/@dynDate/ge.m index 05fa1850d..15cec1a6a 100644 --- a/matlab/@dynDate/ge.m +++ b/matlab/@dynDate/ge.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = ge(a,b) %@info: diff --git a/matlab/@dynDate/gt.m b/matlab/@dynDate/gt.m index c881b1942..0f2bde4d9 100644 --- a/matlab/@dynDate/gt.m +++ b/matlab/@dynDate/gt.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = gt(a,b) %@info: diff --git a/matlab/@dynDate/isempty.m b/matlab/@dynDate/isempty.m index ee90a40e3..df8c9adba 100644 --- a/matlab/@dynDate/isempty.m +++ b/matlab/@dynDate/isempty.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function b = isempty(a) %@info: diff --git a/matlab/@dynDate/le.m b/matlab/@dynDate/le.m index 14b198330..63e94d5fb 100644 --- a/matlab/@dynDate/le.m +++ b/matlab/@dynDate/le.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = le(a,b) %@info: diff --git a/matlab/@dynDate/lt.m b/matlab/@dynDate/lt.m index 0aef47153..e48eec784 100644 --- a/matlab/@dynDate/lt.m +++ b/matlab/@dynDate/lt.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = lt(a,b) %@info: diff --git a/matlab/@dynDate/max.m b/matlab/@dynDate/max.m index 451c050f6..196ff3248 100644 --- a/matlab/@dynDate/max.m +++ b/matlab/@dynDate/max.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = max(a,b) %@info: diff --git a/matlab/@dynDate/min.m b/matlab/@dynDate/min.m index 78c7281af..29dea5d74 100644 --- a/matlab/@dynDate/min.m +++ b/matlab/@dynDate/min.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = min(a,b) %@info: diff --git a/matlab/@dynDate/minus.m b/matlab/@dynDate/minus.m index 248cb679c..bebd9f7d1 100644 --- a/matlab/@dynDate/minus.m +++ b/matlab/@dynDate/minus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = minus(a,b) %@info: diff --git a/matlab/@dynDate/ne.m b/matlab/@dynDate/ne.m index d6ae7f1f1..d5b5585a5 100644 --- a/matlab/@dynDate/ne.m +++ b/matlab/@dynDate/ne.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = ne(a,b) %@info: diff --git a/matlab/@dynDate/plus.m b/matlab/@dynDate/plus.m index 51158612d..aaea7c680 100644 --- a/matlab/@dynDate/plus.m +++ b/matlab/@dynDate/plus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = plus(a,b) %@info: diff --git a/matlab/@dynDate/subsref.m b/matlab/@dynDate/subsref.m index 6186eb6f0..c70bf12c0 100644 --- a/matlab/@dynDate/subsref.m +++ b/matlab/@dynDate/subsref.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function B = subsref(A,S) %@info: diff --git a/matlab/@dynDate/uminus.m b/matlab/@dynDate/uminus.m index 814afe12e..02b9bb7db 100644 --- a/matlab/@dynDate/uminus.m +++ b/matlab/@dynDate/uminus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function b = uminus(a) %@info: diff --git a/matlab/@dynDate/uplus.m b/matlab/@dynDate/uplus.m index 054057215..c056d265b 100644 --- a/matlab/@dynDate/uplus.m +++ b/matlab/@dynDate/uplus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function b = uplus(a) %@info: diff --git a/matlab/@dynDates/append.m b/matlab/@dynDates/append.m index 651b95e0a..df0d52fa6 100644 --- a/matlab/@dynDates/append.m +++ b/matlab/@dynDates/append.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = append(dd,a) % append method for dynDates class. diff --git a/matlab/@dynDates/dynDates.m b/matlab/@dynDates/dynDates.m index 826b10fde..ceb5b521c 100644 --- a/matlab/@dynDates/dynDates.m +++ b/matlab/@dynDates/dynDates.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = dynDates(varargin) %@info: diff --git a/matlab/@dynDates/eq.m b/matlab/@dynDates/eq.m index 7639ca1a2..567c087f0 100644 --- a/matlab/@dynDates/eq.m +++ b/matlab/@dynDates/eq.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = eq(A,B) %@info: diff --git a/matlab/@dynDates/intersect.m b/matlab/@dynDates/intersect.m index b61eee2a7..8e70ebab6 100644 --- a/matlab/@dynDates/intersect.m +++ b/matlab/@dynDates/intersect.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = intersect(A,B) %@info: diff --git a/matlab/@dynDates/isempty.m b/matlab/@dynDates/isempty.m index ea76bd968..e8be87b26 100644 --- a/matlab/@dynDates/isempty.m +++ b/matlab/@dynDates/isempty.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function B = isempty(A) %@info: diff --git a/matlab/@dynDates/minus.m b/matlab/@dynDates/minus.m index 693c8a3f6..fd209b0c5 100644 --- a/matlab/@dynDates/minus.m +++ b/matlab/@dynDates/minus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = minus(A,B) %@info: diff --git a/matlab/@dynDates/plus.m b/matlab/@dynDates/plus.m index 626e46daa..f1a769617 100644 --- a/matlab/@dynDates/plus.m +++ b/matlab/@dynDates/plus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = plus(A,B) %@info: diff --git a/matlab/@dynDates/pop.m b/matlab/@dynDates/pop.m index 3013c876b..83448580c 100644 --- a/matlab/@dynDates/pop.m +++ b/matlab/@dynDates/pop.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = pop(dd,a) % pop method for dynDates class (removes a date)). diff --git a/matlab/@dynDates/sort.m b/matlab/@dynDates/sort.m index 52467bfc4..32b2abe71 100644 --- a/matlab/@dynDates/sort.m +++ b/matlab/@dynDates/sort.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = sort(dd) % sort method for dynDates class. diff --git a/matlab/@dynDates/subsref.m b/matlab/@dynDates/subsref.m index d15a17f2e..b1ac3a4b0 100644 --- a/matlab/@dynDates/subsref.m +++ b/matlab/@dynDates/subsref.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function B = subsref(A,S) %@info: diff --git a/matlab/@dynDates/union.m b/matlab/@dynDates/union.m index e0799d834..54e596d9c 100644 --- a/matlab/@dynDates/union.m +++ b/matlab/@dynDates/union.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = union(A,varargin) %@info: diff --git a/matlab/@dynDates/unique.m b/matlab/@dynDates/unique.m index b37292fb8..06c1515ec 100644 --- a/matlab/@dynDates/unique.m +++ b/matlab/@dynDates/unique.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = unique(dd) % unique method for dynDates class. diff --git a/matlab/@dynSeries/align.m b/matlab/@dynSeries/align.m index 6096b5fa9..63b983da3 100644 --- a/matlab/@dynSeries/align.m +++ b/matlab/@dynSeries/align.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function [a,b] = align(a, b) %@info: diff --git a/matlab/@dynSeries/dynSeries.m b/matlab/@dynSeries/dynSeries.m index 58454cfa6..92d357468 100644 --- a/matlab/@dynSeries/dynSeries.m +++ b/matlab/@dynSeries/dynSeries.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function ts = dynSeries(varargin) %@info: @@ -124,13 +125,18 @@ switch nargin ts.vobs = length(varlist); ts.nobs = size(data,1); if isempty(tex) - ts.tex = cell(ts.vobs,1); - for i=1:ts.vobs - ts.tex(i) = {name2tex(varlist{i})}; - end + ts.tex = name2tex(varlist); else - ts.tex = tex; + ts.tex = tex; end + elseif isnumeric(varargin{1}) && isequal(ndims(varargin{1}),2) + ts.data = varargin{1}; + [ts.nobs, ts.vobs] = size(ts.data); + ts.freq = 1; + ts.init = dynDate(1); + ts.time = ts.init:ts.init+ts.nobs; + ts.name = default_name(ts.vobs); + ts.tex = name2tex(ts.name); end case {2,3,4} a = varargin{1}; @@ -177,9 +183,7 @@ switch nargin error('dynSeries::dynSeries: The number of declared names does not match the number of variables!') end else - for i=1:ts.vobs - ts.name = vertcat(ts.name, {['Variable_' int2str(i)]}); - end + ts.name = default_name(ts.vobs); end if ~isempty(d) if ts.vobs==length(d) @@ -190,9 +194,7 @@ switch nargin error('dynSeries::dynSeries: The number of declared tex names does not match the number of variables!') end else - for i=1:ts.vobs - ts.tex = vertcat(ts.tex, {name2tex(ts.name{i})}); - end + ts.tex = name2tex(ts.name); end otherwise error('dynSeries::dynSeries: Can''t instantiate the class, wrong calling sequence!') diff --git a/matlab/@dynSeries/eq.m b/matlab/@dynSeries/eq.m index 1850f3e52..d8d2f7ee4 100644 --- a/matlab/@dynSeries/eq.m +++ b/matlab/@dynSeries/eq.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = eq(A,B) %@info: diff --git a/matlab/@dynSeries/extract.m b/matlab/@dynSeries/extract.m index 185c20c56..feabd0547 100644 --- a/matlab/@dynSeries/extract.m +++ b/matlab/@dynSeries/extract.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = extract(B,varargin) % Extract some variables from a database. diff --git a/matlab/@dynSeries/horzcat.m b/matlab/@dynSeries/horzcat.m index 97ea8ebc6..798ad2657 100644 --- a/matlab/@dynSeries/horzcat.m +++ b/matlab/@dynSeries/horzcat.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function a = horzcat(varargin) %@info: diff --git a/matlab/@dynSeries/insert.m b/matlab/@dynSeries/insert.m index 7b6307deb..9dba32239 100644 --- a/matlab/@dynSeries/insert.m +++ b/matlab/@dynSeries/insert.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function ts = insert(ts,us,id) % Add a variable in a dynSeries object. diff --git a/matlab/@dynSeries/lag.m b/matlab/@dynSeries/lag.m index 918510af1..c82e26e03 100644 --- a/matlab/@dynSeries/lag.m +++ b/matlab/@dynSeries/lag.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function us = lag(ts,p) %@info: diff --git a/matlab/@dynSeries/merge.m b/matlab/@dynSeries/merge.m index e9f29611a..436a67aa8 100644 --- a/matlab/@dynSeries/merge.m +++ b/matlab/@dynSeries/merge.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = merge(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} merge (@var{B},@var{C}) diff --git a/matlab/@dynSeries/minus.m b/matlab/@dynSeries/minus.m index c7e4736db..3154a9f32 100644 --- a/matlab/@dynSeries/minus.m +++ b/matlab/@dynSeries/minus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = minus(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} minus (@var{B},@var{C}) diff --git a/matlab/@dynSeries/mrdivide.m b/matlab/@dynSeries/mrdivide.m index cabc91636..f05dc6eea 100644 --- a/matlab/@dynSeries/mrdivide.m +++ b/matlab/@dynSeries/mrdivide.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = mrdivide(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} mrdivide (@var{B},@var{C}) diff --git a/matlab/@dynSeries/mtimes.m b/matlab/@dynSeries/mtimes.m index b81cd4145..758342c72 100644 --- a/matlab/@dynSeries/mtimes.m +++ b/matlab/@dynSeries/mtimes.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = mtimes(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} mtimes (@var{B},@var{C}) diff --git a/matlab/@dynSeries/plus.m b/matlab/@dynSeries/plus.m index 10767f2e9..165039fc0 100644 --- a/matlab/@dynSeries/plus.m +++ b/matlab/@dynSeries/plus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = plus(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} plus (@var{B},@var{C}) diff --git a/matlab/@dynSeries/pop.m b/matlab/@dynSeries/pop.m index b6c178ed0..c242af042 100644 --- a/matlab/@dynSeries/pop.m +++ b/matlab/@dynSeries/pop.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function [ts,id] = pop(ts,a) % Removes a variable from a dynSeries object. diff --git a/matlab/@dynSeries/private/default_name.m b/matlab/@dynSeries/private/default_name.m new file mode 100644 index 000000000..1711195c4 --- /dev/null +++ b/matlab/@dynSeries/private/default_name.m @@ -0,0 +1,27 @@ +function names = default_name(dim) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + + +names = {}; +for i=1:dim + names = vertcat(names, {['Variable_' int2str(i)]}); +end + + + diff --git a/matlab/@dynSeries/qdiff.m b/matlab/@dynSeries/qdiff.m index e11dd3b5f..528cbd95b 100644 --- a/matlab/@dynSeries/qdiff.m +++ b/matlab/@dynSeries/qdiff.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function us = qdiff(ts) %@info: diff --git a/matlab/@dynSeries/qgrowth.m b/matlab/@dynSeries/qgrowth.m index 8823e70ca..6ed395efc 100644 --- a/matlab/@dynSeries/qgrowth.m +++ b/matlab/@dynSeries/qgrowth.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function us = qgrowth(ts) %@info: diff --git a/matlab/@dynSeries/rename.m b/matlab/@dynSeries/rename.m index 80b391d63..005cc1985 100644 --- a/matlab/@dynSeries/rename.m +++ b/matlab/@dynSeries/rename.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function ts = rename(ts,old,new) % Copyright (C) 2013 Dynare Team diff --git a/matlab/@dynSeries/save.m b/matlab/@dynSeries/save.m index a399a8a95..ff3269a96 100644 --- a/matlab/@dynSeries/save.m +++ b/matlab/@dynSeries/save.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function save(A,basename,format) % Saves a dynSeries object on disk. diff --git a/matlab/@dynSeries/set_names.m b/matlab/@dynSeries/set_names.m index bee843788..b316c090e 100644 --- a/matlab/@dynSeries/set_names.m +++ b/matlab/@dynSeries/set_names.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = set_names(B,varargin) %@info: diff --git a/matlab/@dynSeries/subsasgn.m b/matlab/@dynSeries/subsasgn.m index b91ee5e77..fbc4d09c9 100644 --- a/matlab/@dynSeries/subsasgn.m +++ b/matlab/@dynSeries/subsasgn.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = subsasgn(A,S,B) %@info: diff --git a/matlab/@dynSeries/subsref.m b/matlab/@dynSeries/subsref.m index 159bb0f9a..866b20058 100644 --- a/matlab/@dynSeries/subsref.m +++ b/matlab/@dynSeries/subsref.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function B = subsref(A, S) %@info: %! @deftypefn {Function File} {@var{us} =} subsref (@var{ts},S) diff --git a/matlab/@dynSeries/tex_rename.m b/matlab/@dynSeries/tex_rename.m index 1a8a569cb..7b3da171f 100644 --- a/matlab/@dynSeries/tex_rename.m +++ b/matlab/@dynSeries/tex_rename.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function ts = tex_rename(ts, varargin) % Copyright (C) 2013 Dynare Team diff --git a/matlab/@dynSeries/uminus.m b/matlab/@dynSeries/uminus.m index a8a6100f8..3a4b0a8b0 100644 --- a/matlab/@dynSeries/uminus.m +++ b/matlab/@dynSeries/uminus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = uminus(B) %@info: %! @deftypefn {Function File} {@var{A} =} plus (@var{B},@var{C}) diff --git a/matlab/@dynSeries/vertcat.m b/matlab/@dynSeries/vertcat.m index 53eb4774d..a2a909479 100644 --- a/matlab/@dynSeries/vertcat.m +++ b/matlab/@dynSeries/vertcat.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function a = vertcat(varargin) %@info: @@ -30,7 +31,7 @@ function a = vertcat(varargin) %! @end deftypefn %@eod: -% Copyright (C) 2011-2013 Dynare Team +% Copyright (C) 2013 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/@dynSeries/ydiff.m b/matlab/@dynSeries/ydiff.m index fbaa0489c..d4ac43d04 100644 --- a/matlab/@dynSeries/ydiff.m +++ b/matlab/@dynSeries/ydiff.m @@ -1,4 +1,4 @@ - +% --*-- Unitary tests --*-- function us = ydiff(ts) %@info: diff --git a/matlab/@dynSeries/ygrowth.m b/matlab/@dynSeries/ygrowth.m index 32a7161ef..78df1d1cc 100644 --- a/matlab/@dynSeries/ygrowth.m +++ b/matlab/@dynSeries/ygrowth.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function us = ygrowth(ts) %@info: diff --git a/matlab/cycle_reduction.m b/matlab/cycle_reduction.m index 04fca27a7..1449e2a52 100644 --- a/matlab/cycle_reduction.m +++ b/matlab/cycle_reduction.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch) %@info: @@ -43,7 +44,7 @@ function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch) %! @end deftypefn %@eod: -% Copyright (C) 2012 Dynare Team +% Copyright (C) 2013 Dynare Team % % This file is part of Dynare. % @@ -112,23 +113,39 @@ if (nargin == 5 && ~isempty(ch) ) end %@test:1 -%$ addpath ../matlab %$ -%$ % Set the dimension of the problem to be solved +%$ t = zeros(3,1); +%$ +%$ % Set the dimension of the problem to be solved. %$ n = 2000; +%$ %$ % Set the equation to be solved %$ A = eye(n); %$ B = diag(30*ones(n,1)); B(1,1) = 20; B(end,end) = 20; B = B - diag(10*ones(n-1,1),-1); B = B - diag(10*ones(n-1,1),1); %$ C = diag(15*ones(n,1)); C = C - diag(5*ones(n-1,1),-1); C = C - diag(5*ones(n-1,1),1); %$ %$ % Solve the equation with the cycle reduction algorithm -%$ tic, X1 = cycle_reduction(C,B,A,1e-7); toc +%$ try +%$ t=cputime; X1 = cycle_reduction(C,B,A,1e-7); elapsedtime = cputime-t; +%$ disp(['cputime for cycle reduction algorithm is: ' num2str(elapsedtime) ' (n=' int2str(n) ').']) +%$ t(1) = 1; +%$ catch +%$ % nothing to do here. +%$ end %$ %$ % Solve the equation with the logarithmic reduction algorithm -%$ tic, X2 = logarithmic_reduction(A,B,C,1e-16,100); toc +%$ try +%$ t=cputime; X2 = logarithmic_reduction(A,B,C,1e-16,100); elapsedtime = cputime-t; +%$ disp(['cputime for logarithmic reduction algorithm is: ' num2str(elapsedtime) ' (n=' int2str(n) ').']) +%$ t(2) = 1; +%$ catch +%$ % nothing to do here. +%$ end %$ %$ % Check the results. -%$ t(1) = dyn_assert(X1,X2,1e-12); +%$ if t(1) && t(2) +%$ t(3) = dyn_assert(X1,X2,1e-12); +%$ end %$ %$ T = all(t); %@eof:1 \ No newline at end of file diff --git a/matlab/name2tex.m b/matlab/name2tex.m deleted file mode 100644 index ed8b259e5..000000000 --- a/matlab/name2tex.m +++ /dev/null @@ -1,103 +0,0 @@ -function tex = name2tex(name, info) -% Converts plain text name into tex name. - -% Copyright (C) 2013 Dynare Team -% -% This file is part of Dynare. -% -% Dynare is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% Dynare is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with Dynare. If not, see . - -if nargin<2 - info = 0; -end - -id = findstr('_',name); -if isempty(id) - tex = name; - return -end - -if info - tex = name; - n = length(id); - if id(1)==1 - tex = ['\_', tex(2:end)]; - if n>1 - id = id(2:end)+1; - n = n-1; - else - return - end - end - if id(end)==length(tex) - tex = [tex(1:end-1) '\_']; - if n>1 - id = id(1:end-1); - n = n-1; - else - return - end - end - if n==1 - tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ]; - return - else - for i=1:n-1 - tex = [tex(1:id(1)-1) '\_' tex((id(1)+1):end)]; - id = id(2:end)+1; - end - tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}']; - end -else - tex = strrep(name, '_', '\_'); -end - -%@test:1 -%$ t = zeros(16,1); -%$ t1 = name2tex('_azert'); -%$ t2 = name2tex('azert_'); -%$ t3 = name2tex('_azert_'); -%$ t4 = name2tex('azert_uiop'); -%$ t5 = name2tex('azert_uiop_qsdfg'); -%$ t6 = name2tex('azert_uiop_qsdfg_'); -%$ t7 = name2tex('_azert_uiop_qsdfg'); -%$ t8 = name2tex('_azert_uiop_qsdfg_'); -%$ t11 = name2tex('_azert',1); -%$ t12 = name2tex('azert_',1); -%$ t13 = name2tex('_azert_',1); -%$ t14 = name2tex('azert_uiop',1); -%$ t15 = name2tex('azert_uiop_qsdfg',1); -%$ t16 = name2tex('azert_uiop_qsdfg_',1); -%$ t17 = name2tex('_azert_uiop_qsdfg',1); -%$ t18 = name2tex('_azert_uiop_qsdfg_',1); -%$ -%$ t(1) = dyn_assert(strcmp(t1,'\\_azert'),1); -%$ t(2) = dyn_assert(strcmp(t2,'azert\\_'),1); -%$ t(3) = dyn_assert(strcmp(t3,'\\_azert\\_'),1); -%$ t(4) = dyn_assert(strcmp(t4,'azert\\_uiop'),1); -%$ t(5) = dyn_assert(strcmp(t5,'azert\\_uiop\\_qsdfg'),1); -%$ t(6) = dyn_assert(strcmp(t6,'azert\\_uiop\\_qsdfg\\_'),1); -%$ t(7) = dyn_assert(strcmp(t7,'\\_azert\\_uiop\\_qsdfg'),1); -%$ t(8) = dyn_assert(strcmp(t8,'\\_azert\\_uiop\\_qsdfg\\_'),1); -%$ t(9) = dyn_assert(strcmp(t11,'\\_azert'),1); -%$ t(10) = dyn_assert(strcmp(t12,'azert\\_'),1); -%$ t(11) = dyn_assert(strcmp(t13,'\\_azert\\_'),1); -%$ t(12) = dyn_assert(strcmp(t14,'azert_{uiop}'),1); -%$ t(13) = dyn_assert(strcmp(t15,'azert\\_uiop_{qsdfg}'),1); -%$ t(14) = dyn_assert(strcmp(t16,'azert\\_uiop_{qsdfg\\_}'),1); -%$ t(15) = dyn_assert(strcmp(t17,'\\_azert\\_uiop_{qsdfg}'),1); -%$ t(16) = dyn_assert(strcmp(t18,'\\_azert\\_uiop_{qsdfg\\_}'),1); -%$ -%$ T = all(t); -%@eof:1 \ No newline at end of file diff --git a/matlab/utilities/general/name2tex.m b/matlab/utilities/general/name2tex.m new file mode 100644 index 000000000..b95807e4d --- /dev/null +++ b/matlab/utilities/general/name2tex.m @@ -0,0 +1,218 @@ +% --*-- Unitary tests --*-- +function tex = name2tex(name, info) +% Converts plain text name into tex name. + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +if nargin<2 + info = 0; +end + +if iscell(name) + nn = length(name); + id = findstr(cell2mat(transpose(name)),'_'); +else + nn = 1; + id = findstr(name,'_'); +end + +if isempty(id) + tex = name; + return +end + +if iscell(name) + tex = cell(nn,1); +end + +for i=1:nn + if info + if iscell(name) + tex(i) = {name{i}}; + id = findstr(name{i},'_'); + len = length(tex{i}); + else + tex = name; + id = findstr(name,'_'); + len = length(tex); + end + n = length(id); + if id(1)==1 + if iscell(name) + tex(i) = {['\_', tex{i}(2:end)]}; + else + tex = ['\_', tex(2:end)]; + end + if n>1 + id = id(2:end)+1; + n = n-1; + len = len+1; + else + continue + end + end + if id(end)==len + if iscell(name) + tex(i) = {[tex{i}(1:end-1) '\_']}; + else + tex = [tex(1:end-1) '\_']; + end + if n>1 + id = id(1:end-1); + n = n-1; + else + continue + end + end + if n==1 + if iscell(name) + tex(i) = {[ tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}' ]}; + else + tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ]; + end + continue + else + for j=1:n-1 + if iscell(name) + tex(i) = {[tex{i}(1:id(j)-1) '\_' tex{i}((id(j)+1):end)]}; + else + tex = [tex(1:id(j)-1) '\_' tex((id(j)+1):end)]; + end + id = id(2:end)+1; + end + if iscell(name) + tex(i) = {[tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}']}; + else + tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}']; + end + end + else + if iscell(name) + tex(i) = {strrep(name{i}, '_', '\_')}; + else + tex = strrep(name, '_', '\_'); + end + end +end + +%@test:1 +%$ t = zeros(16,1); +%$ t1 = name2tex('_azert'); +%$ t2 = name2tex('azert_'); +%$ t3 = name2tex('_azert_'); +%$ t4 = name2tex('azert_uiop'); +%$ t5 = name2tex('azert_uiop_qsdfg'); +%$ t6 = name2tex('azert_uiop_qsdfg_'); +%$ t7 = name2tex('_azert_uiop_qsdfg'); +%$ t8 = name2tex('_azert_uiop_qsdfg_'); +%$ t11 = name2tex('_azert',1); +%$ t12 = name2tex('azert_',1); +%$ t13 = name2tex('_azert_',1); +%$ t14 = name2tex('azert_uiop',1); +%$ t15 = name2tex('azert_uiop_qsdfg',1); +%$ t16 = name2tex('azert_uiop_qsdfg_',1); +%$ t17 = name2tex('_azert_uiop_qsdfg',1); +%$ t18 = name2tex('_azert_uiop_qsdfg_',1); +%$ +%$ t(1) = dyn_assert(strcmp(t1,'\\_azert'),1); +%$ t(2) = dyn_assert(strcmp(t2,'azert\\_'),1); +%$ t(3) = dyn_assert(strcmp(t3,'\\_azert\\_'),1); +%$ t(4) = dyn_assert(strcmp(t4,'azert\\_uiop'),1); +%$ t(5) = dyn_assert(strcmp(t5,'azert\\_uiop\\_qsdfg'),1); +%$ t(6) = dyn_assert(strcmp(t6,'azert\\_uiop\\_qsdfg\\_'),1); +%$ t(7) = dyn_assert(strcmp(t7,'\\_azert\\_uiop\\_qsdfg'),1); +%$ t(8) = dyn_assert(strcmp(t8,'\\_azert\\_uiop\\_qsdfg\\_'),1); +%$ t(9) = dyn_assert(strcmp(t11,'\\_azert'),1); +%$ t(10) = dyn_assert(strcmp(t12,'azert\\_'),1); +%$ t(11) = dyn_assert(strcmp(t13,'\\_azert\\_'),1); +%$ t(12) = dyn_assert(strcmp(t14,'azert_{uiop}'),1); +%$ t(13) = dyn_assert(strcmp(t15,'azert\\_uiop_{qsdfg}'),1); +%$ t(14) = dyn_assert(strcmp(t16,'azert\\_uiop_{qsdfg\\_}'),1); +%$ t(15) = dyn_assert(strcmp(t17,'\\_azert\\_uiop_{qsdfg}'),1); +%$ t(16) = dyn_assert(strcmp(t18,'\\_azert\\_uiop_{qsdfg\\_}'),1); +%$ +%$ T = all(t); +%@eof:1 + +%@test:2 +%$ t = zeros(16,1); +%$ t1 = name2tex({'_azert'}); +%$ t2 = name2tex({'azert_'}); +%$ t3 = name2tex({'_azert_'}); +%$ t4 = name2tex({'azert_uiop'}); +%$ t5 = name2tex({'azert_uiop_qsdfg'}); +%$ t6 = name2tex({'azert_uiop_qsdfg_'}); +%$ t7 = name2tex({'_azert_uiop_qsdfg'}); +%$ t8 = name2tex({'_azert_uiop_qsdfg_'}); +%$ t11 = name2tex({'_azert'},1); +%$ t12 = name2tex({'azert_'},1); +%$ t13 = name2tex({'_azert_'},1); +%$ t14 = name2tex({'azert_uiop'},1); +%$ t15 = name2tex({'azert_uiop_qsdfg'},1); +%$ t16 = name2tex({'azert_uiop_qsdfg_'},1); +%$ t17 = name2tex({'_azert_uiop_qsdfg'},1); +%$ t18 = name2tex({'_azert_uiop_qsdfg_'},1); +%$ +%$ t(1) = dyn_assert(t1,{'\\_azert'}); +%$ t(2) = dyn_assert(t2,{'azert\\_'}); +%$ t(3) = dyn_assert(t3,{'\\_azert\\_'}); +%$ t(4) = dyn_assert(t4,{'azert\\_uiop'}); +%$ t(5) = dyn_assert(t5,{'azert\\_uiop\\_qsdfg'}); +%$ t(6) = dyn_assert(t6,{'azert\\_uiop\\_qsdfg\\_'}); +%$ t(7) = dyn_assert(t7,{'\\_azert\\_uiop\\_qsdfg'}); +%$ t(8) = dyn_assert(t8,{'\\_azert\\_uiop\\_qsdfg\\_'}); +%$ t(9) = dyn_assert(t11,{'\\_azert'}); +%$ t(10) = dyn_assert(t12,{'azert\\_'}); +%$ t(11) = dyn_assert(t13,{'\\_azert\\_'}); +%$ t(12) = dyn_assert(t14,{'azert_{uiop}'}); +%$ t(13) = dyn_assert(t15,{'azert\\_uiop_{qsdfg}'}); +%$ t(14) = dyn_assert(t16,{'azert\\_uiop_{qsdfg\\_}'}); +%$ t(15) = dyn_assert(t17,{'\\_azert\\_uiop_{qsdfg}'}); +%$ t(16) = dyn_assert(t18,{'\\_azert\\_uiop_{qsdfg\\_}'}); +%$ +%$ T = all(t); +%@eof:2 + +%@test:3 +%$ t = zeros(4,1); +%$ try +%$ t1 = name2tex({'_azert';'azert_';'_azert_';'azert_uiop';'azert_uiop_qsdfg';'azert_uiop_qsdfg_'}); +%$ t(1) = 1; +%$ catch +%$ % Nothing to do here. +%$ end +%$ +%$ if t(1) +%$ try +%$ t2 = name2tex({'_azert';'azert_';'_azert_';'azert_uiop';'azert_uiop_qsdfg';'azert_uiop_qsdfg_'},1); +%$ t(2) = 1; +%$ catch +%$ % Nothing to do here. +%$ end +%$ end +%$ +%$ if t(1) +%$ t(3) = dyn_assert(t1,{'\\_azert';'azert\\_';'\\_azert\\_';'azert\\_uiop';'azert\\_uiop\\_qsdfg';'azert\\_uiop\\_qsdfg\\_'}); +%$ end +%$ +%$ if t(2) +%$ t(4) = dyn_assert(t2,{'\\_azert';'azert\\_';'\\_azert\\_';'azert_{uiop}';'azert\\_uiop_{qsdfg}';'azert\\_uiop_{qsdfg\\_}'}); +%$ end +%$ +%$ T = all(t); +%@eof:3 \ No newline at end of file diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m new file mode 100644 index 000000000..9e2fc0eae --- /dev/null +++ b/matlab/utilities/tests/build_report_summary.m @@ -0,0 +1,101 @@ +function str = build_report_summary(reportfile, printonscreen, mailreport) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +if isequal(nargin,1) + printonscreen = 1; + mailreport = 0; +end + +if nargin<3 + mailreport = 0; +else + if ischar(mailreport) + mailto = mailreport; + mailreport = 1; + fid = fopen('~/.matlab-send-report'); + server = fgetl(fid); + fclose(fid); + fprintf('\n\n'); + disp('Send report...') + system(['scp ' reportfile ' ' server]); + system(['scp ' reportfile(1:end-3) 'log ' server]); + else + if ~isequal(mailreport,0) + error('build_report_summary:: Third argument must be an adress email!') + end + end +end + +reportfilecontent = load(reportfile); +reportcell = reportfilecontent.report; +gitinfo = reportfilecontent.gitinfo; +gitlastcommithash = reportfilecontent.gitlastcommithash; + +str = 'Hi,'; +str = char(str,''); +str = char(str,'This is a summary report for the unitary tests in Dynare. Full report can be found at'); +str = char(str,''); +str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile]); +str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile(1:end-3) 'log']); +str = char(str,''); +str = char(str,gitinfo(1,:)); +str = char(str,gitinfo(2,:)); + +str = char(str,''); +str = char(str,''); + +str = char(str,['===========================']); +str = char(str,'DYNARE/MATLAB UNITARY TESTS'); +str = char(str,'==========================='); +str = char(str,['| TOTAL: ' int2str(size(reportcell,1))]); +str = char(str,['| PASS: ' int2str(length(find(cell2mat(reportcell(:,3)))))]); +str = char(str,['| FAIL: ' int2str(length(find(~cell2mat(reportcell(:,3)))))]); +str = char(str,'|'); +str = char(str,'| LIST OF FAILED TESTS:'); +for i=1:size(reportcell,1) + if ~reportcell{i,3} + str = char(str,['| * ' reportcell{i,1} ' (test #' int2str(reportcell{i,2}) '{' strrep(int2str(transpose(find(~reportcell{i,4}))),' ',',') '})']); + end +end + +if printonscreen + fprintf('\n\n') + disp(str) + fprintf('\n\n') +end + +if mailreport + if exist('~/.matlab-send-mail-info','file') + fid = fopen('~/.matlab-send-mail-info','r'); + else + disp(['build_report_summary:: I Cannot send the report to ' mailto ' because the sender and the smtp server are not defined!']) + disp([' You probably need to add a ''.matlab-send-mail-info'' in your root directory...']) + return + end + setpref('Internet','SMTP_Server',fgetl(fid)); + setpref('Internet','SMTP_Username',fgetl(fid)); + setpref('Internet','E_mail',fgetl(fid)); + setpref('Internet','SMTP_Passeword',fgetl(fid)); + fclose(fid); + STR = [deblank(str(1,:))]; + for i=2:size(str,1) + STR = [STR 10 deblank(str(i,:)) ]; + end + sendmail(mailto,'Dynare/Matlab unitary tests',STR); +end \ No newline at end of file diff --git a/matlab/utilities/tests/get_directory_description.m b/matlab/utilities/tests/get_directory_description.m new file mode 100644 index 000000000..674af2f8a --- /dev/null +++ b/matlab/utilities/tests/get_directory_description.m @@ -0,0 +1,33 @@ +function flist = get_directory_description(basedir) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +dd = dir(basedir); +flist = {}; +file = 1; + +for f=1:length(dd) + if ~(isequal(dd(f).name,'.') || isequal(dd(f).name,'..')) + if dd(f).isdir + flist(file) = { get_directory_description([ basedir filesep dd(f).name]) }; + else + flist(file) = { [basedir filesep dd(f).name] }; + end + file = file + 1; + end +end \ No newline at end of file diff --git a/matlab/utilities/tests/is_unitary_test_available.m b/matlab/utilities/tests/is_unitary_test_available.m new file mode 100644 index 000000000..e4e34e08d --- /dev/null +++ b/matlab/utilities/tests/is_unitary_test_available.m @@ -0,0 +1,52 @@ +function info = is_unitary_test_available(fun) + +%@info: +%! @deftypefn {Function File} {@var{info} =} is_unitary_test_available (@var{fun}) +%! @anchor{is_unitary_test_available} +%! @sp 1 +%! Tests if matlab/octave routine @var{fun} has unitary tests. +%! @sp 2 +%! @strong{Inputs} +%! @sp 1 +%! @table @ @var +%! @item fun +%! string, name of the matlab/octave routine to be tested. +%! @end table +%! @sp 2 +%! @strong{Outputs} +%! @sp 1 +%! @table @ @var +%! @item info +%! Integer scalar equal to one if unitary tests are available, zero otherwise. +%! @end table +%! @sp 2 +%! @end deftypefn +%@eod: + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +info = 0; + +fid = fopen(fun,'r'); +first_line = fgetl(fid); + +if strcmp(first_line,'% --*-- Unitary tests --*--') + info = 1; +end + +fclose(fid); \ No newline at end of file diff --git a/matlab/utilities/tests/mtest.m b/matlab/utilities/tests/mtest.m index f12e4d9ff..ef325b99c 100644 --- a/matlab/utilities/tests/mtest.m +++ b/matlab/utilities/tests/mtest.m @@ -1,7 +1,7 @@ -function check = mtest(fname,fpath) +function [check, info] = mtest(fname, fpath) % Extract test sections from matlab's routine executes the test and report errors. -% Copyright (C) 2011-2012 Dynare Team +% Copyright (C) 2011-2013 Dynare Team % % This file is part of Dynare. % @@ -24,7 +24,17 @@ function check = mtest(fname,fpath) check = 1; % Open the matlab file. -fid = fopen([fpath '/' fname '.m'],'r'); +if nargin<2 || isempty(fpath) + if nargout<2 + error('mtest:: Wrong calling sequence!') + end + % The full path to the matlab routine (with extension) is given. + fid = fopen(fname,'r'); + [junk, FNAME, vessel] = fileparts(fname); +else + fid = fopen([fpath '/' fname '.m'],'r'); + FNAME = fname; +end % Read the matlab file. file = textscan(fid,'%s','delimiter','\n'); @@ -42,11 +52,25 @@ if length(b1)-length(b2) error('test:: There is a problem with the test blocks definition!') end +% Initialize the second output if necessary. +if nargout>1 + % First column name of the tested routine. + % Second column number of the unitary test. + % Third column status of the unitary test (0 if the test fails, 1 otherwise) + % Fourth column details about the failure (vector of integers) + % Fifth column elapsed time in seconds (cpu time). + info = cell(nn,4); +end + % Perform the tests. for i=1:nn + if nargout>1 + info(i,1) = {fname}; + info(i,2) = {i}; + end % Write the temporary test routine. - tid = fopen([fname '_test_' int2str(i) '.m'],'w'); - fprintf(tid,['function [T,t,LOG] = ' fname '_test_' int2str(i) '()\n']); + tid = fopen([FNAME '_test_' int2str(i) '.m'],'w'); + fprintf(tid,['function [T,t,LOG] = ' FNAME '_test_' int2str(i) '()\n']); fprintf(tid,['try\n']); for j=b1(i):b2(i) str = file{j}; @@ -60,24 +84,43 @@ for i=1:nn fprintf(tid,['end\n']); fclose(tid); % Call the temporary test routine. - [TestFlag,TestDetails,LOG] = feval([fname '_test_' int2str(i)]); + init = cputime; + [TestFlag,TestDetails,LOG] = feval([FNAME '_test_' int2str(i)]); + time = cputime-init; if isnan(TestFlag) fprintf(['\n']) - fprintf(['Call to ' fname ' test routine n°' int2str(i) ' failed (' datestr(now) ')!\n']) + fprintf(['Call to ' FNAME ' test routine n°' int2str(i) ' failed (' datestr(now) ')!\n']) fprintf(['\n']) disp(LOG) check = 0; + if nargout>1 + info(i,3) = {0}; + end continue end if ~TestFlag - fprintf(['Test n°' int2str(i) ' for routine ' fname ' failed (' datestr(now) ')!\n']); + if nargout>1 + info(i,3) = {0}; + tmp = ones(length(TestDetails),1); + end + fprintf(['Test n°' int2str(i) ' for routine ' FNAME ' failed (' datestr(now) ')!\n']); for j=1:length(TestDetails) if ~TestDetails(j) + if nargout>1 + tmp(j) = 0; + end fprintf(['Output argument n°' int2str(j) ' didn''t give the expected result.\n']); end end + info(i,4) = {tmp}; + info(i,5) = {NaN}; check = 0; else - delete([fname '_test_' int2str(i) '.m']) + if nargout>1 + info(i,3) = {1}; + info(i,4) = {ones(length(TestDetails),1)}; + info(i,5) = {time}; + end + delete([FNAME '_test_' int2str(i) '.m']) end end \ No newline at end of file diff --git a/matlab/utilities/tests/run_unitary_tests.m b/matlab/utilities/tests/run_unitary_tests.m new file mode 100644 index 000000000..86885f880 --- /dev/null +++ b/matlab/utilities/tests/run_unitary_tests.m @@ -0,0 +1,41 @@ +function [report, time] = run_unitary_tests(listoffiles) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +report = {}; + +for f=1:length(listoffiles) + if iscell(listoffiles{f}) + info = run_unitary_tests(listoffiles{f}); + report = [report; info]; + else + if isequal(listoffiles{f}(end-1:end),'.m') && isempty(strfind(listoffiles{f},'.#')) + if is_unitary_test_available(listoffiles{f}) + disp(['***** Process unitary tests in ' listoffiles{f}]) + [check, info] = mtest(listoffiles{f}); + report = [report; info]; + else + disp(['Booh! No unitary tests available in ' listoffiles{f}]) + end + end + end +end + +if nargout>1 + time = clock; +end \ No newline at end of file diff --git a/matlab/utilities/tests/run_unitary_tests_in_directory.m b/matlab/utilities/tests/run_unitary_tests_in_directory.m new file mode 100644 index 000000000..ef2499eb5 --- /dev/null +++ b/matlab/utilities/tests/run_unitary_tests_in_directory.m @@ -0,0 +1,47 @@ +function report = run_unitary_tests_in_directory(dirname,savereport,printreport,sendreport) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +system('git show --pretty=format:"Last commit %H by %an, %ar %n-> %s" HEAD > git.info'); +system('git rev-parse HEAD > git.last-commit-hash'); + +fid = fopen('git.info'); +gitinfo = fgetl(fid); +gitinfo = char(gitinfo,fgetl(fid)); +fclose(fid); + +fid = fopen('git.last-commit-hash'); +gitlastcommithash = fgetl(fid); +fclose(fid); + +matlabverion = version; +platform = computer; + +listoffiles = get_directory_description(dirname); + +diary(['report-' gitlastcommithash '.log'] ) +[report, time] = run_unitary_tests(listoffiles) +diary off + +if nargin>1 && savereport>0 + save(['report-' gitlastcommithash '.mat'],'report','time','gitinfo','gitlastcommithash','matlabverion','platform'); +end + +if nargin>2 + build_report_summary(['report-' gitlastcommithash '.mat'], printreport, sendreport); +end \ No newline at end of file