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

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

Issue 326913002: Make dart2js unittests async. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 6 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 4
5 import "dart:async";
5 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart";
6 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart"; 8 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart";
7 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t"; 9 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t";
8 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart"; 10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart";
9 import "../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart";
10 import "../../../sdk/lib/_internal/compiler/implementation/util/util.dart"; 11 import "../../../sdk/lib/_internal/compiler/implementation/util/util.dart";
11 import "mock_compiler.dart"; 12 import "mock_compiler.dart";
12 import "parser_helper.dart"; 13
13 14
14 class CallbackMockCompiler extends MockCompiler { 15 class CallbackMockCompiler extends MockCompiler {
15 CallbackMockCompiler(); 16 CallbackMockCompiler() : super.internal();
16 17
17 var onError; 18 var onError;
18 var onWarning; 19 var onWarning;
19 20
20 setOnError(var f) => onError = f; 21 setOnError(var f) => onError = f;
21 setOnWarning(var f) => onWarning = f; 22 setOnWarning(var f) => onWarning = f;
22 23
23 void reportWarning(Spannable node, 24 void reportWarning(Spannable node,
24 MessageKind messageKind, 25 MessageKind messageKind,
25 [Map arguments = const {}]) { 26 [Map arguments = const {}]) {
26 if (onWarning != null) { 27 if (onWarning != null) {
27 onWarning(this, node, messageKind.message(arguments)); 28 onWarning(this, node, messageKind.message(arguments));
28 } 29 }
29 super.reportWarning(node, messageKind, arguments); 30 super.reportWarning(node, messageKind, arguments);
30 } 31 }
31 32
32 void reportError(Spannable node, 33 void reportError(Spannable node,
33 MessageKind messageKind, 34 MessageKind messageKind,
34 [Map arguments = const {}]) { 35 [Map arguments = const {}]) {
35 if (onError != null) { 36 if (onError != null) {
36 onError(this, node, messageKind.message(arguments)); 37 onError(this, node, messageKind.message(arguments));
37 } 38 }
38 super.reportError(node, messageKind, arguments); 39 super.reportError(node, messageKind, arguments);
39 } 40 }
40 } 41 }
41 42
42 testErrorHandling() { 43 Future testErrorHandling() {
43 // Test that compiler.currentElement is set correctly when 44 // Test that compiler.currentElement is set correctly when
44 // reporting errors/warnings. 45 // reporting errors/warnings.
45 CallbackMockCompiler compiler = new CallbackMockCompiler(); 46 CallbackMockCompiler compiler = new CallbackMockCompiler();
46 ResolverVisitor visitor = compiler.resolverVisitor(); 47 return compiler.init().then((_) {
47 compiler.parseScript('NoSuchPrefix.NoSuchType foo() {}'); 48 ResolverVisitor visitor = compiler.resolverVisitor();
48 FunctionElement foo = compiler.mainApp.find('foo'); 49 compiler.parseScript('NoSuchPrefix.NoSuchType foo() {}');
49 compiler.setOnWarning( 50 FunctionElement foo = compiler.mainApp.find('foo');
50 (c, n, m) => Expect.equals(foo, compiler.currentElement)); 51 compiler.setOnWarning(
51 foo.computeType(compiler); 52 (c, n, m) => Expect.equals(foo, compiler.currentElement));
52 Expect.equals(1, compiler.warnings.length); 53 foo.computeType(compiler);
54 Expect.equals(1, compiler.warnings.length);
55 });
53 } 56 }
54 57
55 main() { 58 main() {
56 testErrorHandling(); 59 asyncTest(() => testErrorHandling());
57 } 60 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/compiler_helper.dart ('k') | tests/compiler/dart2js/constant_folding_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698