summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/code_test.py
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2015-03-26 17:13:13 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-27 00:14:15 +0000
commit8ea16e11973638ad0aafa9681997fade9305bcff (patch)
tree224acb041a3b871edff03d03a89e009edaddc109 /tools/json_schema_compiler/code_test.py
parent164855329ada6f5ef96d2147fe38ae25111258c4 (diff)
downloadchromium_src-8ea16e11973638ad0aafa9681997fade9305bcff.zip
chromium_src-8ea16e11973638ad0aafa9681997fade9305bcff.tar.gz
chromium_src-8ea16e11973638ad0aafa9681997fade9305bcff.tar.bz2
[Extension API Extern Generation] Fix comment indentation
For extern comments, line wrapping sometimes has indentation. For instance: /** * @param {FooBar} This is some foobar * that has the comment wrapped. */ We should support this. Add an optional parameter to the Code Comment method to allow for comment indentation. BUG=461039 Review URL: https://codereview.chromium.org/1010603007 Cr-Commit-Position: refs/heads/master@{#322504}
Diffstat (limited to 'tools/json_schema_compiler/code_test.py')
-rwxr-xr-xtools/json_schema_compiler/code_test.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/tools/json_schema_compiler/code_test.py b/tools/json_schema_compiler/code_test.py
index ca36524..c6ca33f 100755
--- a/tools/json_schema_compiler/code_test.py
+++ b/tools/json_schema_compiler/code_test.py
@@ -117,14 +117,14 @@ class CodeTest(unittest.TestCase):
self.assertFalse(c.IsEmpty())
def testComment(self):
- long_comment = ('This comment is eighty nine characters in longness, '
- 'that is, to use another word, length')
+ long_comment = ('This comment is ninety one characters in longness, '
+ 'that is, using a different word, length.')
c = Code()
c.Comment(long_comment)
self.assertEquals(
- '// This comment is eighty nine characters '
- 'in longness, that is, to use another\n'
- '// word, length',
+ '// This comment is ninety one characters '
+ 'in longness, that is, using a different\n'
+ '// word, length.',
c.Render())
c = Code()
c.Sblock('sblock')
@@ -133,13 +133,13 @@ class CodeTest(unittest.TestCase):
c.Comment(long_comment)
self.assertEquals(
'sblock\n'
- ' // This comment is eighty nine characters '
- 'in longness, that is, to use\n'
- ' // another word, length\n'
+ ' // This comment is ninety one characters '
+ 'in longness, that is, using a\n'
+ ' // different word, length.\n'
'eblock\n'
- '// This comment is eighty nine characters in '
- 'longness, that is, to use another\n'
- '// word, length',
+ '// This comment is ninety one characters in '
+ 'longness, that is, using a different\n'
+ '// word, length.',
c.Render())
long_word = 'x' * 100
c = Code()
@@ -148,6 +148,14 @@ class CodeTest(unittest.TestCase):
'// ' + 'x' * 77 + '\n'
'// ' + 'x' * 23,
c.Render())
+ c = Code(indent_size=2, comment_length=40)
+ c.Comment('Pretend this is a Closure Compiler style comment, which should '
+ 'both wrap and indent', comment_prefix=' * ', wrap_indent=4)
+ self.assertEquals(
+ ' * Pretend this is a Closure Compiler\n'
+ ' * style comment, which should both\n'
+ ' * wrap and indent',
+ c.Render())
def testCommentWithSpecialCharacters(self):
c = Code()