OLD | NEW |
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 "dart:_js_helper"; | 5 import "dart:_js_helper"; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 // Test similar to NativeCallArity1FrogTest, but with default values to | 8 // Test similar to NativeCallArity1FrogTest, but with default values to |
9 // parameters set to null. These parameters should be treated as if they | 9 // parameters set to null. These parameters should be treated as if they |
10 // do not have a default value for the native methods. | 10 // do not have a default value for the native methods. |
11 | 11 |
12 @Native("A") | 12 @Native("A") |
13 class A { | 13 class A { |
14 int foo(int x) native; | 14 int foo(int x) native; |
15 } | 15 } |
16 | 16 |
17 @Native("B") | 17 @Native("B") |
18 class B { | 18 class B { |
19 int foo([x = null, y, z = null]) native; | 19 int foo([x = null, y, z = null]) native; |
20 } | 20 } |
21 | 21 |
22 // TODO(sra): Add a case where the parameters have default values. Wait until | 22 // TODO(sra): Add a case where the parameters have default values. Wait until |
23 // dart:html need non-null default values. | 23 // dart:html need non-null default values. |
24 | 24 |
25 A makeA() native { return new A(); } | 25 A makeA() native; |
26 B makeB() native { return new B(); } | 26 B makeB() native; |
27 | 27 |
28 void setup() native """ | 28 void setup() native """ |
29 function A() {} | 29 function A() {} |
30 A.prototype.foo = function () { return arguments.length; }; | 30 A.prototype.foo = function () { return arguments.length; }; |
31 | 31 |
32 function B() {} | 32 function B() {} |
33 B.prototype.foo = function () { return arguments.length; }; | 33 B.prototype.foo = function () { return arguments.length; }; |
34 | 34 |
35 makeA = function(){return new A;}; | 35 makeA = function(){return new A;}; |
36 makeB = function(){return new B;}; | 36 makeB = function(){return new B;}; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 Expect.equals(2, b.foo(null, 20)); | 76 Expect.equals(2, b.foo(null, 20)); |
77 Expect.equals(3, b.foo(null, null, 30)); | 77 Expect.equals(3, b.foo(null, null, 30)); |
78 Expect.throws(() => b.foo(10, 20, 30, 40)); | 78 Expect.throws(() => b.foo(10, 20, 30, 40)); |
79 } | 79 } |
80 | 80 |
81 main() { | 81 main() { |
82 setup(); | 82 setup(); |
83 testDynamicContext(); | 83 testDynamicContext(); |
84 testStaticContext(); | 84 testStaticContext(); |
85 } | 85 } |
OLD | NEW |