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

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

Issue 1033223007: [Extension API Extern Generation] Support inline object definitions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Presubmit fix 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
« no previous file with comments | « tools/json_schema_compiler/code.py ('k') | tools/json_schema_compiler/h_generator.py » ('j') | 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 (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 30 matching lines...) Expand all
41 (b.Sblock('2') 41 (b.Sblock('2')
42 .Append('2') 42 .Append('2')
43 .Eblock('2') 43 .Eblock('2')
44 ) 44 )
45 c = Code() 45 c = Code()
46 (c.Sblock('1') 46 (c.Sblock('1')
47 .Concat(b) 47 .Concat(b)
48 .Append('1') 48 .Append('1')
49 .Eblock('1') 49 .Eblock('1')
50 ) 50 )
51 self.assertEquals( 51 self.assertMultiLineEqual(
52 '1\n' 52 '1\n'
53 ' 2\n' 53 ' 2\n'
54 ' 2\n' 54 ' 2\n'
55 ' 2\n' 55 ' 2\n'
56 ' 1\n' 56 ' 1\n'
57 '1', 57 '1',
58 c.Render()) 58 c.Render())
59 d = Code() 59 d = Code()
60 a = Code() 60 a = Code()
61 a.Concat(d) 61 a.Concat(d)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 c.Comment('20% of 80%s') 162 c.Comment('20% of 80%s')
163 c.Substitute({}) 163 c.Substitute({})
164 self.assertEquals('// 20% of 80%s', c.Render()) 164 self.assertEquals('// 20% of 80%s', c.Render())
165 d = Code() 165 d = Code()
166 d.Append('90') 166 d.Append('90')
167 d.Concat(c) 167 d.Concat(c)
168 self.assertEquals('90\n' 168 self.assertEquals('90\n'
169 '// 20% of 80%s', 169 '// 20% of 80%s',
170 d.Render()) 170 d.Render())
171 171
172 def testLinePrefixes(self):
173 c = Code()
174 c.Sblock(line='/**', line_prefix=' * ')
175 c.Sblock('@typedef {{')
176 c.Append('foo: bar,')
177 c.Sblock('baz: {')
178 c.Append('x: y')
179 c.Eblock('}')
180 c.Eblock('}}')
181 c.Eblock(line=' */')
182 output = c.Render()
183 self.assertMultiLineEqual(
184 '/**\n'
185 ' * @typedef {{\n'
186 ' * foo: bar,\n'
187 ' * baz: {\n'
188 ' * x: y\n'
189 ' * }\n'
190 ' * }}\n'
191 ' */',
192 output)
193
194 def testSameLineAppendAndConcat(self):
195 c = Code()
196 c.Append('This is a line.')
197 c.Append('This too.', new_line=False)
198 d = Code()
199 d.Append('And this.')
200 c.Concat(d, new_line=False)
201 self.assertEquals('This is a line.This too.And this.', c.Render())
202
172 if __name__ == '__main__': 203 if __name__ == '__main__':
173 unittest.main() 204 unittest.main()
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/code.py ('k') | tools/json_schema_compiler/h_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698