File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
### Fixed
9
9
* Fix a bug where the compiler would always generate inline function definitions even if the ` inline-functions ` compiler option is disabled (#1023 )
10
10
* Fix a bug where ` defrecord ` /` deftype ` constructors could not be used in the type's methods. (#1025 )
11
+ * Fix a bug where ` keys ` and ` vals ` would fail for records (#1030 )
11
12
12
13
## [ v0.2.1]
13
14
### Changed
Original file line number Diff line number Diff line change 6869
6869
(contains? ~'_recmap ~key-gs)
6870
6870
(get ~'_recmap ~key-gs default#))))
6871
6871
(~'__getitem__ [~this-gs ~key-gs]
6872
- (. ~this-gs ~'entry ~key-gs))
6872
+ (.val-at ~this-gs ~key-gs))
6873
6873
(~'__iter__ [~this-gs]
6874
- (seq ~this-gs))
6874
+ (python/iter (map first ( seq ~this-gs)) ))
6875
6875
(~'__len__ [~this-gs]
6876
6876
(+ ~(count field-kw-set)
6877
6877
(count ~'_recmap)))
Original file line number Diff line number Diff line change 73
73
((juxt :w :x :y :z :new-key) p2)))
74
74
(is (= [1 nil 3] ((juxt :x :y :z) p3))))
75
75
76
+ (testing "__getitem__ field access"
77
+ (is (= 1 (.__getitem__ p :x)))
78
+ (is (= 2 (.__getitem__ p :y)))
79
+ (is (= 3 (.__getitem__ p :z)))
80
+ (is (nil? (.__getitem__ p :l)))
81
+ (is (= 0 (.__getitem__ p1 :w))))
82
+
76
83
(testing "assoc"
77
84
(is (= 4 (:x (assoc p :x 4))))
78
85
(is (= 5 (:y (assoc p :y 5))))
150
157
(is (= #{[:x 1] [:z 3]}
151
158
(set (seq p3)))))
152
159
160
+ (testing "iterator"
161
+ (is (= #{:x :y :z} (set (seq (python/iter p)))))
162
+ (is (= #{:w :x :y :z} (set (seq (python/iter p1)))))
163
+ (is (= #{:w :x :y :z :new-key} (set (seq (python/iter p2))))))
164
+
165
+ (testing "keys"
166
+ (is (= #{:x :y :z} (set (keys p))))
167
+ (is (= #{:w :x :y :z} (set (keys p1))))
168
+ (is (= #{:w :x :y :z :new-key} (set (keys p2)))))
169
+
170
+ (testing "vals"
171
+ (is (= #{1 2 3} (set (vals p))))
172
+ (is (= #{0 1 2 3} (set (vals p1))))
173
+ (is (= #{0 1 2 3 "some-value"} (set (vals p2)))))
174
+
153
175
(testing "equals"
154
176
(is (= (->Point 1 2 3) p))
155
177
(is (= p1
You can’t perform that action at this time.
0 commit comments