Source

clojurian / tests / syntax.scm

(use test srfi-1)

(load-relative "../clojurian-syntax")
(import clojurian-syntax)

(test-group "clojurian-syntax"
  (test (vector 1 2)
        (doto (make-vector 2)
              (vector-set! 0 1)
              (vector-set! 1 2)))

  (test 'foo (doto 'foo)))

(test-group "thrush"
  (test 1 (-> 99 (/ 11) (/ 9)))

  (test '(1 2 3 4)
        (->* (values 1 2)
             (list 3)
             (append '(4))))

  (test 7 (-> 10 (- 3)))
  (test -7 (->> 10 (- 3)))

  (test 9 (->> 1 (+ 2) (* 3)))

  (test 9 (->> '(1 2 3)
               (map add1)
               (fold + 0)))

  (test '((foo . 100) (bar . 200))
        (->>* (values '(foo bar) '(100 200))
              (map cons))))

(test-group "if-let & if-let*"
  (test 2 (if-let (x 1) (+ x x) 9))
  (test 9 (if-let (x #f) (+ x x) 9))

  (test (list 3 6)
        (if-let* ((foo 3) (bar (* foo 2)))
                 (list foo bar)
                 'wrong))

  (test 'wrong
        (if-let* ((foo #f) (bar (* foo 2)))
                 (list foo bar)
                 'wrong)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.