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

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

Issue 2379173002: Add native_testing library to mock @Native classes (Closed)
Patch Set: xxx Created 4 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "dart:_js_helper"; 5 import 'native_testing.dart';
6 import "package:expect/expect.dart";
7 6
8 // Test calling convention of property extraction closures. 7 // Test calling convention of property extraction closures.
9 8
10 class AA { 9 class AA {
11 bar(a, [b = 'A']) => 'AA.bar($a, $b)'; // bar is plain dart convention. 10 bar(a, [b = 'A']) => 'AA.bar($a, $b)'; // bar is plain dart convention.
12 foo(a, [b = 'A']) => 'AA.foo($a, $b)'; // foo has interceptor convention. 11 foo(a, [b = 'A']) => 'AA.foo($a, $b)'; // foo has interceptor convention.
13 } 12 }
14 13
15 @Native("BB") 14 @Native("BB")
16 class BB { 15 class BB {
(...skipping 18 matching lines...) Expand all
35 }; 34 };
36 35
37 function CC() {} 36 function CC() {}
38 CC.prototype.foo = function(u, v) { 37 CC.prototype.foo = function(u, v) {
39 return 'CC.foo(' + u + ', ' + v + ')'; 38 return 'CC.foo(' + u + ', ' + v + ')';
40 }; 39 };
41 40
42 makeBB = function(){return new BB;}; 41 makeBB = function(){return new BB;};
43 makeCC = function(){return new CC;}; 42 makeCC = function(){return new CC;};
44 inscrutable = function(a){return a;}; 43 inscrutable = function(a){return a;};
44
45 self.nativeConstructor(BB);
46 self.nativeConstructor(CC);
45 """; 47 """;
46 48
47 main() { 49 main() {
50 nativeTesting();
48 setup(); 51 setup();
49 var a = inscrutable(new AA()); 52 var a = inscrutable(new AA());
50 var b = inscrutable(makeBB()); 53 var b = inscrutable(makeBB());
51 var c = inscrutable(makeCC)(); 54 var c = inscrutable(makeCC)();
52 55
53 Expect.equals('AA.bar(1, A)', inscrutable(a).bar(1)); 56 Expect.equals('AA.bar(1, A)', inscrutable(a).bar(1));
54 Expect.equals('AA.bar(2, 3)', inscrutable(a).bar(2, 3)); 57 Expect.equals('AA.bar(2, 3)', inscrutable(a).bar(2, 3));
55 58
56 Expect.equals('AA.foo(1, A)', inscrutable(a).foo(1)); 59 Expect.equals('AA.foo(1, A)', inscrutable(a).foo(1));
57 Expect.equals('AA.foo(2, 3)', inscrutable(a).foo(2, 3)); 60 Expect.equals('AA.foo(2, 3)', inscrutable(a).foo(2, 3));
(...skipping 14 matching lines...) Expand all
72 75
73 Expect.equals('AA.foo(1, A)', afoo(1)); 76 Expect.equals('AA.foo(1, A)', afoo(1));
74 Expect.equals('AA.foo(2, 3)', afoo(2, 3)); 77 Expect.equals('AA.foo(2, 3)', afoo(2, 3));
75 78
76 Expect.equals('BB.foo(1, B)', bfoo(1)); 79 Expect.equals('BB.foo(1, B)', bfoo(1));
77 Expect.equals('BB.foo(2, 3)', bfoo(2, 3)); 80 Expect.equals('BB.foo(2, 3)', bfoo(2, 3));
78 81
79 Expect.equals('CC.foo(1, C)', cfoo(1)); 82 Expect.equals('CC.foo(1, C)', cfoo(1));
80 Expect.equals('CC.foo(2, 3)', cfoo(2, 3)); 83 Expect.equals('CC.foo(2, 3)', cfoo(2, 3));
81 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698