exercism / exercism/prolog

non-exhaustive tests

Open
#81 6 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Prolog
Stars
34
Forks
46
PR merge metrics
No merged PRs in 30d

Description

As explained here #80 there is a way to write tests that is not exhaustive enough. As an example, if we have a simple program like:

```Prolog
add(X,Y,Z) :-
Z >= X+Y.
```
A test like:
```
?- add(1,2,3).
true.
```
succeeds. When is obviously not correct. nevertheless if we do this:
```

?- add(1,2,X).
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR: [9] _2658>=1+2
ERROR: [7]
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
```
throws an error. In this case, this predicate should be tested like so `add(1,2,X), x =:= 3`.

This is a particular characteristic of Prolog, and that is why is particularly confusing.

This are all tests that have this flaw:

- [x] anagram
- [x] binary
- [X] complex-numbers
- [x] grains
- [x] hamming
- [x] nucleotide-count
- [x] pascals-triangle
- [x] rna-transcription
- [x] spiral-matrix
- [x] sum-of-multiples
- [ ] triangle

If you submit a PR to fix one of them, please refer to this issue. And if you find another exercise with this problem add a comment here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.