Skip to content

Commit

Permalink
Issue #783: remove trait; adjust spec_0085 for Issue #931 and move tr…
Browse files Browse the repository at this point in the history
…ait to symbol dictionary is working correctly
  • Loading branch information
dalehenrich committed Jun 11, 2024
1 parent 05f1855 commit 790e2b8
Show file tree
Hide file tree
Showing 2 changed files with 294 additions and 3 deletions.
153 changes: 152 additions & 1 deletion rowan/src/Rowan-TestsV3/RwRowanSample9V3Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3259,6 +3259,63 @@ RwRowanSample9V3Test >> testSpec_0085_03_to_02 [
expectedProjectNames: projectNames.
]

{ #category : 'tests' }
RwRowanSample9V3Test >> testSpec_0085_03_to_03_removeTrait [
"load spec_0085 C03, T03, Tr03 then load spec_0085 C03, T03 - load without trait"

"https://github.com/GemTalk/Rowan/issues/783"

| loadSpec projectName projectNames loadSpecs loadedProjects trait1 project audit class1 |
loadSpec := self _loadSpecNamed: 'spec_0085'.

projectName := loadSpec projectName.
projectNames := {projectName }.

projectNames do: [:pn |
(Rowan image loadedProjectNamed: pn ifAbsent: [ ])
ifNotNil: [ :proj | Rowan image _removeLoadedProject: proj ] ].

"resolve project"
loadSpec customConditionalAttributes: { 'C03' . 'T03' . 'Tr03' }.
loadSpecs := loadSpec resolve.

"load project: C01, T01, Tr01"
loadedProjects := loadSpecs load.
project := loadedProjects projectNamed: projectName.

"validate"
self assert: (audit := project audit) isEmpty.
self
_standard_validateLoadedProjects: loadedProjects
expectedProjectNames: projectNames.

class1 := Rowan globalNamed: 'RowanSample9V3Class1'.
self assert: class1 classHistory size equals: 1.

trait1 := Rowan globalNamed: 'RowanSample9V3Trait1'.
self assert: ((ClassOrganizer new traits) includes: trait1) description: 'trait1 is unexpectedly not present'.
self assert: ((System myUserProfile symbolList dictionaryAndSymbolOf: trait1) at: 1) name equals: #'RowanSample9_1'.

"resolve project"
loadSpec customConditionalAttributes: { 'C03' . 'T03' }.
loadSpecs := loadSpec resolve.

"load project: C03, T03 (no trait included) on top of C03, T03, Tr03 - should load cleanly"
loadedProjects := loadSpecs load.
project := loadedProjects projectNamed: projectName.

"validate"
self assert: (audit := project audit) isEmpty.
self
_standard_validateLoadedProjects: loadedProjects
expectedProjectNames: projectNames.

trait1 := Rowan globalNamed: 'RowanSample9V3Trait1'.
self assert: trait1 isNil description: 'trait1 is unexpectedly present'.
self assert: class1 traits asArray equals: #().
self assert: class1 classTraits asArray equals: #().
]

{ #category : 'tests' }
RwRowanSample9V3Test >> testSpec_0085_03_to_04 [
"load spec_0085 C03, T03, Tr03 then load spec_0085 C02, T02, Tr04 - remove/add instance, class instance and class variables"
Expand Down Expand Up @@ -3312,6 +3369,65 @@ RwRowanSample9V3Test >> testSpec_0085_03_to_04 [
self assert: ((System myUserProfile symbolList dictionaryAndSymbolOf: trait1) at: 1) name equals: #'RowanSample9_2'
]

{ #category : 'tests' }
RwRowanSample9V3Test >> testSpec_0085_03_to_05 [
"load spec_0085 C03, T03, Tr03 then load spec_0085 C05, T05, Tr05 - add instance variable independent of trait"

"https://github.com/GemTalk/Rowan/issues/783"

| loadSpec projectName projectNames loadSpecs loadedProjects trait1 project audit class1 |
loadSpec := self _loadSpecNamed: 'spec_0085'.

projectName := loadSpec projectName.
projectNames := {projectName }.

projectNames do: [:pn |
(Rowan image loadedProjectNamed: pn ifAbsent: [ ])
ifNotNil: [ :proj | Rowan image _removeLoadedProject: proj ] ].

"resolve project"
loadSpec customConditionalAttributes: { 'C03' . 'T03' . 'Tr03' }.
loadSpecs := loadSpec resolve.

"load project: C01, T01, Tr01"
loadedProjects := loadSpecs load.
project := loadedProjects projectNamed: projectName.

"validate"
self assert: (audit := project audit) isEmpty.
self
_standard_validateLoadedProjects: loadedProjects
expectedProjectNames: projectNames.

class1 := Rowan globalNamed: 'RowanSample9V3Class1'.
self assert: class1 classHistory size equals: 1.

trait1 := Rowan globalNamed: 'RowanSample9V3Trait1'.
self assert: ((ClassOrganizer new traits) includes: trait1) description: 'trait1 is unexpectedly not present'.
self assert: ((System myUserProfile symbolList dictionaryAndSymbolOf: trait1) at: 1) name equals: #'RowanSample9_1'.

"resolve project"
loadSpec customConditionalAttributes: { 'C05' . 'T05' . 'Tr05' }.
loadSpecs := loadSpec resolve.

"load project: C05, T05, Tr05 on top of C03, T03, Tr04 - should load cleanly"
loadedProjects := loadSpecs load.
project := loadedProjects projectNamed: projectName.

"validate"
self assert: (audit := project audit) isEmpty.
self
_standard_validateLoadedProjects: loadedProjects
expectedProjectNames: projectNames.

class1 := Rowan globalNamed: 'RowanSample9V3Class1'.
self assert: class1 classHistory size equals: 2.

trait1 := Rowan globalNamed: 'RowanSample9V3Trait1'.
self assert: ((ClassOrganizer new traits) includes: trait1) description: 'trait1 is unexpectedly not present'.
self assert: ((System myUserProfile symbolList dictionaryAndSymbolOf: trait1) at: 1) name equals: #'RowanSample9_1'.
]

{ #category : 'tests' }
RwRowanSample9V3Test >> testSpec_0085_04 [
"spec_0085 C03, T03, Tr04 should load cleanly - move trait to a different symbol dictionary"
Expand Down Expand Up @@ -3344,10 +3460,45 @@ RwRowanSample9V3Test >> testSpec_0085_04 [

trait1 := Rowan globalNamed: 'RowanSample9V3Trait1'.
self assert: ((ClassOrganizer new traits) includes: trait1) description: 'trait1 is unexpectedly not present'.

self assert: ((System myUserProfile symbolList dictionaryAndSymbolOf: trait1) at: 1) name equals: #'RowanSample9_2'
]

{ #category : 'tests' }
RwRowanSample9V3Test >> testSpec_0085_05 [
"spec_0085 C05, T05, Tr05 should load cleanly - move trait to a different symbol dictionary"

"https://github.com/GemTalk/Rowan/issues/783"

| loadSpec projectName projectNames loadSpecs loadedProjects trait1 project audit |
loadSpec := self _loadSpecNamed: 'spec_0085'.

projectName := loadSpec projectName.
projectNames := {projectName }.

projectNames do: [:pn |
(Rowan image loadedProjectNamed: pn ifAbsent: [ ])
ifNotNil: [ :proj | Rowan image _removeLoadedProject: proj ] ].

"resolve project"
loadSpec customConditionalAttributes: { 'C05' . 'T05' . 'Tr05' }.
loadSpecs := loadSpec resolve.

"load project"
loadedProjects := loadSpecs load.
project := loadedProjects projectNamed: projectName.

"validate"
self assert: (audit := project audit) isEmpty.
self
_standard_validateLoadedProjects: loadedProjects
expectedProjectNames: projectNames.

trait1 := Rowan globalNamed: 'RowanSample9V3Trait1'.
self assert: ((ClassOrganizer new traits) includes: trait1) description: 'trait1 is unexpectedly not present'.

self assert: ((System myUserProfile symbolList dictionaryAndSymbolOf: trait1) at: 1) name equals: #'RowanSample9_1'
]

{ #category : 'tests' }
RwRowanSample9V3Test >> testSpec_0085_C03_T03_Tr02 [
"spec_0085 C03, T03, Tr02 should explode"
Expand Down
144 changes: 142 additions & 2 deletions rowan/src/Rowan-TestsV3/RwTestProjectLibraryGeneratorV3.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ List of condition tuples intended to work together, since they were built togeth
B. C02, Tr02, T02 - C01, Tr01, T01 and add IV to class, trait and tests
C. C03, Tr03, T03 - C02, Tr02, T02 - C01, Tr01, T01 and remove IV from class, trait and tests
D. C03, Tr04, T03 - Tr04 moves trait to a different symbol dictionary than Tr03
E. C05, Tr05, T05 - C03, Tr03, T03 and add IV to class only and tests
Interesting things could happen when different conditions are mixed together, but transitions between built tuples should always work.
"
Expand Down Expand Up @@ -1144,6 +1145,7 @@ List of condition tuples intended to work together, since they were built togeth
B. C02, Tr02, T02 - C01, Tr01, T01 and add IV to class, trait and tests
C. C03, Tr03, T03 - C02, Tr02, T02 - C01, Tr01, T01 and remove IV from class, trait and tests
D. C03, Tr04, T03 - Tr04 moves trait to a different symbol dictionary than Tr03
E. C05, Tr05, T05 - C03, Tr03, T03 and add IV to class only and tests
Interesting things could happen when different conditions are mixed together, but transitions between built tuples should always work.
"
Expand Down Expand Up @@ -1282,6 +1284,7 @@ List of condition tuples intended to work together, since they were built togeth
B. C02, Tr02, T02 - C01, Tr01, T01 and add IV to class, trait and tests
C. C03, Tr03, T03 - C02, Tr02, T02 - C01, Tr01, T01 and remove IV from class, trait and tests
D. C03, Tr04, T03 - Tr04 moves trait to a different symbol dictionary than Tr03
E. C05, Tr05, T05 - C03, Tr03, T03 and add IV to class only and tests
Interesting things could happen when different conditions are mixed together, but transitions between built tuples should always work.
"
Expand Down Expand Up @@ -1400,6 +1403,7 @@ List of condition tuples intended to work together, since they were built togeth
B. C02, Tr02, T02 - C01, Tr01, T01 and add IV to class, trait and tests
C. C03, Tr03, T03 - C02, Tr02, T02 - C01, Tr01, T01 and remove IV from class, trait and tests
D. C03, Tr04, T03 - Tr04 moves trait to a different symbol dictionary than Tr03
E. C05, Tr05, T05 - C03, Tr03, T03 and add IV to class only and tests
Interesting things could happen when different conditions are mixed together, but transitions between built tuples should always work.
"
Expand All @@ -1421,12 +1425,23 @@ Interesting things could happen when different conditions are mixed together, bu
toComponentNamed: 'Core';
yourself.

packageName2 := projectName , '-' , 'Tr' , index.
packageName2 := projectName , '-' , 'Tr' , traitIndex.

resolvedProject
addPackagesNamed: {packageName2} toComponentNamed: componentName2;
yourself.

((resolvedProject packageNamed: packageName2)
addTraitNamed: traitName
instvars: #('iv2')
classinstvars: #('civ2')
classvars: #('Cv2')
category: packageName2)
addInstanceMethod: 'iv2_t ^ iv2' protocol: 'accessing';
addInstanceMethod: 'cv2_t ^ Cv2' protocol: 'accessing';
addClassMethod: 'civ2_t ^ civ2' protocol: 'accessing';
yourself.

(resolvedProject componentNamed: componentName2)
conditionalPackageMapSpecsAtGemStoneUserId: RwLoadSpecificationV2 _gemstoneAllUsersName
andPackageName: packageName2
Expand All @@ -1435,6 +1450,128 @@ Interesting things could happen when different conditions are mixed together, bu
^ resolvedProject
]

{ #category : 'private' }
RwTestProjectLibraryGeneratorV3 >> _addDefinitionsFor_0085_E: resolvedProject [
"Start from scratch and build a package/component structure for testing different Class/Trait combinations. Classes are in separate C* packages. Traits are in separate Tr* packages. Tests are in separate T* packages. Each C* package is in a C* conditional (C*) component. Each Tr* package is in a Tr* conditional (Tr*) component. Each Test* package is in a Test* conditional (C*-T*) component. There is a Test package for Core/Trait combo. The idea is that we can test a significant number of Class/Trait combinations in a single project using conditions to control what is loaded.
List of condition tuples intended to work together, since they were built together:
A. C01, Tr01, T01 - baseline
B. C02, Tr02, T02 - C01, Tr01, T01 and add IV to class, trait and tests
C. C03, Tr03, T03 - C02, Tr02, T02 - C01, Tr01, T01 and remove IV from class, trait and tests
D. C03, Tr04, T03 - Tr04 moves trait to a different symbol dictionary than Tr03
E. C05, Tr05, T05 - C03, Tr03, T03 and add IV to class only and tests
Interesting things could happen when different conditions are mixed together, but transitions between built tuples should always work.
"

| componentName1 componentName2 componentName3 componentName4 componentName5 packageName1 packageName2 packageName3 packageName4 packageName5 traitName className1 className2 index |

traitName := projectName , 'Trait1'.
className1 := projectName , 'Class1'.
className2 := projectName , 'TestCase'.

index := '05'.
componentName1 := 'C' , index.
componentName2 := 'Tr' , index.
componentName3 := 'T' , index.
componentName4 := 'T' , index , '_class'.
componentName5 := 'T' , index , '_trait'.
resolvedProject
addSubcomponentNamed: componentName1
condition: 'C' , index
comment: 'Class ', index, ' package'
toComponentNamed: 'Core';
addSubcomponentNamed: componentName2
condition: 'Tr' , index
comment: 'Trait ', index, ' package'
toComponentNamed: 'Core';
addSubcomponentNamed: componentName3
condition: 'T' , index
comment: 'Test ', index, ' package'
toComponentNamed: 'Core';
addSubcomponentNamed: componentName4
condition: 'C' , index
comment: 'Class Test ', index, ' package'
toComponentNamed: componentName3;
addSubcomponentNamed: componentName5
condition: 'Tr' , index
comment: 'Trait Test ', index, ' package'
toComponentNamed: componentName3;
yourself.


packageName1 := projectName , '-' , 'C' , index.
packageName2 := projectName , '-' , 'Tr' , index.
packageName3 := projectName , '-' , 'T' , index.
packageName4 := projectName , '-' , 'C' , '-' , 'T' , index.
packageName5 := projectName , '-' , 'Tr' , '-' , 'T' , index.
resolvedProject
addPackagesNamed: {packageName1} toComponentNamed: componentName1;
addPackagesNamed: {packageName2} toComponentNamed: componentName2;
addPackagesNamed: {packageName3} toComponentNamed: componentName3;
addPackagesNamed: {packageName4} toComponentNamed: componentName4;
addPackagesNamed: {packageName5} toComponentNamed: componentName5;
yourself.
((resolvedProject packageNamed: packageName1)
addClassNamed: className1
super: 'Object'
instvars: #('iv2' 'iv5')
classinstvars: #('civ2')
classvars: #('Cv2')
category: packageName1
comment: 'I am an example class')
traits: traitName;
classTraits: traitName , ' classTrait';
addInstanceMethod: 'iv2 ^ iv2' protocol: 'accessing';
addInstanceMethod: 'iv5 ^ iv5' protocol: 'accessing';
addInstanceMethod: 'cv2 ^ Cv2' protocol: 'accessing';
addClassMethod: 'civ2 ^ civ2' protocol: 'accessing';
yourself.
((resolvedProject packageNamed: packageName2)
addTraitNamed: traitName
instvars: #('iv2')
classinstvars: #('civ2')
classvars: #('Cv2')
category: packageName2)
addInstanceMethod: 'iv2_t ^ iv2' protocol: 'accessing';
addInstanceMethod: 'cv2_t ^ Cv2' protocol: 'accessing';
addClassMethod: 'civ2_t ^ civ2' protocol: 'accessing';
yourself.
(resolvedProject packageNamed: packageName3)
addClassNamed: className2
super: 'TestCase'
category: packageName3
comment: 'I test the example class'.
((resolvedProject packageNamed: packageName4)
addClassExtensionNamed: className2)
addInstanceMethod: 'testIv2 self assert: ' , className1 , ' new iv2 = nil'
protocol: 'tests';
addInstanceMethod: 'testIv5 self assert: ' , className1 , ' new iv5 = nil'
protocol: 'tests';
addInstanceMethod: 'testCiv2 self assert: ' , className1 , ' civ2 = nil'
protocol: 'tests';
addInstanceMethod: 'testCv2 self assert: ' , className1 , ' new cv2 = nil'
protocol: 'tests';
yourself.
((resolvedProject packageNamed: packageName5)
addClassExtensionNamed: className2)
addInstanceMethod:
'testIv2_t self assert: ' , className1 , ' new iv2_t = nil'
protocol: 'tests';
addInstanceMethod: 'testCiv2_t self assert: ' , className1 , ' civ2_t = nil'
protocol: 'tests';
addInstanceMethod:
'testCv2_t self assert: ' , className1 , ' new cv2_t = nil'
protocol: 'tests';
addInstanceMethod:
'testTrait self assert: ((ClassOrganizer new traits) includes: ' , traitName
, ')'
protocol: 'tests';
yourself.

^ resolvedProject
]

{ #category : 'private' }
RwTestProjectLibraryGeneratorV3 >> _addDefinitionsFor_0085: resolvedProject [
"Start from scratch and build a package/component structure for testing different Class/Trait combinations. Classes are in separate C* packages. Traits are in separate Tr* packages. Tests are in separate T* packages. Each C* package is in a C* conditional (C*) component. Each Tr* package is in a Tr* conditional (Tr*) component. Each Test* package is in a Test* conditional (C*-T*) component. There is a Test package for Core/Trait combo. The idea is that we can test a significant number of Class/Trait combinations in a single project using conditions to control what is loaded.
Expand All @@ -1444,6 +1581,7 @@ List of condition tuples intended to work together, since they were built togeth
B. C02, Tr02, T02 - C01, Tr01, T01 and add IV to class, trait and tests
C. C03, Tr03, T03 - C02, Tr02, T02 - C01, Tr01, T01 and remove IV from class, trait and tests
D. C03, Tr04, T03 - Tr04 moves trait to a different symbol dictionary than Tr03
E. C05, Tr05, T05 - C03, Tr03, T03 and add IV to class only and tests
Interesting things could happen when different conditions are mixed together, but transitions between built tuples should always work.
"
Expand All @@ -1455,7 +1593,7 @@ Interesting things could happen when different conditions are mixed together, bu
self _addDefinitionsFor_0085_B: resolvedProject.
self _addDefinitionsFor_0085_C: resolvedProject.
self _addDefinitionsFor_0085_D: resolvedProject.
true ifTrue: [ ^ resolvedProject ].
self _addDefinitionsFor_0085_E: resolvedProject.
^ resolvedProject
]

Expand Down Expand Up @@ -2353,6 +2491,7 @@ List of condition tuples intended to work together, since they were built togeth
B. C02, Tr02, T02 - C01, Tr01, T01 and add IV to class, trait and tests
C. C03, Tr03, T03 - C02, Tr02, T02 - C01, Tr01, T01 and remove IV from class, trait and tests
D. C03, Tr04, T03 - Tr04 moves trait to a different symbol dictionary than Tr03
E. C05, Tr05, T05 - C03, Tr03, T03 and add IV to class only and tests
Interesting things could happen when different conditions are mixed together, but transitions between built tuples should always work.
"
Expand All @@ -2374,6 +2513,7 @@ List of condition tuples intended to work together, since they were built togeth
B. C02, Tr02, T02 - C01, Tr01, T01 and add IV to class, trait and tests
C. C03, Tr03, T03 - C02, Tr02, T02 - C01, Tr01, T01 and remove IV from class, trait and tests
D. C03, Tr04, T03 - Tr04 moves trait to a different symbol dictionary than Tr03
E. C05, Tr05, T05 - C03, Tr03, T03 and add IV to class only and tests
```
Interesting things could happen when different conditions are mixed together, but transitions between built tuples should always work.'.
Expand Down

0 comments on commit 790e2b8

Please sign in to comment.