-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from dionisiydk/dev
redefinedAnnotations
- Loading branch information
Showing
45 changed files
with
406 additions
and
25 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
ClassAnnotation-Tests.package/ClassAnnotationTests.class/instance/tearDown.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
running | ||
tearDown | ||
"Some tests redefine following annotation. | ||
Here we clear redefining state which forces cache reset" | ||
ClassAnnotationExample3 revertRedefinedInstances. | ||
"ClassAnnotationExample3 = ClassWithSingleAnnotation classAnnotations anyOne class" | ||
|
||
super tearDown. |
8 changes: 8 additions & 0 deletions
8
...sAnnotation-Tests.package/ClassAnnotationTests.class/instance/testForgettingAnnotation.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
tests | ||
testForgettingAnnotation | ||
| annotation | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
|
||
ClassAnnotation registry forgetAnnotation: annotation. | ||
|
||
self assert: ClassWithSingleAnnotation classAnnotations isEmpty |
9 changes: 9 additions & 0 deletions
9
...ion-Tests.package/ClassAnnotationTests.class/instance/testGettingAllRedefinedInstances.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests | ||
testGettingAllRedefinedInstances | ||
| annotation allRedefined | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
|
||
allRedefined := annotation class redefinedInstances. | ||
self assert: allRedefined size equals: 1. | ||
self assert: allRedefined anyOne priority equals: 0 |
10 changes: 10 additions & 0 deletions
10
...ClassAnnotationTests.class/instance/testGettingAllRedefinedInstancesShouldCleanGarbage.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tests | ||
testGettingAllRedefinedInstancesShouldCleanGarbage | ||
| annotation allRedefined | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
|
||
ClassAnnotation registry forgetAnnotation: annotation. | ||
|
||
allRedefined := annotation class redefinedInstances. | ||
self assert: allRedefined isEmpty |
10 changes: 10 additions & 0 deletions
10
...on-Tests.package/ClassAnnotationTests.class/instance/testGettingAllRedefiningInstances.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tests | ||
testGettingAllRedefiningInstances | ||
| annotation allRedefining | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
|
||
allRedefining := annotation class redefiningInstances. | ||
self assert: allRedefining size equals: 1. | ||
self assert: allRedefining anyOne priority equals: -1000. | ||
self assert: allRedefining anyOne == annotation |
10 changes: 10 additions & 0 deletions
10
...lassAnnotationTests.class/instance/testGettingAllRedefiningInstancesShouldCleanGarbage.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tests | ||
testGettingAllRedefiningInstancesShouldCleanGarbage | ||
| annotation allRedefined | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
|
||
ClassAnnotation registry forgetAnnotation: annotation. | ||
|
||
allRedefined := annotation class redefiningInstances. | ||
self assert: allRedefined isEmpty |
10 changes: 10 additions & 0 deletions
10
...otation-Tests.package/ClassAnnotationTests.class/instance/testGettingRedefinedInstance.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tests | ||
testGettingRedefinedInstance | ||
| annotation redefinedInstance | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
|
||
redefinedInstance := annotation redefinedInstance. | ||
self deny: redefinedInstance == annotation. | ||
self assert: redefinedInstance priority equals: 0. | ||
self assert: redefinedInstance isRedefined |
9 changes: 9 additions & 0 deletions
9
...tation-Tests.package/ClassAnnotationTests.class/instance/testGettingRedefiningInstance.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests | ||
testGettingRedefiningInstance | ||
| annotation actual | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
|
||
actual := annotation copy redefiningInstance. | ||
|
||
self assert: actual == annotation |
9 changes: 9 additions & 0 deletions
9
...s.package/ClassAnnotationTests.class/instance/testGettingSingleAnnotationUsingSelector.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests | ||
testGettingSingleAnnotationUsingSelector | ||
| expected actual | | ||
|
||
expected := ClassWithThreeAnnotations classAnnotations | ||
detect: [ :each | each declarationSelector = #annotationExample2 ]. | ||
actual := ClassWithThreeAnnotations classAnnotationAt: #annotationExample2. | ||
|
||
self assert: actual == expected |
9 changes: 9 additions & 0 deletions
9
ClassAnnotation-Tests.package/ClassAnnotationTests.class/instance/testObsolete.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests | ||
testObsolete | ||
| annotation | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
self deny: annotation isObsolete. | ||
|
||
ClassAnnotation registry forgetAnnotation: annotation. | ||
|
||
self assert: annotation isObsolete |
13 changes: 13 additions & 0 deletions
13
ClassAnnotation-Tests.package/ClassAnnotationTests.class/instance/testRedefiningInstance.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tests | ||
testRedefiningInstance | ||
| annotation newAnnotation | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
|
||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
self assert: annotation priority equals: -1000. | ||
self assert: annotation isRedefined. | ||
|
||
ClassAnnotation resetCache. | ||
newAnnotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
self assert: newAnnotation priority equals: -1000. | ||
self assert: newAnnotation isRedefined |
16 changes: 16 additions & 0 deletions
16
...notation-Tests.package/ClassAnnotationTests.class/instance/testRedefiningInstanceTwice.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
tests | ||
testRedefiningInstanceTwice | ||
| annotation newAnnotation reverted | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
|
||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
self assert: annotation redefinedInstance priority equals: 0. | ||
annotation redefineBy: [ annotation priority: -2000 ]. | ||
self assert: annotation redefinedInstance priority equals: 0. | ||
|
||
ClassAnnotation resetCache. | ||
newAnnotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
self assert: newAnnotation priority equals: -2000. | ||
newAnnotation revertRedefinedInstance. | ||
reverted := ClassWithSingleAnnotation classAnnotations anyOne. | ||
self assert: reverted priority equals: 0. |
10 changes: 10 additions & 0 deletions
10
...ckage/ClassAnnotationTests.class/instance/testRedefiningInstanceUsingBlockWithArgument.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tests | ||
testRedefiningInstanceUsingBlockWithArgument | ||
| newAnnotation | | ||
|
||
ClassWithSingleAnnotation classAnnotations anyOne | ||
redefineBy: [:annotation | annotation priority: -1000 ]. | ||
|
||
newAnnotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
self assert: newAnnotation priority equals: -1000. | ||
self assert: newAnnotation isRedefined |
8 changes: 8 additions & 0 deletions
8
...n-Tests.package/ClassAnnotationTests.class/instance/testRevertingAllRedefinedInstances.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
tests | ||
testRevertingAllRedefinedInstances | ||
| annotation | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
annotation class revertRedefinedInstances. | ||
|
||
self assert: annotation class redefinedInstances isEmpty. | ||
self assert: annotation class redefiningInstances isEmpty |
11 changes: 11 additions & 0 deletions
11
...ation-Tests.package/ClassAnnotationTests.class/instance/testRevertingRedefinedInstance.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tests | ||
testRevertingRedefinedInstance | ||
| annotation revertedAnnotation | | ||
annotation := ClassWithSingleAnnotation classAnnotations anyOne. | ||
annotation redefineBy: [ annotation priority: -1000 ]. | ||
revertedAnnotation := annotation revertRedefinedInstance. | ||
|
||
self deny: revertedAnnotation == annotation. | ||
self assert: revertedAnnotation == ClassWithSingleAnnotation classAnnotations anyOne. | ||
self assert: revertedAnnotation priority equals: 0. | ||
self deny: revertedAnnotation isRedefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ running | |
setUp | ||
super setUp. | ||
|
||
ClassAnnotation resetAll | ||
ClassAnnotation resetCache |
2 changes: 1 addition & 1 deletion
2
ClassAnnotation-Tests.package/RegisteredClassAnnotationsTests.class/instance/tearDown.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
running | ||
tearDown | ||
|
||
ClassAnnotation resetAll. | ||
ClassAnnotation resetCache. | ||
|
||
super tearDown. |
4 changes: 4 additions & 0 deletions
4
ClassAnnotation.package/Class.extension/instance/classAnnotationAt..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*ClassAnnotation | ||
classAnnotationAt: selector | ||
^self classAnnotations | ||
detect: [ :each | each declarationSelector = selector ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
ClassAnnotation.package/ClassAnnotation.class/class/cleanRedefinedGarbage.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
redefining | ||
cleanRedefinedGarbage | ||
"We should remove here all obsolete annotations which not exist in cache anymore. | ||
It can happen for several reasons: | ||
- annotation method was removed. | ||
- annotated class was removed | ||
- and various changes related to class hierarchy" | ||
redefinedInstances ifNil: [ ^self]. | ||
|
||
(redefinedInstances select: [ :each | each isObsolete ]) | ||
do: [ :each | redefinedInstances removeKey: each ] |
6 changes: 6 additions & 0 deletions
6
ClassAnnotation.package/ClassAnnotation.class/class/isInstanceRedefined..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
testing | ||
isInstanceRedefined: aClassAnnotation | ||
|
||
redefinedInstances ifNil: [ ^false ]. | ||
|
||
^redefinedInstances includesKey: aClassAnnotation |
4 changes: 4 additions & 0 deletions
4
ClassAnnotation.package/ClassAnnotation.class/class/isInstanceRegistered..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
testing | ||
isInstanceRegistered: aClassAnnotation | ||
|
||
^self registry includesAnnotation: aClassAnnotation |
Oops, something went wrong.