| Index: mojo/public/tools/bindings/pylib/mojom_tests/parse/translate_unittest.py
|
| diff --git a/mojo/public/tools/bindings/pylib/mojom_tests/parse/translate_unittest.py b/mojo/public/tools/bindings/pylib/mojom_tests/parse/translate_unittest.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a1de7920587bf30294e2faf1bce62c67a92a72a2
|
| --- /dev/null
|
| +++ b/mojo/public/tools/bindings/pylib/mojom_tests/parse/translate_unittest.py
|
| @@ -0,0 +1,44 @@
|
| +# Copyright 2014 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import imp
|
| +import os.path
|
| +import sys
|
| +import unittest
|
| +
|
| +def _GetDirAbove(dirname):
|
| + """Returns the directory "above" this file containing |dirname| (which must
|
| + also be "above" this file)."""
|
| + path = os.path.abspath(__file__)
|
| + while True:
|
| + path, tail = os.path.split(path)
|
| + assert tail
|
| + if tail == dirname:
|
| + return path
|
| +
|
| +try:
|
| + imp.find_module("mojom")
|
| +except ImportError:
|
| + sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
|
| +import mojom.parse.translate as translate
|
| +
|
| +
|
| +class TranslateTest(unittest.TestCase):
|
| + """Tests |parser.Parse()|."""
|
| +
|
| + def testSimpleArray(self):
|
| + """Tests a simple int32[]."""
|
| + self.assertEquals(translate.MapKind("int32[]"), "a:i32")
|
| +
|
| + def testAssociativeArray(self):
|
| + """Tests a simple uint8{string}."""
|
| + self.assertEquals(translate.MapKind("uint8{string}"), "m[s][u8]")
|
| +
|
| + def testLeftToRightAssociativeArray(self):
|
| + """Makes sure that parsing is done left to right in the presence of an
|
| + associative array."""
|
| + self.assertEquals(translate.MapKind("uint8{string}[]"), "m[s][a:u8]")
|
| +
|
| +if __name__ == "__main__":
|
| + unittest.main()
|
|
|