OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 namespace blink { | 5 namespace blink { |
6 | 6 |
7 class C { | 7 class C { |
8 public: | 8 public: |
9 // Make sure initializers are updated to use the new names. | 9 // Make sure initializers are updated to use the new names. |
10 C() : flag_field_(~0), field_mentioning_http_and_https_(1) {} | 10 C() : flag_field_(~0), field_mentioning_http_and_https_(1) {} |
11 | 11 |
12 int method() { | 12 int Method() { |
13 // Test that references to fields are updated correctly. | 13 // Test that references to fields are updated correctly. |
14 return instance_count_ + flag_field_ + field_mentioning_http_and_https_; | 14 return instance_count_ + flag_field_ + field_mentioning_http_and_https_; |
15 } | 15 } |
16 | 16 |
| 17 // Test that a field without a m_ prefix is correctly renamed. |
| 18 static int instance_count_; |
| 19 |
17 private: | 20 private: |
18 // The m_ prefix, if any, should be removed. | 21 // Test that a field with a m_ prefix is correctly renamed. |
19 static int instance_count_; | |
20 const int flag_field_; | 22 const int flag_field_; |
21 // Statics should be named with s_, but make sure s_ and m_ are both correctly | 23 // Statics should be named with s_, but make sure s_ and m_ are both correctly |
22 // stripped. | 24 // stripped. |
23 static int static_count_; | 25 static int static_count_; |
24 static int static_count_with_bad_name_; | 26 static int static_count_with_bad_name_; |
25 // Make sure that acronyms don't confuse the underscore inserter. | 27 // Make sure that acronyms don't confuse the underscore inserter. |
26 int field_mentioning_http_and_https_; | 28 int field_mentioning_http_and_https_; |
27 // Already Google style, should not change. | 29 // Already Google style, should not change. |
28 int already_google_style_; | 30 int already_google_style_; |
29 }; | 31 }; |
30 | 32 |
31 int C::instance_count_ = 0; | 33 int C::instance_count_ = 0; |
32 | 34 |
33 // Structs are like classes, but don't use a `_` suffix for members. | 35 // Structs are like classes, but don't use a `_` suffix for members. |
34 struct S { | 36 struct S { |
35 int integer_field; | 37 int integer_field; |
36 int google_style_already; | 38 int google_style_already; |
37 }; | 39 }; |
38 | 40 |
39 // Unions also use struct-style naming. | 41 // Unions also use struct-style naming. |
40 union U { | 42 union U { |
41 char fourChars[4]; | 43 char fourChars[4]; |
42 short twoShorts[2]; | 44 short twoShorts[2]; |
43 int one_hopefully_four_byte_int; | 45 int one_hopefully_four_byte_int; |
44 }; | 46 }; |
45 | 47 |
46 } // namespace blink | 48 } // namespace blink |
| 49 |
| 50 void F() { |
| 51 // Test that references to a static field are correctly rewritten. |
| 52 blink::C::instance_count_++; |
| 53 } |
OLD | NEW |