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

Side by Side Diff: dart/tests/compiler/dart2js/compiler_helper.dart

Issue 10879006: Create an outline of metadata API in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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
OLDNEW
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 // Test constant folding. 4 // Test constant folding.
5 5
6 #library("compiler_helper"); 6 #library("compiler_helper");
7 7
8 #import("dart:uri"); 8 #import("dart:uri");
9 #import("../../../lib/compiler/implementation/leg.dart", prefix: "leg"); 9 #import("../../../lib/compiler/implementation/leg.dart", prefix: "leg");
10 #import("../../../lib/compiler/implementation/js_backend/js_backend.dart", prefi x: "js"); 10 #import("../../../lib/compiler/implementation/js_backend/js_backend.dart", prefi x: "js");
(...skipping 23 matching lines...) Expand all
34 34
35 String compileAll(String code) { 35 String compileAll(String code) {
36 Uri uri = new Uri.fromComponents(scheme: 'source'); 36 Uri uri = new Uri.fromComponents(scheme: 'source');
37 MockCompiler compiler = compilerFor(code, uri); 37 MockCompiler compiler = compilerFor(code, uri);
38 compiler.runCompiler(uri); 38 compiler.runCompiler(uri);
39 Expect.isFalse(compiler.compilationFailed, 39 Expect.isFalse(compiler.compilationFailed,
40 'Unexpected compilation error'); 40 'Unexpected compilation error');
41 return compiler.assembledCode; 41 return compiler.assembledCode;
42 } 42 }
43 43
44 lego.Element findElement(var compiler, String name) { 44 Dynamic compileAndCheck(String code,
45 String name,
46 check(MockCompiler compiler, lego.Element element)) {
47 Uri uri = new Uri.fromComponents(scheme: 'source');
48 MockCompiler compiler = compilerFor(code, uri);
49 compiler.runCompiler(uri);
50 lego.Element element = findElement(compiler, name);
51 return check(compiler, element);
52 }
53
54 lego.Element findElement(compiler, String name) {
45 var element = compiler.mainApp.find(buildSourceString(name)); 55 var element = compiler.mainApp.find(buildSourceString(name));
46 Expect.isNotNull(element, 'Could not locate $name.'); 56 Expect.isNotNull(element, 'Could not locate $name.');
47 return element; 57 return element;
48 } 58 }
49 59
50 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*"; 60 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*";
51 61
52 String getIntTypeCheck(String variable) { 62 String getIntTypeCheck(String variable) {
53 return "\\($variable !== \\($variable \\| 0\\)\\)"; 63 return "\\($variable !== \\($variable \\| 0\\)\\)";
54 } 64 }
(...skipping 14 matching lines...) Expand all
69 String generated = compile(code, entry); 79 String generated = compile(code, entry);
70 Expect.isTrue(regexp.hasMatch(generated), 80 Expect.isTrue(regexp.hasMatch(generated),
71 '"$generated" does not match /$regexp/'); 81 '"$generated" does not match /$regexp/');
72 } 82 }
73 83
74 void compileAndDoNotMatch(String code, String entry, RegExp regexp) { 84 void compileAndDoNotMatch(String code, String entry, RegExp regexp) {
75 String generated = compile(code, entry); 85 String generated = compile(code, entry);
76 Expect.isFalse(regexp.hasMatch(generated), 86 Expect.isFalse(regexp.hasMatch(generated),
77 '"$generated" has a match in /$regexp/'); 87 '"$generated" has a match in /$regexp/');
78 } 88 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/scanner/listener.dart ('k') | dart/tests/compiler/dart2js/metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698