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

Side by Side Diff: test/checker/checker_test.dart

Issue 997143003: Fix for conditional expressions (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Add test case Created 5 years, 9 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
« no previous file with comments | « lib/src/checker/resolver.dart ('k') | test/codegen/expect/dart/_internal.js » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// General type checking tests 5 /// General type checking tests
6 library dev_compiler.test.checker_test; 6 library dev_compiler.test.checker_test;
7 7
8 import 'package:unittest/compact_vm_config.dart'; 8 import 'package:unittest/compact_vm_config.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 } 1541 }
1542 void foo(Object o) { 1542 void foo(Object o) {
1543 var a = const A(/*$error*/o); 1543 var a = const A(/*$error*/o);
1544 } 1544 }
1545 '''; 1545 ''';
1546 testChecker({'/main.dart': mk("severe:StaticTypeError")}, 1546 testChecker({'/main.dart': mk("severe:StaticTypeError")},
1547 allowConstCasts: false); 1547 allowConstCasts: false);
1548 testChecker({'/main.dart': mk("info:DownCast")}, allowConstCasts: true); 1548 testChecker({'/main.dart': mk("info:DownCast")}, allowConstCasts: true);
1549 }); 1549 });
1550 1550
1551 test('casts in conditionals', () {
1552 testChecker({
1553 '/main.dart': '''
1554 main() {
1555 bool b = true;
1556 num x = b ? 1 : 2.3;
1557 int y = /*info:DownCast*/b ? 1 : 2.3;
1558 String z = !b ? "hello" : null;
1559 z = b ? null : "hello";
1560 }
1561 '''
1562 });
1563 });
1564
1551 test('redirecting constructor', () { 1565 test('redirecting constructor', () {
1552 testChecker({ 1566 testChecker({
1553 '/main.dart': ''' 1567 '/main.dart': '''
1554 class A { 1568 class A {
1555 A(A x) {} 1569 A(A x) {}
1556 A.two() : this(/*severe:StaticTypeError*/3); 1570 A.two() : this(/*severe:StaticTypeError*/3);
1557 } 1571 }
1558 ''' 1572 '''
1559 }); 1573 });
1560 }); 1574 });
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2704 '/main.dart': ''' 2718 '/main.dart': '''
2705 class A {} 2719 class A {}
2706 class T1 implements A { 2720 class T1 implements A {
2707 /*severe:InferableOverride*/toString() {} 2721 /*severe:InferableOverride*/toString() {}
2708 } 2722 }
2709 ''' 2723 '''
2710 }, inferFromOverrides: false); 2724 }, inferFromOverrides: false);
2711 }); 2725 });
2712 }); 2726 });
2713 } 2727 }
OLDNEW
« no previous file with comments | « lib/src/checker/resolver.dart ('k') | test/codegen/expect/dart/_internal.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698