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

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

Issue 2984403002: dart2js_native tests: Migrate 'native STRING' to JS-calls (Closed)
Patch Set: the rest of the files Created 3 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
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 import 'native_testing.dart'; 7 import 'native_testing.dart';
8 8
9 @Native("A") 9 @Native("A")
10 class A { 10 class A {
11 11
12 // Setters and getters should be similar to these methods: 12 // Setters and getters should be similar to these methods:
13 int getX() => JS('int', '#._x', this); 13 int getX() => JS('int', '#._x', this);
14 void setX(int value) { JS('void', '#._x = #', this, value); } 14 void setX(int value) { JS('void', '#._x = #', this, value); }
15 15
16 int get X() native; 16 int get X() native;
17 set X(int value) native; 17 set X(int value) native;
18 18
19 int get Y() native; 19 int get Y() native;
20 set Y(int value) native; 20 set Y(int value) native;
21 21
22 int get Z => JS('int', '#._z', this); 22 int get Z => JS('int', '#._z', this);
23 set Z(int value) { JS('void', '#._z = #', this, value); } 23 set Z(int value) { JS('void', '#._z = #', this, value); }
24 } 24 }
25 25
26 A makeA() native; 26 A makeA() native;
27 27
28 void setup() native """ 28 void setup() {
29 function A() {} 29 JS('', r"""
30 (function(){
31 function A() {}
30 32
31 Object.defineProperty(A.prototype, "X", { 33 Object.defineProperty(A.prototype, "X", {
32 get: function () { return this._x; }, 34 get: function () { return this._x; },
33 set: function (v) { this._x = v; } 35 set: function (v) { this._x = v; }
34 }); 36 });
35 37
36 makeA = function(){return new A;}; 38 makeA = function(){return new A()};
37 39
38 self.nativeConstructor(A); 40 self.nativeConstructor(A);
39 """; 41 })()""");
42 }
40 43
41 44
42 main() { 45 main() {
43 nativeTesting(); 46 nativeTesting();
44 setup(); 47 setup();
45 48
46 var a = makeA(); 49 var a = makeA();
47 50
48 a.setX(5); 51 a.setX(5);
49 Expect.equals(5, a.getX()); 52 Expect.equals(5, a.getX());
50 53
51 a.X = 10; 54 a.X = 10;
52 a.Y = 20; 55 a.Y = 20;
53 a.Z = 30; 56 a.Z = 30;
54 57
55 Expect.equals(10, a.X); 58 Expect.equals(10, a.X);
56 Expect.equals(20, a.Y); 59 Expect.equals(20, a.Y);
57 Expect.equals(30, a.Z); 60 Expect.equals(30, a.Z);
58 61
59 confuse(a).setX(6); 62 confuse(a).setX(6);
60 Expect.equals(6, confuse(a).getX()); 63 Expect.equals(6, confuse(a).getX());
61 64
62 Expect.equals(6, confuse(a).X); 65 Expect.equals(6, confuse(a).X);
63 Expect.equals(20, confuse(a).Y); 66 Expect.equals(20, confuse(a).Y);
64 Expect.equals(30, confuse(a).Z); 67 Expect.equals(30, confuse(a).Z);
65 } 68 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/native_null_frog_test.dart ('k') | tests/compiler/dart2js_native/native_testing.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698