OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
8 | 8 |
9 // Test for emitting JavaScript pre- and post-increment and assignment ops. | 9 // Test for emitting JavaScript pre- and post-increment and assignment ops. |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 var a = 42; | 73 var a = 42; |
74 int foo() { var r = a; a = a * 2; return a; } // this.a *= 2 | 74 int foo() { var r = a; a = a * 2; return a; } // this.a *= 2 |
75 } | 75 } |
76 | 76 |
77 void main() { | 77 void main() { |
78 var a = new A(); | 78 var a = new A(); |
79 print(a.foo()); | 79 print(a.foo()); |
80 } | 80 } |
81 """; | 81 """; |
82 | 82 |
83 | |
84 main() { | 83 main() { |
85 test(String code, Function f) { | 84 test(String code, Function f) { |
86 asyncTest(() => compileAll(code, disableInlining: true).then((generated) { | 85 asyncTest(() => compileAll(code, disableInlining: true).then((generated) { |
87 Expect.isTrue(f(generated)); | 86 Expect.isTrue(f(generated)); |
88 })); | 87 })); |
89 } | 88 } |
90 | 89 |
91 test(TEST_1, (generated) => generated.contains(r'return this.a++;')); | 90 test(TEST_1, (generated) => generated.contains(r'return this.a++;')); |
92 test(TEST_2, (generated) => generated.contains(r'return ++this.a;')); | 91 test(TEST_2, (generated) => generated.contains(r'return ++this.a;')); |
93 test(TEST_3, (generated) => generated.contains(r'return this.a--;')); | 92 test(TEST_3, (generated) => generated.contains(r'return this.a--;')); |
94 test(TEST_4, (generated) => generated.contains(r'return --this.a;')); | 93 test(TEST_4, (generated) => generated.contains(r'return --this.a;')); |
95 test(TEST_5, (generated) => generated.contains(r' this.a -= 2;')); | 94 test(TEST_5, (generated) => generated.contains(r' this.a -= 2;')); |
96 test(TEST_6, (generated) => generated.contains(r' this.a *= 2;')); | 95 test(TEST_6, (generated) => generated.contains(r' this.a *= 2;')); |
97 } | 96 } |
OLD | NEW |