打印消息升起时出错例外:type_error在plunit run_tests上

发布于 2025-01-31 12:32:12 字数 1146 浏览 3 评论 0原文

这些是在Chess.pl中定义的

:- dynamic drop/1.
:- dynamic start/1.

a_drop(X) :- piese(X), piese_pos(X, Y), \+ on(Y), assertz(drop(X)).
a_pickup(X) :- retract(drop(_-_-X)).
a_clear:- retract(drop(_)).

print_drops:- forall(drop(X), write(X)).


on(X) :- once(drop(_-_-X)).
off(X) :- \+ drop(_-_-X).

,我有此测试文件:

:- begin_tests(chess).

:- include(chess).

clear_board :- a_clear.

  board_1_setup :- a_drop(b-r-(b-6)), a_drop(w-k-(d-5)), a_drop(w-b-(c-4)), a_drop(b-b-(b-3)).

test(hello, [
  setup(board_1_setup),
  cleanup(clear_board)
]) :- on(b-4).


:- end_tests(chess).

运行此命令时: swipp -g run_tests -t halt _chess.plt

这是输出。

% PL-Unit: chess
ERROR:
    [[ EXCEPTION while printing message url('/home/eguneys/chess/pro/_chess.plt':10)
       with arguments []:
       raised: type_error(text,url('/home/eguneys/chess/pro/_chess.plt':10))
    ]]
:
        test hello: failed

 done
% 1 test failed
% 0 tests passed
ERROR: -g run_tests: false

我希望测试失败,但是有了友好的消息,这是什么错误垃圾。

请帮忙。

例如,当我测试时,测试会通过:...: - on(b-6)。

These are defined in chess.pl

:- dynamic drop/1.
:- dynamic start/1.

a_drop(X) :- piese(X), piese_pos(X, Y), \+ on(Y), assertz(drop(X)).
a_pickup(X) :- retract(drop(_-_-X)).
a_clear:- retract(drop(_)).

print_drops:- forall(drop(X), write(X)).


on(X) :- once(drop(_-_-X)).
off(X) :- \+ drop(_-_-X).

I have this test file:

:- begin_tests(chess).

:- include(chess).

clear_board :- a_clear.

  board_1_setup :- a_drop(b-r-(b-6)), a_drop(w-k-(d-5)), a_drop(w-b-(c-4)), a_drop(b-b-(b-3)).

test(hello, [
  setup(board_1_setup),
  cleanup(clear_board)
]) :- on(b-4).


:- end_tests(chess).

When I run this command:
swipl -g run_tests -t halt _chess.plt

This is the output.

% PL-Unit: chess
ERROR:
    [[ EXCEPTION while printing message url('/home/eguneys/chess/pro/_chess.plt':10)
       with arguments []:
       raised: type_error(text,url('/home/eguneys/chess/pro/_chess.plt':10))
    ]]
:
        test hello: failed

 done
% 1 test failed
% 0 tests passed
ERROR: -g run_tests: false

I expected the test to fail, but with a friendlier message, what is this ERROR garbage.

Please help.

Tests passes normal when I test for example: ... :- on(b-6).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋日私语 2025-02-07 12:32:12

这似乎是在开发版本中修复的(ppa:swi-prog/devel)。

您的测试文件中似乎有错别字或缺少的东西:

$ swipl -g run_tests -t halt chess.plt


% PL-Unit: chess 
ERROR: /tmp/chess.plt:9:
    error in setup: plunit_chess:a_drop/1: Unknown procedure: plunit_chess:piese/1
 done
% No tests to run

This seems to be fixed in the development version (ppa:swi-prolog/devel).

There appear to be typos or things missing in your test files:

$ swipl -g run_tests -t halt chess.plt


% PL-Unit: chess 
ERROR: /tmp/chess.plt:9:
    error in setup: plunit_chess:a_drop/1: Unknown procedure: plunit_chess:piese/1
 done
% No tests to run
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文