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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

Issue 2305143003: webkitpy: Make all regex strings use raw string literals. (Closed)
Patch Set: Make all regex strings raw strings. Created 4 years, 3 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 # -*- coding: utf-8; -*- 1 # -*- coding: utf-8; -*-
2 # 2 #
3 # Copyright (C) 2011 Google Inc. All rights reserved. 3 # Copyright (C) 2011 Google Inc. All rights reserved.
4 # Copyright (C) 2009 Torch Mobile Inc. 4 # Copyright (C) 2009 Torch Mobile Inc.
5 # Copyright (C) 2009 Apple Inc. All rights reserved. 5 # Copyright (C) 2009 Apple Inc. All rights reserved.
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
7 # 7 #
8 # Redistribution and use in source and binary forms, with or without 8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are 9 # modification, are permitted provided that the following conditions are
10 # met: 10 # met:
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 file_path = 'mydir/Foo.h' 2247 file_path = 'mydir/Foo.h'
2248 2248
2249 # We can't rely on our internal stuff to get a sane path on the open sou rce 2249 # We can't rely on our internal stuff to get a sane path on the open sou rce
2250 # side of things, so just parse out the suggested header guard. This 2250 # side of things, so just parse out the suggested header guard. This
2251 # doesn't allow us to test the suggested header guard, but it does let u s 2251 # doesn't allow us to test the suggested header guard, but it does let u s
2252 # test all the other header tests. 2252 # test all the other header tests.
2253 error_collector = ErrorCollector(self.assertTrue) 2253 error_collector = ErrorCollector(self.assertTrue)
2254 self.process_file_data(file_path, 'h', [], error_collector) 2254 self.process_file_data(file_path, 'h', [], error_collector)
2255 expected_guard = '' 2255 expected_guard = ''
2256 matcher = re.compile( 2256 matcher = re.compile(
2257 'No \#ifndef header guard found\, suggested CPP variable is\: ([A-Za -z_0-9]+) ') 2257 r'No \#ifndef header guard found\, suggested CPP variable is\: ([A-Z a-z_0-9]+) ')
2258 for error in error_collector.result_list(): 2258 for error in error_collector.result_list():
2259 matches = matcher.match(error) 2259 matches = matcher.match(error)
2260 if matches: 2260 if matches:
2261 expected_guard = matches.group(1) 2261 expected_guard = matches.group(1)
2262 break 2262 break
2263 2263
2264 # Make sure we extracted something for our header guard. 2264 # Make sure we extracted something for our header guard.
2265 self.assertNotEqual(expected_guard, '') 2265 self.assertNotEqual(expected_guard, '')
2266 2266
2267 # Wrong guard 2267 # Wrong guard
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 self.assertEqual('"', collapse('"\\\\\\"')) # "\\\" (bad) 2686 self.assertEqual('"', collapse('"\\\\\\"')) # "\\\" (bad)
2687 self.assertEqual('""', collapse('"\\\\\\\\"')) # "\\\\" (string) 2687 self.assertEqual('""', collapse('"\\\\\\\\"')) # "\\\\" (string)
2688 2688
2689 self.assertEqual('\'\'', collapse('\'\'')) # '' (empty) 2689 self.assertEqual('\'\'', collapse('\'\'')) # '' (empty)
2690 self.assertEqual('\'\'', collapse('\'a\'')) # 'a' (char) 2690 self.assertEqual('\'\'', collapse('\'a\'')) # 'a' (char)
2691 self.assertEqual('\'\'', collapse('\'\\\'\'')) # '\'' (char) 2691 self.assertEqual('\'\'', collapse('\'\\\'\'')) # '\'' (char)
2692 self.assertEqual('\'', collapse('\'\\\'')) # '\' (bad) 2692 self.assertEqual('\'', collapse('\'\\\'')) # '\' (bad)
2693 self.assertEqual('', collapse('\\012')) # '\012' (char) 2693 self.assertEqual('', collapse('\\012')) # '\012' (char)
2694 self.assertEqual('', collapse('\\xfF0')) # '\xfF0' (char) 2694 self.assertEqual('', collapse('\\xfF0')) # '\xfF0' (char)
2695 self.assertEqual('', collapse('\\n')) # '\n' (char) 2695 self.assertEqual('', collapse('\\n')) # '\n' (char)
2696 self.assertEqual('\#', collapse('\\#')) # '\#' (bad) 2696 self.assertEqual('\\#', collapse('\\#')) # '\#' (bad)
2697 2697
2698 self.assertEqual('StringReplace(body, "", "");', 2698 self.assertEqual('StringReplace(body, "", "");',
2699 collapse('StringReplace(body, "\\\\", "\\\\\\\\");')) 2699 collapse('StringReplace(body, "\\\\", "\\\\\\\\");'))
2700 self.assertEqual('\'\' ""', 2700 self.assertEqual('\'\' ""',
2701 collapse('\'"\' "foo"')) 2701 collapse('\'"\' "foo"'))
2702 self.assertEqual('""', collapse('"a" "b" "c"')) 2702 self.assertEqual('""', collapse('"a" "b" "c"'))
2703 2703
2704 2704
2705 class OrderOfIncludesTest(CppStyleTestBase): 2705 class OrderOfIncludesTest(CppStyleTestBase):
2706 2706
(...skipping 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after
5260 def test_ne(self): 5260 def test_ne(self):
5261 """Test __ne__ inequality function.""" 5261 """Test __ne__ inequality function."""
5262 checker1 = self._checker() 5262 checker1 = self._checker()
5263 checker2 = self._checker() 5263 checker2 = self._checker()
5264 5264
5265 # != calls __ne__. 5265 # != calls __ne__.
5266 # By default, __ne__ always returns true on different objects. 5266 # By default, __ne__ always returns true on different objects.
5267 # Thus, just check the distinguishing case to verify that the 5267 # Thus, just check the distinguishing case to verify that the
5268 # code defines __ne__. 5268 # code defines __ne__.
5269 self.assertFalse(checker1 != checker2) 5269 self.assertFalse(checker1 != checker2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698