forked from pharo-project/pharo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmalllintManifestCheckerTest.class.st
121 lines (98 loc) · 3.4 KB
/
SmalllintManifestCheckerTest.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"
SUnit tests for SmalllintManifestChecker
"
Class {
#name : #SmalllintManifestCheckerTest,
#superclass : #TestCaseWithEnvironment,
#instVars : [
'checker'
],
#category : #'Manifest-Tests-Base'
}
{ #category : #running }
SmalllintManifestCheckerTest >> cleaningResources [
testingEnvironment
at: #ManifestManifestResourcesTests
ifPresent: [ :cl |
cl
removeFromChanges;
removeFromSystem ]
]
{ #category : #private }
SmalllintManifestCheckerTest >> package [
MCWorkingCopy managersForClass: MFClassA do: [:p | ^ p packageSet packages first].
" should be equivalent to RPackageOrganizer default packageNamed: #'Manifest-Resources-Tests' "
]
{ #category : #running }
SmalllintManifestCheckerTest >> setUp [
| bm |
super setUp.
self cleaningResources.
bm := TheManifestBuilder of: MFClassA.
bm installFalsePositiveOf: RBCodeCruftLeftInMethodsRule uniqueIdentifierName version: 1.
bm addFalsePositive: MFClassB >> #method3 of: RBCodeCruftLeftInMethodsRule uniqueIdentifierName version: 1.
bm installToDoOf: GRTemporaryNeitherReadNorWrittenRule uniqueIdentifierName version: 1.
bm
addAllToDo:
{(MFClassB >> #method3).
(MFClassA >> #method)}
of: GRTemporaryNeitherReadNorWrittenRule uniqueIdentifierName
version: 1.
checker := ReSmalllintChecker new
]
{ #category : #running }
SmalllintManifestCheckerTest >> tearDown [
self cleaningResources.
ASTCache reset.
super tearDown
]
{ #category : #tests }
SmalllintManifestCheckerTest >> testCriticsOf [
| rule critiques |
rule := ReRuleManager visibleRuleClasses collect: #new.
checker
rule: rule;
environment: self package asEnvironment;
run.
critiques := checker criticsOf: GRTemporaryNeitherReadNorWrittenRule new.
self assert: critiques size = 3.
self assert: (critiques anySatisfy: [ :each |
each sourceAnchor entity = (MFClassB>>#method3)]).
self assert: (critiques anySatisfy: [ :each |
each sourceAnchor entity = (MFClassA>>#method)]).
]
{ #category : #tests }
SmalllintManifestCheckerTest >> testIsFalsePositive [
| rule |
rule := ReRuleManager visibleRuleClasses collect: #new.
checker
rule: rule;
environment: self package asEnvironment;
run.
self assert: (checker isFalsePositive: (MFClassB>>#method3) forRuleId: (RBCodeCruftLeftInMethodsRule uniqueIdentifierName) versionId: 1).
self deny: (checker isFalsePositive: (MFClassA>>#method) forRuleId: (RBCodeCruftLeftInMethodsRule uniqueIdentifierName) versionId: 1).
]
{ #category : #tests }
SmalllintManifestCheckerTest >> testIsToDo [
| rule |
rule := ReRuleManager visibleRuleClasses collect: #new.
checker
rule: rule;
environment: self package asEnvironment;
run.
self assert: (checker isToDo: (MFClassB>>#method3) forRuleId: (GRTemporaryNeitherReadNorWrittenRule uniqueIdentifierName) versionId: 1).
self deny: (checker isToDo: (MFClassB>>#method2) forRuleId: (GRTemporaryNeitherReadNorWrittenRule uniqueIdentifierName) versionId: 1).
]
{ #category : #tests }
SmalllintManifestCheckerTest >> testToDoOf [
| rule |
rule := ReRuleManager visibleRuleClasses collect: #new.
checker
rule: rule;
environment: self package asEnvironment;
run.
self assert: (( checker toDoOf: GRTemporaryNeitherReadNorWrittenRule new) anySatisfy: [:each|
each sourceAnchor entity = (MFClassB>>#method3)]).
self deny: (( checker toDoOf: GRTemporaryNeitherReadNorWrittenRule new) anySatisfy: [:each|
each sourceAnchor entity = (MFClassB>>#method2)]).
]