| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, 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 """Tests for dartgenerator.""" | 6 """Tests for dartgenerator.""" |
| 7 | 7 |
| 8 import logging.config | 8 import logging.config |
| 9 import os.path | 9 import os.path |
| 10 import re | 10 import re |
| 11 import shutil | 11 import shutil |
| 12 import tempfile | 12 import tempfile |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 # Only interfaces with (@A1 and @A2) or @A3 should be generated: | 161 # Only interfaces with (@A1 and @A2) or @A3 should be generated: |
| 162 self.assertTrue(self._InOutput('Shape')) | 162 self.assertTrue(self._InOutput('Shape')) |
| 163 self.assertTrue(self._InOutput('Rectangle')) | 163 self.assertTrue(self._InOutput('Rectangle')) |
| 164 self.assertFalse(self._InOutput('Line')) | 164 self.assertFalse(self._InOutput('Line')) |
| 165 | 165 |
| 166 # Only members with (@A1 and @A2) or @A3 should be generated: | 166 # Only members with (@A1 and @A2) or @A3 should be generated: |
| 167 # TODO(sra): make th | 167 # TODO(sra): make th |
| 168 self._AssertOutputSansHeaderEquals('Shape', """interface Shape { | 168 self._AssertOutputSansHeaderEquals('Shape', """interface Shape { |
| 169 | 169 |
| 170 int get attr(); | 170 final int attr; |
| 171 | 171 |
| 172 boolean op(); | 172 boolean op(); |
| 173 } | 173 } |
| 174 """) | 174 """) |
| 175 | 175 |
| 176 self._AssertOutputContains('Rectangle', | 176 self._AssertOutputContains('Rectangle', |
| 177 'interface Rectangle extends shapes::Shape') | 177 'interface Rectangle extends shapes::Shape') |
| 178 | 178 |
| 179 def testTypeRenames(self): | 179 def testTypeRenames(self): |
| 180 self._database.Load() | 180 self._database.Load() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 196 self._database.Load() | 196 self._database.Load() |
| 197 self._generator.FilterMembersWithUnidentifiedTypes(self._database) | 197 self._generator.FilterMembersWithUnidentifiedTypes(self._database) |
| 198 self._generator.ConvertToDartTypes(self._database) | 198 self._generator.ConvertToDartTypes(self._database) |
| 199 self._generator.Generate(self._database, self._output_dir) | 199 self._generator.Generate(self._database, self._output_dir) |
| 200 self._generator.Flush() | 200 self._generator.Flush() |
| 201 | 201 |
| 202 # Verify primitive conversions are working: | 202 # Verify primitive conversions are working: |
| 203 self._AssertOutputContains('Shape', | 203 self._AssertOutputContains('Shape', |
| 204 'static final int CONSTANT = 1') | 204 'static final int CONSTANT = 1') |
| 205 self._AssertOutputContains('Shape', | 205 self._AssertOutputContains('Shape', |
| 206 'String get strAttr();') | 206 'final String strAttr;') |
| 207 | 207 |
| 208 # Verify interface names are converted: | 208 # Verify interface names are converted: |
| 209 self._AssertOutputContains('Shape', | 209 self._AssertOutputContains('Shape', |
| 210 'interface Shape {') | 210 'interface Shape {') |
| 211 self._AssertOutputContains('Shape', | 211 self._AssertOutputContains('Shape', |
| 212 ' Shape create();') | 212 ' Shape create();') |
| 213 self._AssertOutputContains('Shape', | 213 self._AssertOutputContains('Shape', |
| 214 'void addLine(Line line);') | 214 'void addLine(Line line);') |
| 215 self._AssertOutputContains('Shape', | 215 self._AssertOutputContains('Shape', |
| 216 'Rectangle createRectangle();') | 216 'Rectangle createRectangle();') |
| (...skipping 11 matching lines...) Expand all Loading... |
| 228 # Verify template conversion: | 228 # Verify template conversion: |
| 229 # TODO(vsm): Re-enable when core collections are supported. | 229 # TODO(vsm): Re-enable when core collections are supported. |
| 230 # self._AssertOutputContains('rectangles', 'Rectangle', | 230 # self._AssertOutputContains('rectangles', 'Rectangle', |
| 231 # 'void someTemplatedType(List<Shape> list)') | 231 # 'void someTemplatedType(List<Shape> list)') |
| 232 | 232 |
| 233 | 233 |
| 234 if __name__ == '__main__': | 234 if __name__ == '__main__': |
| 235 logging.config.fileConfig('logging.conf') | 235 logging.config.fileConfig('logging.conf') |
| 236 if __name__ == '__main__': | 236 if __name__ == '__main__': |
| 237 unittest.main() | 237 unittest.main() |
| OLD | NEW |