Skip to content
Permalink
Browse files

Add tests

  • Loading branch information
Lin777 committed Aug 13, 2019
1 parent dcd6d45 commit 219c3293b9525d4dc085f5cd674d4ed22eb9974c
@@ -11,6 +11,17 @@ Class {
#category : #'Refactoring-Core-Refactorings'
}

{ #category : #'instance creation' }
RBReplaceCalledMethodByAnotherRefactoring class >> model: aRBSmalltalk replaceMethod: aSelector in: aClass to: newSelector permutation: aMap [
^(self new)
model: aRBSmalltalk;
replaceCallMethod: aSelector
in: aClass
to: newSelector
permutation: aMap;
yourself
]

{ #category : #'as yet unclassified' }
RBReplaceCalledMethodByAnotherRefactoring class >> replaceCallMethod: aSelector in: aClass to: newSelector permutation: aMap [
^self new replaceCallMethod: aSelector
@@ -22,7 +33,7 @@ RBReplaceCalledMethodByAnotherRefactoring class >> replaceCallMethod: aSelector
{ #category : #transforming }
RBReplaceCalledMethodByAnotherRefactoring >> haveSameNumberOfArgs [
(self numberOfArgs: oldSelector) = (self numberOfArgs: newSelector)
ifFalse: [ self refactoringError: 'The new selector does not have the same number of parameters.']
ifFalse: [ self refactoringFailure: 'The new selector does not have the same number of parameters.']
]

{ #category : #'as yet unclassified' }
@@ -21,3 +21,26 @@ RBReplaceCalledMethodByAnotherTest >> testNotUnderstandSelector [
to: #checkMethod:
permutation: (1 to: 1))
]

{ #category : #tests }
RBReplaceCalledMethodByAnotherTest >> testReplacePrimitive [
"| refactoring count |
count := 0.
model allReferencesTo: #anInstVar: do: [:method | count := count + 1].
refactoring := RBReplaceCalledMethodByAnotherRefactoring
model: model
replaceMethod: #anInstVar:
in: RBBasicLintRuleTestData
to: #newResultClass:
permutation: (1 to: 2).
self proceedThroughWarning: [self executeRefactoring: refactoring]."
]

{ #category : #tests }
RBReplaceCalledMethodByAnotherTest >> testSelectorsNotHaveSameNumberOfArgs [
self shouldFail: (RBReplaceCalledMethodByAnotherRefactoring
replaceCallMethod: #checkClass:
in: RBBasicLintRuleTestData
to: #checkMethod23
permutation: (1 to: 1))
]

0 comments on commit 219c329

Please sign in to comment.
You can’t perform that action at this time.