diff options
| author | Steve Block <steveblock@google.com> | 2009-11-05 09:23:40 +0000 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2009-11-10 22:41:12 +0000 |
| commit | cac0f67c402d107cdb10971b95719e2ff9c7c76b (patch) | |
| tree | d182c7f87211c6f201a5f038e332336493ebdbe7 /WebKitTools/Scripts/modules/cpp_style_unittest.py | |
| parent | 4b2ef0f288e7c6c4602f621b7a0e9feed304b70e (diff) | |
| download | external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.zip external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.gz external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.bz2 | |
Merge webkit.org at r50258 : Initial merge by git.
Change-Id: I1a9e1dc4ed654b69174ad52a4f031a07240f37b0
Diffstat (limited to 'WebKitTools/Scripts/modules/cpp_style_unittest.py')
| -rw-r--r-- | WebKitTools/Scripts/modules/cpp_style_unittest.py | 100 |
1 files changed, 79 insertions, 21 deletions
diff --git a/WebKitTools/Scripts/modules/cpp_style_unittest.py b/WebKitTools/Scripts/modules/cpp_style_unittest.py index 322356e..d5637f4 100644 --- a/WebKitTools/Scripts/modules/cpp_style_unittest.py +++ b/WebKitTools/Scripts/modules/cpp_style_unittest.py @@ -1265,6 +1265,12 @@ class CppStyleTest(CppStyleTestBase): self.assert_lint('a<Foo&> t <<= &b | &c;', '') self.assert_lint('a<Foo*> t <<= &b & &c; // Test', '') self.assert_lint('a<Foo*> t <<= *b / &c; // Test', '') + self.assert_lint('if (a=b == 1)', 'Missing spaces around = [whitespace/operators] [4]') + self.assert_lint('a = 1<<20', 'Missing spaces around << [whitespace/operators] [3]') + self.assert_lint('if (a = b == 1)', '') + self.assert_lint('a = 1 << 20', '') + self.assert_multi_line_lint('#include "config.h"\n#include <sys/io.h>\n', + '') def test_spacing_before_last_semicolon(self): self.assert_lint('call_function() ;', @@ -2806,40 +2812,39 @@ class WebKitStyleTest(CppStyleTestBase): 'Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3]') # FIXME: No tests for 8-spaces. - # 3. In a header, code inside a namespace should be indented. + # 3. In a header, code inside a namespace should not be indented. self.assert_multi_line_lint( 'namespace WebCore {\n\n' - ' class Document {\n' - ' int myVariable;\n' - ' };\n' + 'class Document {\n' + ' int myVariable;\n' + '};\n' '}', '', 'foo.h') self.assert_multi_line_lint( 'namespace OuterNamespace {\n' ' namespace InnerNamespace {\n' - ' class Document {\n' - ' };\n' - ' };\n' + ' class Document {\n' + '};\n' + '};\n' '}', - '', + ['Code inside a namespace should not be indented. [whitespace/indent] [4]', 'namespace should never be indented. [whitespace/indent] [4]'], 'foo.h') self.assert_multi_line_lint( 'namespace WebCore {\n' '#if 0\n' ' class Document {\n' - ' };\n' + '};\n' '#endif\n' '}', - '', + 'Code inside a namespace should not be indented. [whitespace/indent] [4]', 'foo.h') self.assert_multi_line_lint( 'namespace WebCore {\n' 'class Document {\n' '};\n' '}', - 'In a header, code inside a namespace should be indented.' - ' [whitespace/indent] [4]', + '', 'foo.h') # 4. In an implementation file (files with the extension .cpp, .c @@ -2858,14 +2863,52 @@ class WebKitStyleTest(CppStyleTestBase): 'namespace OuterNamespace {\n' 'namespace InnerNamespace {\n' 'Document::Foo() { }\n' - '}', - '', + ' void* p;\n' + '}\n' + '}\n', + 'Code inside a namespace should not be indented. [whitespace/indent] [4]', 'foo.cpp') self.assert_multi_line_lint( - ' namespace WebCore {\n\n' - 'start: // Pointless code, but tests the label regexp.\n' - ' goto start;\n' - ' }', + 'namespace OuterNamespace {\n' + 'namespace InnerNamespace {\n' + 'Document::Foo() { }\n' + '}\n' + ' void* p;\n' + '}\n', + 'Code inside a namespace should not be indented. [whitespace/indent] [4]', + 'foo.cpp') + self.assert_multi_line_lint( + 'namespace WebCore {\n\n' + ' const char* foo = "start:;"\n' + ' "dfsfsfs";\n' + '}\n', + 'Code inside a namespace should not be indented. [whitespace/indent] [4]', + 'foo.cpp') + self.assert_multi_line_lint( + 'namespace WebCore {\n\n' + 'const char* foo(void* a = ";", // ;\n' + ' void* b);\n' + ' void* p;\n' + '}\n', + 'Code inside a namespace should not be indented. [whitespace/indent] [4]', + 'foo.cpp') + self.assert_multi_line_lint( + 'namespace WebCore {\n\n' + 'const char* foo[] = {\n' + ' "void* b);", // ;\n' + ' "asfdf",\n' + ' }\n' + ' void* p;\n' + '}\n', + 'Code inside a namespace should not be indented. [whitespace/indent] [4]', + 'foo.cpp') + self.assert_multi_line_lint( + 'namespace WebCore {\n\n' + 'const char* foo[] = {\n' + ' "void* b);", // }\n' + ' "asfdf",\n' + ' }\n' + '}\n', '', 'foo.cpp') self.assert_multi_line_lint( @@ -2875,15 +2918,30 @@ class WebKitStyleTest(CppStyleTestBase): 'start: // infinite loops are fun!\n' ' goto start;\n' ' }', - '', + 'namespace should never be indented. [whitespace/indent] [4]', 'foo.cpp') self.assert_multi_line_lint( 'namespace WebCore {\n' ' Document::Foo() { }\n' '}', - 'In an implementation file, code inside a namespace should not be indented.' + 'Code inside a namespace should not be indented.' ' [whitespace/indent] [4]', 'foo.cpp') + self.assert_multi_line_lint( + 'namespace WebCore {\n' + '#define abc(x) x; \\\n' + ' x\n' + '}', + '', + 'foo.cpp') + self.assert_multi_line_lint( + 'namespace WebCore {\n' + '#define abc(x) x; \\\n' + ' x\n' + ' void* x;' + '}', + 'Code inside a namespace should not be indented. [whitespace/indent] [4]', + 'foo.cpp') # 5. A case label should line up with its switch statement. The # case statement is indented. @@ -3246,7 +3304,7 @@ class WebKitStyleTest(CppStyleTestBase): '') self.assert_multi_line_lint( 'namespace WebCore {\n' - ' int foo;\n' + 'int foo;\n' '};\n', '') self.assert_multi_line_lint( |
