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

Side by Side Diff: tests/compiler/dart2js_native/native_field_invocation_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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 @Native("A") 7 @Native("A")
8 class A { 8 class A {
9 var foo; 9 var foo;
10 } 10 }
11 11
12 class B { 12 class B {
13 var foo; 13 var foo;
14 } 14 }
15 15
16 nativeId(x) native; 16 nativeId(x) native;
17 17
18 void setup() native """ 18 void setup() {
19 nativeId = function(x) { return x; } 19 JS('', r"""
20 """; 20 (function(){
21 nativeId = function(x) { return x; }
22 })()""");
23 }
21 24
22 main() { 25 main() {
23 setup(); 26 setup();
24 var b = new B(); 27 var b = new B();
25 b.foo = (x) => x + 1; 28 b.foo = (x) => x + 1;
26 b = nativeId(b); // Inferrer doesn't know if A has been instantiated. 29 b = nativeId(b); // Inferrer doesn't know if A has been instantiated.
27 // At this point b could be A or B. The call to "foo" thus needs to go through 30 // At this point b could be A or B. The call to "foo" thus needs to go through
28 // an interceptor. Tests that the interceptor works for retrieving the Dart 31 // an interceptor. Tests that the interceptor works for retrieving the Dart
29 // class field and invoking the closure. 32 // class field and invoking the closure.
30 Expect.equals(499, b.foo(498)); 33 Expect.equals(499, b.foo(498));
31 } 34 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698