Levente Uzonyi uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-ul.122.mcz ==================== Summary ==================== Name: KernelTests-ul.122 Author: ul Time: 18 December 2009, 5:48:43 am UUID: 6fcb1501-cc03-4345-9fca-9cdd763753bd Ancestors: KernelTests-ul.121, KernelTests-bs.121 - updated tests for #ifNil: #ifNotNil: and friends =============== Diff against KernelTests-bs.121 =============== Item was changed: + ----- Method: ProtoObjectTest>>testIsNil (in category 'tests - testing') ----- - ----- Method: ProtoObjectTest>>testIsNil (in category 'testing - testing') ----- testIsNil + self deny: ProtoObject new isNil! - self assert: (ProtoObject new isNil = false).! Item was changed: ----- Method: UndefinedObjectTest>>testNotNil (in category 'tests - testing') ----- testNotNil + self deny: nil notNil! - self deny: (nil notNil).! Item was added: + ----- Method: ObjectTest>>testNotNil (in category 'tests - testing') ----- + testNotNil + + self assert: Object new notNil! Item was changed: ----- Method: UndefinedObjectTest>>testIfNotNil (in category 'tests - testing') ----- testIfNotNil + | block | + self shouldnt: [ nil ifNotNil: [ self halt ] ] raise: Halt. + self shouldnt: [ nil ifNotNil: [ :object | self halt ] ] raise: Halt. + self assert: (nil ifNotNil: [ 1 ]) == nil. + self assert: (nil ifNotNil: [ :o | 1 ]) == nil. + "Now the same without inlining." + block := [ self halt ]. + self shouldnt: [ nil ifNotNil: block ] raise: Halt. + block := [ :object | self halt ]. + self shouldnt: [ nil ifNotNil: block ] raise: Halt. + block := [ 1 ]. + self assert: (nil ifNotNil: block) == nil. + block := [ :o | 1 ]. + self assert: (nil ifNotNil: block) == nil. + - self shouldnt: [ nil ifNotNil: [self halt]] raise: Halt. - ! Item was changed: ----- Method: UndefinedObjectTest>>testIfNotNilIfNil (in category 'tests - testing') ----- testIfNotNilIfNil + | object block | + object := Object new. + self should: [ nil ifNotNil: [ self error ] ifNil: [ self halt ] ] raise: Halt. + self should: [ nil ifNotNil: [ :o | self error] ifNil: [ self halt ] ] raise: Halt. + self assert: (nil ifNotNil: [ 1 ] ifNil: [ object ]) == object. + self assert: (nil ifNotNil: [ :o | 1 ] ifNil: [ object ]) == object. + "Now the same without inlining." + block := [ self error ]. + self should: [ nil ifNotNil: block ifNil: [ self halt ] ] raise: Halt. + block := [ :o | self error]. + self should: [ nil ifNotNil: block ifNil: [ self halt ] ] raise: Halt. + block := [ 1 ]. + self assert: (nil ifNotNil: block ifNil: [ object ]) == object. + block := [ :o | 1 ]. + self assert: (nil ifNotNil: block ifNil: [ object ]) == object! - self should: [ nil ifNotNil: [self error] ifNil: [self halt] ] raise: Halt. - - - ! Item was added: + ----- Method: ProtoObjectTest>>testIfNotNil (in category 'tests - testing') ----- + testIfNotNil + + | object returnValue block | + object := ProtoObject new. + returnValue := Object new. + self should: [ object ifNotNil: [ self halt ] ] raise: Halt. + self should: [ object ifNotNil: [ :o | self halt ] ] raise: Halt. + self assert: (object ifNotNil: [ :o | o == object ]). + self assert: (object ifNotNil: [ returnValue ]) == returnValue. + self assert: (object ifNotNil: [ :o | returnValue ]) == returnValue. + "Now the same without inlining." + block := [ self halt ]. + self should: [ object ifNotNil: block ] raise: Halt. + block := [ :o | self halt ]. + self should: [ object ifNotNil: block ] raise: Halt. + block := [ :o | o == object ]. + self assert: (object ifNotNil: block). + block := [ returnValue ]. + self assert: (object ifNotNil: block) = returnValue. + block := [ :o | returnValue ]. + self assert: (object ifNotNil: block) = returnValue! Item was changed: + ----- Method: ObjectTest>>testHaltIf (in category 'tests - testing') ----- - ----- Method: ObjectTest>>testHaltIf (in category 'tests - debugging') ----- testHaltIf self should: [self haltIf: true] raise: Halt. self shouldnt: [self haltIf: false] raise: Halt. self should: [self haltIf: [true]] raise: Halt. self shouldnt: [self haltIf: [false]] raise: Halt. self should: [self haltIf: #testHaltIf.] raise: Halt. self shouldnt: [self haltIf: #teadfasdfltIf.] raise: Halt. self should: [self a] raise: Halt. self shouldnt: [self a1] raise: Halt. self should: [self haltIf: [:o | o class = self class]] raise: Halt. self shouldnt: [self haltIf: [:o | o class ~= self class]] raise: Halt. ! Item was changed: + ----- Method: ProtoObjectTest>>testFlag (in category 'tests - testing') ----- - ----- Method: ProtoObjectTest>>testFlag (in category 'testing - testing') ----- testFlag self shouldnt: [ProtoObject new flag: #hallo] raise: Error.! Item was changed: ----- Method: UndefinedObjectTest>>testIfNil (in category 'tests - testing') ----- testIfNil + | object block | + object := Object new. + self should: [ nil ifNil: [ self halt ] ] raise: Halt. + self assert: (nil ifNil: [ object ]) == object. + "Now the same without inlining." + block := [ self halt ]. + self should: [ nil ifNil: block ] raise: Halt. + block := [ object ]. + self assert: (nil ifNil: block) == object. + - self should: [ nil ifNil: [self halt]] raise: Halt. ! Item was added: + ----- Method: ProtoObjectTest>>testIfNotNilIfNil (in category 'tests - testing') ----- + testIfNotNilIfNil + + | object returnValue block | + object := ProtoObject new. + returnValue := Object new. + self should: [ object ifNotNil: [ self halt ] ifNil: [ self error ] ] raise: Halt. + self should: [ object ifNotNil: [ :o | self halt ] ifNil: [ self error ] ] raise: Halt. + self assert: (object ifNotNil: [ :o | o == object ] ifNil: [ false ]). + self assert: (object ifNotNil: [ returnValue ] ifNil: [ false ]) == returnValue. + self assert: (object ifNotNil: [ :o | returnValue ] ifNil: [ false ]) == returnValue. + "Now the same without inlining." + block := [ self halt ]. + self should: [ object ifNotNil: block ifNil: [ self error ] ] raise: Halt. + block := [ :o | self halt ]. + self should: [ object ifNotNil: block ifNil: [ self error ] ] raise: Halt. + block := [ :o | o == object ]. + self assert: (object ifNotNil: block ifNil: [ false ]). + block := [ returnValue ]. + self assert: (object ifNotNil: block ifNil: [ false ]) == returnValue. + block := [ :o | returnValue ]. + self assert: (object ifNotNil: block ifNil: [ false ]) == returnValue! Item was changed: ----- Method: UndefinedObjectTest>>testIfNilIfNotNil (in category 'tests - testing') ----- testIfNilIfNotNil + | object block | + object := Object new. + self should: [ nil ifNil: [self halt] ifNotNil: [ self error] ] raise: Halt. + self should: [ nil ifNil: [ self halt ] ifNotNil: [ :o | self error ] ] raise: Halt. + self assert: (nil ifNil: [ object ] ifNotNil: [ 1 ]) == object. + self assert: (nil ifNil: [ object ] ifNotNil: [ :o | 1 ]) == object. + "Now the same without inlining." + block := [ self halt ]. + self should: [ nil ifNil: block ifNotNil: [ self error ] ] raise: Halt. + self should: [ nil ifNil: block ifNotNil: [ :o | self error ] ] raise: Halt. + block := [ object ]. + self assert: (nil ifNil: block ifNotNil: [ 1 ]) == object. + self assert: (nil ifNil: block ifNotNil: [ :o | 1 ]) == object! - self should: [ nil ifNil: [self halt] ifNotNil: [self error] ] raise: Halt. - - - ! Item was added: + ----- Method: ProtoObjectTest>>testIfNil (in category 'tests - testing') ----- + testIfNil + + | object block | + object := ProtoObject new. + self shouldnt: [ object ifNil: [ self halt ]] raise: Halt. + self assert: (object ifNil: [ nil ]) == object. + "Now the same without inlining." + block := [ self halt ]. + self shouldnt: [ object ifNil: block ] raise: Halt. + block := [ nil ]. + self assert: (object ifNil: block) == object. + + ! Item was changed: ----- Method: UndefinedObjectTest>>testIsNil (in category 'tests - testing') ----- testIsNil + self assert: nil isNil! - self assert: (nil isNil).! Item was added: + ----- Method: ProtoObjectTest>>testIfNilIfNotNil (in category 'tests - testing') ----- + testIfNilIfNotNil + + | object returnValue block | + object := ProtoObject new. + returnValue := Object new. + self should: [ object ifNil: [ self error ] ifNotNil: [ self halt ] ] raise: Halt. + self should: [ object ifNil: [ self error ] ifNotNil: [ :o | self halt ] ] raise: Halt. + self assert: (object ifNil: [ false ] ifNotNil: [ :o | o == object ]). + self assert: (object ifNil: [ nil ] ifNotNil: [ returnValue ]) == returnValue. + self assert: (object ifNil: [ nil ] ifNotNil: [ :o | returnValue ]) == returnValue. + "Now the same without inlining." + block := [ self halt ]. + self should: [ object ifNil: [ self error ] ifNotNil: block ] raise: Halt. + block := [ :o | self halt ]. + self should: [ object ifNil: [ self error ] ifNotNil: block ] raise: Halt. + block := [ :o | o == object ]. + self assert: (object ifNil: [ false ] ifNotNil: block). + block := [ returnValue ]. + self assert: (object ifNil: [ nil ] ifNotNil: block) = returnValue. + block := [ :o | returnValue ]. + self assert: (object ifNil: [ nil ] ifNotNil: block) = returnValue! |
Free forum by Nabble | Edit this page |