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

Side by Side Diff: tools/telemetry/third_party/rope/ropetest/simplifytest.py

Issue 1132103009: Example of refactoring using rope library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
(Empty)
1 import unittest
2
3 from rope.base import simplify
4
5
6 class SimplifyTest(unittest.TestCase):
7
8 def setUp(self):
9 super(SimplifyTest, self).setUp()
10
11 def tearDown(self):
12 super(SimplifyTest, self).tearDown()
13
14 def test_trivial_case(self):
15 self.assertEquals('', simplify.real_code(''))
16
17 def test_empty_strs(self):
18 code = 's = ""\n'
19 self.assertEquals(code, simplify.real_code(code))
20
21 def test_blanking_strs(self):
22 code = 's = "..."\n'
23 self.assertEquals('s = " "\n', simplify.real_code(code))
24
25 def test_changing_to_double_quotes(self):
26 code = 's = \'\'\n'
27 self.assertEquals('s = ""\n', simplify.real_code(code))
28
29 def test_changing_to_double_quotes2(self):
30 code = 's = """\n"""\n'
31 self.assertEquals('s = " "\n', simplify.real_code(code))
32
33 def test_removing_comments(self):
34 code = '# c\n'
35 self.assertEquals(' \n', simplify.real_code(code))
36
37 def test_removing_comments_that_contain_strings(self):
38 code = '# "c"\n'
39 self.assertEquals(' \n', simplify.real_code(code))
40
41 def test_removing_strings_containing_comments(self):
42 code = '"#c"\n'
43 self.assertEquals('" "\n', simplify.real_code(code))
44
45 def test_joining_implicit_continuations(self):
46 code = '(\n)\n'
47 self.assertEquals('( )\n', simplify.real_code(code))
48
49 def test_joining_explicit_continuations(self):
50 code = '1 + \\\n 2\n'
51 self.assertEquals('1 + 2\n', simplify.real_code(code))
52
53 def test_replacing_tabs(self):
54 code = '1\t+\t2\n'
55 self.assertEquals('1 + 2\n', simplify.real_code(code))
56
57 def test_replacing_semicolons(self):
58 code = 'a = 1;b = 2\n'
59 self.assertEquals('a = 1\nb = 2\n', simplify.real_code(code))
60
61
62 def suite():
63 result = unittest.TestSuite()
64 result.addTests(unittest.makeSuite(SimplifyTest))
65 return result
66
67 if __name__ == '__main__':
68 unittest.main()
OLDNEW
« no previous file with comments | « tools/telemetry/third_party/rope/ropetest/runmodtest.py ('k') | tools/telemetry/third_party/rope/ropetest/testutils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698