|
63 | 63 | (test:expect (not (dict:contains? d "hello"))) |
64 | 64 | (test:expect (not (dict:contains? d d))) }) |
65 | 65 |
|
66 | | - (test:case "size" { |
67 | | - (test:eq (dict:size d) 6) |
68 | | - (test:eq (dict:size d) (len d)) |
69 | | - (test:eq (dict:size (dict)) 0) |
70 | | - (test:eq (dict:size (dict)) (len (dict))) |
71 | | - (test:eq (dict:size d3) 1) |
72 | | - (test:eq (dict:size d3) (len d3)) |
73 | | - (test:eq (dict:size d4) 1) }) |
| 66 | + (test:case "len" { |
| 67 | + (test:eq (len d) 6) |
| 68 | + (test:eq (len (dict)) 0) |
| 69 | + (test:eq (len d3) 1) |
| 70 | + (test:eq (len d4) 1) }) |
74 | 71 |
|
75 | 72 | (test:case "keys" { |
76 | 73 | (test:eq (dict:keys d) ["key" 5 true false foo closure]) |
|
104 | 101 | (test:eq (dict:get d5 "count") 2) }) |
105 | 102 |
|
106 | 103 | (test:case "remove" { |
107 | | - (test:eq (dict:size d) 7) |
| 104 | + (test:eq (len d) 7) |
108 | 105 | (dict:remove d "test") |
109 | 106 | (test:eq (dict:get d "test") nil) |
110 | | - (test:eq (dict:size d) 6) }) |
| 107 | + (test:eq (len d) 6) }) |
111 | 108 |
|
112 | 109 | (test:case "map" { |
113 | 110 | (let mapped (dict:map d2 map_to_str)) |
114 | | - (test:eq (dict:size d2) (dict:size mapped)) |
| 111 | + (test:eq (len d2) (len mapped)) |
115 | 112 | (test:eq (dict:get d2 "a") 1) |
116 | 113 | (test:eq (dict:get d2 "b") 2) |
117 | 114 | (test:eq (dict:get d2 "c") 3) |
|
120 | 117 | (test:eq (dict:get mapped "c") "3") |
121 | 118 |
|
122 | 119 | (let mapped2 (dict:map (dict) (fun (k v) v))) |
123 | | - (test:eq (dict:size mapped2) 0) }) |
| 120 | + (test:eq (len mapped2) 0) }) |
124 | 121 |
|
125 | 122 | (test:case "map!" { |
126 | 123 | (dict:map! mapped map_to_num) |
127 | | - (test:eq (dict:size d2) (dict:size mapped)) |
| 124 | + (test:eq (len d2) (len mapped)) |
128 | 125 | (test:eq (dict:get d2 "a") 1) |
129 | 126 | (test:eq (dict:get d2 "b") 2) |
130 | 127 | (test:eq (dict:get d2 "c") 3) |
|
133 | 130 | (test:eq (dict:get mapped "c") 3) |
134 | 131 |
|
135 | 132 | (dict:map! empty map_to_num) |
136 | | - (test:eq (dict:size empty) 0) }) |
| 133 | + (test:eq (len empty) 0) }) |
137 | 134 |
|
138 | 135 | (test:case "forEach" { |
139 | 136 | (dict:forEach empty (fun (k v) |
|
144 | 141 | (test:case "copy" { |
145 | 142 | (let d2_copy (dict:copy d2)) |
146 | 143 | (dict:add d2_copy "d" 4) |
147 | | - (test:eq (dict:size d2_copy) 4) |
148 | | - (test:eq (dict:size d2) 3) }) |
| 144 | + (test:eq (len d2_copy) 4) |
| 145 | + (test:eq (len d2) 3) }) |
149 | 146 |
|
150 | 147 | (test:case "filter" { |
151 | 148 | (let filtered (dict:filter d filter_str_keys)) |
152 | | - (test:eq (dict:size d) 6) |
153 | | - (test:eq (dict:size filtered) 1) |
| 149 | + (test:eq (len d) 6) |
| 150 | + (test:eq (len filtered) 1) |
154 | 151 | (test:eq (dict:get filtered "key") 2) |
155 | 152 |
|
156 | 153 | (let empty_filtered (dict:filter empty filter_str_keys)) |
157 | | - (test:eq (dict:size empty_filtered) 0) }) |
| 154 | + (test:eq (len empty_filtered) 0) }) |
158 | 155 |
|
159 | 156 | (test:case "asJson" { |
160 | 157 | (test:eq (dict:asJson empty) "{}") |
|
164 | 161 |
|
165 | 162 | (test:case "filter!" { |
166 | 163 | (dict:filter! d2 filter_odd) |
167 | | - (test:eq (dict:size d2) 2) |
| 164 | + (test:eq (len d2) 2) |
168 | 165 | (test:expect (dict:contains? d2 "a")) |
169 | 166 | (test:expect (not (dict:contains? d2 "b"))) |
170 | 167 | (test:expect (dict:contains? d2 "c")) |
171 | 168 | (test:eq (dict:get d2 "a") 1) |
172 | 169 | (test:eq (dict:get d2 "c") 3) |
173 | 170 |
|
174 | 171 | (dict:filter! empty filter_odd) |
175 | | - (test:eq (dict:size empty_filtered) 0) }) |
| 172 | + (test:eq (len empty_filtered) 0) }) |
176 | 173 |
|
177 | 174 | (test:case "update!" { |
178 | 175 | (dict:update! d d2) |
179 | | - (test:eq (dict:size d) 8) |
| 176 | + (test:eq (len d) 8) |
180 | 177 | (test:eq (dict:get d "a") 1) |
181 | 178 | (test:eq (dict:get d "c") 3) |
182 | 179 | (test:eq (dict:get d "key") 2) |
|
186 | 183 | (test:eq (dict:get d foo) "yes") |
187 | 184 | (test:eq (dict:get d closure) foo) |
188 | 185 |
|
189 | | - (test:eq (dict:size d2) 2) |
| 186 | + (test:eq (len d2) 2) |
190 | 187 | (dict:add d2 "a" 5) |
191 | 188 | (test:eq (dict:get d "a") 1) |
192 | 189 | (test:eq (dict:get d2 "a") 5) |
193 | 190 |
|
194 | 191 | (dict:update! d2 empty) |
195 | | - (test:eq (dict:size d2) 2) |
| 192 | + (test:eq (len d2) 2) |
196 | 193 | (test:eq (dict:get d2 "a") 5) |
197 | 194 | (test:eq (dict:get d2 "c") 3) |
198 | | - (test:eq (dict:size empty) 0) }) }) |
| 195 | + (test:eq (len empty) 0) }) }) |
0 commit comments