Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
scripts.idlnode_test.IDLNodeTestCase Class Reference
Inheritance diagram for scripts.idlnode_test.IDLNodeTestCase:

Public Member Functions

 test_empty_module (self)
 
 test_empty_interface (self)
 
 test_gcc_preprocessor (self)
 
 test_extended_attributes (self)
 
 test_implements_statement (self)
 
 test_attributes (self)
 
 test_operations (self)
 
 test_constants (self)
 
 test_annotations (self)
 
 test_inheritance (self)
 

Protected Member Functions

 _run_test (self, syntax, content, expected)
 

Detailed Description

Definition at line 13 of file idlnode_test.py.

Member Function Documentation

◆ _run_test()

scripts.idlnode_test.IDLNodeTestCase._run_test (   self,
  syntax,
  content,
  expected 
)
protected
Utility run tests and prints extra contextual information.

Args:
syntax -- IDL grammar to use (either idlparser.WEBKIT_SYNTAX,
WEBIDL_SYNTAX or FREMONTCUT_SYNTAX). If None, will run
multiple tests, each with a different syntax.
content -- input text for the parser.
expected -- expected parse result.

Definition at line 15 of file idlnode_test.py.

15 def _run_test(self, syntax, content, expected):
16 """Utility run tests and prints extra contextual information.
17
18 Args:
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.
24 """
25 if syntax is None:
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)
29 return
30
31 actual = None
32 error = None
33 ast = None
34 parseResult = None
35 try:
36 parser = idlparser.IDLParser(syntax)
37 ast = parser.parse(content)
38 node = idlnode.IDLFile(ast)
39 actual = node.to_dict() if node else None
40 except SyntaxError as e:
41 error = e
42 pass
43 if actual == expected:
44 return
45 else:
46 msg = '''
47SYNTAX : %s
48CONTENT :
49%s
50EXPECTED:
51%s
52ACTUAL :
53%s
54ERROR : %s
55AST :
56%s
57 ''' % (syntax, content, expected, actual, error, ast)
58 self.fail(msg)
59

◆ test_annotations()

scripts.idlnode_test.IDLNodeTestCase.test_annotations (   self)

Definition at line 299 of file idlnode_test.py.

299 def test_annotations(self):
300 self._run_test(
301 idlparser.FREMONTCUT_SYNTAX,
302 '@Ano1 @Ano2() @Ano3(x=1) @Ano4(x,y=2) interface I {};', {
303 'interfaces': [{
304 'javascript_binding_name': 'I',
305 'doc_js_name': 'I',
306 'id': 'I',
307 'annotations': {
308 'Ano4': {
309 'y': '2',
310 'x': None
311 },
312 'Ano1': {},
313 'Ano2': {},
314 'Ano3': {
315 'x': '1'
316 }
317 }
318 }]
319 })
320 self._run_test(
321 idlparser.FREMONTCUT_SYNTAX, '''interface I : @Ano1 J {
322 @Ano2 attribute int someAttr;
323 @Ano3 void someOp();
324 @Ano3 const int someConst = 0;
325 };''', {
326 'interfaces': [{
327 'operations': [{
328 'annotations': {
329 'Ano3': {}
330 },
331 'type': {
332 'id': 'void'
333 },
334 'id': 'someOp',
335 'doc_js_interface_name': 'I'
336 }],
337 'javascript_binding_name':
338 'I',
339 'parents': [{
340 'type': {
341 'id': 'J'
342 },
343 'annotations': {
344 'Ano1': {}
345 }
346 }],
347 'attributes': [{
348 'annotations': {
349 'Ano2': {}
350 },
351 'type': {
352 'id': 'int'
353 },
354 'id': 'someAttr',
355 'doc_js_interface_name': 'I'
356 }],
357 'doc_js_name':
358 'I',
359 'id':
360 'I',
361 'constants': [{
362 'annotations': {
363 'Ano3': {}
364 },
365 'type': {
366 'id': 'int'
367 },
368 'id': 'someConst',
369 'value': '0',
370 'doc_js_interface_name': 'I'
371 }]
372 }]
373 })
374

