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

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

Issue 362243003: Generate mock libraries and assert that helpers are non-null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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:async'; 8 import 'dart:async';
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
(...skipping 29 matching lines...) Expand all
40 import 'package:compiler/implementation/dart2jslib.dart' 40 import 'package:compiler/implementation/dart2jslib.dart'
41 show Compiler; 41 show Compiler;
42 42
43 export 'package:compiler/implementation/tree/tree.dart'; 43 export 'package:compiler/implementation/tree/tree.dart';
44 44
45 import 'mock_compiler.dart'; 45 import 'mock_compiler.dart';
46 export 'mock_compiler.dart'; 46 export 'mock_compiler.dart';
47 47
48 Future<String> compile(String code, 48 Future<String> compile(String code,
49 {String entry: 'main', 49 {String entry: 'main',
50 String coreSource: DEFAULT_CORELIB,
51 String interceptorsSource: DEFAULT_INTERCEPTORSLIB,
52 bool enableTypeAssertions: false, 50 bool enableTypeAssertions: false,
53 bool minify: false, 51 bool minify: false,
54 bool analyzeAll: false, 52 bool analyzeAll: false,
55 bool disableInlining: true, 53 bool disableInlining: true,
56 void check(String generated)}) { 54 void check(String generated)}) {
57 MockCompiler compiler = new MockCompiler.internal( 55 MockCompiler compiler = new MockCompiler.internal(
58 enableTypeAssertions: enableTypeAssertions, 56 enableTypeAssertions: enableTypeAssertions,
59 coreSource: coreSource,
60 // Type inference does not run when manually 57 // Type inference does not run when manually
61 // compiling a method. 58 // compiling a method.
62 disableTypeInference: true, 59 disableTypeInference: true,
63 interceptorsSource: interceptorsSource,
64 enableMinification: minify, 60 enableMinification: minify,
65 disableInlining: disableInlining); 61 disableInlining: disableInlining);
66 return compiler.init().then((_) { 62 return compiler.init().then((_) {
67 compiler.parseScript(code); 63 compiler.parseScript(code);
68 lego.Element element = compiler.mainApp.find(entry); 64 lego.Element element = compiler.mainApp.find(entry);
69 if (element == null) return null; 65 if (element == null) return null;
70 compiler.phase = Compiler.PHASE_RESOLVING; 66 compiler.phase = Compiler.PHASE_RESOLVING;
71 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution, 67 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution,
72 compiler.globalDependencies); 68 compiler.globalDependencies);
73 compiler.processQueue(compiler.enqueuer.resolution, element); 69 compiler.processQueue(compiler.enqueuer.resolution, element);
(...skipping 12 matching lines...) Expand all
86 check(generated); 82 check(generated);
87 } 83 }
88 return generated; 84 return generated;
89 }); 85 });
90 } 86 }
91 87
92 // TODO(herhut): Disallow warnings and errors during compilation by default. 88 // TODO(herhut): Disallow warnings and errors during compilation by default.
93 MockCompiler compilerFor(String code, Uri uri, 89 MockCompiler compilerFor(String code, Uri uri,
94 {bool analyzeAll: false, 90 {bool analyzeAll: false,
95 bool analyzeOnly: false, 91 bool analyzeOnly: false,
96 String coreSource: DEFAULT_CORELIB, 92 Map coreSource,
karlklose 2014/07/03 08:31:15 Could you type the map?
Johnni Winther 2014/07/03 09:23:25 Done.
97 bool disableInlining: true, 93 bool disableInlining: true,
98 bool minify: false, 94 bool minify: false,
99 int expectedErrors, 95 int expectedErrors,
100 int expectedWarnings}) { 96 int expectedWarnings}) {
101 MockCompiler compiler = new MockCompiler.internal( 97 MockCompiler compiler = new MockCompiler.internal(
102 analyzeAll: analyzeAll, 98 analyzeAll: analyzeAll,
103 analyzeOnly: analyzeOnly, 99 analyzeOnly: analyzeOnly,
104 coreSource: coreSource, 100 coreSource: coreSource,
105 disableInlining: disableInlining, 101 disableInlining: disableInlining,
106 enableMinification: minify, 102 enableMinification: minify,
107 expectedErrors: expectedErrors, 103 expectedErrors: expectedErrors,
108 expectedWarnings: expectedWarnings); 104 expectedWarnings: expectedWarnings);
109 compiler.registerSource(uri, code); 105 compiler.registerSource(uri, code);
110 return compiler; 106 return compiler;
111 } 107 }
112 108
113 Future<String> compileAll(String code, 109 Future<String> compileAll(String code,
114 {String coreSource: DEFAULT_CORELIB, 110 {Map coreSource,
115 bool disableInlining: true, 111 bool disableInlining: true,
116 bool minify: false, 112 bool minify: false,
117 int expectedErrors, 113 int expectedErrors,
118 int expectedWarnings}) { 114 int expectedWarnings}) {
119 Uri uri = new Uri(scheme: 'source'); 115 Uri uri = new Uri(scheme: 'source');
120 MockCompiler compiler = compilerFor( 116 MockCompiler compiler = compilerFor(
121 code, uri, coreSource: coreSource, disableInlining: disableInlining, 117 code, uri, coreSource: coreSource, disableInlining: disableInlining,
122 minify: minify, expectedErrors: expectedErrors, 118 minify: minify, expectedErrors: expectedErrors,
123 expectedWarnings: expectedWarnings); 119 expectedWarnings: expectedWarnings);
124 return compiler.runCompiler(uri).then((_) { 120 return compiler.runCompiler(uri).then((_) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); 236 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)');
241 final spaceRe = new RegExp('\\s+'); 237 final spaceRe = new RegExp('\\s+');
242 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); 238 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)');
243 if (shouldMatch) { 239 if (shouldMatch) {
244 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); 240 Expect.isTrue(new RegExp(regexp).hasMatch(generated));
245 } else { 241 } else {
246 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); 242 Expect.isFalse(new RegExp(regexp).hasMatch(generated));
247 } 243 }
248 }); 244 });
249 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698