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

Side by Side Diff: tests/compiler/dart2js_native/native_field_optimization_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 "dart:_js_helper"; 5 import "dart:_js_helper";
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 // Test that compiler is cautious with optimizations on native fields. The 8 // Test that compiler is cautious with optimizations on native fields. The
9 // motivation is that DOM properties are getters and setters with arbitrary 9 // motivation is that DOM properties are getters and setters with arbitrary
10 // effects. Setting CSSStyleDeclaration.borderLeft can canonicalize the value 10 // effects. Setting CSSStyleDeclaration.borderLeft can canonicalize the value
11 // and changes the value of CSSStyleDeclaration.border. 11 // and changes the value of CSSStyleDeclaration.border.
12 12
13 @Native("Foo") 13 @Native("Foo")
14 class Foo { 14 class Foo {
15 var a; 15 var a;
16 var b; 16 var b;
17 var ab; 17 var ab;
18 } 18 }
19 19
20 Foo makeFoo() native; 20 Foo makeFoo() native ;
21 21
22 void setup() native """ 22 void setup() native """
23 function Foo() { this.i = 0; } 23 function Foo() { this.i = 0; }
24 24
25 Object.defineProperty(Foo.prototype, 'a', { 25 Object.defineProperty(Foo.prototype, 'a', {
26 get: function () { return (this._a || '') + ++this.i; }, 26 get: function () { return (this._a || '') + ++this.i; },
27 set: function (v) { this._a = v.toLowerCase(); } 27 set: function (v) { this._a = v.toLowerCase(); }
28 }); 28 });
29 29
30 Object.defineProperty(Foo.prototype, 'b', { 30 Object.defineProperty(Foo.prototype, 'b', {
31 get: function () { return this._b || ''; }, 31 get: function () { return this._b || ''; },
32 set: function (v) { this._b = v.toLowerCase(); } 32 set: function (v) { this._b = v.toLowerCase(); }
33 }); 33 });
34 34
35 Object.defineProperty(Foo.prototype, 'ab', { 35 Object.defineProperty(Foo.prototype, 'ab', {
36 get: function () { return this.a + ' ' + this.b; }, 36 get: function () { return this.a + ' ' + this.b; },
37 set: function (v) { 37 set: function (v) {
38 var s = v.split(' '); 38 var s = v.split(' ');
39 this.a = s[0]; 39 this.a = s[0];
40 this.b = s[1]; 40 this.b = s[1];
41 } 41 }
42 }); 42 });
43 43
44 makeFoo = function() { return new Foo() } 44 makeFoo = function() { return new Foo() }
45 """; 45 """;
46 46
47
48 test1() { 47 test1() {
49 var f = makeFoo(); 48 var f = makeFoo();
50 f.a = 'Hi'; 49 f.a = 'Hi';
51 f.b = 'There'; 50 f.b = 'There';
52 Expect.equals('hi1 there', f.ab); 51 Expect.equals('hi1 there', f.ab);
53 } 52 }
54 53
55 test2() { 54 test2() {
56 // Test for CSE. dart2js currently does CSE loads. Is this the right choice? 55 // Test for CSE. dart2js currently does CSE loads. Is this the right choice?
57 var f = makeFoo(); 56 var f = makeFoo();
(...skipping 26 matching lines...) Expand all
84 Expect.equals('a1', a2); 83 Expect.equals('a1', a2);
85 } 84 }
86 85
87 main() { 86 main() {
88 setup(); 87 setup();
89 (test1)(); 88 (test1)();
90 (test2)(); 89 (test2)();
91 (test3)(); 90 (test3)();
92 (test4)(); 91 (test4)();
93 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698