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

Side by Side Diff: tools/json_schema_compiler/code_test.py

Issue 1010603007: [Extension API Extern Generation] Fix comment indentation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 from code import Code 6 from code import Code
7 import unittest 7 import unittest
8 8
9 class CodeTest(unittest.TestCase): 9 class CodeTest(unittest.TestCase):
10 def testAppend(self): 10 def testAppend(self):
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 '// word, length', 127 '// word, length',
128 c.Render()) 128 c.Render())
129 c = Code() 129 c = Code()
130 c.Sblock('sblock') 130 c.Sblock('sblock')
131 c.Comment(long_comment) 131 c.Comment(long_comment)
132 c.Eblock('eblock') 132 c.Eblock('eblock')
133 c.Comment(long_comment) 133 c.Comment(long_comment)
134 self.assertEquals( 134 self.assertEquals(
135 'sblock\n' 135 'sblock\n'
136 ' // This comment is eighty nine characters ' 136 ' // This comment is eighty nine characters '
137 'in longness, that is, to use\n' 137 'in longness, that is, to use\n'
Devlin 2015/03/26 22:36:54 Here, on an 80 char line, 'another' fits on the pr
Dan Beam 2015/03/26 22:41:49 hmmm, I'd just update. seems like an off-by-one er
Devlin 2015/03/26 23:13:08 Done.
138 ' // another word, length\n' 138 ' // another word, length\n'
139 'eblock\n' 139 'eblock\n'
140 '// This comment is eighty nine characters in ' 140 '// This comment is eighty nine characters in '
141 'longness, that is, to use another\n' 141 'longness, that is, to use another\n'
142 '// word, length', 142 '// word, length',
143 c.Render()) 143 c.Render())
144 long_word = 'x' * 100 144 long_word = 'x' * 100
145 c = Code() 145 c = Code()
146 c.Comment(long_word) 146 c.Comment(long_word)
147 self.assertEquals( 147 self.assertEquals(
148 '// ' + 'x' * 77 + '\n' 148 '// ' + 'x' * 77 + '\n'
149 '// ' + 'x' * 23, 149 '// ' + 'x' * 23,
150 c.Render()) 150 c.Render())
151 c = Code(indent_size=2, comment_length=40)
152 c.Comment('Pretend this is a Closure Compiler style comment, which should '
153 'both wrap and indent', comment_prefix=' * ', wrap_indent=4)
154 self.assertEquals(
155 ' * Pretend this is a Closure Compiler\n'
156 ' * style comment, which should both\n'
157 ' * wrap and indent',
158 c.Render())
151 159
152 def testCommentWithSpecialCharacters(self): 160 def testCommentWithSpecialCharacters(self):
153 c = Code() 161 c = Code()
154 c.Comment('20% of 80%s') 162 c.Comment('20% of 80%s')
155 c.Substitute({}) 163 c.Substitute({})
156 self.assertEquals('// 20% of 80%s', c.Render()) 164 self.assertEquals('// 20% of 80%s', c.Render())
157 d = Code() 165 d = Code()
158 d.Append('90') 166 d.Append('90')
159 d.Concat(c) 167 d.Concat(c)
160 self.assertEquals('90\n' 168 self.assertEquals('90\n'
161 '// 20% of 80%s', 169 '// 20% of 80%s',
162 d.Render()) 170 d.Render())
163 171
164 if __name__ == '__main__': 172 if __name__ == '__main__':
165 unittest.main() 173 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698