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

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

Issue 12047041: Testable patch parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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
« no previous file with comments | « dart/tests/compiler/dart2js/mock_compiler.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/compiler/dart2js/patch2_test.dart
diff --git a/dart/tests/compiler/dart2js/patch2_test.dart b/dart/tests/compiler/dart2js/patch2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3a838207f65c94d03d0c6c3f2bb966290b97e665
--- /dev/null
+++ b/dart/tests/compiler/dart2js/patch2_test.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "mock_compiler.dart";
+
+import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart"
+ show Element, FunctionElement;
+import "../../../sdk/lib/_internal/compiler/implementation/patch_parser.dart";
+import "../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart"
+ show StringScanner;
+import "../../../sdk/lib/_internal/compiler/implementation/util/util.dart";
+
+class TestPatchElementListener extends PatchElementListener {
+ TestPatchElementListener(compiler, unit)
+ : super(compiler, unit, compiler.getNextFreeClassId, new LinkBuilder());
+
+ void applyPatch(Element patch) {
+ }
+}
+
+Element buildElement(MockCompiler compiler, String source) {
+ var library = compiler.createLibrary('origin', 'external foo();');
+ var elements = library.localMembers.toList();
+ Expect.equals(1, elements.length);
+ return elements[0];
+}
+
+Element buildPatchElement(MockCompiler compiler, String source) {
+ var library = compiler.createUnparsedLibrary('patch', source);
+ var unit = library.entryCompilationUnit;
+
+ var tokens = new StringScanner(source).tokenize();
+ var listener = new TestPatchElementListener(compiler, unit);
+ new PatchParser(listener).parseUnit(tokens);
+
+ var elements = unit.localMembers.toList();
+ Expect.equals(1, elements.length);
+ Expect.isTrue(isPatchElement(elements[0]));
+ return elements[0];
+}
+
+main() {
+ MockCompiler compiler = new MockCompiler();
+ FunctionElement foo = buildElement(compiler, 'external foo();');
+ FunctionElement fooPatch = buildPatchElement(compiler, 'patch foo() {}');
+ patchElement(null, foo, fooPatch);
+}
« no previous file with comments | « dart/tests/compiler/dart2js/mock_compiler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698