Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: client/dom/scripts/idlnode_test.py

Issue 9403004: Wrapperless dart:html generator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version to check in. changes generator script but doesn't check in an active version of the … Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/dom/scripts/idlnode.py ('k') | client/dom/scripts/systembase.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 import idlnode 6 import idlnode
7 import idlparser 7 import idlparser
8 import logging.config 8 import logging.config
9 import sys 9 import sys
10 import unittest 10 import unittest
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 def test_empty_module(self): 60 def test_empty_module(self):
61 self._run_test( 61 self._run_test(
62 None, 62 None,
63 'module TestModule {};', 63 'module TestModule {};',
64 {'modules': [{'id': 'TestModule'}]}) 64 {'modules': [{'id': 'TestModule'}]})
65 65
66 def test_empty_interface(self): 66 def test_empty_interface(self):
67 self._run_test( 67 self._run_test(
68 None, 68 None,
69 'module TestModule { interface Interface1 {}; };', 69 'module TestModule { interface Interface1 {}; };',
70 {'modules': [{'interfaces': [{'id': 'Interface1'}], 'id': 'TestModule'}]}) 70 {'modules': [{'interfaces': [{'javascript_binding_name': 'Interface1', 'id ': 'Interface1'}], 'id': 'TestModule'}]})
71 71
72 def test_gcc_preprocessor(self): 72 def test_gcc_preprocessor(self):
73 self._run_test( 73 self._run_test(
74 idlparser.WEBKIT_SYNTAX, 74 idlparser.WEBKIT_SYNTAX,
75 '#if 1\nmodule TestModule {};\n#endif\n', 75 '#if 1\nmodule TestModule {};\n#endif\n',
76 {'modules': [{'id': 'TestModule'}]}) 76 {'modules': [{'id': 'TestModule'}]})
77 77
78 def test_extended_attributes(self): 78 def test_extended_attributes(self):
79 self._run_test( 79 self._run_test(
80 idlparser.WEBKIT_SYNTAX, 80 idlparser.WEBKIT_SYNTAX,
81 'module M { interface [ExAt1, ExAt2] I {};};', 81 'module M { interface [ExAt1, ExAt2] I {};};',
82 {'modules': [{'interfaces': [{'id': 'I', 'ext_attrs': {'ExAt1': None, 'ExA t2': None}}], 'id': 'M'}]}) 82 {'modules': [{'interfaces': [{'javascript_binding_name': 'I', 'ext_attrs': {'ExAt1': None, 'ExAt2': None}, 'id': 'I'}], 'id': 'M'}]})
83 83
84 def test_implements_statement(self): 84 def test_implements_statement(self):
85 self._run_test( 85 self._run_test(
86 idlparser.WEBIDL_SYNTAX, 86 idlparser.WEBIDL_SYNTAX,
87 'module M { X implements Y; };', 87 'module M { X implements Y; };',
88 {'modules': [{'implementsStatements': [{'implementor': {'id': 'X'}, 'imple mented': {'id': 'Y'}}], 'id': 'M'}]}) 88 {'modules': [{'implementsStatements': [{'implementor': {'id': 'X'}, 'imple mented': {'id': 'Y'}}], 'id': 'M'}]})
89 89
90 def test_attributes(self): 90 def test_attributes(self):
91 self._run_test( 91 self._run_test(
92 idlparser.WEBIDL_SYNTAX, 92 idlparser.WEBIDL_SYNTAX,
93 '''interface I { 93 '''interface I {
94 attribute long a1; 94 attribute long a1;
95 readonly attribute DOMString a2; 95 readonly attribute DOMString a2;
96 attribute any a3; 96 attribute any a3;
97 };''', 97 };''',
98 {'interfaces': [{'attributes': [{'type': {'id': 'long'}, 'id': 'a1'}, {'ty pe': {'id': 'DOMString'}, 'is_read_only': True, 'id': 'a2'}, {'type': {'id': 'an y'}, 'id': 'a3'}], 'id': 'I'}]}) 98 {'interfaces': [{'javascript_binding_name': 'I', 'attributes': [{'type': { 'id': 'long'}, 'id': 'a1'}, {'type': {'id': 'DOMString'}, 'is_read_only': True, 'id': 'a2'}, {'type': {'id': 'any'}, 'id': 'a3'}], 'id': 'I'}]})
99 99
100 def test_operations(self): 100 def test_operations(self):
101 self._run_test( 101 self._run_test(
102 idlparser.WEBIDL_SYNTAX, 102 idlparser.WEBIDL_SYNTAX,
103 '''interface I { 103 '''interface I {
104 [ExAttr] t1 op1(); 104 [ExAttr] t1 op1();
105 t2 op2(in int arg1, in long arg2); 105 t2 op2(in int arg1, in long arg2);
106 getter any item(in long index); 106 getter any item(in long index);
107 stringifier name(); 107 stringifier name();
108 };''', 108 };''',
109 {'interfaces': [{'operations': [{'type': {'id': 't1'}, 'id': 'op1', 'ext_a ttrs': {'ExAttr': None}}, {'type': {'id': 't2'}, 'id': 'op2', 'arguments': [{'ty pe': {'id': 'int'}, 'id': 'arg1'}, {'type': {'id': 'long'}, 'id': 'arg2'}]}, {'s pecials': ['getter'], 'type': {'id': 'any'}, 'id': 'item', 'arguments': [{'type' : {'id': 'long'}, 'id': 'index'}]}, {'is_stringifier': True, 'type': {'id': 'nam e'}}], 'id': 'I'}]}) 109 {'interfaces': [{'operations': [{'type': {'id': 't1'}, 'ext_attrs': {'ExAt tr': None}, 'id': 'op1'}, {'type': {'id': 't2'}, 'id': 'op2', 'arguments': [{'ty pe': {'id': 'int'}, 'id': 'arg1'}, {'type': {'id': 'long'}, 'id': 'arg2'}]}, {'s pecials': ['getter'], 'type': {'id': 'any'}, 'id': 'item', 'arguments': [{'type' : {'id': 'long'}, 'id': 'index'}]}, {'is_stringifier': True, 'type': {'id': 'nam e'}}], 'javascript_binding_name': 'I', 'id': 'I'}]})
110 110
111 def test_constants(self): 111 def test_constants(self):
112 self._run_test( 112 self._run_test(
113 None, 113 None,
114 '''interface I { 114 '''interface I {
115 const long c1 = 0; 115 const long c1 = 0;
116 const long c2 = 1; 116 const long c2 = 1;
117 const long c3 = 0x01; 117 const long c3 = 0x01;
118 const long c4 = 10; 118 const long c4 = 10;
119 const boolean b1 = false; 119 const boolean b1 = false;
120 const boolean b2 = true; 120 const boolean b2 = true;
121 };''', 121 };''',
122 {'interfaces': [{'id': 'I', 'constants': [{'type': {'id': 'long'}, 'id': ' c1', 'value': '0'}, {'type': {'id': 'long'}, 'id': 'c2', 'value': '1'}, {'type': {'id': 'long'}, 'id': 'c3', 'value': '0x01'}, {'type': {'id': 'long'}, 'id': 'c 4', 'value': '10'}, {'type': {'id': 'boolean'}, 'id': 'b1', 'value': 'false'}, { 'type': {'id': 'boolean'}, 'id': 'b2', 'value': 'true'}]}]}) 122 {'interfaces': [{'javascript_binding_name': 'I', 'id': 'I', 'constants': [ {'type': {'id': 'long'}, 'id': 'c1', 'value': '0'}, {'type': {'id': 'long'}, 'id ': 'c2', 'value': '1'}, {'type': {'id': 'long'}, 'id': 'c3', 'value': '0x01'}, { 'type': {'id': 'long'}, 'id': 'c4', 'value': '10'}, {'type': {'id': 'boolean'}, 'id': 'b1', 'value': 'false'}, {'type': {'id': 'boolean'}, 'id': 'b2', 'value': 'true'}]}]})
123 123
124 def test_annotations(self): 124 def test_annotations(self):
125 self._run_test( 125 self._run_test(
126 idlparser.FREMONTCUT_SYNTAX, 126 idlparser.FREMONTCUT_SYNTAX,
127 '@Ano1 @Ano2() @Ano3(x=1) @Ano4(x,y=2) interface I {};', 127 '@Ano1 @Ano2() @Ano3(x=1) @Ano4(x,y=2) interface I {};',
128 {'interfaces': [{'id': 'I', 'annotations': {'Ano4': {'y': '2', 'x': None}, 'Ano1': {}, 'Ano2': {}, 'Ano3': {'x': '1'}}}]}) 128 {'interfaces': [{'javascript_binding_name': 'I', 'id': 'I', 'annotations': {'Ano4': {'y': '2', 'x': None}, 'Ano1': {}, 'Ano2': {}, 'Ano3': {'x': '1'}}}]})
129 self._run_test( 129 self._run_test(
130 idlparser.FREMONTCUT_SYNTAX, 130 idlparser.FREMONTCUT_SYNTAX,
131 '''interface I : @Ano1 J { 131 '''interface I : @Ano1 J {
132 @Ano2 attribute int someAttr; 132 @Ano2 attribute int someAttr;
133 @Ano3 void someOp(); 133 @Ano3 void someOp();
134 @Ano3 const int someConst = 0; 134 @Ano3 const int someConst = 0;
135 };''', 135 };''',
136 {'interfaces': [{'operations': [{'type': {'id': 'void'}, 'id': 'someOp', ' annotations': {'Ano3': {}}}], 'attributes': [{'type': {'id': 'int'}, 'id': 'some Attr', 'annotations': {'Ano2': {}}}], 'parents': [{'type': {'id': 'J'}, 'annotat ions': {'Ano1': {}}}], 'id': 'I', 'constants': [{'type': {'id': 'int'}, 'annotat ions': {'Ano3': {}}, 'value': '0', 'id': 'someConst'}]}]}) 136 {'interfaces': [{'operations': [{'type': {'id': 'void'}, 'id': 'someOp', ' annotations': {'Ano3': {}}}], 'javascript_binding_name': 'I', 'parents': [{'type ': {'id': 'J'}, 'annotations': {'Ano1': {}}}], 'attributes': [{'type': {'id': 'i nt'}, 'id': 'someAttr', 'annotations': {'Ano2': {}}}], 'id': 'I', 'constants': [ {'type': {'id': 'int'}, 'id': 'someConst', 'value': '0', 'annotations': {'Ano3': {}}}]}]})
137 137
138 def test_inheritance(self): 138 def test_inheritance(self):
139 self._run_test( 139 self._run_test(
140 None, 140 None,
141 'interface Shape {}; interface Rectangle : Shape {}; interface Square : Re ctangle, Shape {};', 141 'interface Shape {}; interface Rectangle : Shape {}; interface Square : Re ctangle, Shape {};',
142 {'interfaces': [{'id': 'Shape'}, {'parents': [{'type': {'id': 'Shape'}}], 'id': 'Rectangle'}, {'parents': [{'type': {'id': 'Rectangle'}}, {'type': {'id': 'Shape'}}], 'id': 'Square'}]}) 142 {'interfaces': [{'javascript_binding_name': 'Shape', 'id': 'Shape'}, {'jav ascript_binding_name': 'Rectangle', 'parents': [{'type': {'id': 'Shape'}}], 'id' : 'Rectangle'}, {'javascript_binding_name': 'Square', 'parents': [{'type': {'id' : 'Rectangle'}}, {'type': {'id': 'Shape'}}], 'id': 'Square'}]})
143 143
144 if __name__ == "__main__": 144 if __name__ == "__main__":
145 logging.config.fileConfig("logging.conf") 145 logging.config.fileConfig("logging.conf")
146 if __name__ == '__main__': 146 if __name__ == '__main__':
147 unittest.main() 147 unittest.main()
OLDNEW
« no previous file with comments | « client/dom/scripts/idlnode.py ('k') | client/dom/scripts/systembase.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698