OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 package formatter | 5 package formatter |
6 | 6 |
7 import ( | 7 import ( |
8 "strings" | 8 "strings" |
9 "testing" | 9 "testing" |
10 ) | 10 ) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 interface InterfaceFoo { // Interface comment. | 60 interface InterfaceFoo { // Interface comment. |
61 const int8 const_in_interface = 20; | 61 const int8 const_in_interface = 20; |
62 | 62 |
63 // Method 1 comment. | 63 // Method 1 comment. |
64 method1@5(int8 hello@10); | 64 method1@5(int8 hello@10); |
65 // Method 2 comment. | 65 // Method 2 comment. |
66 method2([MinVersion=5] int8 hello) => (Foo bar@20); | 66 method2([MinVersion=5] int8 hello) => (Foo bar@20); |
67 method3(); | 67 method3(); |
68 method4() => (Foo bar); | 68 method4() => (Foo bar); |
69 method5(int8 p1 /* p1 comment */, int16 p2); // method comment | 69 method5(int8 p1 /* p1 comment */, int16 p2); // method comment |
70 » method6(int8 p1, int16 p2) | 70 » method6(WayTooLongAndReallyLongFactoryVisitoryFactory field1, |
71 » => (int8 p1, int16 p2); | 71 » WayTooLongAndReallyLongFactoryVisitoryFactory field2) |
72 » method7(int8 p1, | 72 » => (int8 alpha); |
73 int16 p2, | |
74 int16 p3) | |
75 » => (int8 p1, int16 p2); | |
76 }; | 73 }; |
77 | 74 |
78 // Final Comments. | 75 // Final Comments. |
79 ` | 76 ` |
80 | 77 |
81 // TODO(azani): Remove this and just fix the tabs. | 78 // TODO(azani): Remove this and just fix the tabs. |
82 original = strings.Replace(original, "\t", " ", -1) | 79 original = strings.Replace(original, "\t", " ", -1) |
83 original = strings.Replace(original, "\t//", " //", -1) | 80 original = strings.Replace(original, "\t//", " //", -1) |
84 | 81 |
85 actual, err := FormatMojom("test.mojom", original) | 82 actual, err := FormatMojom("test.mojom", original) |
86 if err != nil { | 83 if err != nil { |
87 t.Fatalf("Parser was not supposed to fail: %s", err.Error()) | 84 t.Fatalf("Parser was not supposed to fail: %s", err.Error()) |
88 } | 85 } |
89 | 86 |
90 if original != actual { | 87 if original != actual { |
91 t.Fatalf("\nExpected:\n%v\n\n*****\n\nActual:\n%v eof", original
, actual) | 88 t.Fatalf("\nExpected:\n%v\n\n*****\n\nActual:\n%v eof", original
, actual) |
92 } | 89 } |
93 } | 90 } |
OLD | NEW |