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

Side by Side Diff: dart/tests/compiler/dart2js_foreign/native_property_test.dart

Issue 10823423: Change dart2js_foreign suite to use metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Properties on hidden native classes. 5 // Properties on hidden native classes.
6 6
7 class A native "*A" { 7 @native("*A")
8 class A {
8 9
9 // Setters and getters should be similar to these methods: 10 // Setters and getters should be similar to these methods:
10 int getX() native 'return this._x;'; 11 @native('return this._x;')
11 void setX(int value) native 'this._x = value;'; 12 int getX();
12 13
13 int get X() native; 14 @native('this._x = value;')
14 set X(int value) native; 15 void setX(int value);
15 16
16 int get Y() native; 17 @native
17 set Y(int value) native; 18 int get X();
18 19
19 int get Z() native 'return this._z;'; 20 @native
20 set Z(int value) native 'this._z = value;'; 21 set X(int value);
22
23 @native
24 int get Y();
25
26 @native
27 set Y(int value);
28
29 @native('return this._z;')
30 int get Z();
31
32 @native('this._z = value;')
33 set Z(int value);
21 } 34 }
22 35
23 A makeA() native { return new A(); } 36 @native
37 A makeA() { return new A(); }
24 38
25 void setup() native """ 39 @native("""
26 function A() {} 40 function A() {}
27 41
28 Object.defineProperty(A.prototype, "X", { 42 Object.defineProperty(A.prototype, "X", {
29 get: function () { return this._x; }, 43 get: function () { return this._x; },
30 set: function (v) { this._x = v; } 44 set: function (v) { this._x = v; }
31 }); 45 });
32 46
33 makeA = function(){return new A;}; 47 makeA = function(){return new A;};
34 """; 48 """)
49 void setup();
35 50
36 51
37 main() { 52 main() {
38 setup(); 53 setup();
39 54
40 var a = makeA(); 55 var a = makeA();
41 56
42 a.setX(5); 57 a.setX(5);
43 Expect.equals(5, a.getX()); 58 Expect.equals(5, a.getX());
44 59
45 a.X = 10; 60 a.X = 10;
46 a.Y = 20; 61 a.Y = 20;
47 a.Z = 30; 62 a.Z = 30;
48 63
49 Expect.equals(10, a.X); 64 Expect.equals(10, a.X);
50 Expect.equals(20, a.Y); 65 Expect.equals(20, a.Y);
51 Expect.equals(30, a.Z); 66 Expect.equals(30, a.Z);
52 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698