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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/tests/compiler/dart2js/mock_compiler.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import "mock_compiler.dart";
6
7 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t"
8 show Element, FunctionElement;
9 import "../../../sdk/lib/_internal/compiler/implementation/patch_parser.dart";
10 import "../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da rt"
11 show StringScanner;
12 import "../../../sdk/lib/_internal/compiler/implementation/util/util.dart";
13
14 class TestPatchElementListener extends PatchElementListener {
15 TestPatchElementListener(compiler, unit)
16 : super(compiler, unit, compiler.getNextFreeClassId, new LinkBuilder());
17
18 void applyPatch(Element patch) {
19 }
20 }
21
22 Element buildElement(MockCompiler compiler, String source) {
23 var library = compiler.createLibrary('origin', 'external foo();');
24 var elements = library.localMembers.toList();
25 Expect.equals(1, elements.length);
26 return elements[0];
27 }
28
29 Element buildPatchElement(MockCompiler compiler, String source) {
30 var library = compiler.createUnparsedLibrary('patch', source);
31 var unit = library.entryCompilationUnit;
32
33 var tokens = new StringScanner(source).tokenize();
34 var listener = new TestPatchElementListener(compiler, unit);
35 new PatchParser(listener).parseUnit(tokens);
36
37 var elements = unit.localMembers.toList();
38 Expect.equals(1, elements.length);
39 Expect.isTrue(isPatchElement(elements[0]));
40 return elements[0];
41 }
42
43 main() {
44 MockCompiler compiler = new MockCompiler();
45 FunctionElement foo = buildElement(compiler, 'external foo();');
46 FunctionElement fooPatch = buildPatchElement(compiler, 'patch foo() {}');
47 patchElement(null, foo, fooPatch);
48 }
OLDNEW
« 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