Jelajahi Sumber

New CollectionTest class (work in progress)

Nicolas Petton 12 tahun lalu
induk
melakukan
e23532e6c0
3 mengubah file dengan 576 tambahan dan 186 penghapusan
  1. 228 96
      js/Kernel-Tests.deploy.js
  2. 277 90
      js/Kernel-Tests.js
  3. 71 0
      st/Kernel-Tests.st

File diff ditekan karena terlalu besar
+ 228 - 96
js/Kernel-Tests.deploy.js


File diff ditekan karena terlalu besar
+ 277 - 90
js/Kernel-Tests.js


+ 71 - 0
st/Kernel-Tests.st

@@ -220,6 +220,77 @@ testInstanceVariableNames
 	self assert: (builder instanceVariableNamesFor: '  hello   world   ') equals: #('hello' 'world')
 ! !
 
+TestCase subclass: #CollectionTest
+	instanceVariableNames: ''
+	package: 'Kernel-Tests'!
+
+!CollectionTest methodsFor: 'accessing'!
+
+collection
+	^ self collectionClass withAll: self defaultValues
+!
+
+collectionClass
+	^ self class collectionClass
+!
+
+defaultValues
+	^ #('a' 1 2 #e)
+! !
+
+!CollectionTest methodsFor: 'convenience'!
+
+assertSameContents: aCollection 	as: anotherCollection
+	self assert: aCollection size = anotherCollection size.
+	aCollection do: [ :each |
+		self assert: (aCollection at: each) = (anotherCollection at: each) ]
+! !
+
+!CollectionTest methodsFor: 'testing'!
+
+testAsArray
+	self 
+		assertSameContents: self collection 
+		as: self collection asArray
+!
+
+testAsOrderedCollection
+	self 
+		assertSameContents: self collection 
+		as: self collection asOrderedCollection
+!
+
+testAsSet
+	| c set |
+	c := self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a').
+	set := c asSet.
+	self assert: set size = 5.
+	c do: [ :each |
+		self assert: (set includes: each) ]
+!
+
+testIsEmpty
+	self assert: self collectionClass new isEmpty.
+	self deny: self collection isEmpty
+!
+
+testSize
+	self assert: self collectionClass new size = 0.
+	self assert: self collection size = 4
+! !
+
+!CollectionTest class methodsFor: 'accessing'!
+
+collectionClass
+	^ nil
+! !
+
+!CollectionTest class methodsFor: 'testing'!
+
+isAbstract
+	^ self collectionClass notNil
+! !
+
 TestCase subclass: #DictionaryTest
 	instanceVariableNames: ''
 	package: 'Kernel-Tests'!

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini