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

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

Issue 2383273002: Revert "Add native_testing library to mock @Native classes" (Closed)
Patch Set: Created 4 years, 2 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 "dart:_js_helper";
8
9 import "package:expect/expect.dart";
8 10
9 typedef void MyFunctionType(); 11 typedef void MyFunctionType();
10 12
11 @Native("A") 13 @Native("A")
12 class A { 14 class A {
13 setClosure(MyFunctionType f) native ; 15 setClosure(MyFunctionType f) native ;
14 check(MyFunctionType f) native ; 16 check(MyFunctionType f) native ;
15 invoke() native ; 17 invoke() native ;
16 } 18 }
17 19
18 makeA() native ; 20 makeA() native ;
19 21
20 void setup() native """ 22 void setup() native """
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
27 self.nativeConstructor(A);
28 """; 28 """;
29 29
30 main() { 30 main() {
31 nativeTesting();
32 setup(); 31 setup();
33 A a = makeA(); 32 A a = makeA();
34 a.setClosure(null); 33 a.setClosure(null);
35 Expect.isTrue(a.check(null)); 34 Expect.isTrue(a.check(null));
36 bool caughtException = false; 35 bool caughtException = false;
37 try { 36 try {
38 a.invoke(); 37 a.invoke();
39 } on NoSuchMethodError catch (e) { 38 } on JsNoSuchMethodError catch (e) {
40 print(e); 39 print(e);
41 caughtException = true; 40 caughtException = true;
42 } 41 }
43 Expect.isTrue(caughtException); 42 Expect.isTrue(caughtException);
44 } 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