A new version of KernelTests was added to project The Inbox:
http://source.squeak.org/inbox/KernelTests-mha.167.mcz ==================== Summary ==================== Name: KernelTests-mha.167 Author: mha Time: 23 September 2010, 10:31:18.285 am UUID: a52aec93-e5f8-4957-9b4b-565ae390925d Ancestors: KernelTests-mha.164, KernelTests-nice.166 tests for third attempt to clean up CompiledMethod's closure protocol =============== Diff against KernelTests-mha.164 =============== Item was added: + ----- Method: ClassBuilderTest>>categoryNameForTemporaryClasses (in category 'utilities') ----- + categoryNameForTemporaryClasses + "Answer the category where to classify temporarily created classes" + + ^'Dummy-Tests-ClassBuilder'! Item was changed: ----- Method: ClassBuilderTest>>cleanup (in category 'utilities') ----- cleanup subClass ifNotNil:[subClass removeFromSystem]. + baseClass ifNotNil:[baseClass removeFromSystem]. + (Smalltalk organization listAtCategoryNamed: self categoryNameForTemporaryClasses) isEmpty + ifTrue: [Smalltalk organization removeCategory: self categoryNameForTemporaryClasses]! - baseClass ifNotNil:[baseClass removeFromSystem].! Item was changed: ----- Method: ClassBuilderTest>>makeByteVariableSubclassOf: (in category 'utilities') ----- makeByteVariableSubclassOf: aClass subClass := aClass variableByteSubclass: self subClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses! - category: 'Kernel-Tests-ClassBuilder'! Item was changed: ----- Method: ClassBuilderTest>>makeIVarsSubclassOf: (in category 'utilities') ----- makeIVarsSubclassOf: aClass subClass := aClass subclass: self subClassName instanceVariableNames: 'var3 var4' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses! - category: 'Kernel-Tests-ClassBuilder'! Item was changed: ----- Method: ClassBuilderTest>>makeNormalSubclassOf: (in category 'utilities') ----- makeNormalSubclassOf: aClass subClass := aClass subclass: self subClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses! - category: 'Kernel-Tests-ClassBuilder'! Item was changed: ----- Method: ClassBuilderTest>>makeVariableSubclassOf: (in category 'utilities') ----- makeVariableSubclassOf: aClass subClass := aClass variableSubclass: self subClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses! - category: 'Kernel-Tests-ClassBuilder'.! Item was changed: ----- Method: ClassBuilderTest>>makeWeakSubclassOf: (in category 'utilities') ----- makeWeakSubclassOf: aClass subClass := aClass weakSubclass: self subClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses! - category: 'Kernel-Tests-ClassBuilder'! Item was changed: ----- Method: ClassBuilderTest>>makeWordVariableSubclassOf: (in category 'utilities') ----- makeWordVariableSubclassOf: aClass subClass := aClass variableWordSubclass: self subClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses! - category: 'Kernel-Tests-ClassBuilder'! Item was changed: ----- Method: ClassBuilderTest>>testByteVariableSubclass (in category 'testing - format') ----- testByteVariableSubclass "Ensure that the invariants for superclass/subclass format are preserved" baseClass := Object variableByteSubclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. [ self shouldnt:[self makeNormalSubclassOf: baseClass] raise: Error. self deny: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self assert: (subClass isBytes). subClass removeFromSystem. "pointer classes" self should:[self makeIVarsSubclassOf: baseClass] raise: Error. self should:[self makeVariableSubclassOf: baseClass] raise: Error. self should:[self makeWeakSubclassOf: baseClass] raise: Error. "bit classes" self shouldnt:[self makeByteVariableSubclassOf: baseClass] raise: Error. self deny: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self assert: (subClass isBytes). subClass removeFromSystem. self should:[self makeWordVariableSubclassOf: baseClass] raise: Error. ] ensure:[self cleanup].! Item was changed: ----- Method: ClassBuilderTest>>testChangeToVariableSubclass (in category 'testing - format') ----- testChangeToVariableSubclass "Ensure that the invariants for superclass/subclass format are preserved" baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. [ self shouldnt:[baseClass := Object variableSubclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses] raise: Error. - category: 'Kernel-Tests-ClassBuilder'] raise: Error. ] ensure:[self cleanup].! Item was changed: ----- Method: ClassBuilderTest>>testDuplicateClassVariableError (in category 'testing - reshape') ----- testDuplicateClassVariableError baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: 'TestVar' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. self should:[ subClass := baseClass subclass: self subClassName instanceVariableNames: '' classVariableNames: 'TestVar' poolDictionaries: '' + category: self categoryNameForTemporaryClasses - category: 'Kernel-Tests-ClassBuilder' ] raise: DuplicateVariableError. [subClass := baseClass subclass: self subClassName instanceVariableNames: '' classVariableNames: 'TestVar' poolDictionaries: '' + category: self categoryNameForTemporaryClasses - category: 'Kernel-Tests-ClassBuilder' ] on: DuplicateVariableError do:[:ex| self assert: ex superclass == baseClass. self assert: ex variable = 'TestVar'. ex resume. ]. self shouldnt:[ baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. ] raise: Error. self should:[ baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: 'TestVar' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. ] raise: DuplicateVariableError. [baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: 'TestVar' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. ] on: DuplicateVariableError do:[:ex| self assert: ex superclass == baseClass. self assert: ex variable = 'TestVar'. ex resume. ].! Item was changed: ----- Method: ClassBuilderTest>>testDuplicateInstanceVariableError (in category 'testing - reshape') ----- testDuplicateInstanceVariableError baseClass := Object subclass: self baseClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. self should:[ subClass := baseClass subclass: self subClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses - category: 'Kernel-Tests-ClassBuilder' ] raise: DuplicateVariableError. [subClass := baseClass subclass: self subClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses - category: 'Kernel-Tests-ClassBuilder' ] on: DuplicateVariableError do:[:ex| self assert: ex superclass == baseClass. self assert: ex variable = 'var'. ex resume. ]. self shouldnt:[ baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. ] raise: Error. self should:[ baseClass := Object subclass: self baseClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. ] raise: DuplicateVariableError. [baseClass := Object subclass: self baseClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. ] on: DuplicateVariableError do:[:ex| self assert: ex superclass == baseClass. self assert: ex variable = 'var'. ex resume. ].! Item was changed: ----- Method: ClassBuilderTest>>testMoveVarFromSubToSuperclass (in category 'testing - reshape') ----- testMoveVarFromSubToSuperclass | baseInst subInst | baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. subClass := baseClass subclass: self subClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. subClass compile: 'subGet ^var'. subClass compile: 'subSet: v var := v'. self assert:[baseClass instSize = 0]. self assert:[subClass instSize = 1]. baseInst := baseClass new. subInst := subClass new. subInst instVarAt: 1 put: 123. self assert: (subInst instVarAt: 1) = 123. self assert: (subInst subGet) = 123. [baseClass := Object subclass: self baseClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. ] on: DuplicateVariableError do:[:ex| ex resume]. baseClass compile: 'superGet ^var'. baseClass compile: 'superSet: v var := v'. self assert:[baseClass instSize = 1]. self assert:[subClass instSize = 2]. "the assumption here is that an existing value is propagated up" self assert: (baseInst instVarAt: 1) = nil. self assert: (subInst instVarAt: 1) = 123. self assert: (subInst instVarAt: 2) = 123. "the assumption below is that the subclass binds to the local scope not the outer one, which is in line with common name space approaches." subInst superSet: 666. subInst subSet: 321. self assert: (subInst instVarAt: 1) = 666. self assert: (subInst instVarAt: 2) = 321. self assert: (subInst superGet) = 666. self assert: (subInst subGet) = 321. subClass := baseClass subclass: self subClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. self assert:[baseClass instSize = 1]. self assert:[subClass instSize = 1]. "the assumption here is that the current (subclass) value is propagated up" self assert: (subInst instVarAt: 1) = 321. self assert: (subInst subGet) = 321. ! Item was changed: ----- Method: ClassBuilderTest>>testMoveVarFromSuperToSubclass (in category 'testing - reshape') ----- testMoveVarFromSuperToSubclass | baseInst subInst | baseClass := Object subclass: self baseClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. baseClass compile: 'superGet ^var'. baseClass compile: 'superSet: v var := v'. subClass := baseClass subclass: self subClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. subClass compile: 'subGet ^var'. subClass compile: 'subSet: v var := v'. self assert:[baseClass instSize = 1]. self assert:[subClass instSize = 1]. baseInst := baseClass new. subInst := subClass new. baseInst instVarAt: 1 put: 42. subInst instVarAt: 1 put: 123. self assert: (baseInst instVarAt: 1) = 42. self assert: (subInst instVarAt: 1) = 123. self assert: (subInst subGet) = 123. [subClass := baseClass subclass: self subClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses - category: 'Kernel-Tests-ClassBuilder' ] on: DuplicateVariableError do:[:ex| ex resume]. self assert:[baseClass instSize = 1]. self assert:[subClass instSize = 2]. self assert: (baseInst instVarAt: 1) = 42. "the assumption below is that for duplicate variables the values get duplicated too. this isn't strictly necessary; what we really need is that the old var doesn't get nuked but it has some advantages when moving vars up the hierarchy" self assert: (subInst instVarAt: 1) = 123. self assert: (subInst instVarAt: 2) = 123. self assert: (subInst superGet) = 123. self assert: (subInst subGet) = 123. "the assumption below is that the subclass binds to the local scope not the outer one, which is in line with common name space approaches." subInst superSet: 666. subInst subSet: 321. self assert: (subInst instVarAt: 1) = 666. self assert: (subInst instVarAt: 2) = 321. self assert: (subInst superGet) = 666. self assert: (subInst subGet) = 321. baseClass removeSelector: #superGet. baseClass removeSelector: #superSet:. baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. self assert:[baseClass instSize = 0]. self assert:[subClass instSize = 1]. self assert: (subInst instVarAt: 1) = 321. self assert: (subInst subGet) = 321. ! Item was changed: ----- Method: ClassBuilderTest>>testSubclass (in category 'testing - format') ----- testSubclass "Ensure that the invariants for superclass/subclass format are preserved" baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. [ self shouldnt:[self makeNormalSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self deny: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. "pointer classes" self shouldnt:[self makeIVarsSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self deny: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeVariableSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert:(subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeWeakSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert:(subClass isVariable). self assert:(subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. "bit classes" self shouldnt:[self makeByteVariableSubclassOf: baseClass] raise: Error. self deny: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self assert: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeWordVariableSubclassOf: baseClass] raise: Error. self deny: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. ] ensure:[self cleanup].! Item was changed: ----- Method: ClassBuilderTest>>testSubclassWithInstanceVariables (in category 'testing - format') ----- testSubclassWithInstanceVariables "Ensure that the invariants for superclass/subclass format are preserved" baseClass := Object subclass: self baseClassName instanceVariableNames: 'var1 var2' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. [ self shouldnt:[self makeNormalSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self deny: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. "pointer classes" self shouldnt:[self makeIVarsSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self deny: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeVariableSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeWeakSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self assert: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. "bit classes" self should:[self makeByteVariableSubclassOf: baseClass] raise: Error. self should:[self makeWordVariableSubclassOf: baseClass] raise: Error. ] ensure:[self cleanup].! Item was changed: ----- Method: ClassBuilderTest>>testVariableSubclass (in category 'testing - format') ----- testVariableSubclass "Ensure that the invariants for superclass/subclass format are preserved" baseClass := Object variableSubclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. [ "pointer classes" self shouldnt:[self makeNormalSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeIVarsSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeVariableSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeWeakSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self assert: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. "bit classes" self should:[self makeByteVariableSubclassOf: baseClass] raise: Error. self should:[self makeWordVariableSubclassOf: baseClass] raise: Error. ] ensure:[self cleanup].! Item was changed: ----- Method: ClassBuilderTest>>testWeakSubclass (in category 'testing - format') ----- testWeakSubclass "Ensure that the invariants for superclass/subclass format are preserved" baseClass := Object weakSubclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. [ "pointer classes" self shouldnt:[self makeNormalSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self assert: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeIVarsSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self assert: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeVariableSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. self shouldnt:[self makeWeakSubclassOf: baseClass] raise: Error. self assert: (subClass isPointers). self assert: (subClass isVariable). self assert: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. "bit classes" self should:[self makeByteVariableSubclassOf: baseClass] raise: Error. self should:[self makeWordVariableSubclassOf: baseClass] raise: Error. ] ensure:[self cleanup].! Item was changed: ----- Method: ClassBuilderTest>>testWordVariableSubclass (in category 'testing - format') ----- testWordVariableSubclass "Ensure that the invariants for superclass/subclass format are preserved" baseClass := Object variableWordSubclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses. - category: 'Kernel-Tests-ClassBuilder'. [ self shouldnt:[self makeNormalSubclassOf: baseClass] raise: Error. self deny: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. "pointer classes" self should:[self makeIVarsSubclassOf: baseClass] raise: Error. self should:[self makeVariableSubclassOf: baseClass] raise: Error. self should:[self makeWeakSubclassOf: baseClass] raise: Error. "bit classes" self should:[self makeByteVariableSubclassOf: baseClass] raise: Error. self shouldnt:[self makeWordVariableSubclassOf: baseClass] raise: Error. self deny: (subClass isPointers). self assert: (subClass isVariable). self deny: (subClass isWeak). self deny: (subClass isBytes). subClass removeFromSystem. ] ensure:[self cleanup].! Item was added: + ----- Method: ClassTest>>categoryNameForTemporaryClasses (in category 'setup') ----- + categoryNameForTemporaryClasses + "Answer the category where to classify temporarily created classes" + + ^'Dummy-Tests-Class'! Item was changed: ----- Method: ClassTest>>setUp (in category 'setup') ----- setUp className := #TUTU. renamedName := #RenamedTUTU. self deleteClass. self deleteRenamedClass. Object subclass: className instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses! - category: 'KernelTests-Classes'! Item was changed: ----- Method: ClassTest>>tearDown (in category 'setup') ----- tearDown self deleteClass. + self deleteRenamedClass. + (Smalltalk organization listAtCategoryNamed: self categoryNameForTemporaryClasses) isEmpty + ifTrue: [Smalltalk organization removeCategory: self categoryNameForTemporaryClasses]! - self deleteRenamedClass! Item was changed: ----- Method: CompiledMethodTest>>testHasClosure (in category 'tests - closures') ----- testHasClosure self assert: (self class >> #withClosure) containsBlockClosures; + assert: (self class >> #withClosureNoNLR) containsBlockClosures; + assert: (self class >> #withoutClosure) containsBlockClosures not! - assert: (self class >> #withClosureNoNLR) containsBlockClosures! Item was added: + ----- Method: CompiledMethodTest>>withoutClosure (in category 'examples') ----- + withoutClosure + ^ 23 + 42! Item was added: + ----- Method: FloatTest>>testSign (in category 'testing') ----- + testSign + + "Set up" + | negatives negz positives strictNegatives strictPositives zero | + strictPositives := {2. 2.5. Float infinity}. + strictNegatives := {-3. -3.25. Float infinity negated}. + zero := 0.0. + negz := Float negativeZero. + positives := strictPositives copyWith: zero. + negatives := strictNegatives copyWith: negz. + + "The sign of non zeros" + strictPositives do: [:aPositive | self assert: aPositive sign = 1]. + strictNegatives do: [:aNegative | self assert: aNegative sign = -1]. + + "The sign of zeros" + self assert: zero sign = 0. + self assert: negz sign = -1. "remark though that negz >= 0.0, and is thus considered positive... Weird" + + "Test the copy sign functions" + positives do: [:aPositiveSign | + positives do: [:aPositive | + self assert: (aPositive sign: aPositiveSign) = aPositive]. + negatives do: [:aNegative | + self assert: (aNegative sign: aPositiveSign) = aNegative negated]. + (zero sign: aPositiveSign) sign = 0. + (negz sign: aPositiveSign) sign = 0]. + + negatives do: [:aNegativeSign | + positives do: [:aPositive | + self assert: (aPositive sign: aNegativeSign) = aPositive negated]. + negatives do: [:aNegative | + self assert: (aNegative sign: aNegativeSign) = aNegative]. + (zero sign: aNegativeSign) sign = -1. + (negz sign: aNegativeSign) sign = -1].! Item was added: + ----- Method: NumberParsingTest>>testNegativeZero (in category 'tests - Integer') ----- + testNegativeZero + "This test ensure that -0.0 will produce a negativeZero" + + | negativeZero | + negativeZero := Number readFrom: '-0.0' readStream. + + "If it is a negative zero, it must behave like a negative zero... IEEE 754 tells how it should behave" + self deny: (negativeZero at: 1) = 0 description: 'In IEEE 754, a negative zero has its sign bit set to 1'.. + self assert: negativeZero = 0 description: 'In IEEE 754, a negative zero cannot be distinguished from zero'.! |
Free forum by Nabble | Edit this page |