302
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
TestCase subclass:#MCDependencySorterTest
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Monticello-Tests'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCDependencySorterTest methodsFor:'asserting'!
|
|
12 |
|
|
13 |
assertItems: anArray orderAs: depOrder withRequired: missingDeps toLoad: unloadableItems
|
|
14 |
self assertItems: anArray orderAs: depOrder withRequired: missingDeps toLoad: unloadableItems extraProvisions: #()
|
|
15 |
!
|
|
16 |
|
|
17 |
assertItems: anArray orderAs: depOrder withRequired: missingDeps toLoad: unloadableItems extraProvisions: provisions
|
|
18 |
| order sorter items missing unloadable |
|
|
19 |
items := anArray collect: [:ea | self itemWithSpec: ea].
|
|
20 |
sorter := MCDependencySorter items: items.
|
|
21 |
sorter addExternalProvisions: provisions.
|
|
22 |
order := (sorter orderedItems collect: [:ea | ea name]) asArray.
|
|
23 |
self assert: order = depOrder.
|
|
24 |
missing := sorter externalRequirements.
|
|
25 |
self assert: missing asSet = missingDeps asSet.
|
|
26 |
unloadable := (sorter itemsWithMissingRequirements collect: [:ea | ea name]) asArray.
|
|
27 |
self assert: unloadable asSet = unloadableItems asSet
|
|
28 |
! !
|
|
29 |
|
|
30 |
!MCDependencySorterTest methodsFor:'building'!
|
|
31 |
|
|
32 |
itemWithSpec: anArray
|
|
33 |
^ MCMockDependentItem new
|
|
34 |
name: anArray first;
|
|
35 |
provides: anArray second;
|
|
36 |
requires: anArray third
|
|
37 |
! !
|
|
38 |
|
|
39 |
!MCDependencySorterTest methodsFor:'tests'!
|
|
40 |
|
|
41 |
testCascadingUnresolved
|
|
42 |
self assertItems: #(
|
|
43 |
(a (x) (z))
|
|
44 |
(b () (x))
|
|
45 |
(c () ()))
|
|
46 |
orderAs: #(c)
|
|
47 |
withRequired: #(z)
|
|
48 |
toLoad: #(a b)
|
|
49 |
!
|
|
50 |
|
|
51 |
testCycle
|
|
52 |
self assertItems: #(
|
|
53 |
(a (x) (y))
|
|
54 |
(b (y) (x)))
|
|
55 |
orderAs: #()
|
|
56 |
withRequired: #()
|
|
57 |
toLoad: #(a b)
|
|
58 |
!
|
|
59 |
|
|
60 |
testExtraProvisions
|
|
61 |
self assertItems:
|
|
62 |
#((a (x) (z))
|
|
63 |
(b () (x)))
|
|
64 |
orderAs: #(a b)
|
|
65 |
withRequired: #()
|
|
66 |
toLoad: #()
|
|
67 |
extraProvisions: #(x z)
|
|
68 |
!
|
|
69 |
|
|
70 |
testMultiRequirementOrdering
|
|
71 |
self assertItems: #(
|
|
72 |
(a (x) (z))
|
|
73 |
(b (y) ())
|
|
74 |
(c (z) ())
|
|
75 |
(d () (x y z)))
|
|
76 |
orderAs: #(b c a d)
|
|
77 |
withRequired: #()
|
|
78 |
toLoad: #()
|
|
79 |
!
|
|
80 |
|
|
81 |
testSimpleOrdering
|
|
82 |
self assertItems: #((a (x) ())
|
|
83 |
(c () (y))
|
|
84 |
(b (y) (x)))
|
|
85 |
orderAs: #(a b c)
|
|
86 |
withRequired: #()
|
|
87 |
toLoad: #()
|
|
88 |
!
|
|
89 |
|
|
90 |
testSimpleUnresolved
|
|
91 |
self assertItems: #(
|
|
92 |
(a () (z)))
|
|
93 |
orderAs: #()
|
|
94 |
withRequired: #(z)
|
|
95 |
toLoad: #(a)
|
|
96 |
|
|
97 |
!
|
|
98 |
|
|
99 |
testUnusedAlternateProvider
|
|
100 |
self assertItems: #(
|
|
101 |
(a (x) (z))
|
|
102 |
(b () (x))
|
|
103 |
(c (x) ()))
|
|
104 |
orderAs: #(c b)
|
|
105 |
withRequired: #(z)
|
|
106 |
toLoad: #(a)
|
|
107 |
! !
|
|
108 |
|
|
109 |
!MCDependencySorterTest class methodsFor:'documentation'!
|
|
110 |
|
|
111 |
version
|
|
112 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCDependencySorterTest.st,v 1.1 2011-08-20 12:20:16 cg Exp $'
|
|
113 |
!
|
|
114 |
|
|
115 |
version_CVS
|
|
116 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCDependencySorterTest.st,v 1.1 2011-08-20 12:20:16 cg Exp $'
|
|
117 |
!
|
|
118 |
|
|
119 |
version_SVN
|
|
120 |
^ '§Id: MCDependencySorterTest.st 5 2010-08-29 07:30:29Z vranyj1 §'
|
|
121 |
! !
|