258
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCTestCase subclass:#MCAncestryTest
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Monticello-Tests'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCAncestryTest methodsFor:'asserting'!
|
|
12 |
|
|
13 |
assertCommonAncestorOf: leftName and: rightName in: options in: tree
|
|
14 |
| left right ancestor |
|
|
15 |
left := self versionForName: leftName in: tree.
|
|
16 |
right := self versionForName: rightName in: tree.
|
|
17 |
|
|
18 |
ancestor := left commonAncestorWith: right.
|
|
19 |
|
|
20 |
self assert: (options includes: ancestor name)
|
|
21 |
!
|
|
22 |
|
|
23 |
assertCommonAncestorOf: leftName and: rightName is: ancestorName in: tree
|
|
24 |
self assertCommonAncestorOf: leftName and: rightName in: (Array with: ancestorName) in: tree
|
|
25 |
!
|
|
26 |
|
|
27 |
assertNamesOf: versionInfoCollection are: nameArray
|
|
28 |
| names |
|
|
29 |
names := versionInfoCollection collect: [:ea | ea name].
|
|
30 |
|
|
31 |
self assert: names asArray = nameArray
|
|
32 |
!
|
|
33 |
|
|
34 |
assertPathTo: aSymbol is: anArray
|
|
35 |
self
|
|
36 |
assertNamesOf: (self tree allAncestorsOnPathTo: (self treeFrom: {aSymbol}))
|
|
37 |
are: anArray
|
|
38 |
! !
|
|
39 |
|
|
40 |
!MCAncestryTest methodsFor:'building'!
|
|
41 |
|
|
42 |
tree
|
|
43 |
^ self treeFrom:
|
|
44 |
#(c1
|
|
45 |
((e2
|
|
46 |
((e1
|
|
47 |
((a1
|
|
48 |
(('00')))))))
|
|
49 |
(a2
|
|
50 |
((a1
|
|
51 |
(('00')))))
|
|
52 |
(b3
|
|
53 |
((b2
|
|
54 |
((b1
|
|
55 |
((b0
|
|
56 |
(('00')))))))
|
|
57 |
(a1
|
|
58 |
(('00')))))
|
|
59 |
(d1)))
|
|
60 |
!
|
|
61 |
|
|
62 |
twoPersonTree
|
|
63 |
^ self treeFrom:
|
|
64 |
#(c1
|
|
65 |
((a4
|
|
66 |
((a1)
|
|
67 |
(b3
|
|
68 |
((b2
|
|
69 |
((a1)))))))
|
|
70 |
(b5
|
|
71 |
((b2
|
|
72 |
((a1)))))))
|
|
73 |
!
|
|
74 |
|
|
75 |
versionForName: name in: tree
|
|
76 |
(tree name = name) ifTrue: [^ tree].
|
|
77 |
|
|
78 |
tree ancestors do: [:ea | (self versionForName: name in: ea) ifNotNil:
|
|
79 |
[^ (self versionForName: name in: ea)]].
|
|
80 |
^ nil
|
|
81 |
|
|
82 |
"Modified: / 26-08-2009 / 13:35:20 / Jaroslav Havlin <havlij6@fel.cvut.cz>"
|
|
83 |
! !
|
|
84 |
|
|
85 |
!MCAncestryTest methodsFor:'tests'!
|
|
86 |
|
|
87 |
testCommonAncestors
|
|
88 |
self assertCommonAncestorOf: #a2 and: #e2 is: #a1 in: self tree.
|
|
89 |
self assertCommonAncestorOf: #e2 and: #b3 is: #a1 in: self tree.
|
|
90 |
self assertCommonAncestorOf: #b2 and: #e2 is: #'00' in: self tree.
|
|
91 |
|
|
92 |
self assertCommonAncestorOf: #a4 and: #b5 in: #(b2 a1) in: self twoPersonTree.
|
|
93 |
self assertCommonAncestorOf: #b5 and: #b3 is: #b2 in: self twoPersonTree.
|
|
94 |
self assertCommonAncestorOf: #b2 and: #a4 is: #b2 in: self twoPersonTree.
|
|
95 |
self assertCommonAncestorOf: #b2 and: #b2 is: #b2 in: self twoPersonTree.
|
|
96 |
self assertCommonAncestorOf: #b2 and: #a1 is: #a1 in: self twoPersonTree.
|
|
97 |
self assertCommonAncestorOf: #a1 and: #b2 is: #a1 in: self twoPersonTree.
|
|
98 |
!
|
|
99 |
|
|
100 |
testDescendants
|
|
101 |
| c1 a1 b3 q1 q2 c2 |
|
|
102 |
c1 := self tree.
|
|
103 |
a1 := self treeFrom: #(a1 (('00'))).
|
|
104 |
b3 := self treeFrom: #(b3
|
|
105 |
((b2
|
|
106 |
((b1
|
|
107 |
((b0
|
|
108 |
(('00')))))))
|
|
109 |
(a1
|
|
110 |
(('00'))))).
|
|
111 |
q1 := MCWorkingAncestry new addAncestor: a1.
|
|
112 |
q2 := MCWorkingAncestry new addAncestor: q1.
|
|
113 |
self assert: (q2 commonAncestorWith: b3) = a1.
|
|
114 |
self assert: (b3 commonAncestorWith: q2) = a1.
|
|
115 |
self assert: (q2 commonAncestorWith: c1) = a1.
|
|
116 |
self assert: (c1 commonAncestorWith: q2) = a1.
|
|
117 |
q1 addStepChild: c1.
|
|
118 |
self assert: (q2 commonAncestorWith: c1) = q1.
|
|
119 |
self assert: (c1 commonAncestorWith: q2) = q1.
|
|
120 |
c2 := MCWorkingAncestry new addAncestor: c1.
|
|
121 |
self assert: (q2 commonAncestorWith: c2) = q1.
|
|
122 |
self assert: (c2 commonAncestorWith: q2) = q1.
|
|
123 |
|
|
124 |
!
|
|
125 |
|
|
126 |
testLinearPath
|
|
127 |
self assertPathTo: #b1 is: #(b3 b2)
|
|
128 |
!
|
|
129 |
|
|
130 |
testPathToMissingAncestor
|
|
131 |
self assert: (self tree allAncestorsOnPathTo: MCVersionInfo new) isEmpty
|
|
132 |
! !
|
|
133 |
|
|
134 |
!MCAncestryTest class methodsFor:'documentation'!
|
|
135 |
|
|
136 |
version
|
281
|
137 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCAncestryTest.st,v 1.2 2011-08-20 12:04:04 cg Exp $'
|
258
|
138 |
!
|
|
139 |
|
|
140 |
version_CVS
|
281
|
141 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCAncestryTest.st,v 1.2 2011-08-20 12:04:04 cg Exp $'
|
258
|
142 |
!
|
|
143 |
|
|
144 |
version_SVN
|
|
145 |
^ '§Id: MCAncestryTest.st 5 2010-08-29 07:30:29Z vranyj1 §'
|
|
146 |
! !
|