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

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

Issue 2763823002: Move spaces from before comments to within comments (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 // Check that calls through fields elide the call-through stub. This 5 // Check that calls through fields elide the call-through stub. This
6 // optimization is done by the simplifier, so inlining does not need to be 6 // optimization is done by the simplifier, so inlining does not need to be
7 // enabled. 7 // enabled.
8 8
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
11 import 'compiler_helper.dart'; 11 import 'compiler_helper.dart';
12 12
13 const String TEST1 = r''' 13 const String TEST1 = r'''
14 class W { 14 class W {
15 final Function _fun; 15 final Function _fun;
16 W(this._fun); 16 W(this._fun);
17 foo(zzz) => _fun(zzz); // this._fun$1(zzz) --> this._fun.call$1(zzz) 17 foo(zzz) => _fun(zzz); // this._fun$1(zzz) --> this._fun.call$1(zzz)
18 } 18 }
19 add1(x) => x + 1; 19 add1(x) => x + 1;
20 main() { 20 main() {
21 var w = new W(add1); 21 var w = new W(add1);
22 var x = w.foo(42); 22 var x = w.foo(42);
23 } 23 }
24 '''; 24 ''';
25 25
26 const String TEST2 = r''' 26 const String TEST2 = r'''
27 class W { 27 class W {
28 final Function __fun; 28 final Function __fun;
29 Function get _fun => __fun; 29 Function get _fun => __fun;
30 W(this.__fun); 30 W(this.__fun);
31 foo(zzz) => _fun(zzz); // this._fun$1(zzz) stays same. 31 foo(zzz) => _fun(zzz); // this._fun$1(zzz) stays same.
32 } 32 }
33 add1(x) => x + 1; 33 add1(x) => x + 1;
34 main() { 34 main() {
35 var w = new W(add1); 35 var w = new W(add1);
36 var x = w.foo(42); 36 var x = w.foo(42);
37 } 37 }
38 '''; 38 ''';
39 39
40 main() { 40 main() {
41 asyncTest(() => compileAll(TEST1).then((generated) { 41 asyncTest(() => compileAll(TEST1).then((generated) {
42 // Direct call through field. 42 // Direct call through field.
43 Expect.isTrue(generated.contains(r'this._fun.call$1(zzz)')); 43 Expect.isTrue(generated.contains(r'this._fun.call$1(zzz)'));
44 // No stub. 44 // No stub.
45 Expect.isFalse(generated.contains(r'_fun$1:')); 45 Expect.isFalse(generated.contains(r'_fun$1:'));
46 // No call to stub. 46 // No call to stub.
47 Expect.isFalse(generated.contains(r'_fun$1(')); 47 Expect.isFalse(generated.contains(r'_fun$1('));
48 })); 48 }));
49 49
50 asyncTest(() => compileAll(TEST2).then((generated) { 50 asyncTest(() => compileAll(TEST2).then((generated) {
51 // No call through field. 51 // No call through field.
52 Expect.isFalse(generated.contains(r'this._fun.call$1(zzz)')); 52 Expect.isFalse(generated.contains(r'this._fun.call$1(zzz)'));
53 // Call through stub. 53 // Call through stub.
54 Expect.isTrue(generated.contains(r'this._fun$1(zzz)')); 54 Expect.isTrue(generated.contains(r'this._fun$1(zzz)'));
55 // Stub is generated. 55 // Stub is generated.
56 Expect.isTrue(generated.contains(r'_fun$1:')); 56 Expect.isTrue(generated.contains(r'_fun$1:'));
57 // Call through getter (inside stub). 57 // Call through getter (inside stub).
58 Expect.isTrue(generated.contains(r'get$_fun().call$1')); 58 Expect.isTrue(generated.contains(r'get$_fun().call$1'));
59 })); 59 }));
60 } 60 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_spec_optimization_test.dart » ('j') | tests/compiler/dart2js_extra/23486_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698