15 def _run_test(self, syntax, content, expected):
16 """Utility run tests and prints extra contextual information.
19 syntax -- IDL grammar to use (either idlparser.WEBKIT_SYNTAX,
20 WEBIDL_SYNTAX or FREMONTCUT_SYNTAX). If
None, will run
21 multiple tests, each
with a different syntax.
22 content -- input text
for the parser.
23 expected -- expected parse result.
26 self.
_run_test(idlparser.WEBIDL_SYNTAX, content, expected)
27 self.
_run_test(idlparser.WEBKIT_SYNTAX, content, expected)
28 self.
_run_test(idlparser.FREMONTCUT_SYNTAX, content, expected)
36 parser = idlparser.IDLParser(syntax)
37 ast = parser.parse(content)
39 actual = node.to_dict()
if node
else None
40 except SyntaxError
as e:
43 if actual == expected:
57 ''' % (syntax, content, expected, actual, error, ast)
61 self.
_run_test(
None,
'module TestModule {};',
68 None,
'module TestModule { interface Interface1 {}; };', {
71 'javascript_binding_name':
'Interface1',
72 'doc_js_name':
'Interface1',
82 '#if 1\nmodule TestModule {};\n#endif\n',
89 idlparser.WEBKIT_SYNTAX,
90 'module M { interface [ExAt1, ExAt2] I {};};', {
93 'javascript_binding_name':
'I',
108 idlparser.WEBIDL_SYNTAX,
'module M { X implements Y; };', {
110 'implementsStatements': [{
125 idlparser.WEBIDL_SYNTAX,
'''interface I {
127 readonly attribute DOMString a2;
131 'javascript_binding_name':
138 'doc_js_interface_name':
'I'
144 'is_read_only':
True,
146 'doc_js_interface_name':
'I'
153 'doc_js_interface_name':
'I'
164 idlparser.WEBIDL_SYNTAX,
'''interface I {
166 t2 op2(in int arg1,
in long arg2);
167 getter any item(
in long index);
172 'doc_js_interface_name':
'I',
182 'doc_js_interface_name':
202 'specials': [
'getter'],
203 'doc_js_interface_name':
'I',
216 'is_stringifier':
True,
220 'doc_js_interface_name':
'I'
222 'javascript_binding_name':
233 None,
'''interface I {
236 const long c3 = 0x01;
238 const boolean b1 = false;
239 const boolean b2 = true;
242 'javascript_binding_name':
254 'doc_js_interface_name':
'I'
262 'doc_js_interface_name':
'I'
270 'doc_js_interface_name':
'I'
278 'doc_js_interface_name':
'I'
286 'doc_js_interface_name':
'I'
294 'doc_js_interface_name':
'I'
301 idlparser.FREMONTCUT_SYNTAX,
302 '@Ano1 @Ano2() @Ano3(x=1) @Ano4(x,y=2) interface I {};', {
304 'javascript_binding_name':
'I',
321 idlparser.FREMONTCUT_SYNTAX,
'''interface I : @Ano1 J {
322 @Ano2 attribute int someAttr;
324 @Ano3 const int someConst = 0;
335 'doc_js_interface_name':
'I'
337 'javascript_binding_name':
355 'doc_js_interface_name':
'I'
370 'doc_js_interface_name':
'I'
378 'interface Shape {}; interface Rectangle : Shape {}; interface Square : Rectangle, Shape {};',
381 'javascript_binding_name':
'Shape',
382 'doc_js_name':
'Shape',
386 'javascript_binding_name':
'Rectangle',
387 'doc_js_name':
'Rectangle',
396 'javascript_binding_name':
415if __name__ ==
"__main__":
416 logging.config.fileConfig(
"logging.conf")
417 if __name__ ==
'__main__':
def test_empty_interface(self)
def test_implements_statement(self)
def test_gcc_preprocessor(self)
def test_inheritance(self)
def test_empty_module(self)
def test_annotations(self)
def _run_test(self, syntax, content, expected)
def test_attributes(self)
def test_extended_attributes(self)
def test_operations(self)