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

Unified Diff: tests/compiler/dart2js/unparser2_test.dart

Issue 10913067: Simplify Unparser.unparseClassWithBody. (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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/unparser2_test.dart
diff --git a/tests/compiler/dart2js/unparser2_test.dart b/tests/compiler/dart2js/unparser2_test.dart
index 8d8567a6c54bf8f70a5e0b4e2dcef694049fb9af..782198d368cee03d5f1552db6b74e9ac2b48679f 100644
--- a/tests/compiler/dart2js/unparser2_test.dart
+++ b/tests/compiler/dart2js/unparser2_test.dart
@@ -7,10 +7,6 @@
#import("../../../lib/compiler/implementation/tree/tree.dart");
#import("../../../lib/compiler/implementation/leg.dart"); // only need DiagnosticListener & Script
-// This is the number of spaces to trim from the test code.
-// New tests should be indented this amount.
-const int BUILT_IN_TEST_INDENTATION = 6;
-
main() {
testClassDef();
testClass1Field();
@@ -21,81 +17,31 @@ main() {
}
testClassDef() {
- compareCode('''
- class T{}
- ''', '''
- class T{
- }
- ''');
+ compareCode('class T{}');
}
testClass1Field() {
- compareCode('''
- class T{var x;}
- ''', '''
- class T{
- var x;
- }
- ''');
+ compareCode('class T{var x;}');
}
testClass2Fields() {
- compareCode('''
- class T{var x; var y;}
- ''', '''
- class T{
- var x;
- var y;
- }
- ''');
+ compareCode('class T{var x;var y;}');
}
testClass1Field1Method() {
- compareCode('''
- class T{var x;m(){}}
- ''', '''
- class T{
- var x;
- m(){}
- }
- ''');
+ compareCode('class T{var x;m(){}}');
}
testClass1Field2Method() {
- compareCode('''
- class T{a(){}b(){}}
- ''', '''
- class T{
- a(){}
- b(){}
- }
- ''');
+ compareCode('class T{a(){}b(){}}');
}
testClassDefTypeParam() {
- compareCode('''
- class T<X>{}
- ''', '''
- class T<X>{
- }
- ''');
-}
-
-void compareCode(String original, String expected) {
- String unparsed = doUnparse(cleanUpLiteral(original));
- Expect.equals(cleanUpLiteral(expected), unparsed);
+ compareCode('class T<X>{}');
}
-String cleanUpLiteral(String text) {
- var lines = text.split('\n');
- for (var j = 0; j < lines.length; j++) {
- if (lines[j].length > BUILT_IN_TEST_INDENTATION) {
- lines[j] = lines[j].substring(BUILT_IN_TEST_INDENTATION, lines[j].length);
- } else {
- lines[j] = '';
- }
- }
- return Strings.join(lines, '\n');
+void compareCode(String code) {
+ Expect.equals(code, doUnparse(code));
}
String doUnparse(String source) {

Powered by Google App Engine
This is Rietveld 408576698