The Inbox: CollectionsTests-cmm.314.mcz

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

The Inbox: CollectionsTests-cmm.314.mcz

commits-2
Chris Muller uploaded a new version of CollectionsTests to project The Inbox:
http://source.squeak.org/inbox/CollectionsTests-cmm.314.mcz

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

Name: CollectionsTests-cmm.314
Author: cmm
Time: 4 June 2019, 9:15:34.016525 pm
UUID: a6094c13-6cf5-4b63-84b7-9e0a77df21b9
Ancestors: CollectionsTests-cmm.313

Additional test for #joinSeparatedBy: describes the expected behavior for unordered collections.

=============== Diff against CollectionsTests-cmm.313 ===============

Item was added:
+ ----- Method: CollectionTest>>runJoinTestUsing: (in category 'running') -----
+ runJoinTestUsing: classSelector
+ | joinedString joinedParts source |
+ source := #(#a #b #c #c #b #a #x #x #x #y #z #z #z #z #z '1' '22' '33' '33' '22' '1') perform: classSelector.
+ joinedString := source joinSeparatedBy: '|'.
+
+ "Verify output length"
+ joinedParts := joinedString subStrings: '|'.
+ self assert: (joinedString subStrings: '|') size = source size.
+
+ "Contents check"
+ joinedParts asBag sortedCounts do:
+ [ : each | self assert: (source occurrencesOf: each value) = each key ]!

Item was changed:
  ----- Method: CollectionTest>>testJoin (in category 'tests') -----
  testJoin
+ self assert: #(#a #b #c #d #e) join = 'abcde'.
+ self assert: (#(#a #b #c) joinSeparatedBy: '|') = 'a|b|c'.
+ #(#asArray #asOrderedCollection #asSet #asBag #asSortedArray #asSortedCollection) do:
+ [ : each | self runJoinTestUsing: each ]!
- | joined source |
- self assert: #(a b c d e) join = 'abcde'.
- self assert: (#(a b c) joinSeparatedBy: '|') = 'a|b|c'.
- "Test with unordered Set."
- source := #(a b c c b a x x x y z z z z z '1' '2' '3' '3' '2' '1') asSet.
- joined := source joinSeparatedBy: '|'.
- self assert: ((2 to: joined size by: 2) allSatisfy: [ : index | (joined at: index) = $| ]).
- self assert: ((1 to: joined size by: 2) allSatisfy: [ : index | source includes: (joined at: index) asString ]).
- "Repeat with Bag."
- source := #(a b c c b a x x x y z z z z z '1' '2' '3' '3' '2' '1') asBag.
- joined := source joinSeparatedBy: '|'.
- self assert: ((2 to: joined size by: 2) allSatisfy: [ : index | (joined at: index) = $| ]).
- self assert: ((1 to: joined size by: 2) allSatisfy: [ : index | source includes: (joined at: index) asString ]).
- !