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

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

Issue 23816004: Is checks on the right hand side of an || used in an 'if' do not apply to the then branch of that i… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/inferrer_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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "package:async_helper/async_helper.dart"; 6 import "package:async_helper/async_helper.dart";
7 import 7 import
8 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' 8 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
9 show TypeMask; 9 show TypeMask;
10 10
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 var c = topLevelGetter(); 227 var c = topLevelGetter();
228 if (c != null && c is! bool && c is! int) { 228 if (c != null && c is! bool && c is! int) {
229 return 42; 229 return 42;
230 } else if (c is String) { 230 } else if (c is String) {
231 return c; 231 return c;
232 } else { 232 } else {
233 return 68; 233 return 68;
234 } 234 }
235 } 235 }
236 236
237 testIsCheck21(a) {
238 if (a is int || a is List) {
239 return a;
240 } else {
241 return 42;
242 }
243 }
244
245 testIsCheck22(a) {
246 return (a is int || a is List) ? a : 42;
247 }
248
237 testIf1(a) { 249 testIf1(a) {
238 var c = null; 250 var c = null;
239 if (a) { 251 if (a) {
240 c = 10; 252 c = 10;
241 } else { 253 } else {
242 } 254 }
243 return c; 255 return c;
244 } 256 }
245 257
246 testIf2(a) { 258 testIf2(a) {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 testIsCheck11(topLevelGetter()); 550 testIsCheck11(topLevelGetter());
539 testIsCheck12(topLevelGetter()); 551 testIsCheck12(topLevelGetter());
540 testIsCheck13(topLevelGetter()); 552 testIsCheck13(topLevelGetter());
541 testIsCheck14(topLevelGetter()); 553 testIsCheck14(topLevelGetter());
542 testIsCheck15(topLevelGetter()); 554 testIsCheck15(topLevelGetter());
543 testIsCheck16(topLevelGetter()); 555 testIsCheck16(topLevelGetter());
544 testIsCheck17(topLevelGetter()); 556 testIsCheck17(topLevelGetter());
545 testIsCheck18(topLevelGetter()); 557 testIsCheck18(topLevelGetter());
546 testIsCheck19(topLevelGetter()); 558 testIsCheck19(topLevelGetter());
547 testIsCheck20(); 559 testIsCheck20();
560 testIsCheck21(topLevelGetter());
561 testIsCheck22(topLevelGetter());
548 testIf1(topLevelGetter()); 562 testIf1(topLevelGetter());
549 testIf2(topLevelGetter()); 563 testIf2(topLevelGetter());
550 returnAsString(); 564 returnAsString();
551 returnIntAsNum(); 565 returnIntAsNum();
552 returnAsTypedef(); 566 returnAsTypedef();
553 returnTopLevelGetter(); 567 returnTopLevelGetter();
554 testDeadCode(); 568 testDeadCode();
555 testLabeledIf(); 569 testLabeledIf();
556 testSwitch1(); 570 testSwitch1();
557 testSwitch2(); 571 testSwitch2();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 checkReturn('testIsCheck11', intType); 656 checkReturn('testIsCheck11', intType);
643 checkReturn('testIsCheck12', typesTask.dynamicType); 657 checkReturn('testIsCheck12', typesTask.dynamicType);
644 checkReturn('testIsCheck13', intType); 658 checkReturn('testIsCheck13', intType);
645 checkReturn('testIsCheck14', typesTask.dynamicType); 659 checkReturn('testIsCheck14', typesTask.dynamicType);
646 checkReturn('testIsCheck15', intType); 660 checkReturn('testIsCheck15', intType);
647 checkReturn('testIsCheck16', typesTask.dynamicType); 661 checkReturn('testIsCheck16', typesTask.dynamicType);
648 checkReturn('testIsCheck17', intType); 662 checkReturn('testIsCheck17', intType);
649 checkReturn('testIsCheck18', typesTask.dynamicType); 663 checkReturn('testIsCheck18', typesTask.dynamicType);
650 checkReturn('testIsCheck19', typesTask.dynamicType); 664 checkReturn('testIsCheck19', typesTask.dynamicType);
651 checkReturn('testIsCheck20', typesTask.dynamicType.nonNullable()); 665 checkReturn('testIsCheck20', typesTask.dynamicType.nonNullable());
666 checkReturn('testIsCheck21', typesTask.dynamicType);
667 checkReturn('testIsCheck22', typesTask.dynamicType);
652 checkReturn('testIf1', typesTask.intType.nullable()); 668 checkReturn('testIf1', typesTask.intType.nullable());
653 checkReturn('testIf2', typesTask.intType.nullable()); 669 checkReturn('testIf2', typesTask.intType.nullable());
654 checkReturn('returnAsString', 670 checkReturn('returnAsString',
655 new TypeMask.subtype(compiler.stringClass.computeType(compiler))); 671 new TypeMask.subtype(compiler.stringClass.computeType(compiler)));
656 checkReturn('returnIntAsNum', typesTask.intType); 672 checkReturn('returnIntAsNum', typesTask.intType);
657 checkReturn('returnAsTypedef', typesTask.functionType.nullable()); 673 checkReturn('returnAsTypedef', typesTask.functionType.nullable());
658 checkReturn('returnTopLevelGetter', typesTask.intType); 674 checkReturn('returnTopLevelGetter', typesTask.intType);
659 checkReturn('testDeadCode', typesTask.intType); 675 checkReturn('testDeadCode', typesTask.intType);
660 checkReturn('testLabeledIf', typesTask.intType.nullable()); 676 checkReturn('testLabeledIf', typesTask.intType.nullable());
661 checkReturn('testSwitch1', typesTask.intType 677 checkReturn('testSwitch1', typesTask.intType
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 checkFactoryConstructor('A', ''); 729 checkFactoryConstructor('A', '');
714 730
715 checkReturn('testCascade1', typesTask.growableListType); 731 checkReturn('testCascade1', typesTask.growableListType);
716 checkReturn('testCascade2', new TypeMask.nonNullExact( 732 checkReturn('testCascade2', new TypeMask.nonNullExact(
717 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper')))); 733 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper'))));
718 checkReturn('testSpecialization1', typesTask.numType); 734 checkReturn('testSpecialization1', typesTask.numType);
719 checkReturn('testSpecialization2', typesTask.dynamicType); 735 checkReturn('testSpecialization2', typesTask.dynamicType);
720 checkReturn('testSpecialization3', typesTask.intType.nullable()); 736 checkReturn('testSpecialization3', typesTask.intType.nullable());
721 })); 737 }));
722 } 738 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/inferrer_visitor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698