The Inbox: CollectionsTests-ct.334.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-ct.334.mcz

commits-2
A new version of CollectionsTests was added to project The Inbox:
http://source.squeak.org/inbox/CollectionsTests-ct.334.mcz

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

Name: CollectionsTests-ct.334
Author: ct
Time: 16 February 2020, 3:33:18.927 pm
UUID: 95a1a103-7864-9a4b-acf3-40dbe978c0b0
Ancestors: CollectionsTests-ul.333

Tests #findFirst: and #findLast: versions. Complements Collections-ct.875.

=============== Diff against CollectionsTests-ul.333 ===============

Item was added:
+ ----- Method: SequenceableCollectionTest>>testFindFirst (in category 'tests - enumerating') -----
+ testFindFirst
+
+ | array |
+ array := (1 to: 10) asArray.
+ self
+ assert: 2 equals: (array findFirst: [:x | x \\ 2 = 0]);
+ assert: 1 equals: (array findFirst: [:x | x \\ 2 = 1]);
+ assert: 0 equals: (array findFirst: [:x | x \\ 2 = 2]).
+ self
+ assert: 2 equals: (array findFirst: [:x | x \\ 2 = 0] ifNone: [self fail: 'noneBlock should not be called']);
+ assert: 1 equals: (array findFirst: [:x | x \\ 2 = 1] ifNone: [self fail: 'noneBlock should not be called']);
+ assert: 42 equals: (array findFirst: [:x | x \\ 2 = 2] ifNone: [42]).
+ self
+ assert: 4 equals: (array findFirst: [:x | x \\ 2 = 0] startingAt: 3);
+ assert: 3 equals: (array findFirst: [:x | x \\ 2 = 1] startingAt: 3);
+ assert: 0 equals: (array findFirst: [:x | x = 2] startingAt: 3).
+ self
+ assert: 4 equals: (array findFirst: [:x | x \\ 2 = 0] startingAt: 3 ifNone: [self fail: 'noneBlock should not be called']);
+ assert: 3 equals: (array findFirst: [:x | x \\ 2 = 1] startingAt: 3 ifNone: [self fail: 'noneBlock should not be called']);
+ assert: 42 equals: (array findFirst: [:x | x \\ 2 = 2] startingAt: 3 ifNone: [42]).!

Item was added:
+ ----- Method: SequenceableCollectionTest>>testFindLast (in category 'tests - enumerating') -----
+ testFindLast
+
+ | array |
+ array := (1 to: 10) asArray.
+ self
+ assert: 10 equals: (array findLast: [:x | x \\ 2 = 0]);
+ assert: 9 equals: (array findLast: [:x | x \\ 2 = 1]);
+ assert: 0 equals: (array findLast: [:x | x \\ 2 = 2]).
+ self
+ assert: 10 equals: (array findLast: [:x | x \\ 2 = 0] ifNone: [self fail: 'noneBlock should not be called']);
+ assert: 9 equals: (array findLast: [:x | x \\ 2 = 1] ifNone: [self fail: 'noneBlock should not be called']);
+ assert: 42 equals: (array findLast: [:x | x \\ 2 = 2] ifNone: [42]).
+ self
+ assert: 10 equals: (array findLast: [:x | x \\ 2 = 0] startingAt: 3);
+ assert: 9 equals: (array findLast: [:x | x \\ 2 = 1] startingAt: 3);
+ assert: 0 equals: (array findLast: [:x | x = 2] startingAt: 3).
+ self
+ assert: 10 equals: (array findLast: [:x | x \\ 2 = 0] startingAt: 3 ifNone: [self fail: 'noneBlock should not be called']);
+ assert: 9 equals:(array findLast: [:x | x \\ 2 = 1] startingAt: 3 ifNone: [self fail: 'noneBlock should not be called']);
+ assert: 42 equals: (array findLast: [:x | x \\ 2 = 2] startingAt: 3 ifNone: [42]).!