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

Side by Side Diff: dart/tests/try/web/incremental_compilation_update_test.dart

Issue 738423002: Use serialized scope info to test incremental compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r41910 and CL 750653002. Created 6 years 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/site/try/poi/scope_information_visitor.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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library trydart.incremental_compilation_update_test; 5 library trydart.incremental_compilation_update_test;
6 6
7 import 'dart:html'; 7 import 'dart:html' hide
8 Element;
8 9
9 import 'dart:async' show 10 import 'dart:async' show
10 Future; 11 Future;
11 12
12 import 'package:async_helper/async_helper.dart' show 13 import 'package:async_helper/async_helper.dart' show
13 asyncTest; 14 asyncTest;
14 15
16 import 'package:expect/expect.dart' show
17 Expect;
18
15 import 'package:try/src/interaction_manager.dart' show 19 import 'package:try/src/interaction_manager.dart' show
16 splitLines; 20 splitLines;
17 21
22 import 'package:try/poi/scope_information_visitor.dart' show
23 ScopeInformationVisitor;
24
18 import 'sandbox.dart' show 25 import 'sandbox.dart' show
19 appendIFrame, 26 appendIFrame,
20 listener; 27 listener;
21 28
22 import 'web_compiler_test_case.dart' show 29 import 'web_compiler_test_case.dart' show
23 WebCompilerTestCase, 30 WebCompilerTestCase,
24 WebInputProvider; 31 WebInputProvider;
25 32
33 import '../poi/compiler_test_case.dart' show
34 CompilerTestCase;
35
36 import 'package:compiler/src/elements/elements.dart' show
37 Element,
38 LibraryElement;
39
40 import 'package:compiler/src/dart2jslib.dart' show
41 Compiler;
42
26 import 'program_result.dart'; 43 import 'program_result.dart';
27 44
28 const int TIMEOUT = 100; 45 const int TIMEOUT = 100;
29 46
30 const List<List<ProgramResult>> tests = const <List<ProgramResult>>[ 47 const List<List<ProgramResult>> tests = const <List<ProgramResult>>[
31 // Basic hello-world test. 48 // Basic hello-world test.
32 const <ProgramResult>[ 49 const <ProgramResult>[
33 const ProgramResult( 50 const ProgramResult(
34 "main() { print('Hello, World!'); }", 51 "main() { print('Hello, World!'); }",
35 const <String> ['Hello, World!']), 52 const <String> ['Hello, World!']),
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 test.incrementalCompiler.inputProvider; 1120 test.incrementalCompiler.inputProvider;
1104 Uri uri = test.scriptUri.resolve('?v${version++}'); 1121 Uri uri = test.scriptUri.resolve('?v${version++}');
1105 inputProvider.cachedSources[uri] = new Future.value(program.code); 1122 inputProvider.cachedSources[uri] = new Future.value(program.code);
1106 Future future = test.incrementalCompiler.compileUpdates( 1123 Future future = test.incrementalCompiler.compileUpdates(
1107 {test.scriptUri: uri}, logVerbose: logger, logTime: logger); 1124 {test.scriptUri: uri}, logVerbose: logger, logTime: logger);
1108 return future.then((String update) { 1125 return future.then((String update) {
1109 print({'update': update}); 1126 print({'update': update});
1110 iframe.contentWindow.postMessage(['apply-update', update], '*'); 1127 iframe.contentWindow.postMessage(['apply-update', update], '*');
1111 1128
1112 return listener.expect( 1129 return listener.expect(
1113 program.messagesWith('iframe-dart-updated-main-done')); 1130 program.messagesWith('iframe-dart-updated-main-done'))
1131 .then((_) {
1132 return new SerializeScopeTestCase(
1133 program.code, test.incrementalCompiler.mainApp,
1134 test.incrementalCompiler.compiler).run();
1135 });
1114 }); 1136 });
1115 }); 1137 });
1116 }); 1138 });
1117 }); 1139 });
1118 }).then((_) { 1140 }).then((_) {
1119 status.style.color = 'limegreen'; 1141 status.style.color = 'limegreen';
1120 1142
1121 // Remove the iframe to work around a bug in test.dart. 1143 // Remove the iframe to work around a bug in test.dart.
1122 iframe.remove(); 1144 iframe.remove();
1123 }); 1145 });
1124 } 1146 }
1125 1147
1148 class SerializeScopeTestCase extends CompilerTestCase {
1149 final String scopeInfo;
1150
1151 SerializeScopeTestCase(
1152 String source,
1153 LibraryElement library,
1154 Compiler compiler)
1155 : scopeInfo = computeScopeInfo(compiler, library),
1156 super(source, '${library.canonicalUri}');
1157
1158 Future run() => mainApp.then(checkScopes);
Johnni Winther 2014/11/24 10:30:46 Maybe `mainApp` should be a function `compileMainA
ahe 2014/11/25 14:19:22 Then it should be something like "loadMainApp", as
Johnni Winther 2014/11/25 14:22:21 I found it difficult to reason about the control f
ahe 2014/11/25 14:30:55 Since you found it difficult to reason about the c
ahe 2014/11/25 15:15:36 Follow up in https://codereview.chromium.org/75704
1159
1160 void checkScopes(LibraryElement library) {
1161 Expect.stringEquals(computeScopeInfo(compiler, library), scopeInfo);
1162 }
1163
1164 static String computeScopeInfo(Compiler compiler, LibraryElement library) {
1165 ScopeInformationVisitor visitor =
1166 new ScopeInformationVisitor(compiler, library, 0);
1167
1168 visitor.ignoreImports = true;
1169 visitor.indented.write('[\n');
1170 visitor.indentationLevel++;
1171 visitor.indented;
1172 library.accept(visitor);
1173 library.forEachLocalMember((Element member) {
1174 if (member.isClass) {
1175 visitor.buffer.write(',\n');
1176 visitor.indented;
1177 member.accept(visitor);
1178 }
1179 });
1180 visitor.buffer.write('\n');
1181 visitor.indentationLevel--;
1182 visitor.indented.write(']');
1183 return '${visitor.buffer}';
1184 }
1185 }
1186
1126 void logger(x) { 1187 void logger(x) {
1127 print(x); 1188 print(x);
1128 bool isCheckedMode = false; 1189 bool isCheckedMode = false;
1129 assert(isCheckedMode = true); 1190 assert(isCheckedMode = true);
1130 int timeout = isCheckedMode ? TIMEOUT * 2 : TIMEOUT; 1191 int timeout = isCheckedMode ? TIMEOUT * 2 : TIMEOUT;
1131 if (listener.elapsed > timeout) { 1192 if (listener.elapsed > timeout) {
1132 throw 'Test timed out.'; 1193 throw 'Test timed out.';
1133 } 1194 }
1134 } 1195 }
1135 1196
1136 Element numberedLines(String code) { 1197 DivElement numberedLines(String code) {
1137 DivElement result = new DivElement(); 1198 DivElement result = new DivElement();
1138 result.classes.add("output"); 1199 result.classes.add("output");
1139 1200
1140 for (String text in splitLines(code)) { 1201 for (String text in splitLines(code)) {
1141 Element line = new PreElement() 1202 PreElement line = new PreElement()
1142 ..appendText(text.trimRight()) 1203 ..appendText(text.trimRight())
1143 ..classes.add("line"); 1204 ..classes.add("line");
1144 result.append(line); 1205 result.append(line);
1145 } 1206 }
1146 1207
1147 return result; 1208 return result;
1148 } 1209 }
1149 1210
1150 1211
1151 StyleElement lineNumberStyle() { 1212 StyleElement lineNumberStyle() {
(...skipping 21 matching lines...) Expand all
1173 position: absolute; 1234 position: absolute;
1174 left: 0px; 1235 left: 0px;
1175 width: 3em; 1236 width: 3em;
1176 text-align: right; 1237 text-align: right;
1177 background-color: lightgoldenrodyellow; 1238 background-color: lightgoldenrodyellow;
1178 } 1239 }
1179 '''); 1240 ''');
1180 style.type = 'text/css'; 1241 style.type = 'text/css';
1181 return style; 1242 return style;
1182 } 1243 }
OLDNEW
« no previous file with comments | « dart/site/try/poi/scope_information_visitor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698