Merge pull request #648 from Foxboron/rename-slot-attr
Rename slots to attribute/attr
This commit is contained in:
commit
c52cff8245
@ -2003,12 +2003,12 @@ class HyASTCompiler(object):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
raise HyTypeError(
|
raise HyTypeError(
|
||||||
expression,
|
expression,
|
||||||
"Wrong argument type for defclass slots definition.")
|
"Wrong argument type for defclass attributes definition.")
|
||||||
for b in body_expression:
|
for b in body_expression:
|
||||||
if len(b) != 2:
|
if len(b) != 2:
|
||||||
raise HyTypeError(
|
raise HyTypeError(
|
||||||
expression,
|
expression,
|
||||||
"Wrong number of argument in defclass slot.")
|
"Wrong number of argument in defclass attribute.")
|
||||||
body += self._compile_assign(b[0], b[1],
|
body += self._compile_assign(b[0], b[1],
|
||||||
b.start_line, b.start_column)
|
b.start_line, b.start_column)
|
||||||
body += body.expr_as_stmt()
|
body += body.expr_as_stmt()
|
||||||
|
@ -20,16 +20,16 @@
|
|||||||
(assert (not (isinstance (A) D))))
|
(assert (not (isinstance (A) D))))
|
||||||
|
|
||||||
|
|
||||||
(defn test-defclass-slots []
|
(defn test-defclass-attrs []
|
||||||
"NATIVE: test defclass slots"
|
"NATIVE: test defclass attributes"
|
||||||
(defclass A []
|
(defclass A []
|
||||||
[[x 42]])
|
[[x 42]])
|
||||||
(assert (= A.x 42))
|
(assert (= A.x 42))
|
||||||
(assert (= (getattr (A) "x") 42)))
|
(assert (= (getattr (A) "x") 42)))
|
||||||
|
|
||||||
|
|
||||||
(defn test-defclass-slots-fn []
|
(defn test-defclass-attrs-fn []
|
||||||
"NATIVE: test defclass slots with fn"
|
"NATIVE: test defclass attributes with fn"
|
||||||
(defclass B []
|
(defclass B []
|
||||||
[[x 42]
|
[[x 42]
|
||||||
[y (fn [self value]
|
[y (fn [self value]
|
||||||
@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn test-defclass-no-fn-leak []
|
(defn test-defclass-no-fn-leak []
|
||||||
"NATIVE: test defclass slots with fn"
|
"NATIVE: test defclass attributes with fn"
|
||||||
(defclass A []
|
(defclass A []
|
||||||
[[x (fn [] 1)]])
|
[[x (fn [] 1)]])
|
||||||
(try
|
(try
|
||||||
|
Loading…
Reference in New Issue
Block a user