[net.lang.prolog] Syntax variant tests

cdsm@icdoc.UUCP (07/11/86)

Here are some tests that I've been trying; I'd be grateful to anyone
who can run them on versions of Prolog not included below and post me
the results direct. Do NOT post them to the network! I will summarise
the conclusions in due course.
Reply to cdsm@doc.ic.ac.uk or cdsm@icdoc.uucp

/* tests for syntax variation in Prolog implementations 

    Chris Moss 1986 

To run the test simply call "dotest" with appropriate
parameters, or "test" if that doesn't work, ignoring any syntax
errors and deleting any clauses necessary.  Then send me the
resultant file, or a list of the first letter of each answer,
with an S for those that couldn't be run.

Note that many of these tests will cause syntax errors in most
processors. This is intentional, but it does mean that some care
must be applied to get sensible results.  Be careful to start
with a fresh copy of Prolog each time and avoid any startup
files with non-standard operator definitions. Set option to fail
on no definition, if necessary.  You CAN add any other
declarations necessary and change operator definitions if they
don't work on your system, but DON'T do any lexical changes (in
particular don't change white space).

Results I have so far:

Version			1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 

CProlog	5.1		Y Y Y Y Y Y Y N N  Y  Y  Y  Y  D  Y  I  N  Y  N  Y
Poplog 6.3		N N Y Y Y N N Y A  Y  Y  Y  Y  D  Y  F  O  Y  Y  Y
MuProlog 3.1		Y Y Y Y Y Y Y N N  Y  Y  Y  Y  N  Y  F  N  Y  N  Y
sigmaProlog 1.1		Y Y Y Y Y Y Y N N  Y  Y  Y  S  N  N  F  N  S  N  Y
ADA PDProlog 		N N Y N S S S N N  N  Y  Y  S  N  Y  I  N  Y  S  Y
Turbo Prolog		N N N S S S S N N  N  S  N  ?  N  Y
MACProlog 1.1		Y Y Y N N N Y N N  Y  Y  N  N  N  N
NIP 1.3			Y Y Y Y Y Y Y N N  Y  Y  Y  Y  D  Y 
Quintus 1.5 (C & I)	Y Y Y Y Y Y Y N N  Y  Y  Y  Y  N  Y
ICL Prolog 1.7		Y Y Y Y N N Y Y ?  Y  Y  Y  N  N  Y 

 */

dotest(File,Version) :-
   tell(File),w(['syntax test version 3 using',Version]), test, told.

test :- test(1,20).

test(I,N) :- I>N, !.
test(I,N) :- I=<N, (atest(I);true), !, J is I+1, test(J,N).

w(X) :- write(X), nl.

atest(1) :- a1(b), w('1 No, space between functor & bracket insignificant')
       ; w('1 Yes, space is significant between functor & bracket').
atest(2) :-a2(c),a2(d),
	  w('2 No, period at end of clause does not need a space')
	; a2(c), w('2 First clause only seen when no space after dot')
        ; w('2. Yes, period at end of clause needs a space afterwards').
atest(3) :- a3('.'), w('3 Yes, Dot without quotes ok')
              ; w('3 No, needs quotes round dot').
atest(4) :- a4(X,X), w('4 Yes, Dot is list constructor')
             ; w('4 No, dot is not list constructor=dot').
atest(5) :- a5(X), X='.'(a,b), w('5 Yes, Dot can be declared as an operator')
         ; w('5 No, Dot cannot be declared as an operator').
atest(6) :- a6(X), X = '.'(a,b), w('6 Yes, Dot used as an operator outside')
         ; w('6 No, Dot cannot be used as an operator outside parens').
atest(7) :- 
        a7('.'(b,c)), w('7 No, space insignificant after dot inside parens')
         ; w('7 Yes, space is significant after dot inside parens').
atest(8) :- b(X), w('8 Yes, :- works without extra parens')
         ; w('8 No, :- in parens fails').
