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

Unified Diff: tests/language/getter_setter_order_test.dart

Issue 13094013: Fix bug 9239 by always evaluating the receiver before the value in an instance SendSet. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/getter_setter_order_test.dart
===================================================================
--- tests/language/getter_setter_order_test.dart (revision 0)
+++ tests/language/getter_setter_order_test.dart (revision 0)
@@ -0,0 +1,92 @@
+// Copyright (c) 2013, 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.
+
+// Test for the evaluation order of getters and setters.
+
+var trace;
+
+class X {
+ get b {
+ trace.add('get b');
+ return new X();
+ }
+
+ set c (value) {
+ trace.add('set c');
+ }
+
+ toString() {
+ trace.add('toString');
+ return 'X';
+ }
+
+ get c {
+ trace.add('get c');
+ return 42;
+ }
+
+ get d {
+ trace.add('get d');
+ return new X();
+ }
+
+ operator [] (index) {
+ trace.add('index');
+ return 42;
+ }
+
+ operator []=(index, value) {
+ trace.add('indexSet');
+ }
+}
+
+main() {
+ var x = new X();
+
+ trace = [];
+ x.b.c = '$x';
+ Expect.listEquals(['get b', 'toString', 'set c'], trace);
+
+ trace = [];
+ x.b.c += '$x'.hashCode;
+ Expect.listEquals(['get b', 'get c', 'toString', 'set c'], trace);
+
+ trace = [];
+ x.b.c++;
+ Expect.listEquals(['get b', 'get c', 'set c'], trace);
+
+ trace = [];
+ x.b.d[42] = '$x';
+ Expect.listEquals(['get b', 'get d', 'toString', 'indexSet'], trace);
+
+ trace = [];
+ x.b.d[42] += '$x'.hashCode;
+ Expect.listEquals(['get b', 'get d', 'index', 'toString', 'indexSet'], trace);
+
+ trace = [];
+ x.b.d[42]++;
+ Expect.listEquals(['get b', 'get d', 'index', 'indexSet'], trace);
+
+ trace = [];
+ ++x.b.d[42];
+ Expect.listEquals(['get b', 'get d', 'index', 'indexSet'], trace);
+
+ trace = [];
+ x.b.d[x.c] *= '$x'.hashCode;
+ Expect.listEquals(
+ ['get b', 'get d', 'get c', 'index', 'toString', 'indexSet'], trace);
+
+ trace = [];
+ x.b.c = x.d.c = '$x';
+ Expect.listEquals(['get b', 'get d', 'toString', 'set c', 'set c',], trace);
+
+ trace = [];
+ x.b.c = x.d[42] *= '$x'.hashCode;
+ Expect.listEquals(
+ ['get b', 'get d', 'index', 'toString', 'indexSet', 'set c'], trace);
+
+ trace = [];
+ x.b.c = ++x.d.c;
+ Expect.listEquals(['get b', 'get d', 'get c', 'set c', 'set c'], trace);
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698