OLD | NEW |
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 '/**\n' | 184 '/**\n' |
185 ' * @typedef {{\n' | 185 ' * @typedef {{\n' |
186 ' * foo: bar,\n' | 186 ' * foo: bar,\n' |
187 ' * baz: {\n' | 187 ' * baz: {\n' |
188 ' * x: y\n' | 188 ' * x: y\n' |
189 ' * }\n' | 189 ' * }\n' |
190 ' * }}\n' | 190 ' * }}\n' |
191 ' */', | 191 ' */', |
192 output) | 192 output) |
193 | 193 |
194 def testSameLineAppendAndConcat(self): | 194 def testSameLineAppendConcatComment(self): |
195 c = Code() | 195 c = Code() |
196 c.Append('This is a line.') | 196 c.Append('This is a line.') |
197 c.Append('This too.', new_line=False) | 197 c.Append('This too.', new_line=False) |
198 d = Code() | 198 d = Code() |
199 d.Append('And this.') | 199 d.Append('And this.') |
200 c.Concat(d, new_line=False) | 200 c.Concat(d, new_line=False) |
201 self.assertEquals('This is a line.This too.And this.', c.Render()) | 201 self.assertEquals('This is a line.This too.And this.', c.Render()) |
| 202 c = Code() |
| 203 c.Append('This is a') |
| 204 c.Comment(' spectacular 80-character line thingy ' + |
| 205 'that fits wonderfully everywhere.', |
| 206 comment_prefix='', |
| 207 new_line=False) |
| 208 self.assertEquals('This is a spectacular 80-character line thingy that ' + |
| 209 'fits wonderfully everywhere.', |
| 210 c.Render()) |
202 | 211 |
203 if __name__ == '__main__': | 212 if __name__ == '__main__': |
204 unittest.main() | 213 unittest.main() |
OLD | NEW |