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

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

Issue 16944004: Change how we deal with manual inlining of argument error and NSM when propagating types. This chan… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 "package:expect/expect.dart";
6 import 'compiler_helper.dart'; 6 import 'compiler_helper.dart';
7 7
8 const String TEST_IF = r""" 8 const String TEST_IF = r"""
9 test(param) { 9 test(param) {
10 print('Printing this ensures that String+ is in the system.');
10 if (param is int) { 11 if (param is int) {
11 param = param + 42; 12 param = param + 42;
12 } 13 }
13 return param + 53; 14 return param + 53;
14 } 15 }
15 """; 16 """;
16 17
17 const String TEST_IF_ELSE = r""" 18 const String TEST_IF_ELSE = r"""
18 test(param) { 19 test(param) {
20 print('Printing this ensures that String+ is in the system.');
19 if (param is int) { 21 if (param is int) {
20 param = param + 42; 22 param = param + 42;
21 } else { 23 } else {
22 param = param + 53; 24 param = param + 53;
23 } 25 }
24 return param + 53; 26 return param + 53;
25 } 27 }
26 """; 28 """;
27 29
28 const String TEST_IF_RETURN = r""" 30 const String TEST_IF_RETURN = r"""
29 test(param) { 31 test(param) {
32 print('Printing this ensures that String+ is in the system.');
30 if (param is int) { 33 if (param is int) {
31 return param + 42; 34 return param + 42;
32 } 35 }
33 return param + 53; 36 return param + 53;
34 } 37 }
35 """; 38 """;
36 39
37 const String TEST_IF_NOT_ELSE = r""" 40 const String TEST_IF_NOT_ELSE = r"""
38 test(param) { 41 test(param) {
42 print('Printing this ensures that String+ is in the system.');
39 if (param is !int) { 43 if (param is !int) {
40 param = param + 53; 44 param = param + 53;
41 } else { 45 } else {
42 param = param + 42; 46 param = param + 42;
43 } 47 }
44 return param; 48 return param;
45 } 49 }
46 """; 50 """;
47 51
48 const String TEST_IF_NOT_RETURN = r""" 52 const String TEST_IF_NOT_RETURN = r"""
49 test(param) { 53 test(param) {
54 print('Printing this ensures that String+ is in the system.');
50 if (param is !int) return param + 53; 55 if (param is !int) return param + 53;
51 return param + 42; 56 return param + 42;
52 } 57 }
53 """; 58 """;
54 59
55 const String TEST_IF_NOT_ELSE_RETURN = r""" 60 const String TEST_IF_NOT_ELSE_RETURN = r"""
56 test(param) { 61 test(param) {
62 print('Printing this ensures that String+ is in the system.');
57 if (param is !int) { 63 if (param is !int) {
58 return param + 53; 64 return param + 53;
59 } else { 65 } else {
60 param = param + 42; 66 param = param + 42;
61 } 67 }
62 return param; 68 return param;
63 } 69 }
64 """; 70 """;
65 71
66 compileAndTest(String code) { 72 compileAndTest(String code) {
67 String generated = compile(code, entry: 'test'); 73 String generated = compile(code, entry: 'test');
68 RegExp validAdd = 74 RegExp validAdd =
69 new RegExp("($anyIdentifier \\+ 42)|($anyIdentifier \\+= 42)"); 75 new RegExp("($anyIdentifier \\+ 42)|($anyIdentifier \\+= 42)");
70 RegExp invalidAdd = new RegExp("$anyIdentifier \\+ 53"); 76 RegExp invalidAdd = new RegExp("$anyIdentifier \\+ 53");
71 Expect.isTrue(validAdd.hasMatch(generated)); 77 Expect.isTrue(validAdd.hasMatch(generated));
72 Expect.isFalse(invalidAdd.hasMatch(generated)); 78 Expect.isFalse(invalidAdd.hasMatch(generated));
73 } 79 }
74 80
75 main() { 81 main() {
76 compileAndTest(TEST_IF); 82 compileAndTest(TEST_IF);
77 compileAndTest(TEST_IF_ELSE); 83 compileAndTest(TEST_IF_ELSE);
78 compileAndTest(TEST_IF_RETURN); 84 compileAndTest(TEST_IF_RETURN);
79 compileAndTest(TEST_IF_NOT_ELSE); 85 compileAndTest(TEST_IF_NOT_ELSE);
80 compileAndTest(TEST_IF_NOT_RETURN); 86 compileAndTest(TEST_IF_NOT_RETURN);
81 compileAndTest(TEST_IF_NOT_ELSE_RETURN); 87 compileAndTest(TEST_IF_NOT_ELSE_RETURN);
82 } 88 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/interceptor_test.dart ('k') | tests/compiler/dart2js/value_range_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698