The Trunk: CollectionsTests-ul.161.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-ul.161.mcz

commits-2
Levente Uzonyi uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-ul.161.mcz

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

Name: CollectionsTests-ul.161
Author: ul
Time: 3 May 2010, 9:34:10.316 pm
UUID: 7a976293-ead3-2d44-bc31-01b1430fb034
Ancestors: CollectionsTests-ul.160

- added a test for WeakSet >> #do:after:
- categorized methods

=============== Diff against CollectionsTests-ul.160 ===============

Item was changed:
+ ----- Method: WeakSetTest>>testIncludes (in category 'tests') -----
- ----- Method: WeakSetTest>>testIncludes (in category 'as yet unclassified') -----
  testIncludes
 
  | weakSet transientFakeNilObject |
  weakSet := WeakSet new.
  #(true nil 1) do: [ :each |
  self deny: (weakSet includes: each) ].
  weakSet add: true.
  self assert: (weakSet includes: true).
  weakSet remove: true.
  self deny: (weakSet includes: true).
  transientFakeNilObject := ((1 to: 1000) detect: [ :each | each asString hash - nil hash \\ weakSet capacity = 0 ]) asString. "this string will occupy the same slot as nil would"
  weakSet add: transientFakeNilObject.
  transientFakeNilObject := transientFakeNilObject copy.
  Smalltalk garbageCollect. "get rid of transientFakeNilObject"
  self deny: (weakSet includes: transientFakeNilObject).
  self deny: (weakSet includes: nil)
 
 
  !

Item was added:
+ ----- Method: WeakSetTest>>testDoAfter (in category 'tests') -----
+ testDoAfter
+
+ | input weakSet array |
+ input := (1 to: 11) collect: [ :each | each asString asSymbol ]. "Some symbols might be garbage collected without this variable"
+ weakSet := WeakSet withAll: input.
+ array := weakSet asArray. "Assume that the elements will have the same order as the internal array of the weakset"
+ 0 to: array size do: [ :index |
+ | element result |
+ element := array at: index ifAbsent: nil.
+ result := Array new: weakSet size - index streamContents: [ :stream |
+ weakSet
+ do: [ :each | stream nextPut: each ]
+ after: element ].
+ self assert: result sort = (array allButFirst: index) sort ]!