Reindentation of Octave code

time-shift
Sébastien Villemot 2012-04-06 21:53:50 +02:00
parent e7369c3691
commit 5696dadf27
1 changed files with 116 additions and 116 deletions

View File

@ -27,7 +27,7 @@ addpath([top_test_dir '/../matlab']);
## Test Dynare Version ## Test Dynare Version
if !strcmp(dynare_version(), getenv("DYNARE_VERSION")) if !strcmp(dynare_version(), getenv("DYNARE_VERSION"))
error("Incorrect version of Dynare is being tested") error("Incorrect version of Dynare is being tested")
endif endif
## Ask gnuplot to create graphics in text mode ## Ask gnuplot to create graphics in text mode
@ -41,25 +41,25 @@ name = strsplit(getenv("MODFILES"), " ");
failedBase = {}; failedBase = {};
for i=1:size(name,2) for i=1:size(name,2)
[directory, testfile, ext] = fileparts([top_test_dir '/' name{i}]); [directory, testfile, ext] = fileparts([top_test_dir '/' name{i}]);
cd(directory); cd(directory);
printf("\n*** TESTING: %s ***\n", name{i}); printf("\n*** TESTING: %s ***\n", name{i});
try try
old_path = path; old_path = path;
save wsOct save wsOct
dynare([testfile ext]) dynare([testfile ext])
clear -all clear -all
load wsOct load wsOct
path(old_path); path(old_path);
catch catch
clear -all clear -all
load wsOct load wsOct
path(old_path); path(old_path);
failedBase{size(failedBase,2)+1} = name{i}; failedBase{size(failedBase,2)+1} = name{i};
printMakeCheckOctaveErrMsg(name{i}, lasterror); printMakeCheckOctaveErrMsg(name{i}, lasterror);
end_try_catch end_try_catch
delete('wsOct'); delete('wsOct');
cd(top_test_dir); cd(top_test_dir);
end end
## Test block_bytecode/ls2003.mod with various combinations of ## Test block_bytecode/ls2003.mod with various combinations of
@ -68,88 +68,88 @@ failedBlock = {};
num_block_tests = 0; num_block_tests = 0;
cd([top_test_dir '/block_bytecode']); cd([top_test_dir '/block_bytecode']);
for blockFlag = 0:1 for blockFlag = 0:1
for bytecodeFlag = 0:1 for bytecodeFlag = 0:1
## Recall that solve_algo=7 and stack_solve_algo=2 are not supported ## Recall that solve_algo=7 and stack_solve_algo=2 are not supported
## under Octave ## under Octave
default_solve_algo = 2; default_solve_algo = 2;
default_stack_solve_algo = 0; default_stack_solve_algo = 0;
if !blockFlag && !bytecodeFlag if !blockFlag && !bytecodeFlag
solve_algos = 0:4; solve_algos = 0:4;
stack_solve_algos = 0; stack_solve_algos = 0;
elseif blockFlag && !bytecodeFlag elseif blockFlag && !bytecodeFlag
solve_algos = [0:4 6 8]; solve_algos = [0:4 6 8];
stack_solve_algos = [0 1 3 4]; stack_solve_algos = [0 1 3 4];
else else
solve_algos = [0:6 8]; solve_algos = [0:6 8];
stack_solve_algos = [0 1 3:5]; stack_solve_algos = [0 1 3:5];
endif
for i = 1:length(solve_algos)
num_block_tests = num_block_tests + 1;
if !blockFlag && !bytecodeFlag && (i == 1)
## This is the reference simulation path against which all
## other simulations will be tested
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
load wsOct
path(old_path);
y_ref = oo_.endo_simul;
save('test.mat','y_ref');
catch
load wsOct
path(old_path);
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror);
end_try_catch
else
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
load wsOct
path(old_path);
## Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
differr.message = ["ERROR: simulation path differs from the reference path" ];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], differr);
endif
catch
load wsOct
path(old_path);
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror);
end_try_catch
endif
endfor
for i = 1:length(stack_solve_algos)
num_block_tests = num_block_tests + 1;
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, default_solve_algo, stack_solve_algos(i))
load wsOct
path(old_path);
## Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(default_solve_algo) ', ' num2str(stack_solve_algos(i)) ')'];
differr.message = ["ERROR: simulation path differs from the reference path" ];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(default_solve_algo) ', ' num2str(stack_solve_algos(i)) ')'], differr);
endif endif
catch
load wsOct for i = 1:length(solve_algos)
path(old_path); num_block_tests = num_block_tests + 1;
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')']; if !blockFlag && !bytecodeFlag && (i == 1)
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror); ## This is the reference simulation path against which all
end_try_catch ## other simulations will be tested
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
load wsOct
path(old_path);
y_ref = oo_.endo_simul;
save('test.mat','y_ref');
catch
load wsOct
path(old_path);
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror);
end_try_catch
else
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
load wsOct
path(old_path);
## Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
differr.message = ["ERROR: simulation path differs from the reference path" ];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], differr);
endif
catch
load wsOct
path(old_path);
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror);
end_try_catch
endif
endfor
for i = 1:length(stack_solve_algos)
num_block_tests = num_block_tests + 1;
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, default_solve_algo, stack_solve_algos(i))
load wsOct
path(old_path);
## Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(default_solve_algo) ', ' num2str(stack_solve_algos(i)) ')'];
differr.message = ["ERROR: simulation path differs from the reference path" ];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(default_solve_algo) ', ' num2str(stack_solve_algos(i)) ')'], differr);
endif
catch
load wsOct
path(old_path);
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror);
end_try_catch
endfor
endfor endfor
endfor
endfor endfor
delete('wsOct'); delete('wsOct');
@ -158,7 +158,7 @@ cd(top_test_dir);
total_tests = size(name,2)+num_block_tests; total_tests = size(name,2)+num_block_tests;
% print output to screen and to file % print output to screen and to file
fid = fopen("run_test_octave_output.txt", "w"); fid = fopen("run_test_octave_output.txt", "w");
printf("\n\n\n"); printf("\n\n\n");
@ -176,22 +176,22 @@ fprintf(fid," %d tests PASSED out of %d tests run\n", total_tests-size(failedBas
printf("***************************************\n"); printf("***************************************\n");
fprintf(fid,"***************************************\n"); fprintf(fid,"***************************************\n");
if size(failedBase,2) > 0 || size(failedBlock,2) > 0 if size(failedBase,2) > 0 || size(failedBlock,2) > 0
printf("List of %d tests FAILED:\n", size(failedBase,2)+size(failedBlock,2)); printf("List of %d tests FAILED:\n", size(failedBase,2)+size(failedBlock,2));
fprintf(fid,"List of %d tests FAILED:\n", size(failedBase,2)+size(failedBlock,2)); fprintf(fid,"List of %d tests FAILED:\n", size(failedBase,2)+size(failedBlock,2));
for i=1:size(failedBase,2) for i=1:size(failedBase,2)
printf(" * %s\n",failedBase{i}); printf(" * %s\n",failedBase{i});
fprintf(fid," * %s\n", failedBase{i}); fprintf(fid," * %s\n", failedBase{i});
end end
for i=1:size(failedBlock,2) for i=1:size(failedBlock,2)
printf(" * %s\n",failedBlock{i}); printf(" * %s\n",failedBlock{i});
fprintf(fid," * %s\n", failedBlock{i}); fprintf(fid," * %s\n", failedBlock{i});
end end
printf("***************************************\n\n"); printf("***************************************\n\n");
fprintf(fid,"***************************************\n\n"); fprintf(fid,"***************************************\n\n");
fclose(fid); fclose(fid);
error("make check-octave FAILED"); error("make check-octave FAILED");
else else
fclose(fid); fclose(fid);
endif endif
## Local variables: ## Local variables: