| OLD | NEW |
| 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "package:compiler/src/parser/element_listener.dart"; | 6 import "package:compiler/src/parser/element_listener.dart"; |
| 7 import "package:compiler/src/parser/node_listener.dart"; | 7 import "package:compiler/src/parser/node_listener.dart"; |
| 8 import "package:compiler/src/parser/parser.dart"; | 8 import "package:compiler/src/parser/parser.dart"; |
| 9 import "package:compiler/src/scanner/string_scanner.dart"; | 9 import "package:compiler/src/scanner/string_scanner.dart"; |
| 10 import "package:compiler/src/tokens/token.dart"; | 10 import "package:compiler/src/tokens/token.dart"; |
| 11 import "package:compiler/src/tree/tree.dart"; | 11 import "package:compiler/src/tree/tree.dart"; |
| 12 | 12 |
| 13 import "package:compiler/src/diagnostics/diagnostic_listener.dart"; | 13 import "package:compiler/src/diagnostics/diagnostic_listener.dart"; |
| 14 import "package:compiler/src/elements/elements.dart" | 14 import "package:compiler/src/elements/elements.dart" |
| 15 show CompilationUnitElement, | 15 show CompilationUnitElement, LibraryElement; |
| 16 LibraryElement; | |
| 17 import "package:compiler/src/elements/modelx.dart" | 16 import "package:compiler/src/elements/modelx.dart" |
| 18 show CompilationUnitElementX, | 17 show CompilationUnitElementX, LibraryElementX; |
| 19 LibraryElementX; | |
| 20 import "package:compiler/src/script.dart"; | 18 import "package:compiler/src/script.dart"; |
| 21 | 19 |
| 22 import "options_helper.dart"; | 20 import "options_helper.dart"; |
| 23 | 21 |
| 24 main() { | 22 main() { |
| 25 testClassDef(); | 23 testClassDef(); |
| 26 testClass1Field(); | 24 testClass1Field(); |
| 27 testClass2Fields(); | 25 testClass2Fields(); |
| 28 testClass1Field1Method(); | 26 testClass1Field1Method(); |
| 29 testClass1Field2Method(); | 27 testClass1Field2Method(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 Expect.equals(expectedResult, doUnparse(code)); | 84 Expect.equals(expectedResult, doUnparse(code)); |
| 87 } | 85 } |
| 88 | 86 |
| 89 String doUnparse(String source) { | 87 String doUnparse(String source) { |
| 90 MessageCollector diagnosticListener = new MessageCollector(); | 88 MessageCollector diagnosticListener = new MessageCollector(); |
| 91 Script script = new Script(null, null, null); | 89 Script script = new Script(null, null, null); |
| 92 LibraryElement lib = new LibraryElementX(script); | 90 LibraryElement lib = new LibraryElementX(script); |
| 93 CompilationUnitElement element = new CompilationUnitElementX(script, lib); | 91 CompilationUnitElement element = new CompilationUnitElementX(script, lib); |
| 94 StringScanner scanner = new StringScanner.fromString(source); | 92 StringScanner scanner = new StringScanner.fromString(source); |
| 95 Token beginToken = scanner.tokenize(); | 93 Token beginToken = scanner.tokenize(); |
| 96 NodeListener listener = new NodeListener( | 94 NodeListener listener = |
| 97 const ScannerOptions(), diagnosticListener, element); | 95 new NodeListener(const ScannerOptions(), diagnosticListener, element); |
| 98 Parser parser = new Parser(listener, new MockParserOptions()); | 96 Parser parser = new Parser(listener, new MockParserOptions()); |
| 99 parser.parseUnit(beginToken); | 97 parser.parseUnit(beginToken); |
| 100 Node node = listener.popNode(); | 98 Node node = listener.popNode(); |
| 101 Expect.isTrue(listener.nodes.isEmpty); | 99 Expect.isTrue(listener.nodes.isEmpty); |
| 102 return unparse(node); | 100 return unparse(node); |
| 103 } | 101 } |
| 104 | 102 |
| 105 class MessageCollector extends DiagnosticReporter { | 103 class MessageCollector extends DiagnosticReporter { |
| 106 List<String> messages; | 104 List<String> messages; |
| 107 MessageCollector() { | 105 MessageCollector() { |
| 108 messages = []; | 106 messages = []; |
| 109 } | 107 } |
| 110 void internalError(node, String reason) { | 108 void internalError(node, String reason) { |
| 111 messages.add(reason); | 109 messages.add(reason); |
| 112 throw reason; | 110 throw reason; |
| 113 } | 111 } |
| 114 | 112 |
| 115 void log(message) { | 113 void log(message) { |
| 116 messages.add(message); | 114 messages.add(message); |
| 117 } | 115 } |
| 118 | 116 |
| 119 noSuchMethod(Invocation invocation) => throw 'unsupported operation'; | 117 noSuchMethod(Invocation invocation) => throw 'unsupported operation'; |
| 120 } | 118 } |
| OLD | NEW |