Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.163.mcz ==================== Summary ==================== Name: KernelTests-nice.163 Author: nice Time: 21 September 2010, 12:28:36.525 pm UUID: c76beccf-c07c-0245-bc5a-2ac4a6d5b9f9 Ancestors: KernelTests-klc.162 Let the tests create a dummy category rather than a category belonging to an existing package. Let the tests clean the dummy category if empty. =============== Diff against KernelTests-klc.162 =============== 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! |
Free forum by Nabble | Edit this page |