Modify octave exception checking test to take account of newlines being added in older (3.0) versions, but not in newer (3.2) versions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12483 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
95de0a3437
commit
964532ed86
1 changed files with 13 additions and 15 deletions
|
|
@ -1,44 +1,42 @@
|
||||||
exception_order
|
exception_order
|
||||||
|
|
||||||
|
function check_lasterror(expected)
|
||||||
|
if (!strcmp(lasterror.message, expected))
|
||||||
|
# Take account of older versions adding a newline at the end
|
||||||
|
if (!strcmp(regexprep(lasterror.message, '(.*)\n$', '$1'), expected))
|
||||||
|
error(["Bad exception order. Expected: \"", expected, "\" Got: \"", lasterror.message, "\""])
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
a = A();
|
a = A();
|
||||||
|
|
||||||
try
|
try
|
||||||
a.foo()
|
a.foo()
|
||||||
catch
|
catch
|
||||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
|
check_lasterror("error: C++ side threw an exception of type E1")
|
||||||
error("bad exception order")
|
|
||||||
endif
|
|
||||||
end_try_catch
|
end_try_catch
|
||||||
|
|
||||||
try
|
try
|
||||||
a.bar()
|
a.bar()
|
||||||
catch
|
catch
|
||||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2\n"))
|
check_lasterror("error: C++ side threw an exception of type E2")
|
||||||
error("bad exception order")
|
|
||||||
endif
|
|
||||||
end_try_catch
|
end_try_catch
|
||||||
|
|
||||||
try
|
try
|
||||||
a.foobar()
|
a.foobar()
|
||||||
catch
|
catch
|
||||||
if (!strcmp(lasterror.message, "error: postcatch unknown (SWIG_RuntimeError)\n"))
|
check_lasterror("error: postcatch unknown (SWIG_RuntimeError)")
|
||||||
error("bad exception order")
|
|
||||||
endif
|
|
||||||
end_try_catch
|
end_try_catch
|
||||||
|
|
||||||
try
|
try
|
||||||
a.barfoo(1)
|
a.barfoo(1)
|
||||||
catch
|
catch
|
||||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
|
check_lasterror("error: C++ side threw an exception of type E1")
|
||||||
error("bad exception order")
|
|
||||||
endif
|
|
||||||
end_try_catch
|
end_try_catch
|
||||||
|
|
||||||
try
|
try
|
||||||
a.barfoo(2)
|
a.barfoo(2)
|
||||||
catch
|
catch
|
||||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2 *\n"))
|
check_lasterror("error: C++ side threw an exception of type E2 *")
|
||||||
error("bad exception order")
|
|
||||||
endif
|
|
||||||
end_try_catch
|
end_try_catch
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue