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

Side by Side Diff: tests/compiler/dart2js/is_inference_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 "package:expect/expect.dart"; 5 import 'dart:async';
6 import 'package:expect/expect.dart';
7 import 'package:async_helper/async_helper.dart';
6 import 'compiler_helper.dart'; 8 import 'compiler_helper.dart';
7 9
8 const String TEST_IF = r""" 10 const String TEST_IF = r"""
9 test(param) { 11 test(param) {
10 print('Printing this ensures that String+ is in the system.'); 12 print('Printing this ensures that String+ is in the system.');
11 if (param is int) { 13 if (param is int) {
12 param = param + 42; 14 param = param + 42;
13 } 15 }
14 return param + 53; 16 return param + 53;
15 } 17 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 print('Printing this ensures that String+ is in the system.'); 64 print('Printing this ensures that String+ is in the system.');
63 if (param is !int) { 65 if (param is !int) {
64 return param + 53; 66 return param + 53;
65 } else { 67 } else {
66 param = param + 42; 68 param = param + 42;
67 } 69 }
68 return param; 70 return param;
69 } 71 }
70 """; 72 """;
71 73
72 compileAndTest(String code) { 74 Future compileAndTest(String code) {
73 String generated = compile(code, entry: 'test'); 75 return compile(code, entry: 'test', check: (String generated) {
74 RegExp validAdd = 76 RegExp validAdd =
75 new RegExp("($anyIdentifier \\+ 42)|($anyIdentifier \\+= 42)"); 77 new RegExp("($anyIdentifier \\+ 42)|($anyIdentifier \\+= 42)");
76 RegExp invalidAdd = new RegExp("$anyIdentifier \\+ 53"); 78 RegExp invalidAdd = new RegExp("$anyIdentifier \\+ 53");
77 Expect.isTrue(validAdd.hasMatch(generated)); 79 Expect.isTrue(validAdd.hasMatch(generated));
78 Expect.isFalse(invalidAdd.hasMatch(generated)); 80 Expect.isFalse(invalidAdd.hasMatch(generated));
81 });
79 } 82 }
80 83
81 main() { 84 main() {
82 compileAndTest(TEST_IF); 85 asyncTest(() => Future.wait([
83 compileAndTest(TEST_IF_ELSE); 86 compileAndTest(TEST_IF),
84 compileAndTest(TEST_IF_RETURN); 87 compileAndTest(TEST_IF_ELSE),
85 compileAndTest(TEST_IF_NOT_ELSE); 88 compileAndTest(TEST_IF_RETURN),
86 compileAndTest(TEST_IF_NOT_RETURN); 89 compileAndTest(TEST_IF_NOT_ELSE),
87 compileAndTest(TEST_IF_NOT_ELSE_RETURN); 90 compileAndTest(TEST_IF_NOT_RETURN),
91 compileAndTest(TEST_IF_NOT_ELSE_RETURN),
92 ]));
88 } 93 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/is_inference2_test.dart ('k') | tests/compiler/dart2js/js_parser_statements_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698