A fork of Crisp for HARP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
1.8 KiB

  1. ;; Testing cons function
  2. (cons 1 (list))
  3. ;=>(1)
  4. (cons 1 (list 2))
  5. ;=>(1 2)
  6. (cons 1 (list 2 3))
  7. ;=>(1 2 3)
  8. (cons (list 1) (list 2 3))
  9. ;=>((1) 2 3)
  10. ;; Testing concat function
  11. (concat)
  12. ;=>()
  13. (concat (list 1 2))
  14. ;=>(1 2)
  15. (concat (list 1 2) (list 3 4))
  16. ;=>(1 2 3 4)
  17. (concat (list 1 2) (list 3 4) (list 5 6))
  18. ;=>(1 2 3 4 5 6)
  19. (concat (concat))
  20. ;=>()
  21. ;; Testing regular quote
  22. (quote 7)
  23. ;=>7
  24. '7
  25. ;=>7
  26. (quote (1 2 3))
  27. ;=>(1 2 3)
  28. '(1 2 3)
  29. ;=>(1 2 3)
  30. (quote (1 2 (3 4)))
  31. ;=>(1 2 (3 4))
  32. '(1 2 (3 4))
  33. ;=>(1 2 (3 4))
  34. ;; Testing simple quasiquote
  35. (quasiquote 7)
  36. ;=>7
  37. `7
  38. ;=>7
  39. (quasiquote (1 2 3))
  40. ;=>(1 2 3)
  41. `(1 2 3)
  42. ;=>(1 2 3)
  43. (quasiquote (1 2 (3 4)))
  44. ;=>(1 2 (3 4))
  45. `(1 2 (3 4))
  46. ;=>(1 2 (3 4))
  47. ;; Testing unquote
  48. `~7
  49. ;=>7
  50. (def! a 8)
  51. ;=>8
  52. `a
  53. ;=>a
  54. `~a
  55. ;=>8
  56. `(1 a 3)
  57. ;=>(1 a 3)
  58. `(1 ~a 3)
  59. ;=>(1 8 3)
  60. (def! b '(1 "b" "d"))
  61. ;=>(1 "b" "d")
  62. `(1 b 3)
  63. ;=>(1 b 3)
  64. `(1 ~b 3)
  65. ;=>(1 (1 "b" "d") 3)
  66. ;; Testing splice-unquote
  67. (def! c '(1 "b" "d"))
  68. ;=>(1 "b" "d")
  69. `(1 c 3)
  70. ;=>(1 c 3)
  71. `(1 ~@c 3)
  72. ;=>(1 1 "b" "d" 3)
  73. ;; Testing symbol equality
  74. (= 'abc 'abc)
  75. ;=>true
  76. (= 'abc 'abcd)
  77. ;=>false
  78. (= 'abc "abc")
  79. ;=>false
  80. (= "abc" 'abc)
  81. ;=>false
  82. ;;;;; Test quine
  83. ;;; TODO: needs expect line length fix
  84. ;;;((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
  85. ;;;=>((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
  86. ;;
  87. ;; -------- Optional Functionality --------
  88. ;; Testing cons, concat, first, rest with vectors
  89. (cons [1] [2 3])
  90. ;=>([1] 2 3)
  91. (cons 1 [2 3])
  92. ;=>(1 2 3)
  93. (concat [1 2] (list 3 4) [5 6])
  94. ;=>(1 2 3 4 5 6)
  95. ;; Testing unquote with vectors
  96. (def! a 8)
  97. ;=>8
  98. `[1 a 3]
  99. ;=>(1 a 3)
  100. ;;; TODO: fix this
  101. ;;;;=>[1 a 3]
  102. ;; Testing splice-unquote with vectors
  103. (def! c '(1 "b" "d"))
  104. ;=>(1 "b" "d")
  105. `[1 ~@c 3]
  106. ;=>(1 1 "b" "d" 3)
  107. ;;; TODO: fix this
  108. ;;;;=>[1 1 "b" "d" 3]