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

Side by Side Diff: tests/compiler/dart2js_native/native_wrapping_function3_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 import "native_testing.dart"; 5 import "native_testing.dart";
6 6
7 typedef void Callback0(); 7 typedef void Callback0();
8 typedef void Callback1(arg1); 8 typedef void Callback1(arg1);
9 typedef void Callback2(arg1, arg2); 9 typedef void Callback2(arg1, arg2);
10 10
11 @Native("A") 11 @Native("A")
12 class A { 12 class A {
13 foo1(Callback1 closure, [arg1 = 0]) native; 13 foo1(Callback1 closure, [arg1 = 0]) native;
14 foo2(Callback2 closure, [arg1 = 0, arg2 = 1]) native; 14 foo2(Callback2 closure, [arg1 = 0, arg2 = 1]) native;
15 } 15 }
16 16
17 A makeA() native; 17 A makeA() native;
18 18
19 void setup() native """ 19 void setup() {
20 function A() {} 20 JS('', r"""
21 A.prototype.foo1 = function(closure, arg1) { return closure(arg1); }; 21 (function(){
22 A.prototype.foo2 = function(closure, arg1, arg2) { 22 function A() {}
23 return closure(arg1, arg2); 23 A.prototype.foo1 = function(closure, arg1) { return closure(arg1); };
24 }; 24 A.prototype.foo2 = function(closure, arg1, arg2) {
25 makeA = function(){return new A;}; 25 return closure(arg1, arg2);
26 self.nativeConstructor(A); 26 };
27 """; 27 makeA = function(){return new A()};
28 self.nativeConstructor(A);
29 })()""");
30 }
28 31
29 main() { 32 main() {
30 nativeTesting(); 33 nativeTesting();
31 setup(); 34 setup();
32 var a = makeA(); 35 var a = makeA();
33 // Statically known receiver type calls. 36 // Statically known receiver type calls.
34 Expect.equals(43, a.foo1((arg1) => arg1, 43)); 37 Expect.equals(43, a.foo1((arg1) => arg1, 43));
35 Expect.equals(0, a.foo1((arg1) => arg1)); 38 Expect.equals(0, a.foo1((arg1) => arg1));
36 39
37 Expect.equals(44, a.foo2((arg1, arg2) => arg1 + arg2, 21, 23)); 40 Expect.equals(44, a.foo2((arg1, arg2) => arg1 + arg2, 21, 23));
38 Expect.equals(22, a.foo2((arg1, arg2) => arg1 + arg2, 21)); 41 Expect.equals(22, a.foo2((arg1, arg2) => arg1 + arg2, 21));
39 42
40 // Dynamic calls. 43 // Dynamic calls.
41 Expect.equals(43, confuse(a).foo1((arg1) => arg1, 43)); 44 Expect.equals(43, confuse(a).foo1((arg1) => arg1, 43));
42 Expect.equals(0, confuse(a).foo1((arg1) => arg1)); 45 Expect.equals(0, confuse(a).foo1((arg1) => arg1));
43 46
44 Expect.equals(44, confuse(a).foo2((arg1, arg2) => arg1 + arg2, 21, 23)); 47 Expect.equals(44, confuse(a).foo2((arg1, arg2) => arg1 + arg2, 21, 23));
45 Expect.equals(22, confuse(a).foo2((arg1, arg2) => arg1 + arg2, 21)); 48 Expect.equals(22, confuse(a).foo2((arg1, arg2) => arg1 + arg2, 21));
46 } 49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698