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

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

Issue 2990083002: dart2js_native tests: Migrate 'native STRING' to JS-calls - part 2/2 (Closed)
Patch Set: remove defunct comments 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 import "native_testing.dart"; 5 import "native_testing.dart";
6 6
7 // Verify that methods are not renamed to clash with native field names 7 // Verify that methods are not renamed to clash with native field names
8 // that are known from the DOM (like x, y, z). 8 // that are known from the DOM (like x, y, z).
9 @Native("A") 9 @Native("A")
10 class A { 10 class A {
11 int x; 11 int x;
12 int y; 12 int y;
13 int z; 13 int z;
14 int gettersCalled; 14 int gettersCalled;
15 } 15 }
16 16
17 void setup() native r""" 17 void setup() {
18 function getter() { 18 JS('', r"""
19 this.gettersCalled++; 19 (function(){
20 return 42; 20 function getter() {
21 this.gettersCalled++;
22 return 42;
23 }
24
25 function A(){
26 var a = Object.create(
27 { constructor: A },
28 { x: { get: getter, configurable: false, writeable: false },
29 y: { get: getter, configurable: false, writeable: false },
30 z: { get: getter, configurable: false, writeable: false }
31 });
32 a.gettersCalled = 0;
33 return a;
34 }
35
36 makeA = function() { return new A(); };
37 self.nativeConstructor(A);
38 })()""");
21 } 39 }
22 40
23 function A(){
24 var a = Object.create(
25 { constructor: A },
26 { x: { get: getter, configurable: false, writeable: false },
27 y: { get: getter, configurable: false, writeable: false },
28 z: { get: getter, configurable: false, writeable: false }
29 });
30 a.gettersCalled = 0;
31 return a;
32 }
33
34 makeA = function() { return new A; };
35 self.nativeConstructor(A);
36 """;
37
38 A makeA() native; 41 A makeA() native;
39 42
40 class B { 43 class B {
41 void a() {} 44 void a() {}
42 void a0() {} 45 void a0() {}
43 void a1() {} 46 void a1() {}
44 void a2() {} 47 void a2() {}
45 void a3() {} 48 void a3() {}
46 void a4() {} 49 void a4() {}
47 void a5() {} 50 void a5() {}
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 try { 164 try {
162 x.a25(); 165 x.a25();
163 } catch (e) {} 166 } catch (e) {}
164 try { 167 try {
165 x.a26(); 168 x.a26();
166 } catch (e) {} 169 } catch (e) {}
167 Expect.equals(0, x.gettersCalled); 170 Expect.equals(0, x.gettersCalled);
168 Expect.equals(42, x.z); 171 Expect.equals(42, x.z);
169 Expect.equals(1, x.gettersCalled); 172 Expect.equals(1, x.gettersCalled);
170 } 173 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/jsobject_test.dart ('k') | tests/compiler/dart2js_native/native_class_fields_3_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698