| OLD | NEW |
| 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 "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 // Test calling convention of property extraction closures. | 8 // Test calling convention of property extraction closures. |
| 9 | 9 |
| 10 class AA { | 10 class AA { |
| 11 bar(a, [b = 'A']) => 'AA.bar($a, $b)'; // bar is plain dart convention. | 11 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. | 12 foo(a, [b = 'A']) => 'AA.foo($a, $b)'; // foo has interceptor convention. |
| 13 } | 13 } |
| 14 | 14 |
| 15 @Native("BB") | 15 @Native("BB") |
| 16 class BB { | 16 class BB { |
| 17 foo(a, [b = 'B']) native; | 17 foo(a, [b = 'B']) native ; |
| 18 } | 18 } |
| 19 | 19 |
| 20 @Native("CC") | 20 @Native("CC") |
| 21 class CC extends BB { | 21 class CC extends BB { |
| 22 foo(a, [b = 'C']) native; | 22 foo(a, [b = 'C']) native ; |
| 23 | 23 |
| 24 get superfoo => super.foo; | 24 get superfoo => super.foo; |
| 25 } | 25 } |
| 26 | 26 |
| 27 makeBB() native; | 27 makeBB() native ; |
| 28 makeCC() native; | 28 makeCC() native ; |
| 29 inscrutable(a) native; | 29 inscrutable(a) native ; |
| 30 | 30 |
| 31 void setup() native r""" | 31 void setup() native r""" |
| 32 function BB() {} | 32 function BB() {} |
| 33 BB.prototype.foo = function(u, v) { | 33 BB.prototype.foo = function(u, v) { |
| 34 return 'BB.foo(' + u + ', ' + v + ')'; | 34 return 'BB.foo(' + u + ', ' + v + ')'; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 function CC() {} | 37 function CC() {} |
| 38 CC.prototype.foo = function(u, v) { | 38 CC.prototype.foo = function(u, v) { |
| 39 return 'CC.foo(' + u + ', ' + v + ')'; | 39 return 'CC.foo(' + u + ', ' + v + ')'; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 makeBB = function(){return new BB;}; | 42 makeBB = function(){return new BB;}; |
| 43 makeCC = function(){return new CC;}; | 43 makeCC = function(){return new CC;}; |
| 44 inscrutable = function(a){return a;}; | 44 inscrutable = function(a){return a;}; |
| 45 """; | 45 """; |
| 46 | 46 |
| 47 | |
| 48 main() { | 47 main() { |
| 49 setup(); | 48 setup(); |
| 50 var a = inscrutable(new AA()); | 49 var a = inscrutable(new AA()); |
| 51 var b = inscrutable(makeBB()); | 50 var b = inscrutable(makeBB()); |
| 52 var c = inscrutable(makeCC)(); | 51 var c = inscrutable(makeCC)(); |
| 53 | 52 |
| 54 Expect.equals('AA.bar(1, A)', inscrutable(a).bar(1)); | 53 Expect.equals('AA.bar(1, A)', inscrutable(a).bar(1)); |
| 55 Expect.equals('AA.bar(2, 3)', inscrutable(a).bar(2, 3)); | 54 Expect.equals('AA.bar(2, 3)', inscrutable(a).bar(2, 3)); |
| 56 | 55 |
| 57 Expect.equals('AA.foo(1, A)', inscrutable(a).foo(1)); | 56 Expect.equals('AA.foo(1, A)', inscrutable(a).foo(1)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 73 | 72 |
| 74 Expect.equals('AA.foo(1, A)', afoo(1)); | 73 Expect.equals('AA.foo(1, A)', afoo(1)); |
| 75 Expect.equals('AA.foo(2, 3)', afoo(2, 3)); | 74 Expect.equals('AA.foo(2, 3)', afoo(2, 3)); |
| 76 | 75 |
| 77 Expect.equals('BB.foo(1, B)', bfoo(1)); | 76 Expect.equals('BB.foo(1, B)', bfoo(1)); |
| 78 Expect.equals('BB.foo(2, 3)', bfoo(2, 3)); | 77 Expect.equals('BB.foo(2, 3)', bfoo(2, 3)); |
| 79 | 78 |
| 80 Expect.equals('CC.foo(1, C)', cfoo(1)); | 79 Expect.equals('CC.foo(1, C)', cfoo(1)); |
| 81 Expect.equals('CC.foo(2, 3)', cfoo(2, 3)); | 80 Expect.equals('CC.foo(2, 3)', cfoo(2, 3)); |
| 82 } | 81 } |
| OLD | NEW |