| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.parser; | 5 package com.google.dart.compiler.parser; |
| 6 | 6 |
| 7 import com.google.dart.compiler.CompilerTestCase; | 7 import com.google.dart.compiler.CompilerTestCase; |
| 8 import com.google.dart.compiler.ast.DartToSourceVisitor; | 8 import com.google.dart.compiler.ast.DartToSourceVisitor; |
| 9 import com.google.dart.compiler.ast.DartUnit; | 9 import com.google.dart.compiler.ast.DartUnit; |
| 10 import com.google.dart.compiler.util.DefaultTextOutput; | |
| 11 | 10 |
| 12 /** | 11 /** |
| 13 * Tests, for each of the parser test examples, that {@link DartToSourceVisitor}
produces | 12 * Tests, for each of the parser test examples, that {@link DartToSourceVisitor}
produces |
| 14 * something parseable. It's an imperfect test, as it doesn't account for semant
ic changes, | 13 * something parseable. It's an imperfect test, as it doesn't account for semant
ic changes, |
| 15 * but it catches a lot of common problems. | 14 * but it catches a lot of common problems. |
| 16 */ | 15 */ |
| 17 public class ParserRoundTripTest extends CompilerTestCase { | 16 public class ParserRoundTripTest extends CompilerTestCase { |
| 18 | 17 |
| 19 public void testClasses() { | 18 public void testClasses() { |
| 20 roundTrip("ClassesInterfaces.dart"); | 19 roundTrip("ClassesInterfaces.dart"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 61 |
| 63 public void testStrings() { | 62 public void testStrings() { |
| 64 roundTrip("Strings.dart"); | 63 roundTrip("Strings.dart"); |
| 65 } | 64 } |
| 66 | 65 |
| 67 /** | 66 /** |
| 68 * Ensures that a unit can be parsed, re-serialized, and re-parsed without err
or. | 67 * Ensures that a unit can be parsed, re-serialized, and re-parsed without err
or. |
| 69 */ | 68 */ |
| 70 private void roundTrip(String path) { | 69 private void roundTrip(String path) { |
| 71 DartUnit unit = parseUnit(path); | 70 DartUnit unit = parseUnit(path); |
| 72 | 71 String src = unit.toSource(); |
| 73 DefaultTextOutput out = new DefaultTextOutput(false); | |
| 74 new DartToSourceVisitor(out, false).accept(unit); | |
| 75 String src = out.toString(); | |
| 76 parseUnit(path, src); | 72 parseUnit(path, src); |
| 77 } | 73 } |
| 78 } | 74 } |
| OLD | NEW |