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