/
RBRemoveMethodTest.class.st
54 lines (49 loc) · 1.86 KB
/
RBRemoveMethodTest.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Class {
#name : #RBRemoveMethodTest,
#superclass : #RBRefactoringTest,
#category : #'Refactoring-Tests-Core'
}
{ #category : #accessing }
RBRemoveMethodTest >> expectedFailures [
^ #(testRemoveSameMethodButSendsSuper)
]
{ #category : #tests }
RBRemoveMethodTest >> testModelRecursiveMethodThatIsNotReferencedFromOtherMethods [
| class otherClass |
class := model classNamed: #Object.
class compile: 'someMethodThatIsNotReferenced ^2' classified: #(#accessing).
self assert: (class definesMethod: #someMethodThatIsNotReferenced).
otherClass := model metaclassNamed: self class superclass name.
otherClass
compile: 'someMethodThatIsNotReferenced ^3 someMethodThatIsNotReferenced'
classified: #(#accessing).
model removeClassNamed: self class name.
self executeRefactoring: (RBRemoveMethodRefactoring
model: model
removeMethods: #(#someMethodThatIsNotReferenced)
from: class).
self deny: (class definesMethod: #someMethodThatIsNotReferenced)
]
{ #category : #tests }
RBRemoveMethodTest >> testRemoveMethod [
| refactoring selectors |
selectors := Array with: ('selectorNot' , 'Referenced') asSymbol.
refactoring := RBRemoveMethodRefactoring
removeMethods: selectors
from: RBRefactoryTestDataApp.
self assert: ((refactoring model classNamed: #RBRefactoryTestDataApp) directlyDefinesMethod: selectors first).
self executeRefactoring: refactoring.
self deny: ((refactoring model classNamed: #RBRefactoryTestDataApp) directlyDefinesMethod: selectors first)
]
{ #category : #'failure tests' }
RBRemoveMethodTest >> testRemoveReferenced [
self shouldFail: (RBRemoveMethodRefactoring
removeMethods: #(#checkClass: )
from: RBBasicLintRuleTestData)
]
{ #category : #'failure tests' }
RBRemoveMethodTest >> testRemoveSameMethodButSendsSuper [
self shouldWarn: (RBRemoveMethodRefactoring
removeMethods: #(#new )
from: RBBasicLintRuleTestData class)
]