The Trunk: CollectionsTests-pre.314.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: CollectionsTests-pre.314.mcz

commits-2
Marcel Taeumel uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-pre.314.mcz

==================== Summary ====================

Name: CollectionsTests-pre.314
Author: pre
Time: 22 July 2019, 3:14:39.839761 pm
UUID: e3cb9512-d24c-034b-9c4d-31dc6aa3c7e4
Ancestors: CollectionsTests-mt.313

Adds tests for collect:as: which has a suprising limitation for collecting a Set as a Dictionary.

=============== Diff against CollectionsTests-mt.313 ===============

Item was added:
+ ----- Method: CollectionTest>>testCollectAs (in category 'tests') -----
+ testCollectAs
+
+ | classes collection newCollection |
+ classes := {Array . OrderedCollection . Set . Bag}.
+ classes do: [:originClass |
+ classes do: [:targetClass |
+ collection := originClass with: 1 with: 2 with: 3.
+ newCollection := collection collect: [:v | v + 1] as: targetClass.
+ self
+ assert: collection size equals: newCollection size;
+ assert: (newCollection includesAllOf: { 2 . 3. 4})]]!

Item was added:
+ ----- Method: DictionaryTest>>testCollectAs (in category 'tests - collection protocol') -----
+ testCollectAs
+
+ | classes collection dictionary |
+ classes := {Array . OrderedCollection . Set . Bag}.
+ classes do: [:originClass |
+ collection := originClass with: 1 with: 2 with: 3.
+ dictionary := collection collect: [:v | v -> (v + 1)] as: Dictionary.
+ self
+ assert: collection size equals: dictionary size;
+ assert: (dictionary associations includesAllOf: { 1 -> 2 . 2 -> 3. 3 -> 4})]!