application/octet-stream
•
992 B
•
27 lines
#!/usr/bin/env nujel
;; Simple test program that should give the same result as `wc -l` or `wc -w`
[defn count-lines [filename]
[def text [string [file/read filename]]]
[- [count [split text "\n"]] 1]]
[defn count-words [filename]
[def text [string [file/read filename]]]
[-> text
[split "\n"]
[reduce [fn [a b]
[+ a [count [split b " "] [fn [a] [> [string/length [trim a]] 0]]]]]
0]]]
[def lines [count-lines "CODE_OF_CONDUCT.md"]]
[when [not= lines 136]
[throw [list :wrong-result "CoC Lines Wrong" lines]]]
[def words [count-words "CODE_OF_CONDUCT.md"]]
[when [not= words 717]
[throw [list :wrong-result "CoC Words Wrong" words]]]
[def llines [count-lines "LICENSE"]]
[when [not= llines 19]
[throw [list :wrong-result "LICENSE Lines Wrong" llines]]]
[def lwords [count-words "LICENSE"]]
[when [not= lwords 168]
[throw [list :wrong-result "LICENSE Words Wrong" lwords]]]