Allow Octave modules to be re-loaded after a "clear all" (thanks to Karl Wette; SF 3418908)

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12824 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Xavier Delacour 2011-10-13 23:48:28 +00:00
commit f8774be92d
8 changed files with 196 additions and 17 deletions

View file

@ -5,6 +5,7 @@
1;
##### BEGIN TEST #####
function func
example
global cvar
@ -21,3 +22,38 @@ func
example
global cvar
assert(cvar.ivar == example.ifunc())
##### END TEST #####
# clearing a module results in a segfault for Octave <= 3.0.*
# (tested on Octave 3.0.5), so skip the following test
try
vers = cellfun("str2num", strsplit(OCTAVE_VERSION, "."));
catch
vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, ".")));
end_try_catch
assert(length(vers) >= 2);
if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0)
disp("skipping 'clear all' test");
return
endif
clear all;
##### BEGIN TEST #####
function func
example
global cvar
assert(cvar.ivar == example.ifunc())
endfunction
# test loading in a function
func
# test a second time to check everything works
func
# test that everything works from the base context
example
global cvar
assert(cvar.ivar == example.ifunc())
##### END TEST #####