didoudiaz / gprolog

GNU Prolog
Other
106 stars 13 forks source link

write_term/2-3 predicate max_depth/1 option test failures #55

Closed pmoura closed 1 year ago

pmoura commented 1 year ago

After https://github.com/trealla-prolog/trealla/issues/250, I pushed tests for the write_term/2-3 predicate max_depth/1 option to the Logtalk git repo. With d9333a3a50ee57781e64bbd97a2bdb46ca624a1f I get:

$ logtalk_tester -p gnu -s Documents/Logtalk/
% Batch testing started @ 2023-07-10 12:05:24
%         Logtalk version: 3.68.0-b01
%         GNU Prolog version: 1.6.0
%
% /Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3
%         134 tests: 0 skipped, 129 passed, 5 failed (0 flaky)
%         completed tests from object tests in 3 seconds
%         clause coverage n/a
%
% Compilation errors/warnings and failed unit tests
% (compilation errors/warnings might be expected depending on the test)
!     lgt_write_term_3_125: failure (in 0.000000000 seconds)
!       test goal succeeded but should have thrown an error:
!         expected error(domain_error(write_option,max_depth(-1)),A)
!       in file /Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt between lines 674-676
!     lgt_write_term_3_127: failure (in 0.001000000 seconds)
!       test assertion failed: '1'== ..
!       in file /Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt between lines 683-686
!     lgt_write_term_3_132: failure (in 0.002000000 seconds)
!       test assertion failed: '[1,2,3|...]'=='[1,2,...]'
!       in file /Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt between lines 708-711
!     lgt_write_term_3_133: failure (in 0.000000000 seconds)
!       test assertion failed: 'a(b(c(d(e(f(g(h(i(j(k(l(m))))))))))))'== ...
!       in file /Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt between lines 713-716
!     lgt_write_term_3_134: failure (in 0.000000000 seconds)
!       test assertion failed: '[1,2,3,4,5,6,7,8,9,10,11,12,13]'== ...
!       in file /Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt between lines 718-721
%
% Failed tests
/Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt - lgt_write_term_3_125 @ tests
/Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt - lgt_write_term_3_127 @ tests
/Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt - lgt_write_term_3_132 @ tests
/Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt - lgt_write_term_3_133 @ tests
/Users/pmoura/Documents/Logtalk/logtalk3/tests/prolog/predicates/write_term_3/tests.lgt - lgt_write_term_3_134 @ tests
%
% 1 test sets: 1 completed, 0 skipped, 0 broken, 0 timedout, 0 crashed
% 134 tests: 0 skipped, 129 passed, 5 failed (0 flaky)
%
% Batch testing ended @ 2023-07-10 12:05:28

See my portability comments at the end of the cited thread.

pmoura commented 1 year ago

Note that the failures for the lgt_write_term_3_133 and lgt_write_term_3_134 occur as GNU Prolog is not interpreting max_depth(0) as specifying that the term should be written fully (as common in other systems). This is an essential feature of this write option:

test(lgt_write_term_3_133, true(Assertion), [condition(max_depth_option_supported)]) :-
    ^^set_text_output(''),
    {write_term(a(b(c(d(e(f(g(h(i(j(k(l(m)))))))))))), [max_depth(0)])},
    ^^text_output_assertion('a(b(c(d(e(f(g(h(i(j(k(l(m))))))))))))', Assertion).

test(lgt_write_term_3_134, true(Assertion), [condition(max_depth_option_supported)]) :-
    ^^set_text_output(''),
    {write_term([1,2,3,4,5,6,7,8,9,10,11,12,13], [max_depth(0)])},
    ^^text_output_assertion('[1,2,3,4,5,6,7,8,9,10,11,12,13]', Assertion).
didoudiaz commented 1 year ago

See also issue #56 for discussion about what to display (and how)

pmoura commented 1 year ago

With 1ce0e592fe0a79e17e394599e093babf23b676df, we now get:

$ logtalk_tester -p gnu -s ~/Documents/Logtalk/
% Batch testing started @ 2023-07-11 15:09:11
%         Logtalk version: 3.68.0-b01
%         GNU Prolog version: 1.6.0
%
% logtalk3/tests/prolog/predicates/write_term_3
%         134 tests: 0 skipped, 133 passed, 1 failed (0 flaky)
%         completed tests from object tests in 3 seconds
%         clause coverage n/a
%
% Compilation errors/warnings and failed unit tests
% (compilation errors/warnings might be expected depending on the test)
!     lgt_write_term_3_132: failure (in 0.000000000 seconds)
!       test assertion failed: '[1,2,3|...]'=='[1,2,...]'
!       in file logtalk3/tests/prolog/predicates/write_term_3/tests.lgt between lines 708-711
%
% Failed tests
logtalk3/tests/prolog/predicates/write_term_3/tests.lgt - lgt_write_term_3_132 @ tests
%
% 1 test sets: 1 completed, 0 skipped, 0 broken, 0 timedout, 0 crashed
% 134 tests: 0 skipped, 133 passed, 1 failed (0 flaky)
%
% Batch testing ended @ 2023-07-11 15:09:15

Nice progress!

pmoura commented 1 year ago

See also issue #56 for discussion about what to display (and how)

Some variation in the exact output is not too problematic. Of course, it would be nice to have greater convergence between systems.

Btw, systems that pass the lgt_write_term_3_132 test include Ciao Prolog, CxProlog, LVM, SICStus Prolog, Trealla Prolog, and XSB (didn't test B-Prolog and Tau Prolog so far).

didoudiaz commented 1 year ago

lgt_write_term_3_132 is now OK too.