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

Side by Side Diff: tests/compiler/dart2js_native/native_null_closure_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Test that exception unwrapping handle cases like ({foo:null}).foo(). 5 // Test that exception unwrapping handle cases like ({foo:null}).foo().
6 6
7 import "native_testing.dart"; 7 import "native_testing.dart";
8 8
9 typedef void MyFunctionType(); 9 typedef void MyFunctionType();
10 10
11 @Native("A") 11 @Native("A")
12 class A { 12 class A {
13 setClosure(MyFunctionType f) native; 13 setClosure(MyFunctionType f) native;
14 check(MyFunctionType f) native; 14 check(MyFunctionType f) native;
15 invoke() native; 15 invoke() native;
16 } 16 }
17 17
18 makeA() native; 18 makeA() native;
19 19
20 void setup() native """ 20 void setup() {
21 JS('', r"""
22 (function(){
21 function A() {} 23 function A() {}
22 A.prototype.setClosure = function(f) { this.f = f; }; 24 A.prototype.setClosure = function(f) { this.f = f; };
23 A.prototype.check = function(f) { return this.f === f; }; 25 A.prototype.check = function(f) { return this.f === f; };
24 A.prototype.invoke = function() { return this.f(); }; 26 A.prototype.invoke = function() { return this.f(); };
25 makeA = function(){return new A;}; 27 makeA = function(){return new A()};
26 28
27 self.nativeConstructor(A); 29 self.nativeConstructor(A);
28 """; 30 })()""");
31 }
29 32
30 main() { 33 main() {
31 nativeTesting(); 34 nativeTesting();
32 setup(); 35 setup();
33 A a = makeA(); 36 A a = makeA();
34 a.setClosure(null); 37 a.setClosure(null);
35 Expect.isTrue(a.check(null)); 38 Expect.isTrue(a.check(null));
36 bool caughtException = false; 39 bool caughtException = false;
37 try { 40 try {
38 a.invoke(); 41 a.invoke();
39 } on NoSuchMethodError catch (e) { 42 } on NoSuchMethodError catch (e) {
40 print(e); 43 print(e);
41 caughtException = true; 44 caughtException = true;
42 } 45 }
43 Expect.isTrue(caughtException); 46 Expect.isTrue(caughtException);
44 } 47 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/native_novel_html_test.dart ('k') | tests/compiler/dart2js_native/native_null_frog_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698