home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / TESTS / LF / SUBSORT.LF < prev    next >
Text File  |  1996-06-04  |  1KB  |  64 lines

  1. % test out the subsort(A,B) predicate which returns true if A :=< B and
  2. % residuates on B, else it returns false.
  3.  
  4. wln(A) :- write(A), nl.
  5. wless(A,B) :- write(A, " :<= ", B), nl.
  6.  
  7. testnum(A) :- subsort(A, B), wless(A,B),
  8.      B = real, wless(A,B), gc,
  9.      B = int, wless(A,B),
  10.      B = 1, wless(A,B).
  11.  
  12. testreal(A) :- subsort(A, B), wless(A,B),
  13.      B = real, wless(A,B), gc,
  14.      B = 3.2, wless(A,B),
  15.      B = int, wless(A,B),
  16.      B = 1, wless(A,B).
  17.  
  18. allChildren(X) -> A | genChildren(children(X), A).
  19.  
  20. genChildren([H|T], H).
  21. genChildren([X|T], Y) :- genChildren(T, Y).
  22.              
  23. seqFile <| file.
  24. randFile <| file.
  25. readFile <| file.
  26. writeFile <| file.
  27.  
  28. seqWriteFile <| seqFile.
  29. seqWriteFile <| writeFile.
  30.  
  31. seqReadFile <| seqFile.
  32. seqReadFile <| readFile.
  33.  
  34. randReadFile <| readFile.
  35. randReadFile <| randFile.
  36.  
  37. terminal <| seqWriteFile.
  38. terminal <| readFile.
  39.  
  40. testFile(A,B) :- subsort(A, B),
  41.          wless(A,B),
  42.          wln("stage one"), gc,
  43.          B = allChildren(B), wless(A,B),
  44.          wln("stage two"),
  45.          B = allChildren(B), wless(A,B),
  46.          wln("stage three"), gc,
  47.          B = allChildren(B), wless(A,B),
  48.          wln("***********"),
  49.          fail.
  50.  
  51. %testnum(2)?
  52. %testnum(int)?
  53. %testnum(3.2)?
  54. %
  55. %testreal(string)?
  56. %testreal(1)?
  57. %testreal(4.0)?
  58. %
  59. %testFile(terminal, file)?
  60. %testFile(seqFile, file)?
  61. %
  62. %testFile(mouse_event, event)?
  63.  
  64.