Sha256: 0455acce750df0e4aea0ec5a8d266f0e04a35beaa4f05ad50341bc73f90a1182

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

(ns wisp.test.string
  (:use [wisp.src.string :only [join split]]
        [wisp.src.sequence :only [list]]
        [wisp.src.runtime :only [str =]]))

(print "test join")

(assert (= "" (join nil)))
(assert (= "" (join "-" nil)))

(assert (= "" (join "")))
(assert (= "" (join "-" "")))
(assert (= "h" (join "-" "h")))
(assert (= "hello" (join "hello")))
(assert (= "h-e-l-l-o" (join "-" "hello")))

(assert (= "" (join [])))
(assert (= "" (join "-" [])))
(assert (= "1" (join "-" [1])))
(assert (= "1-2-3" (join "-" [1 2 3])))

(assert (= "" (join '())))
(assert (= "" (join "-" '())))
(assert (= "1" (join "-" '(1))))
(assert (= "1-2-3" (join "-" '(1 2 3))))

(assert (= "" (join {})))
(assert (= (str [:a 1]) (join {:a 1})))
(assert (= (str [:a 1]) (join "," {:a 1})))
(assert (= (str [:a 1] [:b 2]) (join {:a 1 :b 2})))
(assert (= (str [:a 1] "," [:b 2]) (join "," {:a 1 :b 2})))

(print "test split")

(assert (= [""] (split "" #"\s")))
(assert (= ["hello"] (split "hello" #"world")))
(assert (= ["q" "w" "e" "r" "t" "y" "u" "i" "o" "p"]
           (split "q1w2e3r4t5y6u7i8o9p" #"\d+")))

(assert (= ["q" "w" "e" "r" "t"]
           ; TODO: In clojure => ["q" "w" "e" "r" "t5y6u7i8o9p0"]
           (split "q1w2e3r4t5y6u7i8o9p0" #"\d+" 5)))

(assert (= ["Some" "words" "to" "split"]
           (split "Some words to split" " ")))

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-wisp-source-0.8.0 vendor/node_modules/wisp/test/string.wisp
ruby-wisp-source-0.7.0 vendor/test/string.wisp