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

Side by Side Diff: tests/language/logical_expression5_test.dart

Issue 182373002: Fix bad type-inferrence for logical expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use lhs of &&. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « tests/language/logical_expression4_test.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
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'package:expect/expect.dart';
6
7 bool nonInlinedNumTypeCheck(Object object) {
8 if (new DateTime.now().millisecondsSinceEpoch == 42) {
9 return nonInlinedNumTypeCheck(object);
10 }
11 return object is num;
12 }
13
14 bool nonInlinedStringTypeCheck(Object object) {
15 if (new DateTime.now().millisecondsSinceEpoch == 42) {
16 return nonInlinedStringTypeCheck(object);
17 }
18 return object is String;
19 }
20
21 int confuse(x) {
22 if (new DateTime.now().millisecondsSinceEpoch == 42) return confuse(x - 1);
23 return x;
24 }
25
26 main() {
27 var o = [ "foo", 499 ][confuse(0)];
28
29 // The is-checks in the '!' must not be propagated to the if-body, but
30 // the second is-check should.
31 if (!(o is num) && o is String) {
32 Expect.isFalse((nonInlinedNumTypeCheck(o)));
33 Expect.isTrue((nonInlinedStringTypeCheck(o)));
34 }
35 }
OLDNEW
« no previous file with comments | « tests/language/logical_expression4_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698