atest(9) :- c(X), w('9 Yes, arbitrary expressions work inside parens')
         ; c(X , Y), w('9 Alternative priority of :- , ; in parameter list')
         ; w('9 No, arbitrary expressions fail inside parens').
atest(10) :- d(X), w('10 Yes, clauses work inside double parens')
         ; w('10 No, clauses dont work even inside double parens').
atest(11) :- e(X), X = ','(a,b), w('11 Yes, commas as operators in parens')
         ; w('11 No, commas dont work as functors').
atest(12) :- a12(a),a12(b), w('12 Yes, definitions can be split')
         ; a12(a), w('12 First definition only accepted')
	 ; a12(b), w('12 Last definition only accepted')
	 ; w('12 No, definitions cannot be split, syntax error').
atest(13) :- a13(X,Y), w('13 No, % is not end of line comment')
         ; a13(X), w('13 Yes, % is end of line comment')
	 ; w('13 Syntax error with % in a line').
atest(14) :- g([X,Y|Z]), w('14 No decimal notation recognized')
         ; g([X|Y]), w('14 Decimal and dot notation mix')
         ; w('14 No, decimals with dots not allowed').
atest(15) :- h(X), w('15 Yes, digit ok at end of clause')
         ; w('15 No, digit fails at end of clause').
atest(16) :- a16(X), integer(X), 
	 w('16 Integer true for - 3')
	 ; functor(X,'-',1), w('16 Functor true for - 3')
	 ; w('16 Syntax error for - 3'). 
atest(17) :- a17([1,2|','(3,4)]), w('17 Comma term accepted after | in list')
	 ; a17([X|Y]), w('17 Other interpretation of comma term after |')
	 ; w('17 No, does not accept comma after | in list').
atest(18) :- a18(foo,baz), w('18 Yes, Anonymous variable works')
	 ; a18(foo,foo), w('18 No, anonymous variable has singular use')
	 ; a18(X,X), w('18 Constant interpretation for _')
	 ; w('18 Syntax error when anonymous variable used').
atest(19) :- a19(A), w('19 Yes, nested comments handled')
	 ; a19(A,B), w('19 No, nested comments ignored')
	 ; w('19 Syntax error with nested comments').
atest(20) :- a20(X), a20(X,Y), w('20 Yes, different arities mix')
         ; a20(X), w('20 First definition only for changed arity')
         ; a20(X,Y), w('20 Last definition only for changed arity')
         ; w('20 No definition remembered with changed arity').

      /* 1. Is a space between functor and bracket significant ? */
a1 (b).

      /* 2. is a space necessary after end of clause? */
a2(c).a2(d).

      /* 3. Can . be used as a term within parentheses? */
a3(.).

      /* 4. Is list constructor = dot */
a4('.'(a,b), [a|b]).

      /* 5. can dot be declared as an operator? */
:- op(50,xfy,'.').
a5(a.b).

      /* 6. can dot be used as an operator outside parentheses */
:-op(60,fx,a6).
a6 a.b.

      /* 7. is a space after dot significant within brackets */
a7(b . c).

      /* 8. do lower precedence ops work inside parentheses */
b(a:-c).

      /* 9. a more complicated example */
c(a:-b,c;d).

      /* 10. test arbitrary clauses inside double parens */
d((a:-b,c;d)).

      /* 11. can operator commas be used effectively as functors */
e((a,b)).

      /* 12. can definitions be split into more than one part */
a12(a).
b12(a).
a12(b).

/* 13. Does it have end of line comments */
a13(%,
   b).
/* 14. what about dotted lists which contain digits */
g(1.2.3).

/* 15. digit at end of clause */ 
h(X) :- X is 4.
dummy.

/* 16. Test - 3 with included space */
a16(- 3).

/* 17. Test comma after | in a list */
a17([1,2|3,4]).

/* 18. Anonymous variable test */
a18(_,_).

/* 19. Are nested comments allowed? */
:-op(60, fx, a19).
a19(a
/* /* this is a nested comment */
  , */ 
 ).

/* 20. Do different arities mix? */
a20(a).
a20(a,b).