Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(888)

Unified Diff: mojo/public/tools/bindings/pylib/mojom_tests/parse/translate_unittest.py

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py ('k') | mojo/services/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 2b08bb7282cec3327e164fd1db625c95747d5084..9f2d985d1fa3767a34b5a613809b62e7a1966cdc 100644
--- a/mojo/public/tools/bindings/pylib/mojom_tests/parse/translate_unittest.py
+++ b/mojo/public/tools/bindings/pylib/mojom_tests/parse/translate_unittest.py
@@ -21,7 +21,8 @@ try:
imp.find_module("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
-import mojom.parse.translate as translate
+from mojom.parse import ast
+from mojom.parse import translate
class TranslateTest(unittest.TestCase):
@@ -43,5 +44,22 @@ class TranslateTest(unittest.TestCase):
# pylint: disable=W0212
self.assertEquals(translate._MapKind("uint8[]{string}"), "m[s][a:u8]")
+ def testTranslateSimpleUnions(self):
+ """Makes sure that a simple union is translated correctly."""
+ tree = ast.Mojom(
+ None,
+ ast.ImportList(),
+ [ast.Union("SomeUnion", ast.UnionBody(
+ [ast.UnionField("a", None, "int32"),
+ ast.UnionField("b", None, "string")]))])
+ expected = [{
+ "name": "SomeUnion",
+ "fields": [
+ {"kind": "i32", "name": "a", "ordinal": None},
+ {"kind": "s", "name": "b", "ordinal": None}]}]
+ actual = translate.Translate(tree, "mojom_tree")
+ self.assertEquals(actual["union"], expected)
+
+
if __name__ == "__main__":
unittest.main()
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py ('k') | mojo/services/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698