【问题标题】:ERROR EXCEPTION while printing message raised: type_error on plunit run_tests打印消息时出现错误异常:plunit run_tests 上的 type_error
【发布时间】:2022-10-14 04:55:24
【问题描述】:

这些在 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).

当我运行这个命令时: swipl -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

我预计测试会失败,但有一个更友好的消息,这个 ERROR 垃圾是什么。

请帮忙。

当我测试时测试通过正常例如:... :- on(b-6).

【问题讨论】:

    标签: prolog swi-prolog plunit


    【解决方案1】:

    这似乎已在开发版本 (ppa:swi-prolog/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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-20
      • 2017-11-30
      • 1970-01-01
      • 1970-01-01
      • 2017-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多