diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-15 22:30:11 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-15 22:30:11 +0000 |
commit | da2779345b281f06d0bfd6791171b3d70bccfbfb (patch) | |
tree | ab639aa82aaa6c904568bf7e43daebb4dc1c0d14 /tools/json_schema_compiler | |
parent | 9ae3a4d9944cebe3ac7b68bfd41f1555d9643f5b (diff) | |
download | chromium_src-da2779345b281f06d0bfd6791171b3d70bccfbfb.zip chromium_src-da2779345b281f06d0bfd6791171b3d70bccfbfb.tar.gz chromium_src-da2779345b281f06d0bfd6791171b3d70bccfbfb.tar.bz2 |
Allow leading underscore on identifier names in IDL parser
This lets us have identifiers that match reserved words.
BUG=166268
Review URL: https://chromiumcodereview.appspot.com/11565053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler')
-rwxr-xr-x | tools/json_schema_compiler/idl_schema_test.py | 19 | ||||
-rw-r--r-- | tools/json_schema_compiler/test/idl_reserved_words.idl | 25 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tools/json_schema_compiler/idl_schema_test.py b/tools/json_schema_compiler/idl_schema_test.py index a710323..a4fd0d8 100755 --- a/tools/json_schema_compiler/idl_schema_test.py +++ b/tools/json_schema_compiler/idl_schema_test.py @@ -121,5 +121,24 @@ class IdlSchemaTest(unittest.TestCase): '<br/><br/> It also tests a comment with two newlines.'), func['description']) + def testReservedWords(self): + schema = idl_schema.Load('test/idl_reserved_words.idl')[0] + + foo_type = getType(schema, 'reserved_words.Foo') + self.assertEquals(['float', 'DOMString'], foo_type['enum']) + + enum_type = getType(schema, 'reserved_words.enum') + self.assertEquals(['callback', 'namespace'], enum_type['enum']) + + dictionary = getType(schema, 'reserved_words.dictionary'); + self.assertEquals('integer', dictionary['properties']['long']['type']) + + mytype = getType(schema, 'reserved_words.MyType') + self.assertEquals('string', mytype['properties']['interface']['type']) + + params = getParams(schema, 'static') + self.assertEquals('reserved_words.Foo', params[0]['$ref']) + self.assertEquals('reserved_words.enum', params[1]['$ref']) + if __name__ == '__main__': unittest.main() diff --git a/tools/json_schema_compiler/test/idl_reserved_words.idl b/tools/json_schema_compiler/test/idl_reserved_words.idl new file mode 100644 index 0000000..61ddabd --- /dev/null +++ b/tools/json_schema_compiler/test/idl_reserved_words.idl @@ -0,0 +1,25 @@ +// Copyright (c) 2012 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. + +namespace reserved_words { + + enum Foo { _float, _DOMString }; + + enum _enum { + _callback, + _namespace + }; + + dictionary _dictionary { + long _long; + }; + + dictionary MyType { + DOMString _interface; + }; + + interface Functions { + static void _static(Foo foo, _enum e); + }; +}; |