Add emacs and vim editing settings to the bottom of *.py files.
[scons.git] / src / engine / SCons / Node / AliasTests.py
1 #
2 # __COPYRIGHT__
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #
23
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
25
26 import sys
27 import unittest
28
29 import SCons.Errors
30 import SCons.Node.Alias
31
32 class AliasTestCase(unittest.TestCase):
33
34     def test_AliasNameSpace(self):
35         """Test creating an Alias name space
36         """
37         ans = SCons.Node.Alias.AliasNameSpace()
38         assert not ans is None, ans
39
40     def test_ANS_Alias(self):
41         """Test the Alias() factory
42         """
43         ans = SCons.Node.Alias.AliasNameSpace()
44
45         a1 = ans.Alias('a1')
46         assert a1.name == 'a1', a1.name
47
48         a2 = ans.Alias('a1')
49         assert a1 is a2, (a1, a2)
50
51     def test_get_contents(self):
52         """Test the get_contents() method
53         """
54         class DummyNode:
55             def __init__(self, contents):
56                 self.contents = contents
57             def get_csig(self):
58                 return self.contents
59             def get_contents(self):
60                 return self.contents
61
62         ans = SCons.Node.Alias.AliasNameSpace()
63
64         ans.Alias('a1')
65         a = ans.lookup('a1')
66
67         a.sources = [ DummyNode('one'), DummyNode('two'), DummyNode('three') ]
68
69         c = a.get_contents()
70         assert c == 'onetwothree', c
71
72     def test_lookup(self):
73         """Test the lookup() method
74         """
75         ans = SCons.Node.Alias.AliasNameSpace()
76
77         ans.Alias('a1')
78         a = ans.lookup('a1')
79         assert a.name == 'a1', a.name
80
81         a1 = ans.lookup('a1')
82         assert a is a1, a1
83
84         a = ans.lookup('a2')
85         assert a == None, a
86
87     def test_Alias(self):
88         """Test creating an Alias() object
89         """
90         a1 = SCons.Node.Alias.Alias('a')
91         assert a1.name == 'a', a1.name
92
93         a2 = SCons.Node.Alias.Alias('a')
94         assert a2.name == 'a', a2.name
95
96         assert not a1 is a2
97         assert a1.name == a2.name
98
99 class AliasNodeInfoTestCase(unittest.TestCase):
100     def test___init__(self):
101         """Test AliasNodeInfo initialization"""
102         ans = SCons.Node.Alias.AliasNameSpace()
103         aaa = ans.Alias('aaa')
104         ni = SCons.Node.Alias.AliasNodeInfo(aaa)
105
106 class AliasBuildInfoTestCase(unittest.TestCase):
107     def test___init__(self):
108         """Test AliasBuildInfo initialization"""
109         ans = SCons.Node.Alias.AliasNameSpace()
110         aaa = ans.Alias('aaa')
111         bi = SCons.Node.Alias.AliasBuildInfo(aaa)
112
113 if __name__ == "__main__":
114     suite = unittest.TestSuite()
115     tclasses = [
116         AliasTestCase,
117         AliasBuildInfoTestCase,
118         AliasNodeInfoTestCase,
119     ]
120     for tclass in tclasses:
121         names = unittest.getTestCaseNames(tclass, 'test_')
122         suite.addTests(map(tclass, names))
123     if not unittest.TextTestRunner().run(suite).wasSuccessful():
124         sys.exit(1)
125
126 # Local Variables:
127 # tab-width:4
128 # indent-tabs-mode:nil
129 # End:
130 # vim: set expandtab tabstop=4 shiftwidth=4: