[squeak-dev] The Trunk: CollectionsTests-fbs.208.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Nov 5 19:09:49 UTC 2013


Frank Shearar uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-fbs.208.mcz

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

Name: CollectionsTests-fbs.208
Author: fbs
Time: 5 November 2013, 5:09:38.804 pm
UUID: 3aac2521-c3f8-3540-93d3-db038c31e177
Ancestors: CollectionsTests-fbs.207

"self shouldnt: [foo] raise: Error" -> "foo" because the original form does nothing but obscure real bugs. Use #shouldnt:raise: with a_subclass_ of Error.

Rename some tests where appropriate.

Use #assert:equals: rather than assert: foo = bar, to give better error messages.

=============== Diff against CollectionsTests-fbs.207 ===============

Item was removed:
- ----- Method: ByteArrayTest>>testByteArrayLongAt (in category 'as yet unclassified') -----
- testByteArrayLongAt
- 	| ba value |
- 	ba := ByteArray new: 4.
- 	value := -1.
- 	self shouldnt:[ba longAt: 1 put: value bigEndian: true] raise: Error.
- 	self assert: (ba longAt: 1 bigEndian: true) = value.
- 	self shouldnt:[ba longAt: 1 put: value bigEndian: false] raise: Error.
- 	self assert: (ba longAt: 1 bigEndian: false) = value.!

Item was added:
+ ----- Method: ByteArrayTest>>testByteArrayLongAtPreservesSign (in category 'as yet unclassified') -----
+ testByteArrayLongAtPreservesSign
+ 	| ba value |
+ 	ba := ByteArray new: 4.
+ 	value := -1.
+ 	ba longAt: 1 put: value bigEndian: true.
+ 	self assert: (ba longAt: 1 bigEndian: true) = value.
+ 	ba longAt: 1 put: value bigEndian: false.
+ 	self assert: (ba longAt: 1 bigEndian: false) = value.!

Item was changed:
  ----- Method: CharacterSetComplementTest>>testPrintString (in category 'testing') -----
  testPrintString
+ 	|s|
+ 	s := CharacterSet separators complement printString.
+ 	self assert: (s includesSubString: 'complement') description: 'Doesn''t describe its fundamental characteristic'.
+ 	self assert: (s includesSubString: 'Character space') description: 'Doesn''t mention an important separator'.!
- 	"This is about CharacterSetComplementTest"
- 	
- 	self shouldnt: [CharacterSet separators complement printString] raise: Error!

Item was changed:
  ----- Method: CharacterTest>>testCharacterSeparators (in category 'tests - various') -----
  testCharacterSeparators
  	"Regression test"
  
  	| result |
+ 	result := '/', Character separators.
- 	self shouldnt:[result := '/', Character separators] raise: Error.
  	self assert: result size = (Character separators size + 1).
  
+ 	result := '/', CharacterSet separators.
- 	self shouldnt:[result := '/', CharacterSet separators] raise: Error.
  	self assert: result size = (CharacterSet separators asArray size + 1).
  !

Item was changed:
  ----- Method: CharacterTest>>testCodePoint (in category 'tests - creation') -----
  testCodePoint
  	self assert: (Character codePoint: $A asciiValue) = $A.
- 	self shouldnt:[Character codePoint: 500] raise: Error.
  	self assert: (Character codePoint: 500) asciiValue = 500.!

Item was changed:
  ----- Method: DictionaryTest>>testAtNil (in category 'implementation tests') -----
  testAtNil
  	"(self run: #testAtNil)"
  	"nil is a valid key in squeak. In VW nil is not a valid key"
  	"Ansi 1.9 p, 168
      		5.7.2.5 Message: at: key put: newElement
      		Synopsis
      			Store newElement at key in the receiver. Answer newElement.
      		Definition: <abstractDictionary>
      		If lookup succeeds for key, then newElement replaces the element previously stored at key.
      		Otherwise, the newElement is stored at the new key. In either case, subsequent successful
      		lookups for key will answer newElement.  Answer newElement.
  
      		The result is undefined if the key is nil.
  
  		This clearly indicates that different smalltalks where doing different assumptions."
  	
  	
  	
  	| dict1  |
  	dict1 := Dictionary new.
