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

Side by Side Diff: build/android/gyp/java_cpp_enum_tests.py

Issue 842043003: Use parens in multilne C++ -> Java enum generator directives. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « build/android/gyp/java_cpp_enum.py ('k') | no next file » | 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/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Tests for enum_preprocess.py. 6 """Tests for enum_preprocess.py.
7 7
8 This test suite containss various tests for the C++ -> Java enum generator. 8 This test suite containss various tests for the C++ -> Java enum generator.
9 """ 9 """
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // GENERATED_JAVA_ENUM_PACKAGE: test.namespace 218 // GENERATED_JAVA_ENUM_PACKAGE: test.namespace
219 enum class Foo: foo_type { 219 enum class Foo: foo_type {
220 FOO_A, 220 FOO_A,
221 }; 221 };
222 """.split('\n') 222 """.split('\n')
223 with self.assertRaises(Exception): 223 with self.assertRaises(Exception):
224 HeaderParser(test_data).ParseDefinitions() 224 HeaderParser(test_data).ParseDefinitions()
225 225
226 def testParseSimpleMultiLineDirective(self): 226 def testParseSimpleMultiLineDirective(self):
227 test_data = """ 227 test_data = """
228 // GENERATED_JAVA_ENUM_PACKAGE: \\ 228 // GENERATED_JAVA_ENUM_PACKAGE: (
229 // test.namespace 229 // test.namespace)
230 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: Bar 230 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: Bar
231 enum Foo { 231 enum Foo {
232 FOO_A, 232 FOO_A,
233 }; 233 };
234 """.split('\n') 234 """.split('\n')
235 definitions = HeaderParser(test_data).ParseDefinitions() 235 definitions = HeaderParser(test_data).ParseDefinitions()
236 self.assertEqual('test.namespace', definitions[0].enum_package) 236 self.assertEqual('test.namespace', definitions[0].enum_package)
237 self.assertEqual('Bar', definitions[0].class_name) 237 self.assertEqual('Bar', definitions[0].class_name)
238 238
239 def testParseMultiLineDirective(self): 239 def testParseMultiLineDirective(self):
240 test_data = """ 240 test_data = """
241 // GENERATED_JAVA_ENUM_PACKAGE: te\\ 241 // GENERATED_JAVA_ENUM_PACKAGE: (te
242 // st.name\\ 242 // st.name
243 // space 243 // space)
244 enum Foo { 244 enum Foo {
245 FOO_A, 245 FOO_A,
246 }; 246 };
247 """.split('\n') 247 """.split('\n')
248 definitions = HeaderParser(test_data).ParseDefinitions() 248 definitions = HeaderParser(test_data).ParseDefinitions()
249 self.assertEqual('test.namespace', definitions[0].enum_package) 249 self.assertEqual('test.namespace', definitions[0].enum_package)
250 250
251 def testParseMultiLineDirectiveWithOtherDirective(self): 251 def testParseMultiLineDirectiveWithOtherDirective(self):
252 test_data = """ 252 test_data = """
253 // GENERATED_JAVA_ENUM_PACKAGE: \\ 253 // GENERATED_JAVA_ENUM_PACKAGE: (
254 // test.namespace 254 // test.namespace)
255 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: \\ 255 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: (
256 // Ba\\ 256 // Ba
257 // r 257 // r
258 // )
258 enum Foo { 259 enum Foo {
259 FOO_A, 260 FOO_A,
260 }; 261 };
261 """.split('\n') 262 """.split('\n')
262 definitions = HeaderParser(test_data).ParseDefinitions() 263 definitions = HeaderParser(test_data).ParseDefinitions()
263 self.assertEqual('test.namespace', definitions[0].enum_package) 264 self.assertEqual('test.namespace', definitions[0].enum_package)
264 self.assertEqual('Bar', definitions[0].class_name) 265 self.assertEqual('Bar', definitions[0].class_name)
265 266
266 def testParseMalformedMultiLineDirectiveWithOtherDirective(self): 267 def testParseMalformedMultiLineDirectiveWithOtherDirective(self):
267 test_data = """ 268 test_data = """
268 // GENERATED_JAVA_ENUM_PACKAGE: \\ 269 // GENERATED_JAVA_ENUM_PACKAGE: (
269 // test.name\\ 270 // test.name
270 // space\\ 271 // space
271 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: Bar 272 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: Bar
272 enum Foo { 273 enum Foo {
273 FOO_A, 274 FOO_A,
274 }; 275 };
275 """.split('\n') 276 """.split('\n')
276 with self.assertRaises(Exception): 277 with self.assertRaises(Exception):
277 HeaderParser(test_data).ParseDefinitions() 278 HeaderParser(test_data).ParseDefinitions()
278 279
279 def testParseMalformedMultiLineDirective(self): 280 def testParseMalformedMultiLineDirective(self):
280 test_data = """ 281 test_data = """
281 // GENERATED_JAVA_ENUM_PACKAGE: \\ 282 // GENERATED_JAVA_ENUM_PACKAGE: (
282 // test.name\\ 283 // test.name
283 // space\\ 284 // space
284 enum Foo { 285 enum Foo {
285 FOO_A, 286 FOO_A,
286 }; 287 };
287 """.split('\n') 288 """.split('\n')
288 with self.assertRaises(Exception): 289 with self.assertRaises(Exception):
289 HeaderParser(test_data).ParseDefinitions() 290 HeaderParser(test_data).ParseDefinitions()
290 291
291 def testParseMalformedMultiLineDirectiveShort(self): 292 def testParseMalformedMultiLineDirectiveShort(self):
292 test_data = """ 293 test_data = """
293 // GENERATED_JAVA_ENUM_PACKAGE: \\ 294 // GENERATED_JAVA_ENUM_PACKAGE: (
294 enum Foo { 295 enum Foo {
295 FOO_A, 296 FOO_A,
296 }; 297 };
297 """.split('\n') 298 """.split('\n')
298 with self.assertRaises(Exception): 299 with self.assertRaises(Exception):
299 HeaderParser(test_data).ParseDefinitions() 300 HeaderParser(test_data).ParseDefinitions()
300 301
301 def testEnumValueAssignmentNoneDefined(self): 302 def testEnumValueAssignmentNoneDefined(self):
302 definition = EnumDefinition(original_enum_name='c', enum_package='p') 303 definition = EnumDefinition(original_enum_name='c', enum_package='p')
303 definition.AppendEntry('A', None) 304 definition.AppendEntry('A', None)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 options, _ = parser.parse_args(argv) 409 options, _ = parser.parse_args(argv)
409 410
410 suite = unittest.TestLoader().loadTestsFromTestCase(TestPreprocess) 411 suite = unittest.TestLoader().loadTestsFromTestCase(TestPreprocess)
411 unittest.TextTestRunner(verbosity=0).run(suite) 412 unittest.TextTestRunner(verbosity=0).run(suite)
412 413
413 if options.stamp: 414 if options.stamp:
414 build_utils.Touch(options.stamp) 415 build_utils.Touch(options.stamp)
415 416
416 if __name__ == '__main__': 417 if __name__ == '__main__':
417 main(sys.argv[1:]) 418 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « build/android/gyp/java_cpp_enum.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698