From: J.J. Tolton Date: Sun, 9 Nov 2025 17:05:23 +0000 (-0500) Subject: Update tests to use format/2 instead of write/1 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=95abc4017e3429fda7bbea3d0185f628c6da50c3;p=scryer-prolog.git Update tests to use format/2 instead of write/1 --- diff --git a/src/tests/custom_toplevel.pl b/src/tests/custom_toplevel.pl index 58221dc3..83001b55 100644 --- a/src/tests/custom_toplevel.pl +++ b/src/tests/custom_toplevel.pl @@ -4,24 +4,24 @@ % Helper predicates for CLI testing custom_halt :- - write('Custom toplevel executed'), nl, + format("Custom toplevel executed~n", []), halt(0). custom_halt_with_code :- - write('Custom toplevel with exit code'), nl, + format("Custom toplevel with exit code~n", []), halt(42). test_predicate :- - write('Test predicate executed'), nl. + format("Test predicate executed~n", []). % Test predicates for g_caused_exception/2 :- dynamic(g_caused_exception/2). check_for_exception :- ( g_caused_exception(_Goal, Exception) -> - write('Exception occurred: '), write(Exception), nl, + format("Exception occurred: ~w~n", [Exception]), halt(1) - ; write('No exception'), nl, + ; format("No exception~n", []), halt(0) ). diff --git a/tests/scryer/cli/fixtures/toplevel_test_helper.pl b/tests/scryer/cli/fixtures/toplevel_test_helper.pl index 4b65a0b5..a4e4106b 100644 --- a/tests/scryer/cli/fixtures/toplevel_test_helper.pl +++ b/tests/scryer/cli/fixtures/toplevel_test_helper.pl @@ -1,50 +1,50 @@ % Helper predicates for testing custom toplevel functionality success_toplevel :- - write('SUCCESS_TOPLEVEL_EXECUTED'), nl, + format("SUCCESS_TOPLEVEL_EXECUTED~n", []), halt(0). failure_toplevel :- - write('FAILURE_TOPLEVEL_EXECUTED'), nl, + format("FAILURE_TOPLEVEL_EXECUTED~n", []), halt(1). exit_code_42 :- - write('EXIT_CODE_42'), nl, + format("EXIT_CODE_42~n", []), halt(42). write_and_exit :- - write('Output from custom toplevel'), nl, + format("Output from custom toplevel~n", []), halt(0). % This one doesn't halt - to test what happens if toplevel doesn't halt non_halting_toplevel :- - write('NON_HALTING_TOPLEVEL'), nl. + format("NON_HALTING_TOPLEVEL~n", []). % Test that toplevel can access loaded predicates test_file_loaded :- - write('LOADED_PREDICATE_CALLED'), nl, + format("LOADED_PREDICATE_CALLED~n", []), halt(0). helper_predicate :- - write('Helper predicate works'), nl. + format("Helper predicate works~n", []). % g_caused_exception/2 testing predicates :- dynamic(g_caused_exception/2). check_exception_halt_1 :- ( g_caused_exception(Goal, Exception) -> - write('EXCEPTION_CAUGHT'), nl, - write('Goal: '), write(Goal), nl, - write('Exception: '), write(Exception), nl, + format("EXCEPTION_CAUGHT~n", []), + format("Goal: ~w~n", [Goal]), + format("Exception: ~w~n", [Exception]), halt(1) - ; write('NO_EXCEPTION'), nl, + ; format("NO_EXCEPTION~n", []), halt(0) ). check_exception_halt_0 :- ( g_caused_exception(_, _) -> - write('UNEXPECTED_EXCEPTION'), nl, + format("UNEXPECTED_EXCEPTION~n", []), halt(1) - ; write('SUCCESS_NO_EXCEPTION'), nl, + ; format("SUCCESS_NO_EXCEPTION~n", []), halt(0) ).