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

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

Issue 196223017: Fix bad generate-at-use-site. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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/pure_function2_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 // Regression test for issue 17483.
8
9 class A {
10 var x, y;
11 A(x, this.y) {
12 this.x = x;
13 }
14 toString() => "a";
15 }
16
17 foo(trace) => trace.add("foo");
18 bar(trace) => trace.add("bar");
19
20 main() {
21 var trace = [];
22 // Dart2js must keep the order of t1 and t2.
23 var t1 = foo(trace);
24 var t2 = bar(trace);
25 // Dart2js inlines the constructor, yielding something like:
26 // t3 = jsNew A(null, t2); // Note that jsNew is pure.
27 // t3.x = t1;
28 // t3 is used twice and cannot be generated at use site.
29 // Dart2js must not allow t1 to cross the t3-line.
30 var a = new A(t1, t2);
31 // Use a. It is already implicitly used by the this.x = x line in its
32 // constructor. With the following use we use it twice and make sure that
33 // the allocation can not be generated at use-site.
34 trace.add(a.toString());
35 Expect.listEquals(["foo", "bar", "a"], trace);
36 }
OLDNEW
« no previous file with comments | « tests/language/pure_function2_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698