2013-04-28 17:14:22 +02:00
|
|
|
(defn foodec [func]
|
|
|
|
(lambda [] (+ 1 1)))
|
|
|
|
|
|
|
|
|
|
|
|
(with-decorator foodec
|
|
|
|
(defn tfunction []
|
|
|
|
(* 2 2)))
|
|
|
|
|
|
|
|
|
2014-11-14 21:21:16 +01:00
|
|
|
(defn bardec [cls]
|
2014-11-15 13:47:55 +01:00
|
|
|
(setv cls.my_attr 123)
|
|
|
|
cls)
|
2014-11-14 21:21:16 +01:00
|
|
|
|
|
|
|
(with-decorator bardec
|
|
|
|
(defclass cls []
|
|
|
|
[[my_attr 456]]))
|
|
|
|
|
|
|
|
|
2013-04-28 17:14:22 +02:00
|
|
|
(defn test-decorators []
|
|
|
|
"NATIVE: test decorators."
|
2014-11-14 21:21:16 +01:00
|
|
|
(assert (= (tfunction) 2))
|
|
|
|
(assert (= cls.my_attr 123)))
|