Flutter Engine
The Flutter Engine
idlrenderer_test.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5
6import idlnode
7import idlparser
8import idlrenderer
9import logging.config
10import unittest
11
12
13class IDLRendererTestCase(unittest.TestCase):
14
15 def _run_test(self, input_text, expected_text):
16 """Parses input, renders it and compares the results"""
17 parser = idlparser.IDLParser(idlparser.FREMONTCUT_SYNTAX)
18 idl_file = idlnode.IDLFile(parser.parse(input_text))
19 output_text = idlrenderer.render(idl_file)
20
21 if output_text != expected_text:
22 msg = '''
23EXPECTED:
24%s
25ACTUAL :
26%s
27''' % (expected_text, output_text)
28 self.fail(msg)
29
30 def test_rendering(self):
31 input_text = \
32 '''module M {
33 [Constructor(long x)] interface I : @A J, K {
34 attribute int attr;
35 readonly attribute long attr2;
36 getter attribute int get_attr;
37 setter attribute int set_attr;
38
39 [A,B=123] void function(in long x, in optional boolean y);
40
41 const boolean CONST = 1;
42
43 @A @B() @C(x) @D(x=1) @E(x,y=2)
44 void something();
45 };
46};
47@X module M2 {
48 @Y interface I {};
49};'''
50
51 expected_text = \
52 '''module M {
53 [Constructor(in long x)]
54 interface I :
55 @A J,
56 K {
57
58 /* Constants */
59 const boolean CONST = 1;
60
61 /* Attributes */
62 attribute int attr;
63 attribute long attr2;
64 getter attribute int get_attr;
65 setter attribute int set_attr;
66
67 /* Operations */
68 [A, B=123] void function(in long x, in optional boolean y);
69 @A @B @C(x) @D(x=1) @E(x, y=2) void something();
70 };
71};
72@X module M2 {
73 @Y
74 interface I {
75 };
76};
77'''
78 self._run_test(input_text, expected_text)
79
80
81if __name__ == "__main__":
82 logging.config.fileConfig("logging.conf")
83 if __name__ == '__main__':
84 unittest.main()
def _run_test(self, input_text, expected_text)
Dart_NativeFunction function
Definition: fuchsia.cc:51