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

Unified Diff: tests/language/async_this_bound_test.dart

Issue 972063003: Make sure to bind a method to its receiver if it is stored in a temporary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/async_await_js_transform_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/async_this_bound_test.dart
diff --git a/tests/language/async_this_bound_test.dart b/tests/language/async_this_bound_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8757f039d37114a07533da99db3b0afb7efb430f
--- /dev/null
+++ b/tests/language/async_this_bound_test.dart
@@ -0,0 +1,59 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+
+class A {
+ int a = -1;
+
+ @NoInline()
+ foo(ignored, val) {
+ Expect.equals(val, this.a);
+ }
+}
+
+testA() async {
+ var a = new A();
+ a.foo(await false, -1);
+ a.a = 0;
+ a.foo(await false, 0);
+}
+
+@NoInline()
+@AssumeDynamic()
+confuse(x) => x;
+
+class B {
+ var f;
+ @NoInline()
+ var b = 10;
+ B(this.f);
+
+ bar(x) => b;
+}
+
+foo(x) => 499;
+bar(x) => 42;
+
+change(x) {
+ x.f = (x) => 99;
+}
+
+testB() async {
+ var b = confuse(new B(foo));
+ Expect.equals(99, b.f(await change(b)));
+ var b2 = confuse(new B(bar));
+ Expect.equals(10, b2.f(await (b2.f = b2.bar)));
+}
+
+test() async {
+ await testA();
+ await testB();
+}
+
+void main() {
+ asyncStart();
+ test().then((_) => asyncEnd());
+}
« no previous file with comments | « tests/compiler/dart2js/async_await_js_transform_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698