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