Questions tagged [plunit]

PlUnit is a unit testing framework for Prolog

PlUnit is a unit testing framework for Prolog. Originally developed as a package for , it is also available in other systems like SICStus Prolog.

17 questions
9
votes
2 answers

What is a "Test succeeded with choicepoint" warning in PL-Unit, and how do I fix it?

I'm writing a prolog program to check if a variable is an integer. The way I'm "returning" the result is strange, but I don't think it's important for answering my question. The Tests I've written passing unit tests for this behaviour; here they…
byxor
  • 5,930
  • 4
  • 27
  • 44
8
votes
1 answer

Unit testing in XSB Prolog?

How do people working with XSB Prolog do unit testing? Is there a library available? Or is it possible to somehow use SWI-Prolog's plunit library in XSB? If there is not an available testing library for XSB (or other Prologs no compatibles with…
Sergio
  • 8,532
  • 11
  • 52
  • 94
3
votes
1 answer

How to run plunit tests in prolog

I'm having difficulty getting plunit to execute tests in seeemingly the most trivial case. Here's my setup: foo.pl x(5) :- !. not(x(6)). foo.plt :- begin_tests(foo). test_something(x) :- not(x(5)). test_seomthing_else(x) :- x(6). :-…
Lucas Wiman
  • 10,021
  • 2
  • 37
  • 41
2
votes
1 answer

ERROR EXCEPTION while printing message raised: type_error on plunit run_tests

These are defined in chess.pl :- dynamic drop/1. :- dynamic start/1. a_drop(X) :- piese(X), piese_pos(X, Y), \+ on(Y), assertz(drop(X)). a_pickup(X) :- retract(drop(_-_-X)). a_clear:- retract(drop(_)). print_drops:- forall(drop(X),…
eguneys
  • 6,028
  • 7
  • 31
  • 63
2
votes
1 answer

SWI-Prolog - Unit testing library plunit - How is forall option used?

For my lexer (tokenizer) all of the ASCII 7-bit characters (0x00 to 0x7F) have a specific token. As SWI-Prolog supports Unicode, the character codes go from 0x0000 to 0xFFFF. In my lexer, since there are many characters that will not map to a…
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
2
votes
2 answers

Declaring facts that are true only within the scope of a single unit test in SWI-Prolog

As an example for this question, I have a very simple Prolog file main.pl, in which I've defined the colours of some shapes. colour(circle, red). colour(triangle, red). colour(square, blue). Now below that I define a predicate same_colour/2, which…
James Hiew
  • 6,040
  • 5
  • 27
  • 41
2
votes
0 answers

Ignored silent flag in a test run

I'm currently trying to use the PlUnit test suit and encounter a problem to turn off the output of my predicates during the test. The documentation says that I should be fine with something along the lines of set_test_options([silent(true)]).,…
m09
  • 7,490
  • 3
  • 31
  • 58
1
vote
1 answer

How can I improve error reporting using PlUnit?

I'm writing tests using SWI-Prolog's PlUnit and would like to provide a better error message, perhaps by diffing what I've got from what I was expecting. The following minimal working example (MWE) exemplifies what I'm after: :- module(mwe,…
Bruno Kim
  • 2,300
  • 4
  • 17
  • 27
1
vote
1 answer

plunit test apparently creates a module behind the scenes ... but can that module be unloaded?

I want to use plunit as implemented in SWI Prolog to run a few unit tests in classy style! So I want to enter them directly on the terminal: [user]. and then copy paste: :- begin_tests(exercise). test(foo) :- bar. :- end_tests(exercise). This…
David Tonhofer
  • 14,559
  • 5
  • 55
  • 51
1
vote
1 answer

How to solve an undefined procedure error in Prolog?

I wrote this chunk of code on a provided computer: factor_in_inches(Unit, Scale) :- scale_of(Unit, Scale, inch). scale_factor(Unit1, Unit2, Factor) :- scale_of(Unit2, Factor, Unit1). %PartI scales(BigUnit, Scale, LittleUnit) :- …
1
vote
1 answer

How can I catch the output to the console in Prolog to verify it?

Suppose I have a hello_name.pl: greeting (Name): - write ('hello'), write (Name), writeln ('!'). And I want to put in my plunit something like catch_output (greeting ('Moncho'), ConsoleOutput), assertion ('hello Moncho!' =:=…
Ruslan López
  • 4,433
  • 2
  • 26
  • 37
0
votes
0 answers

prolog predefined lists search

I'm new to and just started writing prolog code I'm not sure how list of lists works and how to write rules for already defined lists, when I enter run_tests. below test cases should be executing Below is the project I am working on, could anyone…
0
votes
0 answers

What's a bad file descriptor?

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),…
Modotonko
  • 1
  • 1
0
votes
1 answer

Fails to ignore order of elements even though I put them in a setof

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,…
eguneys
  • 6,028
  • 7
  • 31
  • 63
0
votes
1 answer

Test in Prolog. How to run a unit test that checks if my output file matches the my text file?

I'm implementing a natural language generator using prolog (swipl). I have a .txt test file with some of the phrases I should be able to generate in this format: [goal,identify,type_object,animal,object,cat,event,ran…
1
2