Nicolas Cellier uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-nice.128.mcz ==================== Summary ==================== Name: CollectionsTests-nice.128 Author: nice Time: 27 December 2009, 8:53:04 am UUID: 4e5cafc2-cfe9-4d20-93e9-92ed055e9387 Ancestors: CollectionsTests-nice.127 Cosmetic: move or remove a few temps inside closures =============== Diff against CollectionsTests-nice.127 =============== Item was changed: ----- Method: IntegerArrayTest>>testStoreNegativeOutOfRange (in category 'tests') ----- testStoreNegativeOutOfRange "A value too small for a 32-bit signed integer should raise an error." + | ia val | - | ia val storedValue | ia := IntegerArray new: 1. val := (2 raisedTo: 31) negated - 1. " -16r80000001 of range for 32-bit twos complement integer" + self should: [ | storedValue | + ia at: 1 put: val. "should raise error here" - self should: [ia at: 1 put: val. "should raise error here" storedValue := ia at: 1. "lack of range check leads to value of 16r7FFFFFFF" self assert: val = storedValue "fail here"] raise: Error ! Item was changed: ----- Method: IntegerArrayTest>>testStorePositiveOutOfRange (in category 'tests') ----- testStorePositiveOutOfRange "A value too large for a 32-bit signed integer should raise an error." + | ia val | - | ia val storedValue | ia := IntegerArray new: 1. val := 2 raisedTo: 31. "16r80000000 is out of range for 32-bit twos complement" + self should: [ | storedValue | + ia at: 1 put: val. "should raise error here" - self should: [ia at: 1 put: val. "should raise error here" storedValue := ia at: 1. "lack of range check leads to value of 16r-80000000" self assert: val = storedValue "fail here"] raise: Error ! Item was changed: ----- Method: CollectionTest>>testPrintOnDelimiterLast (in category 'testing') ----- testPrintOnDelimiterLast + | delim last | - | delim emptyStream last oneItemStream multiItemStream | delim := ', '. last := ' & '. {OrderedCollection new. Set new.} do: + [ :coll | | emptyStream oneItemStream multiItemStream | - [ :coll | emptyStream := ReadWriteStream on: ''. coll printOn: emptyStream delimiter: delim last: last. self assert: emptyStream contents = ''. coll add: 1. oneItemStream := ReadWriteStream on: ''. coll printOn: oneItemStream delimiter: delim last: last. self assert: oneItemStream contents = '1'. coll add: 2; add: 3. multiItemStream := ReadWriteStream on: ''. coll printOn: multiItemStream delimiter: ', ' last: last. self assert: multiItemStream contents = '1'', ''2'' & ''3'.]! Item was changed: ----- Method: CollectionTest>>testAsStringOnDelimiter (in category 'testing') ----- testAsStringOnDelimiter + | delim | - | delim emptyStream oneItemStream multiItemStream | delim := ', '. {OrderedCollection new. Set new.} do: + [ :coll | | oneItemStream emptyStream multiItemStream | - [ :coll | emptyStream := ReadWriteStream on: ''. coll asStringOn: emptyStream delimiter: delim. self assert: emptyStream contents = ''. coll add: 1. oneItemStream := ReadWriteStream on: ''. coll asStringOn: oneItemStream delimiter: delim. self assert: oneItemStream contents = '1'. coll add: 2; add: 3. multiItemStream := ReadWriteStream on: ''. coll asStringOn: multiItemStream delimiter: ', '. self assert: multiItemStream contents = '1, 2, 3'.]! Item was changed: ----- Method: CollectionTest>>testAsStringOnDelimiterLast (in category 'testing') ----- testAsStringOnDelimiterLast + | delim last | - | delim emptyStream last oneItemStream multiItemStream | delim := ', '. last := ' & '. {OrderedCollection new. Set new.} do: + [ :coll | | multiItemStream emptyStream oneItemStream | - [ :coll | emptyStream := ReadWriteStream on: ''. coll asStringOn: emptyStream delimiter: delim last: last. self assert: emptyStream contents = ''. coll add: 1. oneItemStream := ReadWriteStream on: ''. coll asStringOn: oneItemStream delimiter: delim last: last. self assert: oneItemStream contents = '1'. coll add: 2; add: 3. multiItemStream := ReadWriteStream on: ''. coll asStringOn: multiItemStream delimiter: ', ' last: last. self assert: multiItemStream contents = '1, 2 & 3'.]! Item was changed: ----- Method: HeapTest>>test1 (in category 'testing') ----- test1 + | data | - | data h | "The first element of each array is the sort value, and the second will be updated by the heap with the index of the element within the heap." data := (1 to: 8) collect: [:i | {i*2. 0}]. "Repeat with different data ordering." + 5 timesRepeat: [ | h | - 5 timesRepeat: [ h := Heap new sortBlock: [:e1 :e2 | e1 first < e2 first]. h indexUpdateBlock: [:array :index | array at: 2 put: index]. data shuffled do: [:d | h add: d]. data do: [:d | self should: (h at: d second) == d]. ]! Item was changed: ----- Method: CollectionTest>>testPrintOnDelimiter (in category 'testing') ----- testPrintOnDelimiter + | delim | - | delim emptyStream oneItemStream multiItemStream | delim := ', '. {OrderedCollection new. Set new.} do: + [ :coll | | emptyStream oneItemStream multiItemStream | - [ :coll | emptyStream := ReadWriteStream on: ''. coll printOn: emptyStream delimiter: delim. self assert: emptyStream contents = ''. coll add: 1. oneItemStream := ReadWriteStream on: ''. coll printOn: oneItemStream delimiter: delim. self assert: oneItemStream contents = '1'. coll add: 2; add: 3. multiItemStream := ReadWriteStream on: ''. coll printOn: multiItemStream delimiter: ', '. self assert: multiItemStream contents = '1'', ''2'', ''3'.]! |
Free forum by Nabble | Edit this page |