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

Side by Side Diff: dart/tests/compiler/dart2js_foreign/native_null_closure_test.dart

Issue 11293272: Update dart2js_foreign suite as we now validate annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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 import 'native_metadata.dart';
6
5 typedef void MyFunctionType(); 7 typedef void MyFunctionType();
6 8
7 @native("*A") 9 @Native("*A")
8 class A { 10 class A {
9 @native setClosure(MyFunctionType f); 11 @native setClosure(MyFunctionType f);
10 @native check(MyFunctionType f); 12 @native check(MyFunctionType f);
11 @native invoke(); 13 @native invoke();
12 } 14 }
13 15
14 @native makeA() { return new A(); } 16 @native makeA() { return new A(); }
15 17
16 @native(""" 18 @Native("""
17 function A() {} 19 function A() {}
18 A.prototype.setClosure = function(f) { this.f = f; }; 20 A.prototype.setClosure = function(f) { this.f = f; };
19 A.prototype.check = function(f) { return this.f === f; }; 21 A.prototype.check = function(f) { return this.f === f; };
20 A.prototype.invoke = function() { return this.f(); }; 22 A.prototype.invoke = function() { return this.f(); };
21 makeA = function(){return new A;}; 23 makeA = function(){return new A;};
22 """) 24 """)
23 void setup(); 25 void setup();
24 26
25 27
26 main() { 28 main() {
27 setup(); 29 setup();
28 A a = makeA(); 30 A a = makeA();
29 a.setClosure(null); 31 a.setClosure(null);
30 Expect.isTrue(a.check(null)); 32 Expect.isTrue(a.check(null));
31 bool caughtException = false; 33 bool caughtException = false;
32 try { 34 try {
33 a.invoke(); 35 a.invoke();
34 } on Exception catch (e) { 36 } on Exception catch (e) {
35 caughtException = true; 37 caughtException = true;
36 } 38 }
37 Expect.isTrue(caughtException); 39 Expect.isTrue(caughtException);
38 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698