packages-cpp
packages-cpp copied to clipboard
example average/3 does not clear exceptions
Running the tests with
$HOME//src/swipl-devel/build/src/swipl "-p" "foreign=" "-f" "none" "--no-packs" "--on-error=status" "-s" "$HOME/src/swipl-devel/packages/cpp/test_cpp.pl"
?- average(X, foo(X), Average).
ERROR: Unknown procedure: foo/1
ERROR: In:
ERROR: [13] foo(_6142)
ERROR: [12] call(user:foo(_6176)) at /home/peter/src/swipl-devel/build/home/boot/init.pl:500
ERROR: [11] <meta call>
ERROR: [10] average(_6224,foo(_6232),_6228) <foreign>
ERROR: [9] toplevel_call(user:user: ...) at /home/peter/src/swipl-devel/build/home/boot/toplevel.pl:1173
Exception: (13) foo(_5138) ? l
Thread 1 (main): foreign predicate average/3 did not clear exception:
error(existence_error(procedure,foo/1),context(prolog_stack([frame(13,call(user:foo/1),foo(_140)),frame(12,clause(<clause>(0x5c7a323bc120),3),call(user:foo(_174))),frame(11,meta_call,0),frame(10,foreign(user:average/3),average(_222,foo(_230),_226)),frame(9,clause(<clause>(0x5c7a325e8fc0),3),toplevel_call(user:user: ...))]),_102))
Average = 1.5NaN.
Where does this come from? ctest -R cpp runs fine. So does
src/swipl ../packages/cpp/test_cpp.pl
?- test_cpp.
This isn't a test case (yet). I ran the tests, then manually loaded the foreign code with the command line I gave above (which is what the test cases run)
$HOME/src/swipl-devel/build/src/swipl "-p" "foreign=" "-f" "none" "--no-packs" "--on-error=status" "-s" "$HOME/src/swipl-devel/packages/cpp/test_cpp.pl"
and then ran the example query average(X, foo(X), Average).