#!/usr/local/bin/descartes

//? <include sys>;

// test append & reverse

//?<tron>;

<append #X () #X >;
<append (#A : #Z) (#A : #X)  #Y>
	<append #Z #X #Y >;

<test1 append> 
	<append #x (a b c) (d e f)>
	::sys<writenl test1 append OK>;
<test1 append>
	::sys<writenl test1 append "*NG*">;

<test2 append>
	<append (a b c d e f ) (a b c) #Y> <!>
	::sys<writenl test2 append OK>;
<test2 append>
	::sys<writenl test2 append "*NG*">;


<reverse () ()>;
<reverse #r (#x: #l)>	
	<reverse #r1 #l>
	<append #r #r1 (#x)>;


<test3 reverse> 
	<reverse #rv (a b c d e f)> <!>
	::sys<writenl test3 reverse OK>;
<test3 reverse> 
	::sys<writenl test3 reverse "*NG*">;
<test4 reverse>
	<reverse (a b c d e f) #rv> <!>
	::sys<writenl test4 reverse OK>;
<test4 reverse> 
	::sys<writenl test4 reverse "*NG*">;


// test comment

<ap () #X #X>;
<ap (#A : /* comment */ #X)  #Y  (#A : #Z)>	
	<ap #X #Y #Z>;// comment

// comment
<rev () ()>;
<rev (#x: #l) #r>	
	<rev #l #r1>
	</* comment */ ap #r1 (#x) #r>;

<test5 comment>
	<rev #rv (a b c d e f)/* comment/* comment */ */> <!>
	::sys<writenl test5 comment OK>;
<test5 comment>
	::sys<writenl test5 comment "*NG*">;
<test6 comment>
<rev // comment
(a b c d e f) #rv><!>
	::sys<writenl test6 comment OK>;
<test6 comment>
	::sys<writenl test6 comment "*NG*">;
	

// test args

<test7 args>
	::sys<args #x>
	::sys<eq #x1 "test.pl"> <!>
//	::sys<writenl test7 args #x>
	::sys<writenl test7 args OK>;
<test7 args> 
	::sys<args #x>
	::sys<writenl test7 args #x>
	::sys<writenl test7 args "*NG*">;

// test include
//?::sys<DLIBPATH "test.d/:.">;
//?::sys<DLIBPATH #path>;
?<include list>;

<test8 include>
	<unify list <append #x (a b) (c d)>> <!>
	::sys<writenl test8 include OK>;
<test8 include> 
	::sys<writenl test8 include "*NG*">;

<test9 include>
	::list <append #x (a b) (c d)> <!>
	::sys<writenl test9 include OK>;
<test9 include> 
	::sys<writenl test9 include "*NG*">;

<test10 include>
	::list <reverse (a bc d e f g h i j k l) #x> <!>
	::sys<writenl test10 include OK>;
<test10 include> 
	::sys<writenl test10 include "*NG*">;

<test11 include>
	<unify list <reverse #x (a bc d e f g h i j k l)>> <!>
	::sys<writenl test11 include OK>;
<test11 include> 
	::sys<writenl test11 include "*NG*">;





// test module
<test12 module>
	<module #x> <!>
 	::sys<writenl test12 module OK>;
<test12 module>
 	::sys<writenl test12 module "*NG*">;

// test obj

<test13 obj>
	::penguin <swim> <!>
 	::sys<writenl test13 obj OK>;
<test13 obj>
 	::sys<writenl test13 obj "*NG*">;
<test14 obj>
	<not ::penguin <fly>> <!>
 	::sys<writenl test14 obj OK>;
<test14 obj>
 	::sys<writenl test14 obj "*NG*">;

::<bird
	<fly>;
	<walk>;
>;

::<penguin
	<fly>	<!><unknown>;
	<swim>;
	inherit bird;
>;

::<hawk
	inherit bird;
>;


<test15 token>
	::sys <openr tmptokenfile 
		<TOKEN #x "abc" { <N _> } "cd" >
	>
 	::sys<writenl test15 token OK>
	;
<test15 token>
 	::sys<writenl test15 token "*NG*">;

<test16 char>
	::sys <char #x "abcdefghijklmn">
	::sys <car #y #x>
	::sys <eq a #y>
 	::sys<writenl test16 char OK>
	;
<test16 char>
 	::sys<writenl test16 char "*NG*">
	;

<test17 compare>
	<#y=1>
	<#z=7>
	<compare not ((#y > 1) or (#z < 3))>
	::sys<writenl test17 compare OK>
	;
<test17 compare>
 	::sys<writenl test17 compare "*NG*">
	;
<test18 comparef>
	<#y=1>
	<#z=7>
	<comparef not ((#y > 1.2) or (#z < 3.0))>
	::sys<writenl test18 comparef OK>
	;
<test18 comparef>
 	::sys<writenl test18 comparef "*NG*">
	;
<test19 compare>
	<#y=1>
	<#z=7>
	<compare (#y > 0) and not (#z < 3.0)>
	::sys<writenl test19 compare OK>
	;
<test19 compare>
 	::sys<writenl test19 compare "*NG*">
	;
<test20 comparef>
	<#y=1>
	<#z=7>
	<comparef (#y > 0.2) and not (#z < 3.0)>
	::sys<writenl test20 comparef OK>
	;
<test20 comparef>
 	::sys<writenl test20 comparef "*NG*">
	;
<test21 compare>
	<#y=1>
	<#z=7>
	<compare not(not 1=1)>
	::sys<writenl test21 compare OK>
	;
<test21 compare>
 	::sys<writenl test21 compare "*NG*">
	;
<test22 comparef>
	<#y=1>
	<#z=7>
	<compare not(not 2.3=2.3)>
	::sys<writenl test22 comparef OK>
	;
<test22 comparef>
 	::sys<writenl test22 comparef "*NG*">
	;

?<test1 append>
 <test2 append>
 <test3 reverse>
 <test4 reverse>
 <test5 comment>
 <test6 comment>
 <test7 args>
 <retract append>
 <test8 include>
 <test9 include>
 <erase append>
 <test10 include>
 <test11 include>
 <test12 module>
 <test13 obj>
 <test14 obj>
 <test15 token>
 <test16 char>
 <test17 compare>
 <test18 comparef>
 <test19 compare>
 <test20 comparef>
 <test21 compare>
 <test22 comparef>
;


// test unify test 23-24
?<load unify.pl>;

