author | HG Automerge |
Thu, 24 Nov 2016 21:56:31 +0000 | |
branch | jv |
changeset 1015 | 7b6393ea3d52 |
parent 809 | 611029a80428 |
child 1121 | c5661215109c |
permissions | -rw-r--r-- |
4 | 1 |
"{ Package: 'stx:goodies/monticello/test' }" |
2 |
||
3 |
MCTestCase subclass:#MCAncestryTest |
|
4 |
instanceVariableNames:'' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
809
611029a80428
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
7 |
category:'SCM-Monticello-Tests' |
4 | 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) ifNotNilDo: [:v | ^ v]]. |
|
79 |
||
80 |
^ nil |
|
81 |
! ! |
|
82 |
||
83 |
!MCAncestryTest methodsFor:'tests'! |
|
84 |
||
85 |
testCommonAncestors |
|
86 |
self assertCommonAncestorOf: #a2 and: #e2 is: #a1 in: self tree. |
|
87 |
self assertCommonAncestorOf: #e2 and: #b3 is: #a1 in: self tree. |
|
88 |
self assertCommonAncestorOf: #b2 and: #e2 is: #'00' in: self tree. |
|
89 |
||
90 |
self assertCommonAncestorOf: #a4 and: #b5 in: #(b2 a1) in: self twoPersonTree. |
|
91 |
self assertCommonAncestorOf: #b5 and: #b3 is: #b2 in: self twoPersonTree. |
|
92 |
self assertCommonAncestorOf: #b2 and: #a4 is: #b2 in: self twoPersonTree. |
|
93 |
self assertCommonAncestorOf: #b2 and: #b2 is: #b2 in: self twoPersonTree. |
|
94 |
self assertCommonAncestorOf: #b2 and: #a1 is: #a1 in: self twoPersonTree. |
|
95 |
self assertCommonAncestorOf: #a1 and: #b2 is: #a1 in: self twoPersonTree. |
|
96 |
! |
|
97 |
||
98 |
testDescendants |
|
99 |
| c1 a1 b3 q1 q2 c2 | |
|
100 |
c1 _ self tree. |
|
101 |
a1 _ self treeFrom: #(a1 (('00'))). |
|
102 |
b3 _ self treeFrom: #(b3 |
|
103 |
((b2 |
|
104 |
((b1 |
|
105 |
((b0 |
|
106 |
(('00'))))))) |
|
107 |
(a1 |
|
108 |
(('00'))))). |
|
109 |
q1 _ MCWorkingAncestry new addAncestor: a1. |
|
110 |
q2 _ MCWorkingAncestry new addAncestor: q1. |
|
111 |
self assert: (q2 commonAncestorWith: b3) = a1. |
|
112 |
self assert: (b3 commonAncestorWith: q2) = a1. |
|
113 |
self assert: (q2 commonAncestorWith: c1) = a1. |
|
114 |
self assert: (c1 commonAncestorWith: q2) = a1. |
|
115 |
q1 addStepChild: c1. |
|
116 |
self assert: (q2 commonAncestorWith: c1) = q1. |
|
117 |
self assert: (c1 commonAncestorWith: q2) = q1. |
|
118 |
c2 _ MCWorkingAncestry new addAncestor: c1. |
|
119 |
self assert: (q2 commonAncestorWith: c2) = q1. |
|
120 |
self assert: (c2 commonAncestorWith: q2) = q1. |
|
121 |
! |
|
122 |
||
123 |
testLinearPath |
|
124 |
self assertPathTo: #b1 is: #(b3 b2) |
|
125 |
! |
|
126 |
||
127 |
testPathToMissingAncestor |
|
128 |
self assert: (self tree allAncestorsOnPathTo: MCVersionInfo new) isEmpty |
|
129 |
! ! |
|
130 |
||
131 |
!MCAncestryTest class methodsFor:'documentation'! |
|
132 |
||
133 |
version |
|
809
611029a80428
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
134 |
^ '$Header: /cvs/stx/stx/goodies/monticello/test/MCAncestryTest.st,v 1.2 2013-05-29 00:00:46 vrany Exp $' |
4 | 135 |
! ! |
809
611029a80428
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4
diff
changeset
|
136 |