0

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.

eguneys
  • 6,028
  • 7
  • 31
  • 63

1 Answers1

0

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.

eguneys
  • 6,028
  • 7
  • 31
  • 63