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

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

Issue 383413003: Add @Native(...) annotation for native class names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 5 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) 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 'dart:_js_helper'; 7 import "dart:_js_helper";
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
11 typedef void MyFunctionType(); 11 typedef void MyFunctionType();
12 12
13 class A native "A" { 13 @Native("A")
14 class A {
14 setClosure(MyFunctionType f) native; 15 setClosure(MyFunctionType f) native;
15 check(MyFunctionType f) native; 16 check(MyFunctionType f) native;
16 invoke() native; 17 invoke() native;
17 } 18 }
18 19
19 makeA() native { return new A(); } 20 makeA() native { return new A(); }
20 21
21 void setup() native """ 22 void setup() native """
22 function A() {} 23 function A() {}
23 A.prototype.setClosure = function(f) { this.f = f; }; 24 A.prototype.setClosure = function(f) { this.f = f; };
24 A.prototype.check = function(f) { return this.f === f; }; 25 A.prototype.check = function(f) { return this.f === f; };
25 A.prototype.invoke = function() { return this.f(); }; 26 A.prototype.invoke = function() { return this.f(); };
26 makeA = function(){return new A;}; 27 makeA = function(){return new A;};
27 """; 28 """;
28 29
29 main() { 30 main() {
30 setup(); 31 setup();
31 A a = makeA(); 32 A a = makeA();
32 a.setClosure(null); 33 a.setClosure(null);
33 Expect.isTrue(a.check(null)); 34 Expect.isTrue(a.check(null));
34 bool caughtException = false; 35 bool caughtException = false;
35 try { 36 try {
36 a.invoke(); 37 a.invoke();
37 } on JsNoSuchMethodError catch (e) { 38 } on JsNoSuchMethodError catch (e) {
38 print(e); 39 print(e);
39 caughtException = true; 40 caughtException = true;
40 } 41 }
41 Expect.isTrue(caughtException); 42 Expect.isTrue(caughtException);
42 } 43 }
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