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

Unified Diff: build/android/gyp/java_cpp_enum_tests.py

Issue 2503763004: Fix comment preservation in java_cpp_enum.py. (Closed)
Patch Set: Create separate test for comment preservation w/prefix-stripping Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/gyp/java_cpp_enum.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/java_cpp_enum_tests.py
diff --git a/build/android/gyp/java_cpp_enum_tests.py b/build/android/gyp/java_cpp_enum_tests.py
index b3cef7cdad9658f7a21adb13556784fe2f6df39d..793461e060e9d8c77c6f71303a12fb393ebc1a08 100755
--- a/build/android/gyp/java_cpp_enum_tests.py
+++ b/build/android/gyp/java_cpp_enum_tests.py
@@ -202,7 +202,7 @@ public class ClassName {
('B', 1)]),
definition.entries)
- def testParseTwoEnums(self):
+ def testParsePreservesCommentsWhenPrefixStripping(self):
test_data = """
// GENERATED_JAVA_ENUM_PACKAGE: test.namespace
enum EnumOne {
@@ -232,17 +232,50 @@ public class ClassName {
self.assertEqual(collections.OrderedDict([('A', '1'),
('B', 'A')]),
definition.entries)
- self.assertEqual(collections.OrderedDict([('ENUM_ONE_B', 'Comment there')]),
+ self.assertEqual(collections.OrderedDict([('B', 'Comment there')]),
definition.comments)
definition = definitions[1]
self.assertEqual('EnumTwo', definition.class_name)
self.assertEqual('other.package', definition.enum_package)
self.assertEqual(collections.OrderedDict(
- [('P_B', 'This comment spans two lines.')]), definition.comments)
+ [('B', 'This comment spans two lines.')]), definition.comments)
self.assertEqual(collections.OrderedDict([('A', 0),
('B', 1)]),
definition.entries)
+ def testParseTwoEnums(self):
+ test_data = """
+ // GENERATED_JAVA_ENUM_PACKAGE: test.namespace
+ enum AnEnum {
+ ENUM_ONE_A = 1,
+ ENUM_ONE_B = A,
+ };
+
+ enum EnumIgnore {
+ C, D, E
+ };
+
+ // GENERATED_JAVA_ENUM_PACKAGE: other.package
+ enum EnumTwo {
+ P_A,
+ P_B
+ };
+ """.split('\n')
+ definitions = HeaderParser(test_data).ParseDefinitions()
+ self.assertEqual(2, len(definitions))
+ definition = definitions[0]
+ self.assertEqual('AnEnum', definition.class_name)
+ self.assertEqual('test.namespace', definition.enum_package)
+ self.assertEqual(collections.OrderedDict([('ENUM_ONE_A', '1'),
+ ('ENUM_ONE_B', 'A')]),
+ definition.entries)
+ definition = definitions[1]
+ self.assertEqual('EnumTwo', definition.class_name)
+ self.assertEqual('other.package', definition.enum_package)
+ self.assertEqual(collections.OrderedDict([('P_A', 0),
+ ('P_B', 1)]),
+ definition.entries)
+
def testParseThrowsOnUnknownDirective(self):
test_data = """
// GENERATED_JAVA_UNKNOWN: Value
« 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