Hi
I have been working on a new API to access class, traits, selector for
traits
I wrote some tests in the
PharoTaskForces/Traits-MOPTests package
Now in essence
we have
- The selector of a compiled method should be its name.
An aliased method should have the name of its alias name.
- The class of a compiled method is the class that contains it.
A compiled method cannot be shared.
- The origin of a compiledMethod is its defining class or trait.
- The reachHome of a compiled method is class or traits that you
changed
(and not override) when you want to change a method in the flat view.
T1
c
c1
T2
c
c3
uses: T1
Class A
foo
uses: T2
testSelectorT11T2
"self debug: #testSelectorT11T2"
"The selector of a compiled method should be its name.
An aliased method should have the name of its alias name."
self assert: (AUsingTrait2>>#foo) selector = #foo.
self assert: (Trait1>>#c) selector = #c.
self assert: (Trait2>>#c) selector = #c.
self assert: (AUsingTrait2>>#c) selector = #c.
self assert: (AUsingTrait2>>#c3) selector = #c2.
self assert: (BUsingTrait1>>#c) selector = #c.
testClassT11T2
"The class of a compiled method is the class that contains it.
A compiled method cannot be shared."
self assert: (AUsingTrait2>>#foo) methodClass = AUsingTrait2.
self assert: (AUsingTrait2>>#c) methodClass = AUsingTrait2.
self assert: (AUsingTrait1>>#c3) methodClass = AUsingTrait2.
self assert: (AUsingTrait2>>#c1) methodClass = AUsingTrait2.
self assert: (BUsingTrait1>>#c) methodClass = BUsingTrait1.
self should: (Trait1>>#c1) methodClass = nil. "T1 or nil"
self should: (Trait2>>#c2) methodClass = nil. "T2 or nil"
self should: (Trait2>>#c1) methodClass = nil. "T2 or nil or T1"
testReachHome
"self debug: #testReachHome"
" The reachHome is the method that you changed
(and not override) when you want to change a method in the flat view."
self assert: (AUsingTrait2>>#foo) reachHome = AUsingTrait2.
self assert: (AUsingTrait2>>#c3) reachHome = Trait2.
self assert: (AUsingTrait2>>#c1) reachHome = Trait1.
self assert: (AUsingTrait2>>#c) reachHome = Trait2.
self assert: (Trait11>>#c) reachHome = Trait11.
self assert: (Trait2>>#c) reachHome = Trait2.
self assert: (Trait2>>#c1) reachHome = Trait11.
self assert: (AUsingTrait1>>#c2) reachHome = AUsingTrait1.
testOrigin
"self debug: #testClass"
"The origin of a compiledMethod is its defining class or trait."
self assert: (AUsingTrait2>>#foo) origin = AUsingTrait2.
self assert: (AUsingTrait2>>#c3) origin = Trait2.
self assert: (AUsingTrait2>>#c1) origin = Trait11.
self assert: (AUsingTrait2>>#c) origin = Trait11.
self assert: (BUsingTrait1>>#c) origin = Trait1.
self assert: (Trait2>>#c3) origin = Trait2.
self assert: (Trait11>>#c1) origin = Trait11.
self assert: (Trait2>>#c1) origin = Trait11.
"since it introduced the alias it is its origin"
self assert: (AUsingTrait1>>#c2) origin = AUsingTrait1.
testTraitT11T2
"it seems to me that we do not need trait: but we need origin and
reachHome"
"(A>>foo) trait -> nil
(A>>c3) trait -> T2
(A>>c) trait -> T2
(A>>c1) trait -> T2 ***** since it is flat
(T1>>c1) trait -> ???? T1 or nil
(T2>>c1) trait
(T2>>c2) trait -> ???? T2 or nil"
self assert: (AUsingTrait2>>#foo) trait isNil.
self assert: (AUsingTrait2>>#c3) trait = Trait2
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project