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

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

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

Powered by Google App Engine
This is Rietveld 408576698