diff options
author | Evan Martin <martine@danga.com> | 2014-11-18 15:48:26 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2014-11-18 16:15:36 (GMT) |
commit | 76a95e45bba61b617dfac14e83cb6229a4e4e897 (patch) | |
tree | 3a985efc70044e122011aa8c938fab502ea8c271 /misc/ninja_syntax_test.py | |
parent | f323ff900a23526686af266b0ffabf711f48f19e (diff) | |
download | Ninja-76a95e45bba61b617dfac14e83cb6229a4e4e897.zip Ninja-76a95e45bba61b617dfac14e83cb6229a4e4e897.tar.gz Ninja-76a95e45bba61b617dfac14e83cb6229a4e4e897.tar.bz2 |
add an "expand" function to ninja_syntax
Implements basic variable expansion for use in configure.py.
Diffstat (limited to 'misc/ninja_syntax_test.py')
-rwxr-xr-x | misc/ninja_syntax_test.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/misc/ninja_syntax_test.py b/misc/ninja_syntax_test.py index 2aef7ff..36b2e7b 100755 --- a/misc/ninja_syntax_test.py +++ b/misc/ninja_syntax_test.py @@ -148,5 +148,31 @@ build out: cc in ''', self.out.getvalue()) +class TestExpand(unittest.TestCase): + def test_basic(self): + vars = {'x': 'X'} + self.assertEqual('foo', ninja_syntax.expand('foo', vars)) + + def test_var(self): + vars = {'xyz': 'XYZ'} + self.assertEqual('fooXYZ', ninja_syntax.expand('foo$xyz', vars)) + + def test_vars(self): + vars = {'x': 'X', 'y': 'YYY'} + self.assertEqual('XYYY', ninja_syntax.expand('$x$y', vars)) + + def test_space(self): + vars = {} + self.assertEqual('x y z', ninja_syntax.expand('x$ y$ z', vars)) + + def test_locals(self): + vars = {'x': 'a'} + local_vars = {'x': 'b'} + self.assertEqual('a', ninja_syntax.expand('$x', vars)) + self.assertEqual('b', ninja_syntax.expand('$x', vars, local_vars)) + + def test_double(self): + self.assertEqual('a b$c', ninja_syntax.expand('a$ b$$c', {})) + if __name__ == '__main__': unittest.main() |