+ 	dict1 at: nil put: #none.
- 	self shouldnt: [ dict1 at: nil put: #none] raise: Error.
  	self assert: (dict1 at: nil) = #none. 
  	!

Item was removed:
- ----- Method: DictionaryTest>>testPseudo (in category 'tests') -----
- testPseudo
- 	"(self run: #testPseudo)"
- 	"true and false are valid keys"
- 	
- 	| dict1  |
- 	dict1 := Dictionary new.
- 	self shouldnt: [dict1 at: true put: #true] raise: Error.
- 	self assert: (dict1 at: true) = #true.
- 		
- 	self shouldnt: [dict1 at: false put: #false] raise: Error.
- 	self assert: (dict1 at: false) = #false.!

Item was changed:
  ----- Method: DictionaryTest>>testPseudoVariablesAreValidKeys (in category 'implementation tests') -----
  testPseudoVariablesAreValidKeys
  	"(self run: #testPseudoVariablesAreValidKeys)"
  	"true and false are valid keys"
  	
  	| dict1  |
  	dict1 := Dictionary new.
+ 	dict1 at: true put: #true.
- 	self shouldnt: [dict1 at: true put: #true] raise: Error.
  	self assert: (dict1 at: true) = #true.
  		
+ 	dict1 at: false put: #false.
- 	self shouldnt: [dict1 at: false put: #false] raise: Error.
  	self assert: (dict1 at: false) = #false.!

Item was changed:
  ----- Method: GeneratorTest>>testErrorPropagation (in category 'testing') -----
  testErrorPropagation
  	"Ensure that errors in the generator block are properly propagated"
  	| generator |
+ 	generator := Generator on: [ :g | g yield: 1. g error: 'yo'].
- 	self shouldnt:[generator := Generator on: [ :g | g yield: 1. g error: 'yo']] raise: Error.
  	self should:[generator next] raise: Error.
  !

Item was changed:
  ----- Method: HeapTest>>testExamples (in category 'testing') -----
  testExamples
+ 	self heapExample.
+ 	self heapSortExample.!
- 	self shouldnt: [self heapExample] raise: Error.
- 	self shouldnt: [self heapSortExample] raise: Error.!

Item was changed:
  ----- Method: HeapTest>>testRemove (in category 'basic tests') -----
  testRemove
  	"self run: #testRemove"
  	
  	| heap |
  	heap := Heap new.
  	self should: [heap removeFirst] raise: Error.
  	heap add: 5.
+ 	heap removeFirst.
- 	self shouldnt: [heap removeFirst] raise: Error.
  	self assert: heap size = 0.
  	heap add: 5.
  	self should: [heap removeAt: 2] raise: Error.!

Item was changed:
  ----- Method: IntervalTest>>testAsInterval (in category 'tests') -----
  testAsInterval
  	"This is the same as newFrom:"
  
+ 	self assert: (1 to: 3) equals: (#(1 2 3) as: Interval).
+ 	self assert: (33 to: -23 by: -28) equals: (#(33 5 -23) as: Interval).
+ 	self assert: (2 to: 6 by: 2) equals: (#[2 4 6] as: Interval).
- 	self shouldnt: [
- 		self assert: (#(1 2 3) as: Interval) = (1 to: 3).
- 		self assert: (#(33 5 -23) as: Interval) = (33 to: -23 by: -28).
- 		self assert: (#[2 4 6] as: Interval) = (2 to: 6 by: 2).
- 	] raise: Error.
  
  	self should: [#(33 5 -22) as: Interval]
  		raise: Error
  		description: 'This is not an arithmetic progression'
  !

Item was changed:
  ----- Method: IntervalTest>>testEquals (in category 'tests') -----
  testEquals
  
+ 	self assert: #(3 4 5) equals: (3 to: 5).
+ 	self deny: (3 to: 5) = #(3 5).
+ 	self deny: (3 to: 5) = #().
- 	self shouldnt: [
- 		self assert: (3 to: 5) = #(3 4 5).
- 		self deny: (3 to: 5) = #(3 5).
- 		self deny: (3 to: 5) = #().
  
+ 	self assert: (3 to: 5) equals: #(3 4 5).
+ 	self deny: #(3 5) = (3 to: 5).
+ 	self deny: #() = (3 to: 5).!
- 		self assert: #(3 4 5) = (3 to: 5).
- 		self deny: #(3 5) = (3 to: 5).
- 		self deny: #() = (3 to: 5).
- 	] raise: MessageNotUnderstood.!

Item was changed:
  ----- Method: IntervalTest>>testNewFrom (in category 'tests') -----
  testNewFrom
  
+ 	 self assert: (1 to: 1) equals: (Interval newFrom: (1 to: 1)).
+ 	 self assert: (1 to: 1) equals:  (Interval newFrom: #(1)).
+ 	 self assert: ( 1 to: 0) equals: (Interval newFrom: #()).
+ !
- 	self shouldnt: [
- 		 self assert: ( (Interval newFrom: (1 to: 1)) = (1 to: 1)).
- 		 self assert: ( (Interval newFrom: #(1)) = (1 to: 1)).
- 		 self assert: ( (Interval newFrom: #()) =  ( 1 to: 0)) .
- 	] raise: Error.!

Item was changed:
  ----- Method: OrderedCollectionTest>>testAtIfAbsentPut (in category 'testsAdding') -----
  testAtIfAbsentPut
  	"Allows one to add an element at an index if no element exist at this index"
  	"self run:#testAtIfAbsentPut" 
  	
  	| c |
  	c := #(1 2 3 4 ) asOrderedCollection.
+ 	c at: 2 ifAbsentPut: [5].
+ 	self assert: #(1 2 3 4 ) asOrderedCollection equals: c.
- 	self
- 		shouldnt: [c at: 2 ifAbsentPut: [5]]
- 		raise: Error.
- 	self assert: c = #(1 2 3 4 ) asOrderedCollection.
  	c at: 5 ifAbsentPut: [5].
+ 	self assert: #(1 2 3 4 5 ) asOrderedCollection equals: c.
- 	self assert: c = #(1 2 3 4 5 ) asOrderedCollection.
  	c at: 7 ifAbsentPut: [7].
+ 	self assert: #(1 2 3 4 5 nil 7 ) asOrderedCollection equals: c.!
- 	self assert: c = #(1 2 3 4 5 nil 7 ) asOrderedCollection!

Item was changed:
  ----- Method: OrderedCollectionTest>>testForceToPadding (in category 'testsCopying') -----
  testForceToPadding
  	"This is a non regression bug for http://bugs.squeak.org/view.php?id=7296"
  	
  	| c1 c2 paddingElement |
  	"source collection"
  	c1 := #(5 3 7 2 ) asOrderedCollection.
  	paddingElement := nil.
  	
  	"force length to longer"
+ 	c2 := c1 forceTo: 10 paddingWith: paddingElement.
- 	self shouldnt: [c2 := c1 forceTo: 10 paddingWith: paddingElement] raise: Error.
  	self assert: (c1 ~~ c2) description: 'forceTo:paddingWith: should modify a copy'.
  	self assert: (c2 size = 10).
  	self assert: (c2 copyFrom: 1 to: c1 size) = c1.
  	self assert: ((c1 size + 1 to: c2 size) allSatisfy: [:i | (c2 at: i) = paddingElement]).
  	
  	"force length to shorter"
+ 	c2 := c1 forceTo: 3 paddingWith: paddingElement.
- 	self shouldnt: [c2 := c1 forceTo: 3 paddingWith: paddingElement] raise: Error.
  	self assert: (c1 ~~ c2) description: 'forceTo:paddingWith: should modify a copy'.
  	self assert: (c2 size = 3).
  	self assert: (c2 copyFrom: 1 to: 3) = (c1 copyFrom: 1 to: 3).
  	
  	"SAME TEST BUT PADDING AT START FOLLOWING..."
  	
  	"force length to longer"
+ 	c2 := c1 forceTo: 10 paddingStartWith: paddingElement.
- 	self shouldnt: [c2 := c1 forceTo: 10 paddingStartWith: paddingElement] raise: Error.
  	self assert: (c1 ~~ c2) description: 'forceTo:paddingStartWith: should modify a copy'.
  	self assert: (c2 size = 10).
  	self assert: (c2 copyFrom: c2 size - c1 size + 1 to: c2 size) = c1.
  	self assert: ((1 to: c2 size - c1 size) allSatisfy: [:i | (c2 at: i) = paddingElement]).
  	
  	"force length to shorter"
+ 	c2 := c1 forceTo: 3 paddingStartWith: paddingElement.
- 	self shouldnt: [c2 := c1 forceTo: 3 paddingStartWith: paddingElement] raise: Error.
  	self assert: (c1 ~~ c2) description: 'forceTo:paddingStartWith: should modify a copy'.
  	self assert: (c2 size = 3).
  	self assert: (c2 copyFrom: 1 to: 3) = (c1 copyFrom: 1 to: 3).!

Item was changed:
  ----- Method: ReadStreamTest>>testOn (in category 'tests - instance creation') -----
  testOn
- 	self shouldnt: [self streamOn: '  '] raise: Error.
  	self assert: (self streamOn: '  ') position isZero.!

Item was changed:
  ----- Method: ReadStreamTest>>testSetPosition (in category 'tests - positioning') -----
  testSetPosition
  	| stream |
  
  	stream := self emptyStream.
  	self should: [stream position: -2] raise: Error.
+ 	stream position: 0 "should not fail".
- 	self shouldnt: [stream position: 0] raise: Error.
  
  	stream := self streamOnArray.
  	self should: [stream position: -1] raise: Error.
+ 	"We can iterate over valid positions in the stream."
+ 	stream position: 0.
+ 	stream position: 1.
+ 	stream position: 2.
- 	self shouldnt: [stream position: 0] raise: Error.
- 	self shouldnt: [stream position: 1] raise: Error.
- 	self shouldnt: [stream position: 2] raise: Error.
  
  	"According to ANSI Smalltalk Standard 1.9 Draft, the following should be tested too:
  	self should: [stream position: 3] raise: Error.
  	
  	However, I don't see the point of raising an error when positioning at the end.
  	
  	I prefer testing the absence of error:
  	"
+ 	stream position: 3.
- 	self shouldnt: [stream position: 3] raise: Error.
  	self should: [stream position: 4] raise: Error.!

Item was changed:
  ----- Method: ReadWriteStreamTest>>testReadWriteStreamNextNBug (in category 'tests') -----
  testReadWriteStreamNextNBug
  	| aStream |
  	aStream := ReadWriteStream on: String new.
  	aStream nextPutAll: 'Hello World'.
+ 	"This should not fail"
+ 	aStream next: 5.!
- 	self shouldnt:[aStream next: 5] raise: Error.!

Item was changed:
  ----- 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]) = (newSet value add: nil; yourself).
  	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).
  !

Item was changed:
  ----- Method: StackTest>>testEmptyError (in category 'test') -----
  testEmptyError
  
  	| aStack |
  	aStack := Stack new.
  	self should: [ aStack top ] raise: Error.
  	self should: [ aStack pop] raise: Error.
  	
  	aStack push: 'element'.
  	
+ 	self assert: 'element' equals: aStack top.
+ 	self assert: 'element' equals:  aStack pop.
- 	self shouldnt: [ aStack top ] raise: Error.
- 	self shouldnt: [ aStack pop] raise: Error.
  	
  	
  	"The stack is empty again due to previous pop"
  	self should: [ aStack top ] raise: Error.
  	self should: [ aStack pop] raise: Error.!

Item was changed:
  ----- Method: StringTest>>testWithNoLineLongerThan (in category 'tests - converting') -----
  testWithNoLineLongerThan
  	"self run: #testWithNoLineLongerThan"
+ 	self assert: ('Hello', String cr, 'World') equals: ('Hello World' withNoLineLongerThan: 5).
+ 
+ 	self assert: String crlf equals: (String crlf withNoLineLongerThan: 5).
+ 	self assert: 'Hello\\World' withCRs equals: (('Hello', String cr, String cr,'World') withNoLineLongerThan: 5).
+ 
+ 	self
+ 		assert: ('Sample text to line break at', String cr, 'some point')
+ 		equals: ('Sample text to line break at some point' withNoLineLongerThan:  28).
+ 	self
+ 		assert: ('Sample text', String cr, 'to line break', String cr, 'at some point')
+ 		equals: ('Sample text', String cr, 'to line break', String cr, 'at some point' withNoLineLongerThan:  28).
- 	self assert: ('Hello World' withNoLineLongerThan: 5) = ('Hello', String cr, 'World').
- 	self shouldnt: [String crlf withNoLineLongerThan: 5] raise: Error.
- 	self shouldnt: [('Hello', String cr, String cr,'World') withNoLineLongerThan: 5] raise: Error.
- 	self assert: ('Sample text to line break at some point' withNoLineLongerThan:  28)
- 		= ('Sample text to line break at', String cr, 'some point').
- 	self assert: ('Sample text', String cr, 'to line break', String cr, 'at some point' withNoLineLongerThan:  28)
- 		= ('Sample text', String cr, 'to line break', String cr, 'at some point').
  !

Item was removed:
- ----- Method: WriteStreamTest>>testPosition2 (in category 'tests - positioning') -----
- testPosition2
- 	"self debug: #testPosition2"
- 	
- 	| stream |
- 
- 	stream := WriteStream with: ''.
- 	self should: [stream position: 2] raise: Error.
- 	self should: [stream position: -2] raise: Error.
- 
- 	stream := WriteStream with: 'a test'.
- 	self shouldnt: [stream position: 2] raise: Error.
- 	self should: [stream position: 7] raise: Error.
- 	self should: [stream position: -2] raise: Error.!

Item was added:
+ ----- Method: WriteStreamTest>>testPositionFailsOutsideStreamBounds (in category 'tests - positioning') -----
+ testPositionFailsOutsideStreamBounds
+ 	"self debug: #testPosition2"
+ 	
+ 	| stream |
+ 
+ 	stream := WriteStream with: ''.
+ 	self should: [stream position: 2] raise: Error.
+ 	self should: [stream position: -2] raise: Error.
+ 
+ 	stream := WriteStream with: 'a test'.
+ 	self should: [stream position: 7] raise: Error.
+ 	self should: [stream position: -2] raise: Error.!



More information about the Squeak-dev mailing list