即使我将它们放在setof中,也无法忽略元素的顺序

发布于 2025-02-01 09:27:03 字数 663 浏览 3 评论 0原文

我遵循了这个问题中建议的答案我如何使用PL-UNIT的任何顺序测试非确定性谓词?

test(hello, [
  setup(board_1_setup),
  cleanup(clear_board),
   Ys = [d-6, e-6, f-6, d-5, f-5, e-4, f-4]
]) :-  setof(Y, any_turn_king_move(e-5, Y), Ys).


ERROR: /home/eguneys/chess/pro/_chess.plt:10:
        test hello: wrong answer (compared using =)
ERROR:     Expected: [d-6,e-6,f-6,d-5,f-5,e-4,f-4]
ERROR:     Got:      [d-5,d-6,e-4,e-6,f-4,f-5,f-6]

如果我把它们放在测试中。

即使我将它们放在setof中,为什么仍会检查订单。

I followed the answer suggested in this question How can I test a non-deterministic predicate in any order with PL-Unit? .

test(hello, [
  setup(board_1_setup),
  cleanup(clear_board),
   Ys = [d-6, e-6, f-6, d-5, f-5, e-4, f-4]
]) :-  setof(Y, any_turn_king_move(e-5, Y), Ys).


ERROR: /home/eguneys/chess/pro/_chess.plt:10:
        test hello: wrong answer (compared using =)
ERROR:     Expected: [d-6,e-6,f-6,d-5,f-5,e-4,f-4]
ERROR:     Got:      [d-5,d-6,e-4,e-6,f-4,f-5,f-6]

If I put them in order the test passes.

Why does this still checks for order, even though I put them in a setof.

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

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

发布评论

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

评论(1

不奢求什么 2025-02-08 09:27:03

我在此链接上尝试了一个片段 https://sicstus.sics.sics.se/sicstus/docs/4.2.0/html/sicstus/plunit-a-unit-a-unit-test-box.html

它起作用了。

这样:

test(king_move_safe, [
  setup(board_1_setup),
  cleanup(clear_board),
   set(Y = [d-5, e-4, f-4, f-5])
]) :-  king_move_safe(e-5, Y).

我不确定这是如何工作的,如果有人可以解释发生了什么,我将接受这一点。

I've tried a snippet on this link https://sicstus.sics.se/sicstus/docs/4.2.0/html/sicstus/PlUnit-A-Unit-Test-Box.html .

And it worked.

Like this:

test(king_move_safe, [
  setup(board_1_setup),
  cleanup(clear_board),
   set(Y = [d-5, e-4, f-4, f-5])
]) :-  king_move_safe(e-5, Y).

I am not sure how this works, if someone can explain what's going on I will accept that as an answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文