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

Side by Side Diff: tests/compiler/dart2js/closure_codegen_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 // Test that parameters keep their names in the output. 4 // Test that parameters keep their names in the output.
5 5
6 import "package:expect/expect.dart"; 6 import 'dart:async';
7 import "package:async_helper/async_helper.dart"; 7 import 'package:expect/expect.dart';
8 import 'package:async_helper/async_helper.dart';
8 import 'compiler_helper.dart'; 9 import 'compiler_helper.dart';
9 import 'parser_helper.dart';
10 10
11 const String TEST_INVOCATION0 = r""" 11 const String TEST_INVOCATION0 = r"""
12 main() { 12 main() {
13 var o = null; 13 var o = null;
14 o(); 14 o();
15 } 15 }
16 """; 16 """;
17 17
18 const String TEST_INVOCATION1 = r""" 18 const String TEST_INVOCATION1 = r"""
19 main() { 19 main() {
(...skipping 14 matching lines...) Expand all
34 var x; 34 var x;
35 foo(_) { // make sure only g has no arguments 35 foo(_) { // make sure only g has no arguments
36 var f = function g() { return 499; }; 36 var f = function g() { return 499; };
37 return 499 + x + f(); 37 return 499 + x + f();
38 } 38 }
39 } 39 }
40 40
41 main() { new A().foo(1); } 41 main() { new A().foo(1); }
42 """; 42 """;
43 43
44 closureInvocation(bool minify, String prefix) { 44 Future closureInvocation(bool minify, String prefix) {
45 String generated = compile(TEST_INVOCATION0, minify: minify); 45 return Future.wait([
46 Expect.isTrue(generated.contains(".$prefix\$0()")); 46 compile(TEST_INVOCATION0, minify: minify, check: (String generated) {
47 generated = compile(TEST_INVOCATION1, minify: minify); 47 Expect.isTrue(generated.contains(".$prefix\$0()"));
48 Expect.isTrue(generated.contains(".$prefix\$1(1)")); 48 }),
49 generated = compile(TEST_INVOCATION2, minify: minify); 49 compile(TEST_INVOCATION1, minify: minify, check: (String generated) {
50 Expect.isTrue(generated.contains(".$prefix\$2(1,${minify ? "" : " "}2)")); 50 Expect.isTrue(generated.contains(".$prefix\$1(1)"));
51 }),
52 compile(TEST_INVOCATION2, minify: minify, check: (String generated) {
53 Expect.isTrue(generated.contains(".$prefix\$2(1,${minify ? "" : " "}2)"));
54 })
55 ]);
51 } 56 }
52 57
53 // Make sure that the bailout version does not introduce a second version of 58 // Make sure that the bailout version does not introduce a second version of
54 // the closure. 59 // the closure.
55 closureBailout(bool minify, String prefix) { 60 Future closureBailout(bool minify, String prefix) {
56 asyncTest(() => compileAll(TEST_BAILOUT, minify: minify) 61 return compileAll(TEST_BAILOUT, minify: minify).then((generated) {
57 .then((generated) {
58 RegExp regexp = new RegExp("$prefix\\\$0:${minify ? "" : " "}function"); 62 RegExp regexp = new RegExp("$prefix\\\$0:${minify ? "" : " "}function");
59 Iterator<Match> matches = regexp.allMatches(generated).iterator; 63 Iterator<Match> matches = regexp.allMatches(generated).iterator;
60 checkNumberOfMatches(matches, 1); 64 checkNumberOfMatches(matches, 1);
61 })); 65 });
62 } 66 }
63 67
64 main() { 68 main() {
65 closureInvocation(false, "call"); 69 asyncTest(() => Future.wait([
66 closureInvocation(true, ""); 70 closureInvocation(false, "call"),
67 closureBailout(false, "call"); 71 closureInvocation(true, ""),
68 closureBailout(true, ""); 72 closureBailout(false, "call"),
73 closureBailout(true, ""),
74 ]));
69 } 75 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/builtin_interceptor_test.dart ('k') | tests/compiler/dart2js/code_motion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698