hy/tests/native_tests/language.hy

53 lines
937 B
Hy
Raw Normal View History

2013-03-06 04:08:53 +01:00
;
2013-03-07 00:57:21 +01:00
2013-03-09 00:18:43 +01:00
(defn test_lists []
2013-03-06 04:15:45 +01:00
"NATIVE: test lists work right"
2013-03-09 00:18:43 +01:00
(assert (= [1 2 3 4] (+ [1 2] [3 4]))))
2013-03-08 04:52:47 +01:00
2013-03-09 00:18:43 +01:00
(defn test_for_loop []
2013-03-08 04:52:47 +01:00
"NATIVE: test for loops?"
(def count 0)
(for [x [1 2 3 4 5]]
(def count (+ count x)))
2013-03-09 00:18:43 +01:00
(assert (= count 15)))
2013-03-09 02:45:19 +01:00
(defn test_in []
"NATIVE: test in"
(assert (in "a" ["a" "b" "c" "d"]))
(assert (not-in "f" ["a" "b" "c" "d"])))
(defn test_numops []
"NATIVE: test numpos"
(assert (> 5 4 3 2 1))
(assert (< 1 2 3 4 5))
(assert (<= 5 5 5 5 ))
(assert (>= 5 5 5 5 )))
2013-03-09 06:01:43 +01:00
(defn test_is []
"NATIVE: test is can deal with None"
(def a null)
(assert (is a null))
(assert (is-not a "b")))
(defn test_branching []
"NATIVE: test if branching"
(if true
(assert (= 1 1))
(assert (= 2 1))))
(defn test_branching_with_do []
"NATIVE: test if branching (multiline)"
(if false
(assert (= 2 1))
(do
(assert (= 1 1))
(assert (= 1 1))
(assert (= 1 1)))))