Skip to content

Commit

Permalink
Add tests to ChanelMethodsOnlyCallingSuperCleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Apr 11, 2020
1 parent 12e6f6f commit 1e0be14
Showing 1 changed file with 128 additions and 0 deletions.
128 changes: 128 additions & 0 deletions src/Chanel-Tests/ChanelMethodsOnlyCallingSuperCleanerTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
"
A ChanelMethodsOnlyCallingSuperCleanerTest is a test class for testing the behavior of ChanelMethodsOnlyCallingSuperCleaner
"
Class {
#name : #ChanelMethodsOnlyCallingSuperCleanerTest,
#superclass : #ChanelAbstractCleanerTest,
#category : #'Chanel-Tests'
}

{ #category : #running }
ChanelMethodsOnlyCallingSuperCleanerTest >> setUp [
super setUp.
class := self createTestCaseNamed: #ChanelMethodOnlyCallingSuperFake
]

{ #category : #tests }
ChanelMethodsOnlyCallingSuperCleanerTest >> testDoesNotRemoveMethodCallingOtherSuper [
| oldMethod |
class
compile:
'new
super basicNew'.

oldMethod := class>>#new.
self runCleaner.

self assert: (class localSelectors includes: #new).

"We should not have recompiled the method if we do not clean it."
self assert: (class >> #new) identicalTo: oldMethod
]

{ #category : #tests }
ChanelMethodsOnlyCallingSuperCleanerTest >> testDoesNotRemoveMethodWithOtherStatements [
| oldMethod |
class
compile:
'initialize
super initialize.
^ #test'.

oldMethod := class>>#initialize.
self runCleaner.

self assert: (class localSelectors includes: #initialize).

"We should not have recompiled the method if we do not clean it."
self assert: (class >> #initialize) identicalTo: oldMethod
]

{ #category : #tests }
ChanelMethodsOnlyCallingSuperCleanerTest >> testDoesNotRemoveMethodWithPragma [
| oldMethod |
class
compile:
'initialize
<pragma>
super initialize'.

oldMethod := class>>#initialize.
self runCleaner.

self assert: (class localSelectors includes: #initialize).

"We should not have recompiled the method if we do not clean it."
self assert: (class >> #initialize) identicalTo: oldMethod
]

{ #category : #tests }
ChanelMethodsOnlyCallingSuperCleanerTest >> testRemoveBinaryMethodOnlyCollingSuper [
class
compile:
'= aString
^ super = aString'.

self runCleaner.

self deny: (class localSelectors includes: #=)
]

{ #category : #tests }
ChanelMethodsOnlyCallingSuperCleanerTest >> testRemoveKeywordMethodOnlyCollingSuper [
class
compile:
'initialize: aString
super initialize: aString'.

self runCleaner.

self deny: (class localSelectors includes: #initialize:)
]

{ #category : #tests }
ChanelMethodsOnlyCallingSuperCleanerTest >> testRemoveMethodOnlyCollingSuper [
class
compile:
'initialize
super initialize'.

self runCleaner.

self deny: (class localSelectors includes: #initialize)
]

{ #category : #tests }
ChanelMethodsOnlyCallingSuperCleanerTest >> testRemoveMethodOnlyCollingSuper2 [
class
compile:
'initialize
"I don''t care about comments. If you need them, put them in the class comment."
super initialize'.

self runCleaner.

self deny: (class localSelectors includes: #initialize)
]

{ #category : #tests }
ChanelMethodsOnlyCallingSuperCleanerTest >> testRemoveMethodOnlyCollingSuperEvenIfThereIsAReturn [
class
compile:
'initialize
^super initialize'.

self runCleaner.

self deny: (class localSelectors includes: #initialize)
]

0 comments on commit 1e0be14

Please sign in to comment.