The Trunk: CollectionsTests-mt.310.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-mt.310.mcz

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

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

Name: CollectionsTests-mt.310
Author: mt
Time: 14 May 2019, 9:45:29.021441 am
UUID: 7250e350-3e87-c64c-950e-8a5f794794d1
Ancestors: CollectionsTests-mt.309

Adds more tests for #any:, #any:as:, and #take:.

=============== Diff against CollectionsTests-mt.309 ===============

Item was changed:
  ----- Method: CollectionTest>>testAny (in category 'tests') -----
  testAny
 
+ {
+ "{ numberOfElements. originalCollection }"
+ { 2. Array withAll: #(1 2 3 4) }.
+ { 4. Array withAll: #(1 2 3 4) }.
+ { 0. Array withAll: #(1 2 3 4) }.
+ { 2. OrderedCollection withAll: #(1 2 3 4) }.
+ { 2. Dictionary withAll: { #apple -> #red. #plum -> #purple. #peach -> #orange } }.
+ { 2. Set withAll: #(1 2 3 4) }.
+ { 2. Bag withAll: #(1 1 2 2) }.
+ } do: [:spec | | result |
+ result := spec second any: spec first.
+ self
+ assert: (spec second includesAllOf: result);
+ assert: spec first equals: result size;
+ assert: spec second class equals: result class].!
- self
- assert: #(1 2) equals: (#(1 2 3 4) any: 2);
- assert: #(1 2 3 4) equals: (#(1 2 3 4) any: 4);
- should: [#(1 2 3 4) any: 5] raise: Error.!

Item was changed:
  ----- Method: CollectionTest>>testAnyAs (in category 'tests') -----
  testAnyAs
 
+ {
+ "{ numberOfElements. originalCollection }"
+ { 2. 2. OrderedCollection. Array withAll: #(1 2 3 4) }.
+ { 4. 1. Set. Array withAll: #(1 1 1 1) }.
+ { 4. 4. Bag. Array withAll: #(1 1 1 1) }.
+ { 2. 2. Dictionary. Array withAll: { #apple -> #red. #plum -> #purple. #peach -> #orange } }.
+ } do: [:spec | | result |
+ result := spec fourth any: spec first as: spec third.
+
+ "For Array vs. Dictionary, #includesAllOf: does not work because it would just iterate the values in the dictionary."
+ (result associationsDo: [:each | self assert: (spec fourth includes: each)]).
+
+ self
+ assert: spec second equals: result size;
+ assert: spec third equals: result class].!
- self
- assert: ((#(1 2 3 4) any: 2 as: OrderedCollection) isKindOf: OrderedCollection);
- assert: ((#(1 1 2 3 4) any: 2 as: Set) isKindOf: Set);
- assert: 1 equals: (#(1 1 1 1) any: 3 as: Set) size.!

Item was added:
+ ----- Method: CollectionTest>>testAnyError (in category 'tests') -----
+ testAnyError
+
+ self
+ should: [#(1 2 3 4) any: 5] raise: Error; "Too small."
+ should: [#(1 2 3 4) any: -1] raise: Error. "Bad argument."!

Item was added:
+ ----- Method: CollectionTest>>testAnyStreams (in category 'tests') -----
+ testAnyStreams
+
+ {
+ "{ numberOfElements. originalCollection }"
+ { 2. Array withAll: #(1 2 3 4) }.
+ { 4. Array withAll: #(1 2 3 4) }.
+ { 0. Array withAll: #(1 2 3 4) }.
+ { 2. OrderedCollection withAll: #(1 2 3 4) }.
+ } do: [:spec | | result |
+ result := spec second readStream any: spec first.
+ self
+ assert: (spec second includesAllOf: result);
+ assert: spec first equals: result size;
+ assert: spec second class equals: result class].!

Item was changed:
  ----- Method: CollectionTest>>testTake (in category 'tests') -----
  testTake
 
  self
+ assert: 2 equals: (#(1 2) take: 5) size;
+ assert: 2 equals: (#(1 2) readStream take: 5) size;
+ should: [#(1 2) take: -1] raise: Error.!
- assert: #(1 2) equals: (#(1 2 3 4) take: 2);
- assert: #(1 2) equals: (#(1 2) take: 5).!