388
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCTestCase subclass:#MCMethodDefinitionTest
|
|
4 |
instanceVariableNames:'navigation isModified'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Monticello-Tests'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCMethodDefinitionTest methodsFor:'running'!
|
|
12 |
|
|
13 |
ownPackage
|
|
14 |
^ MCWorkingCopy forPackage: (MCPackage named: 'Monticello')
|
|
15 |
!
|
|
16 |
|
|
17 |
setUp
|
|
18 |
navigation := (Smalltalk hasClassNamed: #SystemNavigation)
|
|
19 |
ifTrue: [(Smalltalk at: #SystemNavigation) new]
|
|
20 |
ifFalse: [Smalltalk].
|
|
21 |
isModified := self ownPackage modified.
|
|
22 |
!
|
|
23 |
|
|
24 |
tearDown
|
|
25 |
self restoreMocks.
|
|
26 |
(MCWorkingCopy forPackage: (MCPackage named: 'FooBarBaz')) unregister.
|
|
27 |
self class compile: 'override ^ 1' classified: 'mocks'.
|
|
28 |
self ownPackage modified: isModified
|
|
29 |
! !
|
|
30 |
|
|
31 |
!MCMethodDefinitionTest methodsFor:'testing'!
|
|
32 |
|
|
33 |
__testRevertOldMethod
|
|
34 |
| definition changeRecord |
|
|
35 |
Object compile: 'yourself ^ self' classified: MCMockPackageInfo new methodCategoryPrefix.
|
|
36 |
definition := (MethodReference class: Object selector: #yourself) asMethodDefinition.
|
|
37 |
changeRecord := definition scanForPreviousVersion.
|
|
38 |
self assert: changeRecord notNil.
|
|
39 |
self assert: changeRecord category = 'accessing'.
|
|
40 |
changeRecord fileIn.
|
|
41 |
|
|
42 |
"Created: / 11-09-2010 / 18:47:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
43 |
!
|
|
44 |
|
|
45 |
testCannotLoad
|
|
46 |
| definition |
|
|
47 |
definition := self mockMethod: #kjahs87 class: 'NoSuchClass' source: 'kjahs87 ^self' meta: false.
|
|
48 |
self should: [definition load] raise: Error.
|
|
49 |
self assert: (navigation allImplementorsOf: #kjahs87) isEmpty
|
|
50 |
!
|
|
51 |
|
|
52 |
testComparison
|
|
53 |
|d1 d2 d3 d4 d5 |
|
|
54 |
d1 := self mockMethod: #one class: 'A' source: '1' meta: false.
|
|
55 |
d2 := self mockMethod: #one class: 'A' source: '2' meta: false.
|
|
56 |
d3 := self mockMethod: #one class: 'A' source: '1' meta: true.
|
|
57 |
d4 := self mockMethod: #two class: 'A' source: '1' meta: false.
|
|
58 |
d5 := self mockMethod: #two class: 'A' source: '1' meta: false.
|
|
59 |
|
|
60 |
self assert: (d1 isRevisionOf: d2).
|
|
61 |
self deny: (d1 isSameRevisionAs: d2).
|
|
62 |
|
|
63 |
self deny: (d1 isRevisionOf: d3).
|
|
64 |
self deny: (d1 isRevisionOf: d4).
|
|
65 |
|
|
66 |
self assert: (d4 isSameRevisionAs: d5).
|
|
67 |
!
|
|
68 |
|
|
69 |
testLoadAndUnload
|
|
70 |
|definition|
|
|
71 |
definition := self mockMethod: #one class: 'MCMockClassA' source: 'one ^2' meta: false.
|
|
72 |
self assert: self mockInstanceA one = 1.
|
|
73 |
definition load.
|
|
74 |
self assert: self mockInstanceA one = 2.
|
|
75 |
definition unload.
|
|
76 |
self deny: (self mockInstanceA respondsTo: #one)
|
|
77 |
!
|
|
78 |
|
|
79 |
testPartiallyRevertOverrideMethod
|
|
80 |
| definition |
|
|
81 |
self class compile: 'override ^ 2' classified: '*foobarbaz'.
|
|
82 |
self class compile: 'override ^ 3' classified: self mockOverrideMethodCategory.
|
|
83 |
self class compile: 'override ^ 4' classified: self mockOverrideMethodCategory.
|
|
84 |
definition := (MethodReference class: self class selector: #override) asMethodDefinition.
|
|
85 |
self assert: definition isOverrideMethod.
|
|
86 |
"/TODO: Fix it later ;-)
|
|
87 |
"/self assert: self override = 4.
|
|
88 |
definition unload.
|
|
89 |
"/self assert: self override = 2.
|
|
90 |
"/self assert: (MethodReference class: self class selector: #override) category = '*foobarbaz'.
|
|
91 |
|
|
92 |
"Modified: / 11-09-2010 / 18:48:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
93 |
!
|
|
94 |
|
|
95 |
testRevertOverrideMethod
|
|
96 |
| definition |
|
|
97 |
self class compile: 'override ^ 2' classified: self mockOverrideMethodCategory.
|
|
98 |
definition := (MethodReference class: self class selector: #override) asMethodDefinition.
|
|
99 |
self assert: definition isOverrideMethod.
|
|
100 |
"/TODO: Fix it later
|
|
101 |
"/self assert: self override = 2.
|
|
102 |
definition unload.
|
|
103 |
"/self assert: self override = 1.
|
|
104 |
"/self assert: (MethodReference class: self class selector: #override) category = 'mocks'.
|
|
105 |
|
|
106 |
"Modified: / 11-09-2010 / 18:46:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
107 |
! !
|
|
108 |
|
|
109 |
!MCMethodDefinitionTest class methodsFor:'documentation'!
|
|
110 |
|
|
111 |
version
|
|
112 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCMethodDefinitionTest.st,v 1.1 2011-08-20 12:33:52 cg Exp $'
|
|
113 |
!
|
|
114 |
|
|
115 |
version_CVS
|
|
116 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCMethodDefinitionTest.st,v 1.1 2011-08-20 12:33:52 cg Exp $'
|
|
117 |
!
|
|
118 |
|
|
119 |
version_SVN
|
|
120 |
^ '§Id: MCMethodDefinitionTest.st 27 2011-03-07 03:48:48Z vranyj1 §'
|
|
121 |
! !
|