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

Side by Side Diff: tests/compiler/dart2js/field_update_test.dart

Issue 218993003: Emit read-modify-write of fields as assignment op. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add test Created 6 years, 8 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 | « sdk/lib/_internal/compiler/implementation/ssa/tracer.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 import "package:async_helper/async_helper.dart";
7 import 'compiler_helper.dart';
8
9 // Test for emitting JavaScript pre- and post-increment and assignment ops.
10
11 const String TEST_1 = """
12 class A {
13 var a = 42;
14 int foo() { var r = a; a = a + 1; return r; } // this.a++
15 }
16
17 void main() {
18 var a = new A();
19 print(a.foo());
20 }
21 """;
22
23 const String TEST_2 = """
24 class A {
25 var a = 42;
26 int foo() { var r = a; a = a + 1; return a; } // ++this.a
27 }
28
29 void main() {
30 var a = new A();
31 print(a.foo());
32 }
33 """;
34
35 const String TEST_3 = """
36 class A {
37 var a = 42;
38 int foo() { var r = a; a = a - 1; return r; } // this.a--
39 }
40
41 void main() {
42 var a = new A();
43 print(a.foo());
44 }
45 """;
46
47 const String TEST_4 = """
48 class A {
49 var a = 42;
50 int foo() { var r = a; a = a - 1; return a; } // --this.a
51 }
52
53 void main() {
54 var a = new A();
55 print(a.foo());
56 }
57 """;
58
59 const String TEST_5 = """
60 class A {
61 var a = 42;
62 int foo() { var r = a; a = a - 2; return a; } // this.a -= 2
63 }
64
65 void main() {
66 var a = new A();
67 print(a.foo());
68 }
69 """;
70
71 const String TEST_6 = """
72 class A {
73 var a = 42;
74 int foo() { var r = a; a = a * 2; return a; } // this.a *= 2
75 }
76
77 void main() {
78 var a = new A();
79 print(a.foo());
80 }
81 """;
82
83
84 main() {
85 test(String code, Function f) {
86 asyncTest(() => compileAll(code, disableInlining: true).then((generated) {
87 Expect.isTrue(f(generated));
88 }));
89 }
90
91 test(TEST_1, (generated) => generated.contains(r'return this.a++;'));
92 test(TEST_2, (generated) => generated.contains(r'return ++this.a;'));
93 test(TEST_3, (generated) => generated.contains(r'return this.a--;'));
94 test(TEST_4, (generated) => generated.contains(r'return --this.a;'));
95 test(TEST_5, (generated) => generated.contains(r' this.a -= 2;'));
96 test(TEST_6, (generated) => generated.contains(r' this.a *= 2;'));
97 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/tracer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698