OLD | NEW |
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 'native_testing.dart'; | 5 import "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; |
6 | 7 |
7 // Test that compiler is cautious with optimizations on native fields. The | 8 // Test that compiler is cautious with optimizations on native fields. The |
8 // motivation is that DOM properties are getters and setters with arbitrary | 9 // motivation is that DOM properties are getters and setters with arbitrary |
9 // effects. Setting CSSStyleDeclaration.borderLeft can canonicalize the value | 10 // effects. Setting CSSStyleDeclaration.borderLeft can canonicalize the value |
10 // and changes the value of CSSStyleDeclaration.border. | 11 // and changes the value of CSSStyleDeclaration.border. |
11 | 12 |
12 @Native("Foo") | 13 @Native("Foo") |
13 class Foo { | 14 class Foo { |
14 var a; | 15 var a; |
15 var b; | 16 var b; |
(...skipping 18 matching lines...) Expand all Loading... |
34 Object.defineProperty(Foo.prototype, 'ab', { | 35 Object.defineProperty(Foo.prototype, 'ab', { |
35 get: function () { return this.a + ' ' + this.b; }, | 36 get: function () { return this.a + ' ' + this.b; }, |
36 set: function (v) { | 37 set: function (v) { |
37 var s = v.split(' '); | 38 var s = v.split(' '); |
38 this.a = s[0]; | 39 this.a = s[0]; |
39 this.b = s[1]; | 40 this.b = s[1]; |
40 } | 41 } |
41 }); | 42 }); |
42 | 43 |
43 makeFoo = function() { return new Foo() } | 44 makeFoo = function() { return new Foo() } |
44 | |
45 self.nativeConstructor(Foo); | |
46 """; | 45 """; |
47 | 46 |
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() { |
(...skipping 22 matching lines...) Expand all Loading... |
78 | 77 |
79 test4() { | 78 test4() { |
80 // Must not store-forward. | 79 // Must not store-forward. |
81 var f = makeFoo(); | 80 var f = makeFoo(); |
82 f.a = 'A'; | 81 f.a = 'A'; |
83 var a2 = f.a; | 82 var a2 = f.a; |
84 Expect.equals('a1', a2); | 83 Expect.equals('a1', a2); |
85 } | 84 } |
86 | 85 |
87 main() { | 86 main() { |
88 nativeTesting(); | |
89 setup(); | 87 setup(); |
90 (test1)(); | 88 (test1)(); |
91 (test2)(); | 89 (test2)(); |
92 (test3)(); | 90 (test3)(); |
93 (test4)(); | 91 (test4)(); |
94 } | 92 } |
OLD | NEW |