0

I have the next system swi-prolog in a file call 'system.pl';

helloWorld :- read(X), write(X).

And i want to test it, then, i write it;

:- begin_tests(helloWorld_test).

test(myTest, true(Output == "hello")) :-
    with_output_to(string(Output), getEntry).

:- end_tests(helloWorld_test).

getEntry :-
    open('testcase.test', read, Myfile),
    set_input(Myfile),
    process_create(path(swipl), ['-g', 'main', '-t', 'halt', 'system.pl'], [stdin(stream(Myfile)), stdout(pipe(Stream))]),
    copy_stream_data(Stream, current_output),
    close(Myfile).

In testcase.test is contained the following;

hello.

Ok, now, when i call to swipl -g run_tests -t halt system.pl i get it;

% PL-Unit: helloWorld_test ERROR: -g helloWorld: read/1: I/O error in read on stream user_input (Bad file descriptor)

ERROR: c:/programasvscode/prolog/programasrandom/system.pl:40:
        test myTest: wrong answer (compared using ==)
ERROR:     Expected: "hello"
ERROR:     Got:      ""
 done
% 1 test failed
% 0 tests passed
ERROR: -g run_tests: false
Warning: Process "c:\swipl\bin\swipl.exe": exit status: 2

I tried use read/2 with current_input but i got the same with the difference of read/2 instead read/1

What does mean it? any solve?

false
  • 10,264
  • 13
  • 101
  • 209
Modotonko
  • 1
  • 1

0 Answers0