|  | @@ -1,440 +1,394 @@
 | 
											
												
													
														|  |  Smalltalk current createPackage: 'Kernel-Tests' properties: #{}!
 |  |  Smalltalk current createPackage: 'Kernel-Tests' properties: #{}!
 | 
											
												
													
														|  | -TestCase subclass: #ArrayTest
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #SetTest
 | 
											
												
													
														|  |  	instanceVariableNames: ''
 |  |  	instanceVariableNames: ''
 | 
											
												
													
														|  |  	category: 'Kernel-Tests'!
 |  |  	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!ArrayTest methodsFor: 'not yet classified'!
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -testFirstN
 |  | 
 | 
											
												
													
														|  | -	self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).
 |  | 
 | 
											
												
													
														|  | -! !
 |  | 
 | 
											
												
													
														|  | 
 |  | +!SetTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #StringTest
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: ''
 |  | 
 | 
											
												
													
														|  | -	category: 'Kernel-Tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testUnicity
 | 
											
												
													
														|  | 
 |  | +	| set |
 | 
											
												
													
														|  | 
 |  | +	set := Set new.
 | 
											
												
													
														|  | 
 |  | +	set add: 21.
 | 
											
												
													
														|  | 
 |  | +	set add: 'hello'.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!StringTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	set add: 21.
 | 
											
												
													
														|  | 
 |  | +	self assert: set size = 2.
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	set add: 'hello'.
 | 
											
												
													
														|  | 
 |  | +	self assert: set size = 2.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testJoin
 |  | 
 | 
											
												
													
														|  | -	self assert: 'hello,world' equals: (',' join: #('hello' 'world'))
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: set asArray equals: #(21 'hello')
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testStreamContents
 |  | 
 | 
											
												
													
														|  | -	self 
 |  | 
 | 
											
												
													
														|  | -		assert: 'hello world' 
 |  | 
 | 
											
												
													
														|  | -		equals: (String streamContents: [:aStream| aStream 
 |  | 
 | 
											
												
													
														|  | -                                                 					nextPutAll: 'hello'; space; 
 |  | 
 | 
											
												
													
														|  | -                                                 					nextPutAll: 'world'])
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAt
 | 
											
												
													
														|  | 
 |  | +	self should: [Set new at: 1 put: 2] raise: Error
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIncludesSubString
 |  | 
 | 
											
												
													
														|  | -	self assert: ('amber' includesSubString: 'ber').
 |  | 
 | 
											
												
													
														|  | -	self deny: ('amber' includesSubString: 'zork').
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAddRemove
 | 
											
												
													
														|  | 
 |  | +	| set |
 | 
											
												
													
														|  | 
 |  | +	set := Set new.
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	self assert: set isEmpty.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testEquality
 |  | 
 | 
											
												
													
														|  | -	self assert: 'hello' = 'hello'.
 |  | 
 | 
											
												
													
														|  | -	self deny: 'hello' = 'world'.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	set add: 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: (set includes: 3).
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: 'hello'  = 'hello' yourself.
 |  | 
 | 
											
												
													
														|  | -	self assert: 'hello' yourself = 'hello'.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	set add: 5.
 | 
											
												
													
														|  | 
 |  | +	self assert: (set includes: 5).
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	"test JS falsy value"
 |  | 
 | 
											
												
													
														|  | -	self deny: '' = 0
 |  | 
 | 
											
												
													
														|  | 
 |  | +	set remove: 3.
 | 
											
												
													
														|  | 
 |  | +	self deny: (set includes: 3)
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testCopyWithoutAll
 |  | 
 | 
											
												
													
														|  | -	self 
 |  | 
 | 
											
												
													
														|  | -		assert: 'hello world' 
 |  | 
 | 
											
												
													
														|  | -		equals: ('*hello* *world*' copyWithoutAll: '*')
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testSize
 | 
											
												
													
														|  | 
 |  | +	self assert: Set new size equals: 0.
 | 
											
												
													
														|  | 
 |  | +	self assert: (Set withAll: #(1 2 3 4)) size equals: 4.
 | 
											
												
													
														|  | 
 |  | +	self assert: (Set withAll: #(1 1 1 1)) size equals: 1
 | 
											
												
													
														|  | 
 |  | +! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAt
 |  | 
 | 
											
												
													
														|  | -	self assert: ('hello' at: 1) = 'h'.
 |  | 
 | 
											
												
													
														|  | -	self assert: ('hello' at: 5) = 'o'.
 |  | 
 | 
											
												
													
														|  | -	self assert: ('hello' at: 6 ifAbsent: [nil]) = nil
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #ClassBuilderTest
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: 'builder theClass'
 | 
											
												
													
														|  | 
 |  | +	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAtPut
 |  | 
 | 
											
												
													
														|  | -	"String instances are read-only"
 |  | 
 | 
											
												
													
														|  | -	self should: ['hello' at: 1 put: 'a'] raise: Error
 |  | 
 | 
											
												
													
														|  | 
 |  | +!ClassBuilderTest methodsFor: 'running'!
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +setUp
 | 
											
												
													
														|  | 
 |  | +	builder := ClassBuilder new
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testSize
 |  | 
 | 
											
												
													
														|  | -	self assert: 'smalltalk' size equals: 9.
 |  | 
 | 
											
												
													
														|  | -	self assert: '' size equals: 0
 |  | 
 | 
											
												
													
														|  | 
 |  | +tearDown
 | 
											
												
													
														|  | 
 |  | +	theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAddRemove
 |  | 
 | 
											
												
													
														|  | -	self should: ['hello' add: 'a'] raise: Error.
 |  | 
 | 
											
												
													
														|  | -	self should: ['hello' remove: 'h'] raise: Error
 |  | 
 | 
											
												
													
														|  | 
 |  | +testClassCopy
 | 
											
												
													
														|  | 
 |  | +	theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.
 | 
											
												
													
														|  | 
 |  | +	self assert: theClass superclass == ObjectMock superclass.
 | 
											
												
													
														|  | 
 |  | +	self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.
 | 
											
												
													
														|  | 
 |  | +	self assert: theClass name equals: 'ObjectMock2'.
 | 
											
												
													
														|  | 
 |  | +	self assert: theClass package == ObjectMock package.
 | 
											
												
													
														|  | 
 |  | +	self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAsArray
 |  | 
 | 
											
												
													
														|  | -	self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').
 |  | 
 | 
											
												
													
														|  | 
 |  | +testInstanceVariableNames
 | 
											
												
													
														|  | 
 |  | +	self assert: (builder instanceVariableNamesFor: '  hello   world   ') equals: #('hello' 'world')
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #DictionaryTest
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #RandomTest
 | 
											
												
													
														|  |  	instanceVariableNames: ''
 |  |  	instanceVariableNames: ''
 | 
											
												
													
														|  |  	category: 'Kernel-Tests'!
 |  |  	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!DictionaryTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +!RandomTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testPrintString
 |  | 
 | 
											
												
													
														|  | -	self
 |  | 
 | 
											
												
													
														|  | -		assert: 'a Dictionary(''firstname'' -> ''James'' , ''lastname'' -> ''Bond'')' 
 |  | 
 | 
											
												
													
														|  | -		equals: (Dictionary new 
 |  | 
 | 
											
												
													
														|  | -                         	at:'firstname' put: 'James';
 |  | 
 | 
											
												
													
														|  | -                        	at:'lastname' put: 'Bond';
 |  | 
 | 
											
												
													
														|  | -                        	printString)
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +textNext
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testEquality
 |  | 
 | 
											
												
													
														|  | -	| d1 d2 |
 |  | 
 | 
											
												
													
														|  | 
 |  | +	10000 timesRepeat: [
 | 
											
												
													
														|  | 
 |  | +			| current next | 
 | 
											
												
													
														|  | 
 |  | +			next := Random new next.
 | 
											
												
													
														|  | 
 |  | +			self assert: (next >= 0).
 | 
											
												
													
														|  | 
 |  | +			self assert: (next < 1).
 | 
											
												
													
														|  | 
 |  | +			self deny: current = next.
 | 
											
												
													
														|  | 
 |  | +			next = current]
 | 
											
												
													
														|  | 
 |  | +! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: Dictionary new = Dictionary new.
 |  | 
 | 
											
												
													
														|  | -		
 |  | 
 | 
											
												
													
														|  | -	d1 := Dictionary new at: 1 put: 2; yourself.
 |  | 
 | 
											
												
													
														|  | -	d2 := Dictionary new at: 1 put: 2; yourself.
 |  | 
 | 
											
												
													
														|  | -	self assert: d1 = d2.
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #PointTest
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: ''
 | 
											
												
													
														|  | 
 |  | +	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d2 := Dictionary new at: 1 put: 3; yourself.
 |  | 
 | 
											
												
													
														|  | -	self deny: d1 = d2.
 |  | 
 | 
											
												
													
														|  | 
 |  | +!PointTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d2 := Dictionary new at: 2 put: 2; yourself.
 |  | 
 | 
											
												
													
														|  | -	self deny: d1 = d2.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAccessing
 | 
											
												
													
														|  | 
 |  | +	self assert: (Point x: 3 y: 4) x equals: 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: (Point x: 3 y: 4) y equals: 4.
 | 
											
												
													
														|  | 
 |  | +	self assert: (Point new x: 3) x equals: 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: (Point new y: 4) y equals: 4
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d2 := Dictionary new at: 1 put: 2; at: 3 put: 4; yourself.
 |  | 
 | 
											
												
													
														|  | -	self deny: d1 = d2.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAt
 | 
											
												
													
														|  | 
 |  | +	self assert: 3@4 equals: (Point x: 3 y: 4)
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testDynamicDictionaries
 |  | 
 | 
											
												
													
														|  | -	self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)
 |  | 
 | 
											
												
													
														|  | 
 |  | +testEgality
 | 
											
												
													
														|  | 
 |  | +	self assert: 3@4 = (3@4).
 | 
											
												
													
														|  | 
 |  | +	self deny: 3@5 = (3@6)
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAccessing
 |  | 
 | 
											
												
													
														|  | -	| d |
 |  | 
 | 
											
												
													
														|  | 
 |  | +testArithmetic
 | 
											
												
													
														|  | 
 |  | +	self assert: 3@4 * (3@4 ) equals: (Point x: 9 y: 16).
 | 
											
												
													
														|  | 
 |  | +	self assert: 3@4 + (3@4 ) equals: (Point x: 6 y: 8).
 | 
											
												
													
														|  | 
 |  | +	self assert: 3@4 - (3@4 ) equals: (Point x: 0 y: 0).
 | 
											
												
													
														|  | 
 |  | +	self assert: 6@8 / (3@4 ) equals: (Point x: 2 y: 2)
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d := Dictionary new.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testTranslateBy
 | 
											
												
													
														|  | 
 |  | +	self assert: 3@4 equals: (3@3 translateBy: 0@1).
 | 
											
												
													
														|  | 
 |  | +	self assert: 3@2 equals: (3@3 translateBy: 0@1 negated).
 | 
											
												
													
														|  | 
 |  | +	self assert: 5@6 equals: (3@3 translateBy: 2@3).
 | 
											
												
													
														|  | 
 |  | +	self assert: 0@3 equals: (3@3 translateBy: 3 negated @0).
 | 
											
												
													
														|  | 
 |  | +! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d at: 'hello' put: 'world'.
 |  | 
 | 
											
												
													
														|  | -	self assert: (d at: 'hello') = 'world'.
 |  | 
 | 
											
												
													
														|  | -	self assert: (d at: 'hello' ifAbsent: [nil]) = 'world'.
 |  | 
 | 
											
												
													
														|  | -	self deny: (d at: 'foo' ifAbsent: [nil]) = 'world'.
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #UndefinedTest
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: ''
 | 
											
												
													
														|  | 
 |  | +	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d at: 1 put: 2.
 |  | 
 | 
											
												
													
														|  | -	self assert: (d at: 1) = 2.
 |  | 
 | 
											
												
													
														|  | 
 |  | +!UndefinedTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d at: 1@3 put: 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: (d at: 1@3) = 3
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIsNil
 | 
											
												
													
														|  | 
 |  | +	self assert: nil isNil.
 | 
											
												
													
														|  | 
 |  | +	self deny: nil notNil.
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testSize
 |  | 
 | 
											
												
													
														|  | -	| d |
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	d := Dictionary new.
 |  | 
 | 
											
												
													
														|  | -	self assert: d size = 0.
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	d at: 1 put: 2.
 |  | 
 | 
											
												
													
														|  | -	self assert: d size = 1.
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	d at: 2 put: 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: d size = 2.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIfNil
 | 
											
												
													
														|  | 
 |  | +	self assert: (nil ifNil: [true]) equals: true.
 | 
											
												
													
														|  | 
 |  | +	self deny: (nil ifNotNil: [true]) = true.
 | 
											
												
													
														|  | 
 |  | +	self assert: (nil ifNil: [true] ifNotNil: [false]) equals: true.
 | 
											
												
													
														|  | 
 |  | +	self deny: (nil ifNotNil: [true] ifNil: [false]) = true
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testValues
 |  | 
 | 
											
												
													
														|  | -	| d |
 |  | 
 | 
											
												
													
														|  | 
 |  | +testCopying
 | 
											
												
													
														|  | 
 |  | +	self assert: nil copy equals: nil
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d := Dictionary new.
 |  | 
 | 
											
												
													
														|  | -	d at: 1 put: 2.
 |  | 
 | 
											
												
													
														|  | -	d at: 2 put: 3.
 |  | 
 | 
											
												
													
														|  | -	d at: 3 put: 4.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testDeepCopy
 | 
											
												
													
														|  | 
 |  | +	self assert: nil deepCopy = nil
 | 
											
												
													
														|  | 
 |  | +! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: d values = #(2 3 4)
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +Object subclass: #ObjectMock
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: 'foo bar'
 | 
											
												
													
														|  | 
 |  | +	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testKeys
 |  | 
 | 
											
												
													
														|  | -	| d |
 |  | 
 | 
											
												
													
														|  | 
 |  | +!ObjectMock methodsFor: 'not yet classified'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	d := Dictionary new.
 |  | 
 | 
											
												
													
														|  | -	d at: 1 put: 2.
 |  | 
 | 
											
												
													
														|  | -	d at: 2 put: 3.
 |  | 
 | 
											
												
													
														|  | -	d at: 3 put: 4.
 |  | 
 | 
											
												
													
														|  | 
 |  | +foo
 | 
											
												
													
														|  | 
 |  | +	^foo
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: d keys = #(1 2 3)
 |  | 
 | 
											
												
													
														|  | 
 |  | +foo: anObject
 | 
											
												
													
														|  | 
 |  | +	foo := anObject
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #BooleanTest
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #SymbolTest
 | 
											
												
													
														|  |  	instanceVariableNames: ''
 |  |  	instanceVariableNames: ''
 | 
											
												
													
														|  |  	category: 'Kernel-Tests'!
 |  |  	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!BooleanTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -testLogic
 |  | 
 | 
											
												
													
														|  | - 
 |  | 
 | 
											
												
													
														|  | -	"Trivial logic table"
 |  | 
 | 
											
												
													
														|  | -	self assert: (true & true); deny: (true & false); deny: (false & true); deny: (false & false).
 |  | 
 | 
											
												
													
														|  | -	self assert: (true | true); assert: (true | false); assert: (false | true); deny: (false | false).
 |  | 
 | 
											
												
													
														|  | -        "Checking that expressions work fine too"
 |  | 
 | 
											
												
													
														|  | -	self assert: (true & (1 > 0)); deny: ((1 > 0) & false); deny: ((1 > 0) & (1 > 2)).
 |  | 
 | 
											
												
													
														|  | -        self assert: (false | (1 > 0)); assert: ((1 > 0) | false); assert: ((1 > 0) | (1 > 2))
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +!SymbolTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  testEquality
 |  |  testEquality
 | 
											
												
													
														|  | -	"We're on top of JS...just be sure to check the basics!!"
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello = #hello.
 | 
											
												
													
														|  | 
 |  | +	self deny: #hello = #world.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self deny: 0 = false. 
 |  | 
 | 
											
												
													
														|  | -	self deny: false = 0.
 |  | 
 | 
											
												
													
														|  | -	self deny: '' = false.
 |  | 
 | 
											
												
													
														|  | -	self deny: false = ''.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello  = #hello yourself.
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello yourself = #hello.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: true = true.
 |  | 
 | 
											
												
													
														|  | -	self deny: false = true.
 |  | 
 | 
											
												
													
														|  | -	self deny: true = false.
 |  | 
 | 
											
												
													
														|  | -	self assert: false = false.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self deny: #hello  = 'hello'.
 | 
											
												
													
														|  | 
 |  | +	self deny: 'hello' = #hello.
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	"JS may do some type coercing after sending a message"
 |  | 
 | 
											
												
													
														|  | -	self assert: true yourself = true.
 |  | 
 | 
											
												
													
														|  | -	self assert: true yourself = true yourself
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAt
 | 
											
												
													
														|  | 
 |  | +	self assert: (#hello at: 1) = 'h'.
 | 
											
												
													
														|  | 
 |  | +	self assert: (#hello at: 5) = 'o'.
 | 
											
												
													
														|  | 
 |  | +	self assert: (#hello at: 6 ifAbsent: [nil]) = nil
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testLogicKeywords
 |  | 
 | 
											
												
													
														|  | - 
 |  | 
 | 
											
												
													
														|  | -	"Trivial logic table"
 |  | 
 | 
											
												
													
														|  | -	self 
 |  | 
 | 
											
												
													
														|  | -		assert: (true and: [ true]); 
 |  | 
 | 
											
												
													
														|  | -		deny: (true and: [ false ]); 
 |  | 
 | 
											
												
													
														|  | -		deny: (false and: [ true ]); 
 |  | 
 | 
											
												
													
														|  | -		deny: (false and: [ false ]).
 |  | 
 | 
											
												
													
														|  | -	self 
 |  | 
 | 
											
												
													
														|  | -		assert: (true or: [ true ]); 
 |  | 
 | 
											
												
													
														|  | -		assert: (true or: [ false ]); 
 |  | 
 | 
											
												
													
														|  | -		assert: (false or: [ true ]); 
 |  | 
 | 
											
												
													
														|  | -		deny: (false or: [ false ]).
 |  | 
 | 
											
												
													
														|  | -        
 |  | 
 | 
											
												
													
														|  | -	"Checking that expressions work fine too"
 |  | 
 | 
											
												
													
														|  | -	self 
 |  | 
 | 
											
												
													
														|  | -		assert: (true and: [ 1 > 0 ]); 
 |  | 
 | 
											
												
													
														|  | -		deny: ((1 > 0) and: [ false ]); 
 |  | 
 | 
											
												
													
														|  | -		deny: ((1 > 0) and: [ 1 > 2 ]).
 |  | 
 | 
											
												
													
														|  | -        self 
 |  | 
 | 
											
												
													
														|  | -		assert: (false or: [ 1 > 0 ]); 
 |  | 
 | 
											
												
													
														|  | -		assert: ((1 > 0) or: [ false ]); 
 |  | 
 | 
											
												
													
														|  | -		assert: ((1 > 0) or: [ 1 > 2 ])
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAtPut
 | 
											
												
													
														|  | 
 |  | +	"Symbol instances are read-only"
 | 
											
												
													
														|  | 
 |  | +	self should: ['hello' at: 1 put: 'a'] raise: Error
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIfTrueIfFalse
 |  | 
 | 
											
												
													
														|  | - 
 |  | 
 | 
											
												
													
														|  | -	self assert: (true ifTrue: ['alternative block']) = 'alternative block'.
 |  | 
 | 
											
												
													
														|  | -	self assert: (true ifFalse: ['alternative block']) = nil.
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	self assert: (false ifTrue: ['alternative block']) = nil.
 |  | 
 | 
											
												
													
														|  | -	self assert: (false ifFalse: ['alternative block']) = 'alternative block'.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIdentity
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello == #hello.
 | 
											
												
													
														|  | 
 |  | +	self deny: #hello == #world.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: (false ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.
 |  | 
 | 
											
												
													
														|  | -	self assert: (false ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello  = #hello yourself.
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello yourself = #hello asString asSymbol
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: (true ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.
 |  | 
 | 
											
												
													
														|  | -	self assert: (true ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.
 |  | 
 | 
											
												
													
														|  | -! !
 |  | 
 | 
											
												
													
														|  | 
 |  | +testComparing
 | 
											
												
													
														|  | 
 |  | +	self assert: #ab > #aa.
 | 
											
												
													
														|  | 
 |  | +	self deny: #ab > #ba.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #NumberTest
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: ''
 |  | 
 | 
											
												
													
														|  | -	category: 'Kernel-Tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: #ab < #ba.
 | 
											
												
													
														|  | 
 |  | +	self deny: #bb < #ba.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!NumberTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: #ab >= #aa.
 | 
											
												
													
														|  | 
 |  | +	self deny: #ab >= #ba.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testPrintShowingDecimalPlaces
 |  | 
 | 
											
												
													
														|  | -	self assert: '23.00' equals: (23 printShowingDecimalPlaces: 2).
 |  | 
 | 
											
												
													
														|  | -	self assert: '23.57' equals: (23.5698 printShowingDecimalPlaces: 2).
 |  | 
 | 
											
												
													
														|  | -	self assert: '-234.56700' equals:( 234.567 negated printShowingDecimalPlaces: 5).
 |  | 
 | 
											
												
													
														|  | -	self assert: '23' equals: (23.4567 printShowingDecimalPlaces: 0).
 |  | 
 | 
											
												
													
														|  | -	self assert: '24' equals: (23.5567 printShowingDecimalPlaces: 0).
 |  | 
 | 
											
												
													
														|  | -	self assert: '-23' equals: (23.4567 negated printShowingDecimalPlaces: 0).
 |  | 
 | 
											
												
													
														|  | -	self assert: '-24' equals: (23.5567 negated printShowingDecimalPlaces: 0).
 |  | 
 | 
											
												
													
														|  | -	self assert: '100000000.0' equals: (100000000 printShowingDecimalPlaces: 1).
 |  | 
 | 
											
												
													
														|  | -	self assert: '0.98000' equals: (0.98 printShowingDecimalPlaces: 5).
 |  | 
 | 
											
												
													
														|  | -	self assert: '-0.98' equals: (0.98 negated printShowingDecimalPlaces: 2).
 |  | 
 | 
											
												
													
														|  | -	self assert: '2.57' equals: (2.567 printShowingDecimalPlaces: 2).
 |  | 
 | 
											
												
													
														|  | -	self assert: '-2.57' equals: (-2.567 printShowingDecimalPlaces: 2).
 |  | 
 | 
											
												
													
														|  | -	self assert: '0.00' equals: (0 printShowingDecimalPlaces: 2).
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: #ab <= #ba.
 | 
											
												
													
														|  | 
 |  | +	self deny: #bb <= #ba
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testEquality
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 = 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: 0 = 0.
 |  | 
 | 
											
												
													
														|  | -	self deny: 1 = 0.
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 yourself = 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 = 1 yourself.
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 yourself = 1 yourself.
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	self deny: 0 = false.
 |  | 
 | 
											
												
													
														|  | -	self deny: false = 0.
 |  | 
 | 
											
												
													
														|  | -	self deny: '' = 0.
 |  | 
 | 
											
												
													
														|  | -	self deny: 0 = ''
 |  | 
 | 
											
												
													
														|  | 
 |  | +testSize
 | 
											
												
													
														|  | 
 |  | +	self assert: #a size equals: 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: #aaaaa size equals: 5
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testArithmetic
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	"We rely on JS here, so we won't test complex behavior, just check if 
 |  | 
 | 
											
												
													
														|  | -	message sends are corrects"
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	self assert: 1.5 + 1 = 2.5.
 |  | 
 | 
											
												
													
														|  | -	self assert: 2 - 1 = 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: -2 - 1 = -3.
 |  | 
 | 
											
												
													
														|  | -	self assert: 12 / 2 = 6.
 |  | 
 | 
											
												
													
														|  | -	self assert: 3 * 4 = 12.
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	"Simple parenthesis and execution order"
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 + 2 * 3 = 9.
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 + (2 * 3) = 7
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAsString
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello asString equals: 'hello'
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testRounded
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	self assert: 3 rounded = 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: 3.212 rounded = 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: 3.51 rounded = 4
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAsSymbol
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello == #hello asSymbol
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testNegated
 |  | 
 | 
											
												
													
														|  | -	self assert: 3 negated = -3.
 |  | 
 | 
											
												
													
														|  | -	self assert: -3 negated = 3
 |  | 
 | 
											
												
													
														|  | 
 |  | +testCopying
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello copy == #hello.
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello deepCopy == #hello
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testComparison
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIsSymbolIsString
 | 
											
												
													
														|  | 
 |  | +	self assert: #hello isSymbol.
 | 
											
												
													
														|  | 
 |  | +	self deny: 'hello' isSymbol.
 | 
											
												
													
														|  | 
 |  | +	self deny: #hello isString.
 | 
											
												
													
														|  | 
 |  | +	self assert: 'hello' isString
 | 
											
												
													
														|  | 
 |  | +! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: 3 > 2.
 |  | 
 | 
											
												
													
														|  | -	self assert: 2 < 3.
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	self deny: 3 < 2.
 |  | 
 | 
											
												
													
														|  | -	self deny: 2 > 3.
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #ObjectTest
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: ''
 | 
											
												
													
														|  | 
 |  | +	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: 3 >= 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: 3.1 >= 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: 3 <= 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: 3 <= 3.1
 |  | 
 | 
											
												
													
														|  | 
 |  | +!ObjectTest methodsFor: 'tests'!
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +testEquality
 | 
											
												
													
														|  | 
 |  | +	| o |
 | 
											
												
													
														|  | 
 |  | +	o := Object new.
 | 
											
												
													
														|  | 
 |  | +	self deny: o = Object new.
 | 
											
												
													
														|  | 
 |  | +	self assert: o = o.
 | 
											
												
													
														|  | 
 |  | +	self assert: o yourself = o.
 | 
											
												
													
														|  | 
 |  | +	self assert: o = o yourself
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testTruncated
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	self assert: 3 truncated = 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: 3.212 truncated = 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: 3.51 truncated = 3
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIdentity
 | 
											
												
													
														|  | 
 |  | +	| o |
 | 
											
												
													
														|  | 
 |  | +	o := Object new.
 | 
											
												
													
														|  | 
 |  | +	self deny: o == Object new.
 | 
											
												
													
														|  | 
 |  | +	self assert: o == o
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testCopying
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 copy == 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 deepCopy == 1
 |  | 
 | 
											
												
													
														|  | 
 |  | +testHalt
 | 
											
												
													
														|  | 
 |  | +	self should: [Object new halt] raise: Error
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testMinMax
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	self assert: (2 max: 5) equals: 5.
 |  | 
 | 
											
												
													
														|  | -	self assert: (2 min: 5) equals: 2
 |  | 
 | 
											
												
													
														|  | 
 |  | +testBasicAccess
 | 
											
												
													
														|  | 
 |  | +	| o |
 | 
											
												
													
														|  | 
 |  | +	o := Object new.
 | 
											
												
													
														|  | 
 |  | +	o basicAt: 'a' put: 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: (o basicAt: 'a') equals: 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: (o basicAt: 'b') equals: nil
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIdentity
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 == 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: 0 == 0.
 |  | 
 | 
											
												
													
														|  | -	self deny: 1 == 0.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testNilUndefined
 | 
											
												
													
														|  | 
 |  | +	"nil in Smalltalk is the undefined object in JS"
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: 1 yourself == 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 == 1 yourself.
 |  | 
 | 
											
												
													
														|  | -	self assert: 1 yourself == 1 yourself.
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	self deny: 1 == 2
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: nil = undefined
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testSqrt
 |  | 
 | 
											
												
													
														|  | 
 |  | +testidentityHash
 | 
											
												
													
														|  | 
 |  | +	| o1 o2 |
 | 
											
												
													
														|  |  	
 |  |  	
 | 
											
												
													
														|  | -	self assert: 4 sqrt = 2.
 |  | 
 | 
											
												
													
														|  | -	self assert: 16 sqrt = 4
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	o1 := Object new.
 | 
											
												
													
														|  | 
 |  | +	o2 := Object new.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testSquared
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	self assert: 4 squared = 16
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: o1 identityHash == o1 identityHash.
 | 
											
												
													
														|  | 
 |  | +	self deny: o1 identityHash == o2 identityHash
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testTimesRepeat
 |  | 
 | 
											
												
													
														|  | -	| i |
 |  | 
 | 
											
												
													
														|  | 
 |  | +testBasicPerform
 | 
											
												
													
														|  | 
 |  | +	| o |
 | 
											
												
													
														|  | 
 |  | +	o := Object new.
 | 
											
												
													
														|  | 
 |  | +	o basicAt: 'func' put: ['hello'].	
 | 
											
												
													
														|  | 
 |  | +	o basicAt: 'func2' put: [:a | a + 1].
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	i := 0.
 |  | 
 | 
											
												
													
														|  | -	0 timesRepeat: [i := i + 1].
 |  | 
 | 
											
												
													
														|  | -	self assert: i equals: 0.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: (o basicPerform: 'func')	 equals: 'hello'.
 | 
											
												
													
														|  | 
 |  | +	self assert: (o basicPerform: 'func2' withArguments: #(3)) equals: 4
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	5 timesRepeat: [i := i + 1].
 |  | 
 | 
											
												
													
														|  | -	self assert: i equals: 5
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIfNil
 | 
											
												
													
														|  | 
 |  | +	self deny: Object new isNil.
 | 
											
												
													
														|  | 
 |  | +	self deny: (Object new ifNil: [true]) = true.
 | 
											
												
													
														|  | 
 |  | +	self assert: (Object new ifNotNil: [true]) = true.
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	self assert: (Object new ifNil: [false] ifNotNil: [true]) = true.
 | 
											
												
													
														|  | 
 |  | +	self assert: (Object new ifNotNil: [true] ifNil: [false]) = true
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testTo
 |  | 
 | 
											
												
													
														|  | -	self assert: (1 to: 5) equals: #(1 2 3 4 5)
 |  | 
 | 
											
												
													
														|  | 
 |  | +testInstVars
 | 
											
												
													
														|  | 
 |  | +	| o |
 | 
											
												
													
														|  | 
 |  | +	o := ObjectMock new.
 | 
											
												
													
														|  | 
 |  | +	self assert: (o instVarAt: #foo) equals: nil.
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	o instVarAt: #foo put: 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: (o instVarAt: #foo) equals: 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: (o instVarAt: 'foo') equals: 1
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testToBy
 |  | 
 | 
											
												
													
														|  | -	self assert: (0 to: 6 by: 2) equals: #(0 2 4 6).
 |  | 
 | 
											
												
													
														|  | 
 |  | +testYourself
 | 
											
												
													
														|  | 
 |  | +	| o |
 | 
											
												
													
														|  | 
 |  | +	o := ObjectMock new.
 | 
											
												
													
														|  | 
 |  | +	self assert: o yourself == o
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self should: [1 to: 4 by: 0] raise: Error
 |  | 
 | 
											
												
													
														|  | 
 |  | +testDNU
 | 
											
												
													
														|  | 
 |  | +	self should: [Object new foo] raise: MessageNotUnderstood
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #JSObjectProxyTest
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #BlockClosureTest
 | 
											
												
													
														|  |  	instanceVariableNames: ''
 |  |  	instanceVariableNames: ''
 | 
											
												
													
														|  |  	category: 'Kernel-Tests'!
 |  |  	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!JSObjectProxyTest methodsFor: 'accessing'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +!BlockClosureTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -jsObject
 |  | 
 | 
											
												
													
														|  | -	<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}}>
 |  | 
 | 
											
												
													
														|  | -! !
 |  | 
 | 
											
												
													
														|  | 
 |  | +testValue
 | 
											
												
													
														|  | 
 |  | +	self assert: ([1+1] value) equals: 2.
 | 
											
												
													
														|  | 
 |  | +	self assert: ([:x | x +1] value: 2) equals: 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: ([:x :y | x*y] value: 2 value: 4) equals: 8. 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!JSObjectProxyTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	"Arguments are optional in Amber. This isn't ANSI compliant."
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testMethodWithArguments
 |  | 
 | 
											
												
													
														|  | -	self deny: ('body' asJQuery hasClass: 'amber').
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	'body' asJQuery addClass: 'amber'.
 |  | 
 | 
											
												
													
														|  | -	self assert: ('body' asJQuery hasClass: 'amber').
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	'body' asJQuery removeClass: 'amber'.
 |  | 
 | 
											
												
													
														|  | -	self deny: ('body' asJQuery hasClass: 'amber').
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: ([:a :b :c | 1] value) equals: 1
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testYourself
 |  | 
 | 
											
												
													
														|  | -	|body|
 |  | 
 | 
											
												
													
														|  | -	body := 'body' asJQuery
 |  | 
 | 
											
												
													
														|  | -				addClass: 'amber';
 |  | 
 | 
											
												
													
														|  | -				yourself.
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	self assert: (body hasClass: 'amber').
 |  | 
 | 
											
												
													
														|  | 
 |  | +testOnDo
 | 
											
												
													
														|  | 
 |  | +	self assert: ([Error new signal] on: Error do: [:ex | true])
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	body removeClass: 'amber'.
 |  | 
 | 
											
												
													
														|  | -	self deny: (body hasClass: 'amber').
 |  | 
 | 
											
												
													
														|  | 
 |  | +testEnsure
 | 
											
												
													
														|  | 
 |  | +	self assert: ([Error new] ensure: [true])
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testPropertyThatReturnsEmptyString
 |  | 
 | 
											
												
													
														|  | -	<document.location.hash = ''>.
 |  | 
 | 
											
												
													
														|  | -	self assert: '' equals: document location hash.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testNumArgs
 | 
											
												
													
														|  | 
 |  | +	self assert: [] numArgs equals: 0.
 | 
											
												
													
														|  | 
 |  | +	self assert: [:a :b | ] numArgs equals: 2
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	document location hash: 'test'.
 |  | 
 | 
											
												
													
														|  | -	self assert: '#test' equals: document location hash.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testValueWithPossibleArguments
 | 
											
												
													
														|  | 
 |  | +	self assert: ([1] valueWithPossibleArguments: #(3 4)) equals: 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: ([:a | a + 4] valueWithPossibleArguments: #(3 4)) equals: 7.
 | 
											
												
													
														|  | 
 |  | +	self assert: ([:a :b | a + b] valueWithPossibleArguments: #(3 4 5)) equals: 7.
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testDNU
 |  | 
 | 
											
												
													
														|  | -	self should: [self jsObject foo] raise: MessageNotUnderstood
 |  | 
 | 
											
												
													
														|  | 
 |  | +testWhileTrue
 | 
											
												
													
														|  | 
 |  | +	| i |
 | 
											
												
													
														|  | 
 |  | +	i := 0.
 | 
											
												
													
														|  | 
 |  | +	[i < 5] whileTrue: [i := i + 1].
 | 
											
												
													
														|  | 
 |  | +	self assert: i equals: 5.
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	i := 0.
 | 
											
												
													
														|  | 
 |  | +	[i := i + 1. i < 5] whileTrue.
 | 
											
												
													
														|  | 
 |  | +	self assert: i equals: 5
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testMessageSend
 |  | 
 | 
											
												
													
														|  | 
 |  | +testWhileFalse
 | 
											
												
													
														|  | 
 |  | +	| i |
 | 
											
												
													
														|  | 
 |  | +	i := 0.
 | 
											
												
													
														|  | 
 |  | +	[i > 5] whileFalse: [i := i + 1].
 | 
											
												
													
														|  | 
 |  | +	self assert: i equals: 6.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: self jsObject a equals: 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: self jsObject b equals: 2.
 |  | 
 | 
											
												
													
														|  | -	self assert: (self jsObject c: 3) equals: 3
 |  | 
 | 
											
												
													
														|  | 
 |  | +	i := 0.
 | 
											
												
													
														|  | 
 |  | +	[i := i + 1. i > 5] whileFalse.
 | 
											
												
													
														|  | 
 |  | +	self assert: i equals: 6
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testPrinting
 |  | 
 | 
											
												
													
														|  | -	self assert: self jsObject printString = '[object Object]'
 |  | 
 | 
											
												
													
														|  | 
 |  | +testCompiledSource
 | 
											
												
													
														|  | 
 |  | +	self assert: ([1+1] compiledSource includesSubString: 'function')
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  TestCase subclass: #PackageTest
 |  |  TestCase subclass: #PackageTest
 | 
											
										
											
												
													
														|  | @@ -481,396 +435,442 @@ testGrulCommitPathJsShouldBeServerGrulJs
 | 
											
												
													
														|  |  	self assert: 'server/grul/js' equals: grulPackage commitPathJs
 |  |  	self assert: 'server/grul/js' equals: grulPackage commitPathJs
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #BlockClosureTest
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #JSObjectProxyTest
 | 
											
												
													
														|  |  	instanceVariableNames: ''
 |  |  	instanceVariableNames: ''
 | 
											
												
													
														|  |  	category: 'Kernel-Tests'!
 |  |  	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!BlockClosureTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +!JSObjectProxyTest methodsFor: 'accessing'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testValue
 |  | 
 | 
											
												
													
														|  | -	self assert: ([1+1] value) equals: 2.
 |  | 
 | 
											
												
													
														|  | -	self assert: ([:x | x +1] value: 2) equals: 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: ([:x :y | x*y] value: 2 value: 4) equals: 8. 
 |  | 
 | 
											
												
													
														|  | 
 |  | +jsObject
 | 
											
												
													
														|  | 
 |  | +	<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}}>
 | 
											
												
													
														|  | 
 |  | +! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	"Arguments are optional in Amber. This isn't ANSI compliant."
 |  | 
 | 
											
												
													
														|  | 
 |  | +!JSObjectProxyTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: ([:a :b :c | 1] value) equals: 1
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testMethodWithArguments
 | 
											
												
													
														|  | 
 |  | +	self deny: ('body' asJQuery hasClass: 'amber').
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testOnDo
 |  | 
 | 
											
												
													
														|  | -	self assert: ([Error new signal] on: Error do: [:ex | true])
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	'body' asJQuery addClass: 'amber'.
 | 
											
												
													
														|  | 
 |  | +	self assert: ('body' asJQuery hasClass: 'amber').
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testEnsure
 |  | 
 | 
											
												
													
														|  | -	self assert: ([Error new] ensure: [true])
 |  | 
 | 
											
												
													
														|  | 
 |  | +	'body' asJQuery removeClass: 'amber'.
 | 
											
												
													
														|  | 
 |  | +	self deny: ('body' asJQuery hasClass: 'amber').
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testNumArgs
 |  | 
 | 
											
												
													
														|  | -	self assert: [] numArgs equals: 0.
 |  | 
 | 
											
												
													
														|  | -	self assert: [:a :b | ] numArgs equals: 2
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testYourself
 | 
											
												
													
														|  | 
 |  | +	|body|
 | 
											
												
													
														|  | 
 |  | +	body := 'body' asJQuery
 | 
											
												
													
														|  | 
 |  | +				addClass: 'amber';
 | 
											
												
													
														|  | 
 |  | +				yourself.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testValueWithPossibleArguments
 |  | 
 | 
											
												
													
														|  | -	self assert: ([1] valueWithPossibleArguments: #(3 4)) equals: 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: ([:a | a + 4] valueWithPossibleArguments: #(3 4)) equals: 7.
 |  | 
 | 
											
												
													
														|  | -	self assert: ([:a :b | a + b] valueWithPossibleArguments: #(3 4 5)) equals: 7.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: (body hasClass: 'amber').
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	body removeClass: 'amber'.
 | 
											
												
													
														|  | 
 |  | +	self deny: (body hasClass: 'amber').
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testWhileTrue
 |  | 
 | 
											
												
													
														|  | -	| i |
 |  | 
 | 
											
												
													
														|  | -	i := 0.
 |  | 
 | 
											
												
													
														|  | -	[i < 5] whileTrue: [i := i + 1].
 |  | 
 | 
											
												
													
														|  | -	self assert: i equals: 5.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testPropertyThatReturnsEmptyString
 | 
											
												
													
														|  | 
 |  | +	<document.location.hash = ''>.
 | 
											
												
													
														|  | 
 |  | +	self assert: '' equals: document location hash.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	i := 0.
 |  | 
 | 
											
												
													
														|  | -	[i := i + 1. i < 5] whileTrue.
 |  | 
 | 
											
												
													
														|  | -	self assert: i equals: 5
 |  | 
 | 
											
												
													
														|  | 
 |  | +	document location hash: 'test'.
 | 
											
												
													
														|  | 
 |  | +	self assert: '#test' equals: document location hash.
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testWhileFalse
 |  | 
 | 
											
												
													
														|  | -	| i |
 |  | 
 | 
											
												
													
														|  | -	i := 0.
 |  | 
 | 
											
												
													
														|  | -	[i > 5] whileFalse: [i := i + 1].
 |  | 
 | 
											
												
													
														|  | -	self assert: i equals: 6.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testDNU
 | 
											
												
													
														|  | 
 |  | +	self should: [self jsObject foo] raise: MessageNotUnderstood
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	i := 0.
 |  | 
 | 
											
												
													
														|  | -	[i := i + 1. i > 5] whileFalse.
 |  | 
 | 
											
												
													
														|  | -	self assert: i equals: 6
 |  | 
 | 
											
												
													
														|  | 
 |  | +testMessageSend
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	self assert: self jsObject a equals: 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: self jsObject b equals: 2.
 | 
											
												
													
														|  | 
 |  | +	self assert: (self jsObject c: 3) equals: 3
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testCompiledSource
 |  | 
 | 
											
												
													
														|  | -	self assert: ([1+1] compiledSource includesSubString: 'function')
 |  | 
 | 
											
												
													
														|  | 
 |  | +testPrinting
 | 
											
												
													
														|  | 
 |  | +	self assert: self jsObject printString = '[object Object]'
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #ObjectTest
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #NumberTest
 | 
											
												
													
														|  |  	instanceVariableNames: ''
 |  |  	instanceVariableNames: ''
 | 
											
												
													
														|  |  	category: 'Kernel-Tests'!
 |  |  	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!ObjectTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +!NumberTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testEquality
 |  | 
 | 
											
												
													
														|  | -	| o |
 |  | 
 | 
											
												
													
														|  | -	o := Object new.
 |  | 
 | 
											
												
													
														|  | -	self deny: o = Object new.
 |  | 
 | 
											
												
													
														|  | -	self assert: o = o.
 |  | 
 | 
											
												
													
														|  | -	self assert: o yourself = o.
 |  | 
 | 
											
												
													
														|  | -	self assert: o = o yourself
 |  | 
 | 
											
												
													
														|  | 
 |  | +testPrintShowingDecimalPlaces
 | 
											
												
													
														|  | 
 |  | +	self assert: '23.00' equals: (23 printShowingDecimalPlaces: 2).
 | 
											
												
													
														|  | 
 |  | +	self assert: '23.57' equals: (23.5698 printShowingDecimalPlaces: 2).
 | 
											
												
													
														|  | 
 |  | +	self assert: '-234.56700' equals:( 234.567 negated printShowingDecimalPlaces: 5).
 | 
											
												
													
														|  | 
 |  | +	self assert: '23' equals: (23.4567 printShowingDecimalPlaces: 0).
 | 
											
												
													
														|  | 
 |  | +	self assert: '24' equals: (23.5567 printShowingDecimalPlaces: 0).
 | 
											
												
													
														|  | 
 |  | +	self assert: '-23' equals: (23.4567 negated printShowingDecimalPlaces: 0).
 | 
											
												
													
														|  | 
 |  | +	self assert: '-24' equals: (23.5567 negated printShowingDecimalPlaces: 0).
 | 
											
												
													
														|  | 
 |  | +	self assert: '100000000.0' equals: (100000000 printShowingDecimalPlaces: 1).
 | 
											
												
													
														|  | 
 |  | +	self assert: '0.98000' equals: (0.98 printShowingDecimalPlaces: 5).
 | 
											
												
													
														|  | 
 |  | +	self assert: '-0.98' equals: (0.98 negated printShowingDecimalPlaces: 2).
 | 
											
												
													
														|  | 
 |  | +	self assert: '2.57' equals: (2.567 printShowingDecimalPlaces: 2).
 | 
											
												
													
														|  | 
 |  | +	self assert: '-2.57' equals: (-2.567 printShowingDecimalPlaces: 2).
 | 
											
												
													
														|  | 
 |  | +	self assert: '0.00' equals: (0 printShowingDecimalPlaces: 2).
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIdentity
 |  | 
 | 
											
												
													
														|  | -	| o |
 |  | 
 | 
											
												
													
														|  | -	o := Object new.
 |  | 
 | 
											
												
													
														|  | -	self deny: o == Object new.
 |  | 
 | 
											
												
													
														|  | -	self assert: o == o
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testEquality
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 = 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: 0 = 0.
 | 
											
												
													
														|  | 
 |  | +	self deny: 1 = 0.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testHalt
 |  | 
 | 
											
												
													
														|  | -	self should: [Object new halt] raise: Error
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 yourself = 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 = 1 yourself.
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 yourself = 1 yourself.
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	self deny: 0 = false.
 | 
											
												
													
														|  | 
 |  | +	self deny: false = 0.
 | 
											
												
													
														|  | 
 |  | +	self deny: '' = 0.
 | 
											
												
													
														|  | 
 |  | +	self deny: 0 = ''
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testBasicAccess
 |  | 
 | 
											
												
													
														|  | -	| o |
 |  | 
 | 
											
												
													
														|  | -	o := Object new.
 |  | 
 | 
											
												
													
														|  | -	o basicAt: 'a' put: 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: (o basicAt: 'a') equals: 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: (o basicAt: 'b') equals: nil
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testArithmetic
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	"We rely on JS here, so we won't test complex behavior, just check if 
 | 
											
												
													
														|  | 
 |  | +	message sends are corrects"
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testNilUndefined
 |  | 
 | 
											
												
													
														|  | -	"nil in Smalltalk is the undefined object in JS"
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: 1.5 + 1 = 2.5.
 | 
											
												
													
														|  | 
 |  | +	self assert: 2 - 1 = 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: -2 - 1 = -3.
 | 
											
												
													
														|  | 
 |  | +	self assert: 12 / 2 = 6.
 | 
											
												
													
														|  | 
 |  | +	self assert: 3 * 4 = 12.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: nil = undefined
 |  | 
 | 
											
												
													
														|  | 
 |  | +	"Simple parenthesis and execution order"
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 + 2 * 3 = 9.
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 + (2 * 3) = 7
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testidentityHash
 |  | 
 | 
											
												
													
														|  | -	| o1 o2 |
 |  | 
 | 
											
												
													
														|  | 
 |  | +testRounded
 | 
											
												
													
														|  |  	
 |  |  	
 | 
											
												
													
														|  | -	o1 := Object new.
 |  | 
 | 
											
												
													
														|  | -	o2 := Object new.
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	self assert: o1 identityHash == o1 identityHash.
 |  | 
 | 
											
												
													
														|  | -	self deny: o1 identityHash == o2 identityHash
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: 3 rounded = 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: 3.212 rounded = 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: 3.51 rounded = 4
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testBasicPerform
 |  | 
 | 
											
												
													
														|  | -	| o |
 |  | 
 | 
											
												
													
														|  | -	o := Object new.
 |  | 
 | 
											
												
													
														|  | -	o basicAt: 'func' put: ['hello'].	
 |  | 
 | 
											
												
													
														|  | -	o basicAt: 'func2' put: [:a | a + 1].
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	self assert: (o basicPerform: 'func')	 equals: 'hello'.
 |  | 
 | 
											
												
													
														|  | -	self assert: (o basicPerform: 'func2' withArguments: #(3)) equals: 4
 |  | 
 | 
											
												
													
														|  | 
 |  | +testNegated
 | 
											
												
													
														|  | 
 |  | +	self assert: 3 negated = -3.
 | 
											
												
													
														|  | 
 |  | +	self assert: -3 negated = 3
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIfNil
 |  | 
 | 
											
												
													
														|  | -	self deny: Object new isNil.
 |  | 
 | 
											
												
													
														|  | -	self deny: (Object new ifNil: [true]) = true.
 |  | 
 | 
											
												
													
														|  | -	self assert: (Object new ifNotNil: [true]) = true.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testComparison
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: (Object new ifNil: [false] ifNotNil: [true]) = true.
 |  | 
 | 
											
												
													
														|  | -	self assert: (Object new ifNotNil: [true] ifNil: [false]) = true
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: 3 > 2.
 | 
											
												
													
														|  | 
 |  | +	self assert: 2 < 3.
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	self deny: 3 < 2.
 | 
											
												
													
														|  | 
 |  | +	self deny: 2 > 3.
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	self assert: 3 >= 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: 3.1 >= 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: 3 <= 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: 3 <= 3.1
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testInstVars
 |  | 
 | 
											
												
													
														|  | -	| o |
 |  | 
 | 
											
												
													
														|  | -	o := ObjectMock new.
 |  | 
 | 
											
												
													
														|  | -	self assert: (o instVarAt: #foo) equals: nil.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testTruncated
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	self assert: 3 truncated = 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: 3.212 truncated = 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: 3.51 truncated = 3
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	o instVarAt: #foo put: 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: (o instVarAt: #foo) equals: 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: (o instVarAt: 'foo') equals: 1
 |  | 
 | 
											
												
													
														|  | 
 |  | +testCopying
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 copy == 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 deepCopy == 1
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testYourself
 |  | 
 | 
											
												
													
														|  | -	| o |
 |  | 
 | 
											
												
													
														|  | -	o := ObjectMock new.
 |  | 
 | 
											
												
													
														|  | -	self assert: o yourself == o
 |  | 
 | 
											
												
													
														|  | 
 |  | +testMinMax
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	self assert: (2 max: 5) equals: 5.
 | 
											
												
													
														|  | 
 |  | +	self assert: (2 min: 5) equals: 2
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testDNU
 |  | 
 | 
											
												
													
														|  | -	self should: [Object new foo] raise: MessageNotUnderstood
 |  | 
 | 
											
												
													
														|  | -! !
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIdentity
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 == 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: 0 == 0.
 | 
											
												
													
														|  | 
 |  | +	self deny: 1 == 0.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #SymbolTest
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: ''
 |  | 
 | 
											
												
													
														|  | -	category: 'Kernel-Tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 yourself == 1.
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 == 1 yourself.
 | 
											
												
													
														|  | 
 |  | +	self assert: 1 yourself == 1 yourself.
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	self deny: 1 == 2
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!SymbolTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testSqrt
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	self assert: 4 sqrt = 2.
 | 
											
												
													
														|  | 
 |  | +	self assert: 16 sqrt = 4
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testEquality
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello = #hello.
 |  | 
 | 
											
												
													
														|  | -	self deny: #hello = #world.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testSquared
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +	self assert: 4 squared = 16
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: #hello  = #hello yourself.
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello yourself = #hello.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testTimesRepeat
 | 
											
												
													
														|  | 
 |  | +	| i |
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self deny: #hello  = 'hello'.
 |  | 
 | 
											
												
													
														|  | -	self deny: 'hello' = #hello.
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	i := 0.
 | 
											
												
													
														|  | 
 |  | +	0 timesRepeat: [i := i + 1].
 | 
											
												
													
														|  | 
 |  | +	self assert: i equals: 0.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAt
 |  | 
 | 
											
												
													
														|  | -	self assert: (#hello at: 1) = 'h'.
 |  | 
 | 
											
												
													
														|  | -	self assert: (#hello at: 5) = 'o'.
 |  | 
 | 
											
												
													
														|  | -	self assert: (#hello at: 6 ifAbsent: [nil]) = nil
 |  | 
 | 
											
												
													
														|  | 
 |  | +	5 timesRepeat: [i := i + 1].
 | 
											
												
													
														|  | 
 |  | +	self assert: i equals: 5
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAtPut
 |  | 
 | 
											
												
													
														|  | -	"Symbol instances are read-only"
 |  | 
 | 
											
												
													
														|  | -	self should: ['hello' at: 1 put: 'a'] raise: Error
 |  | 
 | 
											
												
													
														|  | 
 |  | +testTo
 | 
											
												
													
														|  | 
 |  | +	self assert: (1 to: 5) equals: #(1 2 3 4 5)
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIdentity
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello == #hello.
 |  | 
 | 
											
												
													
														|  | -	self deny: #hello == #world.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testToBy
 | 
											
												
													
														|  | 
 |  | +	self assert: (0 to: 6 by: 2) equals: #(0 2 4 6).
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: #hello  = #hello yourself.
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello yourself = #hello asString asSymbol
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self should: [1 to: 4 by: 0] raise: Error
 | 
											
												
													
														|  | 
 |  | +! !
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #BooleanTest
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: ''
 | 
											
												
													
														|  | 
 |  | +	category: 'Kernel-Tests'!
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +!BooleanTest methodsFor: 'tests'!
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +testLogic
 | 
											
												
													
														|  | 
 |  | + 
 | 
											
												
													
														|  | 
 |  | +	"Trivial logic table"
 | 
											
												
													
														|  | 
 |  | +	self assert: (true & true); deny: (true & false); deny: (false & true); deny: (false & false).
 | 
											
												
													
														|  | 
 |  | +	self assert: (true | true); assert: (true | false); assert: (false | true); deny: (false | false).
 | 
											
												
													
														|  | 
 |  | +        "Checking that expressions work fine too"
 | 
											
												
													
														|  | 
 |  | +	self assert: (true & (1 > 0)); deny: ((1 > 0) & false); deny: ((1 > 0) & (1 > 2)).
 | 
											
												
													
														|  | 
 |  | +        self assert: (false | (1 > 0)); assert: ((1 > 0) | false); assert: ((1 > 0) | (1 > 2))
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testComparing
 |  | 
 | 
											
												
													
														|  | -	self assert: #ab > #aa.
 |  | 
 | 
											
												
													
														|  | -	self deny: #ab > #ba.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testEquality
 | 
											
												
													
														|  | 
 |  | +	"We're on top of JS...just be sure to check the basics!!"
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: #ab < #ba.
 |  | 
 | 
											
												
													
														|  | -	self deny: #bb < #ba.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self deny: 0 = false. 
 | 
											
												
													
														|  | 
 |  | +	self deny: false = 0.
 | 
											
												
													
														|  | 
 |  | +	self deny: '' = false.
 | 
											
												
													
														|  | 
 |  | +	self deny: false = ''.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: #ab >= #aa.
 |  | 
 | 
											
												
													
														|  | -	self deny: #ab >= #ba.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: true = true.
 | 
											
												
													
														|  | 
 |  | +	self deny: false = true.
 | 
											
												
													
														|  | 
 |  | +	self deny: true = false.
 | 
											
												
													
														|  | 
 |  | +	self assert: false = false.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: #ab <= #ba.
 |  | 
 | 
											
												
													
														|  | -	self deny: #bb <= #ba
 |  | 
 | 
											
												
													
														|  | 
 |  | +	"JS may do some type coercing after sending a message"
 | 
											
												
													
														|  | 
 |  | +	self assert: true yourself = true.
 | 
											
												
													
														|  | 
 |  | +	self assert: true yourself = true yourself
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testSize
 |  | 
 | 
											
												
													
														|  | -	self assert: #a size equals: 1.
 |  | 
 | 
											
												
													
														|  | -	self assert: #aaaaa size equals: 5
 |  | 
 | 
											
												
													
														|  | 
 |  | +testLogicKeywords
 | 
											
												
													
														|  | 
 |  | + 
 | 
											
												
													
														|  | 
 |  | +	"Trivial logic table"
 | 
											
												
													
														|  | 
 |  | +	self 
 | 
											
												
													
														|  | 
 |  | +		assert: (true and: [ true]); 
 | 
											
												
													
														|  | 
 |  | +		deny: (true and: [ false ]); 
 | 
											
												
													
														|  | 
 |  | +		deny: (false and: [ true ]); 
 | 
											
												
													
														|  | 
 |  | +		deny: (false and: [ false ]).
 | 
											
												
													
														|  | 
 |  | +	self 
 | 
											
												
													
														|  | 
 |  | +		assert: (true or: [ true ]); 
 | 
											
												
													
														|  | 
 |  | +		assert: (true or: [ false ]); 
 | 
											
												
													
														|  | 
 |  | +		assert: (false or: [ true ]); 
 | 
											
												
													
														|  | 
 |  | +		deny: (false or: [ false ]).
 | 
											
												
													
														|  | 
 |  | +        
 | 
											
												
													
														|  | 
 |  | +	"Checking that expressions work fine too"
 | 
											
												
													
														|  | 
 |  | +	self 
 | 
											
												
													
														|  | 
 |  | +		assert: (true and: [ 1 > 0 ]); 
 | 
											
												
													
														|  | 
 |  | +		deny: ((1 > 0) and: [ false ]); 
 | 
											
												
													
														|  | 
 |  | +		deny: ((1 > 0) and: [ 1 > 2 ]).
 | 
											
												
													
														|  | 
 |  | +        self 
 | 
											
												
													
														|  | 
 |  | +		assert: (false or: [ 1 > 0 ]); 
 | 
											
												
													
														|  | 
 |  | +		assert: ((1 > 0) or: [ false ]); 
 | 
											
												
													
														|  | 
 |  | +		assert: ((1 > 0) or: [ 1 > 2 ])
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAsString
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello asString equals: 'hello'
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIfTrueIfFalse
 | 
											
												
													
														|  | 
 |  | + 
 | 
											
												
													
														|  | 
 |  | +	self assert: (true ifTrue: ['alternative block']) = 'alternative block'.
 | 
											
												
													
														|  | 
 |  | +	self assert: (true ifFalse: ['alternative block']) = nil.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAsSymbol
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello == #hello asSymbol
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: (false ifTrue: ['alternative block']) = nil.
 | 
											
												
													
														|  | 
 |  | +	self assert: (false ifFalse: ['alternative block']) = 'alternative block'.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testCopying
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello copy == #hello.
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello deepCopy == #hello
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: (false ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.
 | 
											
												
													
														|  | 
 |  | +	self assert: (false ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIsSymbolIsString
 |  | 
 | 
											
												
													
														|  | -	self assert: #hello isSymbol.
 |  | 
 | 
											
												
													
														|  | -	self deny: 'hello' isSymbol.
 |  | 
 | 
											
												
													
														|  | -	self deny: #hello isString.
 |  | 
 | 
											
												
													
														|  | -	self assert: 'hello' isString
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: (true ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.
 | 
											
												
													
														|  | 
 |  | +	self assert: (true ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -Object subclass: #ObjectMock
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: 'foo bar'
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #DictionaryTest
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: ''
 | 
											
												
													
														|  |  	category: 'Kernel-Tests'!
 |  |  	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!ObjectMock methodsFor: 'not yet classified'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +!DictionaryTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -foo
 |  | 
 | 
											
												
													
														|  | -	^foo
 |  | 
 | 
											
												
													
														|  | 
 |  | +testPrintString
 | 
											
												
													
														|  | 
 |  | +	self
 | 
											
												
													
														|  | 
 |  | +		assert: 'a Dictionary(''firstname'' -> ''James'' , ''lastname'' -> ''Bond'')' 
 | 
											
												
													
														|  | 
 |  | +		equals: (Dictionary new 
 | 
											
												
													
														|  | 
 |  | +                         	at:'firstname' put: 'James';
 | 
											
												
													
														|  | 
 |  | +                        	at:'lastname' put: 'Bond';
 | 
											
												
													
														|  | 
 |  | +                        	printString)
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -foo: anObject
 |  | 
 | 
											
												
													
														|  | -	foo := anObject
 |  | 
 | 
											
												
													
														|  | -! !
 |  | 
 | 
											
												
													
														|  | 
 |  | +testEquality
 | 
											
												
													
														|  | 
 |  | +	| d1 d2 |
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #UndefinedTest
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: ''
 |  | 
 | 
											
												
													
														|  | -	category: 'Kernel-Tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: Dictionary new = Dictionary new.
 | 
											
												
													
														|  | 
 |  | +		
 | 
											
												
													
														|  | 
 |  | +	d1 := Dictionary new at: 1 put: 2; yourself.
 | 
											
												
													
														|  | 
 |  | +	d2 := Dictionary new at: 1 put: 2; yourself.
 | 
											
												
													
														|  | 
 |  | +	self assert: d1 = d2.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!UndefinedTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d2 := Dictionary new at: 1 put: 3; yourself.
 | 
											
												
													
														|  | 
 |  | +	self deny: d1 = d2.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIsNil
 |  | 
 | 
											
												
													
														|  | -	self assert: nil isNil.
 |  | 
 | 
											
												
													
														|  | -	self deny: nil notNil.
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d2 := Dictionary new at: 2 put: 2; yourself.
 | 
											
												
													
														|  | 
 |  | +	self deny: d1 = d2.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testIfNil
 |  | 
 | 
											
												
													
														|  | -	self assert: (nil ifNil: [true]) equals: true.
 |  | 
 | 
											
												
													
														|  | -	self deny: (nil ifNotNil: [true]) = true.
 |  | 
 | 
											
												
													
														|  | -	self assert: (nil ifNil: [true] ifNotNil: [false]) equals: true.
 |  | 
 | 
											
												
													
														|  | -	self deny: (nil ifNotNil: [true] ifNil: [false]) = true
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d2 := Dictionary new at: 1 put: 2; at: 3 put: 4; yourself.
 | 
											
												
													
														|  | 
 |  | +	self deny: d1 = d2.
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testCopying
 |  | 
 | 
											
												
													
														|  | -	self assert: nil copy equals: nil
 |  | 
 | 
											
												
													
														|  | 
 |  | +testDynamicDictionaries
 | 
											
												
													
														|  | 
 |  | +	self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testDeepCopy
 |  | 
 | 
											
												
													
														|  | -	self assert: nil deepCopy = nil
 |  | 
 | 
											
												
													
														|  | -! !
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAccessing
 | 
											
												
													
														|  | 
 |  | +	| d |
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #PointTest
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: ''
 |  | 
 | 
											
												
													
														|  | -	category: 'Kernel-Tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d := Dictionary new.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!PointTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d at: 'hello' put: 'world'.
 | 
											
												
													
														|  | 
 |  | +	self assert: (d at: 'hello') = 'world'.
 | 
											
												
													
														|  | 
 |  | +	self assert: (d at: 'hello' ifAbsent: [nil]) = 'world'.
 | 
											
												
													
														|  | 
 |  | +	self deny: (d at: 'foo' ifAbsent: [nil]) = 'world'.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAccessing
 |  | 
 | 
											
												
													
														|  | -	self assert: (Point x: 3 y: 4) x equals: 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: (Point x: 3 y: 4) y equals: 4.
 |  | 
 | 
											
												
													
														|  | -	self assert: (Point new x: 3) x equals: 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: (Point new y: 4) y equals: 4
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d at: 1 put: 2.
 | 
											
												
													
														|  | 
 |  | +	self assert: (d at: 1) = 2.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAt
 |  | 
 | 
											
												
													
														|  | -	self assert: 3@4 equals: (Point x: 3 y: 4)
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d at: 1@3 put: 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: (d at: 1@3) = 3
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testEgality
 |  | 
 | 
											
												
													
														|  | -	self assert: 3@4 = (3@4).
 |  | 
 | 
											
												
													
														|  | -	self deny: 3@5 = (3@6)
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +testSize
 | 
											
												
													
														|  | 
 |  | +	| d |
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testArithmetic
 |  | 
 | 
											
												
													
														|  | -	self assert: 3@4 * (3@4 ) equals: (Point x: 9 y: 16).
 |  | 
 | 
											
												
													
														|  | -	self assert: 3@4 + (3@4 ) equals: (Point x: 6 y: 8).
 |  | 
 | 
											
												
													
														|  | -	self assert: 3@4 - (3@4 ) equals: (Point x: 0 y: 0).
 |  | 
 | 
											
												
													
														|  | -	self assert: 6@8 / (3@4 ) equals: (Point x: 2 y: 2)
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d := Dictionary new.
 | 
											
												
													
														|  | 
 |  | +	self assert: d size = 0.
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	d at: 1 put: 2.
 | 
											
												
													
														|  | 
 |  | +	self assert: d size = 1.
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	d at: 2 put: 3.
 | 
											
												
													
														|  | 
 |  | +	self assert: d size = 2.
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testTranslateBy
 |  | 
 | 
											
												
													
														|  | -	self assert: 3@4 equals: (3@3 translateBy: 0@1).
 |  | 
 | 
											
												
													
														|  | -	self assert: 3@2 equals: (3@3 translateBy: 0@1 negated).
 |  | 
 | 
											
												
													
														|  | -	self assert: 5@6 equals: (3@3 translateBy: 2@3).
 |  | 
 | 
											
												
													
														|  | -	self assert: 0@3 equals: (3@3 translateBy: 3 negated @0).
 |  | 
 | 
											
												
													
														|  | -! !
 |  | 
 | 
											
												
													
														|  | 
 |  | +testValues
 | 
											
												
													
														|  | 
 |  | +	| d |
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #RandomTest
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: ''
 |  | 
 | 
											
												
													
														|  | -	category: 'Kernel-Tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d := Dictionary new.
 | 
											
												
													
														|  | 
 |  | +	d at: 1 put: 2.
 | 
											
												
													
														|  | 
 |  | +	d at: 2 put: 3.
 | 
											
												
													
														|  | 
 |  | +	d at: 3 put: 4.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!RandomTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: d values = #(2 3 4)
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -textNext
 |  | 
 | 
											
												
													
														|  | 
 |  | +testKeys
 | 
											
												
													
														|  | 
 |  | +	| d |
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	10000 timesRepeat: [
 |  | 
 | 
											
												
													
														|  | -			| current next | 
 |  | 
 | 
											
												
													
														|  | -			next := Random new next.
 |  | 
 | 
											
												
													
														|  | -			self assert: (next >= 0).
 |  | 
 | 
											
												
													
														|  | -			self assert: (next < 1).
 |  | 
 | 
											
												
													
														|  | -			self deny: current = next.
 |  | 
 | 
											
												
													
														|  | -			next = current]
 |  | 
 | 
											
												
													
														|  | 
 |  | +	d := Dictionary new.
 | 
											
												
													
														|  | 
 |  | +	d at: 1 put: 2.
 | 
											
												
													
														|  | 
 |  | +	d at: 2 put: 3.
 | 
											
												
													
														|  | 
 |  | +	d at: 3 put: 4.
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	self assert: d keys = #(1 2 3)
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #ClassBuilderTest
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: 'builder theClass'
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #StringTest
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: ''
 | 
											
												
													
														|  |  	category: 'Kernel-Tests'!
 |  |  	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!ClassBuilderTest methodsFor: 'running'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +!StringTest methodsFor: 'tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -setUp
 |  | 
 | 
											
												
													
														|  | -	builder := ClassBuilder new
 |  | 
 | 
											
												
													
														|  | 
 |  | +testJoin
 | 
											
												
													
														|  | 
 |  | +	self assert: 'hello,world' equals: (',' join: #('hello' 'world'))
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -tearDown
 |  | 
 | 
											
												
													
														|  | -	theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]
 |  | 
 | 
											
												
													
														|  | 
 |  | +testStreamContents
 | 
											
												
													
														|  | 
 |  | +	self 
 | 
											
												
													
														|  | 
 |  | +		assert: 'hello world' 
 | 
											
												
													
														|  | 
 |  | +		equals: (String streamContents: [:aStream| aStream 
 | 
											
												
													
														|  | 
 |  | +                                                 					nextPutAll: 'hello'; space; 
 | 
											
												
													
														|  | 
 |  | +                                                 					nextPutAll: 'world'])
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testClassCopy
 |  | 
 | 
											
												
													
														|  | -	theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.
 |  | 
 | 
											
												
													
														|  | -	self assert: theClass superclass == ObjectMock superclass.
 |  | 
 | 
											
												
													
														|  | -	self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.
 |  | 
 | 
											
												
													
														|  | -	self assert: theClass name equals: 'ObjectMock2'.
 |  | 
 | 
											
												
													
														|  | -	self assert: theClass package == ObjectMock package.
 |  | 
 | 
											
												
													
														|  | -	self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys
 |  | 
 | 
											
												
													
														|  | 
 |  | +testIncludesSubString
 | 
											
												
													
														|  | 
 |  | +	self assert: ('amber' includesSubString: 'ber').
 | 
											
												
													
														|  | 
 |  | +	self deny: ('amber' includesSubString: 'zork').
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testInstanceVariableNames
 |  | 
 | 
											
												
													
														|  | -	self assert: (builder instanceVariableNamesFor: '  hello   world   ') equals: #('hello' 'world')
 |  | 
 | 
											
												
													
														|  | -! !
 |  | 
 | 
											
												
													
														|  | 
 |  | +testEquality
 | 
											
												
													
														|  | 
 |  | +	self assert: 'hello' = 'hello'.
 | 
											
												
													
														|  | 
 |  | +	self deny: 'hello' = 'world'.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -TestCase subclass: #SetTest
 |  | 
 | 
											
												
													
														|  | -	instanceVariableNames: ''
 |  | 
 | 
											
												
													
														|  | -	category: 'Kernel-Tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self assert: 'hello'  = 'hello' yourself.
 | 
											
												
													
														|  | 
 |  | +	self assert: 'hello' yourself = 'hello'.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -!SetTest methodsFor: 'tests'!
 |  | 
 | 
											
												
													
														|  | 
 |  | +	"test JS falsy value"
 | 
											
												
													
														|  | 
 |  | +	self deny: '' = 0
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testUnicity
 |  | 
 | 
											
												
													
														|  | -	| set |
 |  | 
 | 
											
												
													
														|  | -	set := Set new.
 |  | 
 | 
											
												
													
														|  | -	set add: 21.
 |  | 
 | 
											
												
													
														|  | -	set add: 'hello'.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testCopyWithoutAll
 | 
											
												
													
														|  | 
 |  | +	self 
 | 
											
												
													
														|  | 
 |  | +		assert: 'hello world' 
 | 
											
												
													
														|  | 
 |  | +		equals: ('*hello* *world*' copyWithoutAll: '*')
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	set add: 21.
 |  | 
 | 
											
												
													
														|  | -	self assert: set size = 2.
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	set add: 'hello'.
 |  | 
 | 
											
												
													
														|  | -	self assert: set size = 2.
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAt
 | 
											
												
													
														|  | 
 |  | +	self assert: ('hello' at: 1) = 'h'.
 | 
											
												
													
														|  | 
 |  | +	self assert: ('hello' at: 5) = 'o'.
 | 
											
												
													
														|  | 
 |  | +	self assert: ('hello' at: 6 ifAbsent: [nil]) = nil
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	self assert: set asArray equals: #(21 'hello')
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAtPut
 | 
											
												
													
														|  | 
 |  | +	"String instances are read-only"
 | 
											
												
													
														|  | 
 |  | +	self should: ['hello' at: 1 put: 'a'] raise: Error
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testAt
 |  | 
 | 
											
												
													
														|  | -	self should: [Set new at: 1 put: 2] raise: Error
 |  | 
 | 
											
												
													
														|  | 
 |  | +testSize
 | 
											
												
													
														|  | 
 |  | +	self assert: 'smalltalk' size equals: 9.
 | 
											
												
													
														|  | 
 |  | +	self assert: '' size equals: 0
 | 
											
												
													
														|  |  !
 |  |  !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  testAddRemove
 |  |  testAddRemove
 | 
											
												
													
														|  | -	| set |
 |  | 
 | 
											
												
													
														|  | -	set := Set new.
 |  | 
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | -	self assert: set isEmpty.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	self should: ['hello' add: 'a'] raise: Error.
 | 
											
												
													
														|  | 
 |  | +	self should: ['hello' remove: 'h'] raise: Error
 | 
											
												
													
														|  | 
 |  | +!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	set add: 3.
 |  | 
 | 
											
												
													
														|  | -	self assert: (set includes: 3).
 |  | 
 | 
											
												
													
														|  | 
 |  | +testAsArray
 | 
											
												
													
														|  | 
 |  | +	self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').
 | 
											
												
													
														|  | 
 |  | +! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	set add: 5.
 |  | 
 | 
											
												
													
														|  | -	self assert: (set includes: 5).
 |  | 
 | 
											
												
													
														|  | 
 |  | +TestCase subclass: #ArrayTest
 | 
											
												
													
														|  | 
 |  | +	instanceVariableNames: ''
 | 
											
												
													
														|  | 
 |  | +	category: 'Kernel-Tests'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	set remove: 3.
 |  | 
 | 
											
												
													
														|  | -	self deny: (set includes: 3)
 |  | 
 | 
											
												
													
														|  | -!
 |  | 
 | 
											
												
													
														|  | 
 |  | +!ArrayTest methodsFor: 'testing'!
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -testSize
 |  | 
 | 
											
												
													
														|  | -	self assert: Set new size equals: 0.
 |  | 
 | 
											
												
													
														|  | -	self assert: (Set withAll: #(1 2 3 4)) size equals: 4.
 |  | 
 | 
											
												
													
														|  | -	self assert: (Set withAll: #(1 1 1 1)) size equals: 1
 |  | 
 | 
											
												
													
														|  | 
 |  | +testFirstN
 | 
											
												
													
														|  | 
 |  | +	self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).
 | 
											
												
													
														|  |  ! !
 |  |  ! !
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  PackageTest subclass: #PackageWithDefaultCommitPathChangedTest
 |  |  PackageTest subclass: #PackageWithDefaultCommitPathChangedTest
 |