◆ test_attributes()

scripts.idlnode_test.IDLNodeTestCase.test_attributes (   self)

Definition at line 123 of file idlnode_test.py.

123 def test_attributes(self):
124 self._run_test(
125 idlparser.WEBIDL_SYNTAX, '''interface I {
126 attribute long a1;
127 readonly attribute DOMString a2;
128 attribute any a3;
129 };''', {
130 'interfaces': [{
131 'javascript_binding_name':
132 'I',
133 'attributes': [{
134 'type': {
135 'id': 'long'
136 },
137 'id': 'a1',
138 'doc_js_interface_name': 'I'
139 },
140 {
141 'type': {
142 'id': 'DOMString'
143 },
144 'is_read_only': True,
145 'id': 'a2',
146 'doc_js_interface_name': 'I'
147 },
148 {
149 'type': {
150 'id': 'any'
151 },
152 'id': 'a3',
153 'doc_js_interface_name': 'I'
154 }],
155 'id':
156 'I',
157 'doc_js_name':
158 'I'
159 }]
160 })
161

◆ test_constants()

scripts.idlnode_test.IDLNodeTestCase.test_constants (   self)

Definition at line 231 of file idlnode_test.py.

231 def test_constants(self):
232 self._run_test(
233 None, '''interface I {
234 const long c1 = 0;
235 const long c2 = 1;
236 const long c3 = 0x01;
237 const long c4 = 10;
238 const boolean b1 = false;
239 const boolean b2 = true;
240 };''', {
241 'interfaces': [{
242 'javascript_binding_name':
243 'I',
244 'doc_js_name':
245 'I',
246 'id':
247 'I',
248 'constants': [{
249 'type': {
250 'id': 'long'
251 },
252 'id': 'c1',
253 'value': '0',
254 'doc_js_interface_name': 'I'
255 },
256 {
257 'type': {
258 'id': 'long'
259 },
260 'id': 'c2',
261 'value': '1',
262 'doc_js_interface_name': 'I'
263 },
264 {
265 'type': {
266 'id': 'long'
267 },
268 'id': 'c3',
269 'value': '0x01',
270 'doc_js_interface_name': 'I'
271 },
272 {
273 'type': {
274 'id': 'long'
275 },
276 'id': 'c4',
277 'value': '10',
278 'doc_js_interface_name': 'I'
279 },
280 {
281 'type': {
282 'id': 'boolean'
283 },
284 'id': 'b1',
285 'value': 'false',
286 'doc_js_interface_name': 'I'
287 },
288 {
289 'type': {
290 'id': 'boolean'
291 },
292 'id': 'b2',
293 'value': 'true',
294 'doc_js_interface_name': 'I'
295 }]
296 }]
297 })
298

◆ test_empty_interface()

scripts.idlnode_test.IDLNodeTestCase.test_empty_interface (   self)

Definition at line 66 of file idlnode_test.py.

66 def test_empty_interface(self):
67 self._run_test(
68 None, 'module TestModule { interface Interface1 {}; };', {
69 'modules': [{
70 'interfaces': [{
71 'javascript_binding_name': 'Interface1',
72 'doc_js_name': 'Interface1',
73 'id': 'Interface1'
74 }],
75 'id':
76 'TestModule'
77 }]
78 })
79

◆ test_empty_module()

scripts.idlnode_test.IDLNodeTestCase.test_empty_module (   self)

Definition at line 60 of file idlnode_test.py.

60 def test_empty_module(self):
61 self._run_test(None, 'module TestModule {};',
62 {'modules': [{
63 'id': 'TestModule'
64 }]})
65

◆ test_extended_attributes()

scripts.idlnode_test.IDLNodeTestCase.test_extended_attributes (   self)

Definition at line 87 of file idlnode_test.py.

