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

Side by Side Diff: tests/compiler/dart2js/unparser2_test.dart

Issue 10916053: Get rid of duplication of class node unparsing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #import("../../../lib/compiler/implementation/scanner/scannerlib.dart"); 5 #import("../../../lib/compiler/implementation/scanner/scannerlib.dart");
6 #import("../../../lib/compiler/implementation/elements/elements.dart"); // only need CompilationUnitElement 6 #import("../../../lib/compiler/implementation/elements/elements.dart"); // only need CompilationUnitElement
7 #import("../../../lib/compiler/implementation/tree/tree.dart"); 7 #import("../../../lib/compiler/implementation/tree/tree.dart");
8 #import("../../../lib/compiler/implementation/leg.dart"); // only need Diagnosti cListener & Script 8 #import("../../../lib/compiler/implementation/leg.dart"); // only need Diagnosti cListener & Script
9 9
10 // This is the number of spaces to trim from the test code. 10 // This is the number of spaces to trim from the test code.
11 // New tests should be indented this amount. 11 // New tests should be indented this amount.
12 const int BUILT_IN_TEST_INDENTATION = 6; 12 const int BUILT_IN_TEST_INDENTATION = 6;
13 13
14 main() { 14 main() {
15 testClassDef(); 15 testClassDef();
16 testClass1Field(); 16 testClass1Field();
17 testClass2Fields(); 17 testClass2Fields();
18 testClass1Field1Method(); 18 testClass1Field1Method();
19 testClass1Field2Method(); 19 testClass1Field2Method();
20 testClassDefTypeParam(); 20 testClassDefTypeParam();
21 } 21 }
22 22
23 testClassDef() { 23 testClassDef() {
24 compareCode(''' 24 compareCode('''
25 class T{} 25 class T{}
26 ''', ''' 26 ''', '''
27 class T { 27 class T{
28 } 28 }
29 '''); 29 ''');
30 } 30 }
31 31
32 testClass1Field() { 32 testClass1Field() {
33 compareCode(''' 33 compareCode('''
34 class T{var x;} 34 class T{var x;}
35 ''', ''' 35 ''', '''
36 class T { 36 class T{
37 var x; 37 var x;
38 } 38 }
39 '''); 39 ''');
40 } 40 }
41 41
42 testClass2Fields() { 42 testClass2Fields() {
43 compareCode(''' 43 compareCode('''
44 class T{var x; var y;} 44 class T{var x; var y;}
45 ''', ''' 45 ''', '''
46 class T { 46 class T{
47 var x; 47 var x;
48 var y; 48 var y;
49 } 49 }
50 '''); 50 ''');
51 } 51 }
52 52
53 testClass1Field1Method() { 53 testClass1Field1Method() {
54 compareCode(''' 54 compareCode('''
55 class T{var x;m(){}} 55 class T{var x;m(){}}
56 ''', ''' 56 ''', '''
57 class T { 57 class T{
58 var x; 58 var x;
59 m(){} 59 m(){}
60 } 60 }
61 '''); 61 ''');
62 } 62 }
63 63
64 testClass1Field2Method() { 64 testClass1Field2Method() {
65 compareCode(''' 65 compareCode('''
66 class T{a(){}b(){}} 66 class T{a(){}b(){}}
67 ''', ''' 67 ''', '''
68 class T { 68 class T{
69 a(){} 69 a(){}
70 b(){} 70 b(){}
71 } 71 }
72 '''); 72 ''');
73 } 73 }
74 74
75 testClassDefTypeParam() { 75 testClassDefTypeParam() {
76 compareCode(''' 76 compareCode('''
77 class T<X>{} 77 class T<X>{}
78 ''', ''' 78 ''', '''
79 class T<X> { 79 class T<X>{
80 } 80 }
81 '''); 81 ''');
82 } 82 }
83 83
84 void compareCode(String original, String expected) { 84 void compareCode(String original, String expected) {
85 String unparsed = doUnparse(cleanUpLiteral(original)); 85 String unparsed = doUnparse(cleanUpLiteral(original));
86 Expect.equals(cleanUpLiteral(expected), unparsed); 86 Expect.equals(cleanUpLiteral(expected), unparsed);
87 } 87 }
88 88
89 String cleanUpLiteral(String text) { 89 String cleanUpLiteral(String text) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 void internalErrorOnElement(Element element, String message) { 128 void internalErrorOnElement(Element element, String message) {
129 throw message; 129 throw message;
130 } 130 }
131 void internalError(String message, 131 void internalError(String message,
132 [Node node, Token token, Dynamic instruction, 132 [Node node, Token token, Dynamic instruction,
133 Element element]) { 133 Element element]) {
134 throw message; 134 throw message;
135 } 135 }
136 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698