Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RB missing tests #16917

Open
wants to merge 13 commits into
base: Pharo13
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Refactoring-Core-Tests/ManifestRefactoringCoreTests.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"
Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
"
Class {
#name : 'ManifestRefactoringCoreTests',
#superclass : 'PackageManifest',
#category : 'Refactoring-Core-Tests-Manifest',
#package : 'Refactoring-Core-Tests',
#tag : 'Manifest'
}
49 changes: 49 additions & 0 deletions src/Refactoring-Core-Tests/RBClassTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,35 @@ RBClassTest >> testHierarchy [
self assert: (meta withAllSuperclasses includes: objectClass)
]

{ #category : 'tests - definition' }
RBClassTest >> testHierarchyDefinesClassVariable [

| rootClass middleClass lastLeafClass |

rootClass := rbNamespace classNamed: #RBHierarchyForClassVariable.
middleClass := rbNamespace classNamed: #RBHierarchySubclassAForClassVariable.
lastLeafClass := rbNamespace classNamed: #RBHierarchySubclassBForClassVariable.

self deny: (rootClass hierarchyDefinesClassVariable: #ClassVariable1).
self assert: (rootClass hierarchyDefinesClassVariable: #ClassVarB).

self deny: (middleClass hierarchyDefinesClassVariable: #ClassVariable1).
self assert: (middleClass hierarchyDefinesClassVariable: #ClassVarA).
self assert: (middleClass hierarchyDefinesClassVariable: #ClassVarB).

self deny: (lastLeafClass hierarchyDefinesClassVariable: #ClassVariable1).
self assert: (lastLeafClass hierarchyDefinesClassVariable: #ClassVarA).
]

{ #category : 'tests - definition' }
RBClassTest >> testHierarchyDefinesPoolDictionary [

self deny: (abstractTransformationClass definesPoolDictionary: #OpcodePool).
self assert: (newClass definesPoolDictionary: #TextConstants).
self deny: (refactoringClass definesPoolDictionary: #OpcodePool).
self assert: ((RBNamespace new classNamed: #Text) definesPoolDictionary: #TextConstants)
]

{ #category : 'tests - navigation' }
RBClassTest >> testIsEmptyClass [

Expand Down Expand Up @@ -233,6 +262,26 @@ RBClassTest >> testObjectIsNotAbstract [
self deny: objectClass classSide isAbstract
]

{ #category : 'tests - definition' }
RBClassTest >> testSuperclassRedefines [

| rootClass leafClass |

rootClass := rbNamespace classNamed: #RBEquivalentMethodRootHolder.
leafClass := rbNamespace classNamed: #RBEquivalentMethodSubclassHolder.
self
assert: (leafClass superclassRedefines: #someNumber)
description: 'It test that superclass already defines the existing superimplementor'.

self
deny: (leafClass superclassRedefines: #anotherMethod:)
description: 'It test that superclass does not define a defined subimplementor'.

self
assert: (leafClass superclassRedefines: #yourself)
description: 'It test that a non-direct superclass defined the method'
]

{ #category : 'tests - defining methods' }
RBClassTest >> testWhichClassIncludesSelectorDefinedInTheClass [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,65 @@ Class {
#tag : 'Manifest'
}

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleClassNotReferencedRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGClassDefinition #(#RBHierarchySubclassBForClassVariable)) #'2024-07-18T12:39:47.723158+02:00') #(#(#RGClassDefinition #(#MyClassNonEmptyLeafUnused)) #'2024-07-18T12:40:19.70241+02:00') #(#(#RGClassDefinition #(#RBDummyCompositeLintRuleTest)) #'2024-07-18T12:40:19.702201+02:00') #(#(#RGClassDefinition #(#RBClassUsingSharedPoolForTestData)) #'2024-07-18T12:40:19.701335+02:00') #(#(#RGClassDefinition #(#RBBasicDummyLintRuleTest)) #'2024-07-18T12:40:19.702472+02:00') #(#(#RGClassDefinition #(#RBTransformationRuleTestData2)) #'2024-07-18T12:40:19.701755+02:00') )
]

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleEquivalentSuperclassMethodsRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGMethodDefinition #(#MySubAccessingSuperclassState #accessingSharedVariable #false)) #'2024-07-18T12:38:46.533561+02:00') #(#(#RGMethodDefinition #(#RBTransformationDummyRuleTest1 #openEditor #false)) #'2024-07-18T12:38:46.533586+02:00') #(#(#RGMethodDefinition #(#MySubAccessingSuperclassState #accessing #false)) #'2024-07-18T12:38:46.533614+02:00') #(#(#RGMethodDefinition #(#RBSharedPoolForTestData1 #msg4 #false)) #'2024-07-18T12:38:46.532822+02:00') #(#(#RGMethodDefinition #(#RBEquivalentMethodSubclassHolder #yourself #false)) #'2024-07-18T12:38:46.533594+02:00') #(#(#RGMethodDefinition #(#RBSubclassOfClassToRename #equallyDefinedInSubclass #false)) #'2024-07-18T12:38:46.533603+02:00') #(#(#RGMethodDefinition #(#RBSharedPoolForTestData2 #msg4 #false)) #'2024-07-18T12:38:46.533433+02:00') )
]

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleExcessiveArgumentsRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGMethodDefinition #(#RBBasicLintRuleTestData #method:with:lots:of:arguments: #false)) #'2024-07-18T12:40:39.143779+02:00') #(#(#RGMethodDefinition #(#RBBasicDummyLintRuleTest #method:with:lots:of:arguments: #false)) #'2024-07-18T12:40:39.143696+02:00') )
]

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleExcessiveMethodsRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGClassDefinition #(#RBClassDataForRefactoringTest)) #'2024-07-18T12:41:02.656436+02:00') #(#(#RGMetaclassDefinition #(#'RBBasicDummyLintRuleTest class' #RBBasicDummyLintRuleTest)) #'2024-07-18T12:41:02.656083+02:00') )
]

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleNoUnusedInstanceVariableRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGClassDefinition #(#ReClassForGeneratingEqualAndHash)) #'2024-07-05T12:05:01.988597+02:00') #(#(#RGClassDefinition #(#ReClassForGeneratingEqualAndHashExistingImplementors)) #'2024-07-05T12:07:30.662537+02:00') )
]

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleReClassVariableNeitherReadNorWrittenRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGClassDefinition #(#RBHierarchySubclassAForClassVariable)) #'2024-07-18T12:50:23.92547+02:00') #(#(#RGClassDefinition #(#RBHierarchySubclassBForClassVariable)) #'2024-07-18T12:50:42.673173+02:00') #(#(#RGMetaclassDefinition #(#'RBHierarchySubclassBForClassVariable class' #RBHierarchySubclassBForClassVariable)) #'2024-07-18T14:51:42.347867+02:00') #(#(#RGMetaclassDefinition #(#'RBHierarchySubclassAForClassVariable class' #RBHierarchySubclassAForClassVariable)) #'2024-07-18T14:51:42.347564+02:00') )
]

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleReIvarNeitherReadNorWrittenRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGClassDefinition #(#ReClassForGeneratingPrintOn)) #'2024-06-20T19:43:13.245998+02:00') #(#(#RGClassDefinition #(#ReClassForGeneratingEqualAndHashExistingImplementors)) #'2024-06-20T19:43:13.245838+02:00') #(#(#RGClassDefinition #(#ReClassForGeneratingEqualAndHash)) #'2024-06-20T19:43:13.245672+02:00') )
]

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleRefersToClassRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGMethodDefinition #(#'RBBasicLintRuleTestData class' #modifiesCollection #true)) #'2024-07-18T12:42:35.357229+02:00') #(#(#RGMethodDefinition #(#RBClassDataForRefactoringTest #refersToClass #false)) #'2024-07-18T12:42:35.357361+02:00') )
]

{ #category : 'code-critics' }
ManifestRefactoringDataForTesting class >> ruleSendsDifferentSuperRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGMethodDefinition #(#RBEquivalentMethodSubclassHolder #methodToExtractFromWithSuperAndSimilarMethodInSuper #false)) #'2024-07-18T12:41:57.585437+02:00') #(#(#RGMethodDefinition #(#RBEquivalentMethodRootHolder #methodWithSuper #false)) #'2024-07-18T12:41:57.585423+02:00') #(#(#RGMethodDefinition #(#RBEquivalentMethodSubclassHolder #methodWithSuperSend #false)) #'2024-07-18T12:41:57.585283+02:00') #(#(#RGMethodDefinition #(#RBEquivalentMethodSubclassHolder #methodToExtractFrom #false)) #'2024-07-18T12:41:57.585158+02:00') #(#(#RGMethodDefinition #(#RBClassDataForRefactoringTest #sendsDifferentSuper #false)) #'2024-07-18T12:41:57.585447+02:00') #(#(#RGMethodDefinition #(#RBSubclassOfClassToRename #justSuperSendInSubclassBroken #false)) #'2024-07-18T12:41:57.585456+02:00') )
]
4 changes: 2 additions & 2 deletions src/Refactoring-DataForTesting/MyClassARoot.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ MyClassARoot class >> accessingFromClassSide [
{ #category : 'accessing' }
MyClassARoot >> accessing [

^ instVarName1
^ instVarName1
]

{ #category : 'accessing' }
MyClassARoot >> accessingSharedVariable [

^ Shared1
^ Shared1
]

{ #category : 'initialization' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ MySubAccessingSuperclassState class >> sharedOnlyInClassSideSubclass [
{ #category : 'accessing' }
MySubAccessingSuperclassState >> accessing [

^ instVarName1
^ instVarName1
]

{ #category : 'accessing' }
MySubAccessingSuperclassState >> accessing2InSub [

^ instVarName1
^ instVarName1
]

{ #category : 'accessing' }
MySubAccessingSuperclassState >> accessingSharedVariable [

^ Shared1
^ Shared1
]

{ #category : 'accessing' }
Expand All @@ -45,5 +45,5 @@ MySubAccessingSuperclassState >> accessingSharedVariable2 [
{ #category : 'actions' }
MySubAccessingSuperclassState >> writing [

instVarName1 := 42
instVarName1 := 42
]
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ RBBasicLintRuleTestData >> newResultClass: aClass [
{ #category : 'accessing' }
RBBasicLintRuleTestData >> onlyReferenceToSomeDemoMethod [

^ self onlyReferenceToSomeDemoMethod
^ self onlyReferenceToSomeDemoMethod
]

{ #category : 'accessing' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ RBClassDataForRefactoringTest >> called: anObject on1: aBlock [

{ #category : 'inline' }
RBClassDataForRefactoringTest >> called: anObject on: aBlock [

anObject printString traceCr; cr.
aBlock value
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ RBEquivalentMethodSubclassHolder >> someNumber [

^ 1
]

{ #category : 'accessing' }
RBEquivalentMethodSubclassHolder >> yourself [

^ self
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Class {
#name : 'RBHierarchyForClassVariable',
#superclass : 'Object',
#category : 'Refactoring-DataForTesting-MiniHierarchy',
#package : 'Refactoring-DataForTesting',
#tag : 'MiniHierarchy'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Class {
#name : 'RBHierarchySubclassAForClassVariable',
#superclass : 'RBHierarchyForClassVariable',
#classVars : [
'ClassVarA'
],
#category : 'Refactoring-DataForTesting-MiniHierarchy',
#package : 'Refactoring-DataForTesting',
#tag : 'MiniHierarchy'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Class {
#name : 'RBHierarchySubclassBForClassVariable',
#superclass : 'RBHierarchySubclassAForClassVariable',
#classVars : [
'ClassVarB'
],
#category : 'Refactoring-DataForTesting-MiniHierarchy',
#package : 'Refactoring-DataForTesting',
#tag : 'MiniHierarchy'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Class {
#tag : 'ForSharedPool'
}

{ #category : 'tests perform' }
{ #category : 'tests - perform' }
RBSharedPoolForTestData1 >> msg4 [

^ Var1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ RBSubclassOfClassToRename >> justSuperSendInSubclassBroken [

{ #category : 'accessing' }
RBSubclassOfClassToRename >> methodThatIsNotUsedForSure [


]

{ #category : 'accessing' }
RBSubclassOfClassToRename >> name [
^rewriteRule1
]

{ #category : 'accessing' }
{ #category : 'printing' }
RBSubclassOfClassToRename >> printOn: aStream [

"just for the test"
Expand Down