hy/tests/native_tests/with_decorator.hy

23 lines
338 B
Hy
Raw Normal View History

(defn foodec [func]
(lambda [] (+ 1 1)))
(with-decorator foodec
(defn tfunction []
(* 2 2)))
2014-11-14 21:21:16 +01:00
(defn bardec [cls]
(setv cls.my_attr 123)
cls)
2014-11-14 21:21:16 +01:00
(with-decorator bardec
(defclass cls []
[[my_attr 456]]))
(defn test-decorators []
"NATIVE: test decorators."
2014-11-14 21:21:16 +01:00
(assert (= (tfunction) 2))
(assert (= cls.my_attr 123)))