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

Unified Diff: tests/language/cast2_test.dart

Issue 50293007: Fix a bug in typecasts in the VM. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/cast2_test.dart
diff --git a/tests/language/cast2_test.dart b/tests/language/cast2_test.dart
index 397ac4543ff4c3490b61688db66ebe655ef4aa8f..b2aa11f6d8cff760b62c8b611965751d022feba8 100644
--- a/tests/language/cast2_test.dart
+++ b/tests/language/cast2_test.dart
@@ -3,10 +3,15 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Test 'expression as Type' casts.
class C {
final int foo = 42;
+
+ int val = 0;
+ void inc() { ++val; }
}
class D extends C {
@@ -18,6 +23,10 @@ main() {
Object od = new D();
(oc as dynamic).bar; /// 01: runtime error
-}
-
+ // Casts should always evaluate the left-hand side, if only for its effects.
+ oc.inc() as dynamic;
+ Expect.equals(1, oc.val);
+ oc.inc() as Object;
+ Expect.equals(2, oc.val);
+}
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698