PageRenderTime 25ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/usr/src/common/ficl/test/ficltest.fr

https://github.com/illumos/illumos-gate
Forth | 105 lines | 86 code | 19 blank | 0 comment | 2 complexity | 21ad0b8b05f4a7f39f70a5db9705b666 MD5 | raw file
  1. \ test file for ficl
  2. \ test ANSI CORE stuff first...
  3. -1 set-order
  4. \ set up local variable regressions before { gets redefined!
  5. : local1 { a b c | clr -- c b a 0 }
  6. c b a clr
  7. ;
  8. : local2 { | clr -- 0 } clr ;
  9. : local3 { a b | c }
  10. a to c
  11. b to a
  12. c to b
  13. a b
  14. ;
  15. include tester.fr
  16. include core.fr
  17. { -> }
  18. \ test double stuff
  19. testing 2>r 2r> 2r@
  20. : 2r1 2>r r> r> swap ;
  21. : 2r2 swap >r >r 2r> ;
  22. : 2r3 2>r 2r@ R> R> 2DUP >R >R SWAP 2r> ;
  23. { 1 2 2r1 -> 1 2 }
  24. { 1 2 2r2 -> 1 2 }
  25. { 1 2 2r3 -> 1 2 1 2 1 2 }
  26. { -> }
  27. \ Now test ficl extras and optional word-sets
  28. testing locals
  29. { 1 2 3 local1 -> 3 2 1 0 }
  30. { local2 -> 0 }
  31. { 1 local2 -> 1 0 }
  32. { 1 2 local3 -> 2 1 }
  33. testing :noname
  34. { :noname 1 ; execute -> 1 }
  35. { 1 2 3 -rot -> 3 1 2 }
  36. testing default search order
  37. { get-order -> forth-wordlist 1 }
  38. { only definitions get-order -> forth-wordlist 1 }
  39. testing forget
  40. here constant fence
  41. { fence forget fence -> here }
  42. testing within
  43. { -1 1 0 within -> true }
  44. { 0 1s 2 within -> true }
  45. { -100 0 -1 within -> true }
  46. { -1 1 2 within -> false }
  47. { -1 1 -2 within -> false }
  48. { 1 -5 5 within -> true }
  49. { 33000 32000 34000 within -> true }
  50. { 0x80000000 0x7f000000 0x81000000 within -> true }
  51. testing exception words
  52. : exc1 1 throw ;
  53. : exctest1 [ ' exc1 ] literal catch ;
  54. : exc2 exctest1 1 = if 2 throw endif ;
  55. : exctest2 [ ' exc2 ] literal catch ;
  56. : exctest? ' catch ;
  57. { exctest1 -> 1 }
  58. { exctest2 -> 2 }
  59. { exctest? abort -> -1 }
  60. testing refill
  61. \ from file loading
  62. 0 [if]
  63. .( Error )
  64. [else]
  65. 1 [if]
  66. [else]
  67. .( Error )
  68. [then]
  69. [then]
  70. \ refill from evaluate string
  71. { -> }
  72. { s" 1 refill 2 " evaluate -> 1 0 2 }
  73. testing prefixes
  74. { 0x10 -> decimal 16 }
  75. { hex 0d10 -> decimal 10 }
  76. { hex 100
  77. -> decimal 256 }
  78. testing number builder
  79. { 1 -> 1 }
  80. { 3. -> 3 0 }
  81. s" ficlwin" environment?
  82. [if]
  83. drop
  84. testing OOP support
  85. include ooptest.fr
  86. [endif]