Andreas Raab uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-ar.136.mcz ==================== Summary ==================== Name: CollectionsTests-ar.136 Author: ar Time: 1 February 2010, 9:40:49.176 pm UUID: 61a558f8-21ec-514b-a5e1-9746868ed130 Ancestors: CollectionsTests-ar.135 More tests, including KeyedSet and WeakSet. =============== Diff against CollectionsTests-ar.135 =============== Item was changed: ----- Method: SetWithNilTest>>testIdentitySetWithNil (in category 'tests') ----- testIdentitySetWithNil + self runSetWithNilTestOf: [IdentitySet new]! - self shouldnt:[IdentitySet with: nil] raise: Error. - self shouldnt:[IdentitySet withAll: #(nil nil nil)] raise: Error. - - self assert: (IdentitySet with: nil) size = 1. - self assert: (IdentitySet withAll: #(nil nil nil)) size = 1. - - self assert: (IdentitySet with: nil) anyOne = nil. - self assert: ((IdentitySet with: nil) remove: nil) == nil. - self assert: ((IdentitySet with: nil) remove: nil; yourself) isEmpty. - - self assert: (IdentitySet withAll: #(1 nil foo)) size = 3. - self assert: ((IdentitySet withAll: #(1 nil foo)) remove: nil; yourself) size = 2. - - self assert: ((IdentitySet with: nil) collect:[:x| x]) = (IdentitySet with: nil). - self assert: ((IdentitySet with: nil) collect:[:x| x] as: Array) = #(nil). - ! Item was changed: ----- Method: SetWithNilTest>>testKeyedSetWithNil (in category 'tests') ----- testKeyedSetWithNil + | set | + self runSetWithNilTestOf: [KeyedSet keyBlock:[:o| o]]. + set := KeyedSet keyBlock:[:o| o]. + set add: nil. + self assert: (set at: nil) == nil. - self should:[KeyedSet with: nil] raise: Error. ! Item was changed: ----- Method: SetWithNilTest>>testWeakSetWithNil (in category 'tests') ----- testWeakSetWithNil + | set | + self runSetWithNilTestOf: [WeakSet new]. + "Ensure that GCed entries don't count" + set := WeakSet with: Object new. + Smalltalk garbageCollect. + set do:[:x| self assert: false]. "test for de facto emptyness" + self deny: (set includes: nil). + set add: nil. + self assert: (set includes: nil). + set remove: nil. + self deny: (set includes: nil).! - self should:[WeakSet with: nil] raise: Error. - ! Item was added: + ----- Method: SetWithNilTest>>testKeyedIdentitySetWithNil (in category 'tests') ----- + testKeyedIdentitySetWithNil + | set | + self runSetWithNilTestOf: [KeyedIdentitySet keyBlock:[:o| o]]. + set := KeyedIdentitySet keyBlock:[:o| o]. + set add: nil. + self assert: (set at: nil) == nil. + ! Item was changed: ----- Method: SetWithNilTest>>testSetWithNil (in category 'tests') ----- testSetWithNil + self runSetWithNilTestOf: [Set new]! - self shouldnt:[Set with: nil] raise: Error. - self shouldnt:[Set withAll: #(nil nil nil)] raise: Error. - - self assert: (Set with: nil) size = 1. - self assert: (Set withAll: #(nil nil nil)) size = 1. - - self assert: (Set with: nil) anyOne = nil. - self assert: ((Set with: nil) remove: nil) == nil. - self assert: ((Set with: nil) remove: nil; yourself) isEmpty. - - self assert: (Set withAll: #(1 nil foo)) size = 3. - self assert: ((Set withAll: #(1 nil foo)) remove: nil; yourself) size = 2. - - self assert: ((Set with: nil) collect:[:x| x]) = (Set with: nil). - self assert: ((Set with: nil) collect:[:x| x] as: Array) = #(nil). - ! Item was changed: ----- Method: SetWithNilTest>>testPluggableSetWithNil (in category 'tests') ----- testPluggableSetWithNil + self runSetWithNilTestOf: [PluggableSet new]! - self shouldnt:[PluggableSet with: nil] raise: Error. - self shouldnt:[PluggableSet withAll: #(nil nil nil)] raise: Error. - - self assert: (PluggableSet with: nil) size = 1. - self assert: (PluggableSet withAll: #(nil nil nil)) size = 1. - - self assert: (PluggableSet with: nil) anyOne = nil. - self assert: ((PluggableSet with: nil) remove: nil) == nil. - self assert: ((PluggableSet with: nil) remove: nil; yourself) isEmpty. - - self assert: (PluggableSet withAll: #(1 nil foo)) size = 3. - self assert: ((PluggableSet withAll: #(1 nil foo)) remove: nil; yourself) size = 2. - - self assert: ((PluggableSet with: nil) collect:[:x| x]) = (PluggableSet with: nil). - self assert: ((PluggableSet with: nil) collect:[:x| x] as: Array) = #(nil). - ! Item was added: + ----- Method: SetWithNilTest>>runSetWithNilTestOf: (in category 'tests') ----- + runSetWithNilTestOf: newSet + "Run the common tests for the given set class" + self shouldnt:[newSet value add: nil] raise: Error. + self shouldnt:[newSet value addAll: #(nil nil nil)] raise: Error. + + self assert: (newSet value add: nil; yourself) size = 1. + self assert: (newSet value addAll: #(nil nil nil); yourself) size = 1. + + self assert: ((newSet value add: nil; yourself) includes: nil). + self assert: ((newSet value addAll: #(nil nil nil); yourself) includes: nil). + + self assert: (newSet value add: nil; yourself) anyOne = nil. + self assert: ((newSet value add: nil; yourself) remove: nil) == nil. + self assert: ((newSet value add: nil; yourself) remove: nil; yourself) isEmpty. + + self assert: (newSet value addAll: #(1 nil foo); yourself) size = 3. + self assert: ((newSet value addAll: #(1 nil foo); yourself) remove: nil; yourself) size = 2. + + self assert: ((newSet value add: nil; yourself) collect:[:x| x]) = (PluggableSet with: nil). + self assert: ((newSet value add: nil; yourself) collect:[:x| x] as: Array) = #(nil). + + self deny: ((newSet value) includes: nil). + self deny: ((newSet value add: 3; yourself) includes: nil). + self deny: ((newSet value add: 3; remove: 3; yourself) includes: nil). + ! |
Free forum by Nabble | Edit this page |