87 def test_extended_attributes(self):
88 self._run_test(
89 idlparser.WEBKIT_SYNTAX,
90 'module M { interface [ExAt1, ExAt2] I {};};', {
91 'modules': [{
92 'interfaces': [{
93 'javascript_binding_name': 'I',
94 'doc_js_name': 'I',
95 'ext_attrs': {
96 'ExAt1': None,
97 'ExAt2': None
98 },
99 'id': 'I'
100 }],
101 'id':
102 'M'
103 }]
104 })
105

◆ test_gcc_preprocessor()

scripts.idlnode_test.IDLNodeTestCase.test_gcc_preprocessor (   self)

Definition at line 80 of file idlnode_test.py.

80 def test_gcc_preprocessor(self):
81 self._run_test(idlparser.WEBKIT_SYNTAX,
82 '#if 1\nmodule TestModule {};\n#endif\n',
83 {'modules': [{
84 'id': 'TestModule'
85 }]})
86

◆ test_implements_statement()

scripts.idlnode_test.IDLNodeTestCase.test_implements_statement (   self)

Definition at line 106 of file idlnode_test.py.

106 def test_implements_statement(self):
107 self._run_test(
108 idlparser.WEBIDL_SYNTAX, 'module M { X implements Y; };', {
109 'modules': [{
110 'implementsStatements': [{
111 'implementor': {
112 'id': 'X'
113 },
114 'implemented': {
115 'id': 'Y'
116 }
117 }],
118 'id':
119 'M'
120 }]
121 })
122

◆ test_inheritance()

scripts.idlnode_test.IDLNodeTestCase.test_inheritance (   self)

Definition at line 375 of file idlnode_test.py.

375 def test_inheritance(self):
376 self._run_test(
377 None,
378 'interface Shape {}; interface Rectangle : Shape {}; interface Square : Rectangle, Shape {};',
379 {
380 'interfaces': [{
381 'javascript_binding_name': 'Shape',
382 'doc_js_name': 'Shape',
383 'id': 'Shape'
384 },
385 {
386 'javascript_binding_name': 'Rectangle',
387 'doc_js_name': 'Rectangle',
388 'parents': [{
389 'type': {
390 'id': 'Shape'
391 }
392 }],
393 'id': 'Rectangle'
394 },
395 {
396 'javascript_binding_name':
397 'Square',
398 'doc_js_name':
399 'Square',
400 'parents': [{
401 'type': {
402 'id': 'Rectangle'
403 }
404 }, {
405 'type': {
406 'id': 'Shape'
407 }
408 }],
409 'id':
410 'Square'
411 }]
412 })
413
414

◆ test_operations()

scripts.idlnode_test.IDLNodeTestCase.test_operations (   self)

Definition at line 162 of file idlnode_test.py.

162 def test_operations(self):
163 self._run_test(
164 idlparser.WEBIDL_SYNTAX, '''interface I {
165 [ExAttr] t1 op1();
166 t2 op2(in int arg1, in long arg2);
167 getter any item(in long index);
168 };''', {
169 'interfaces': [{
170 'operations':
171 [{
172 'doc_js_interface_name': 'I',
173 'type': {
174 'id': 't1'
175 },
176 'ext_attrs': {
177 'ExAttr': None
178 },
179 'id': 'op1'
180 },
181 {
182 'doc_js_interface_name':
183 'I',
184 'type': {
185 'id': 't2'
186 },
187 'id':
188 'op2',
189 'arguments': [{
190 'type': {
191 'id': 'int'
192 },
193 'id': 'arg1'
194 }, {
195 'type': {
196 'id': 'long'
197 },
198 'id': 'arg2'
199 }]
200 },
201 {
202 'specials': ['getter'],
203 'doc_js_interface_name': 'I',
204 'type': {
205 'id': 'any'
206 },
207 'id': 'item',
208 'arguments': [{
209 'type': {
210 'id': 'long'
211 },
212 'id': 'index'
213 }]
214 },
215 {
216 'is_stringifier': True,
217 'type': {
218 'id': 'name'
219 },
220 'doc_js_interface_name': 'I'
221 }],
222 'javascript_binding_name':
223 'I',
224 'id':
225 'I',
226 'doc_js_name':
227 'I'
228 }]
229 })
230

The documentation for this class was generated from the following file: