]> Repositorios git - scryer-prolog.git/commitdiff
Update tests to use format/2 instead of write/1
authorJ.J. Tolton <[email protected]>
Sun, 9 Nov 2025 17:05:23 +0000 (12:05 -0500)
committerJ.J. Tolton <[email protected]>
Sun, 9 Nov 2025 17:44:48 +0000 (12:44 -0500)
src/tests/custom_toplevel.pl
tests/scryer/cli/fixtures/toplevel_test_helper.pl

index 58221dc32bf87435173df2cd57b423f00851dfa4..83001b55fe7e3ba23a53a647b220b4a6e1984115 100644 (file)
@@ -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)
     ).
 
index 4b65a0b5073f2ddc388766cd2e043a424e9ad550..a4e4106b81f34819b3490ca3a11ef4d2eded190e 100644 (file)
@@ -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)
     ).