OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import idl_schema | 6 import idl_schema |
7 import unittest | 7 import unittest |
8 | 8 |
9 def getFunction(schema, name): | 9 def getFunction(schema, name): |
10 for item in schema['functions']: | 10 for item in schema['functions']: |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 [{'description': ('So should this comment about the argument. ' | 114 [{'description': ('So should this comment about the argument. ' |
115 '<em>HTML</em> is fine too.'), | 115 '<em>HTML</em> is fine too.'), |
116 'name': 'arg', | 116 'name': 'arg', |
117 '$ref': 'idl_basics.MyType1'}], | 117 '$ref': 'idl_basics.MyType1'}], |
118 func['parameters']) | 118 func['parameters']) |
119 func = getFunction(schema, 'function4') | 119 func = getFunction(schema, 'function4') |
120 self.assertEquals(('This tests if "double-quotes" are escaped correctly.' | 120 self.assertEquals(('This tests if "double-quotes" are escaped correctly.' |
121 '<br/><br/> It also tests a comment with two newlines.'), | 121 '<br/><br/> It also tests a comment with two newlines.'), |
122 func['description']) | 122 func['description']) |
123 | 123 |
| 124 def testReservedWords(self): |
| 125 schema = idl_schema.Load('test/idl_reserved_words.idl')[0] |
| 126 |
| 127 foo_type = getType(schema, 'reserved_words.Foo') |
| 128 self.assertEquals(['float', 'DOMString'], foo_type['enum']) |
| 129 |
| 130 enum_type = getType(schema, 'reserved_words.enum') |
| 131 self.assertEquals(['callback', 'namespace'], enum_type['enum']) |
| 132 |
| 133 dictionary = getType(schema, 'reserved_words.dictionary'); |
| 134 self.assertEquals('integer', dictionary['properties']['long']['type']) |
| 135 |
| 136 mytype = getType(schema, 'reserved_words.MyType') |
| 137 self.assertEquals('string', mytype['properties']['interface']['type']) |
| 138 |
| 139 params = getParams(schema, 'static') |
| 140 self.assertEquals('reserved_words.Foo', params[0]['$ref']) |
| 141 self.assertEquals('reserved_words.enum', params[1]['$ref']) |
| 142 |
124 if __name__ == '__main__': | 143 if __name__ == '__main__': |
125 unittest.main() | 144 unittest.main() |
OLD | NEW |