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

Side by Side Diff: dart/tests/compiler/dart2js_foreign/native_call_arity1_test.dart

Issue 11293272: Update dart2js_foreign suite as we now validate annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 that native methods with unnamed* optional arguments are called with the 5 // Test that native methods with unnamed* optional arguments are called with the
6 // number of arguments in the call site. This is necessary because native 6 // number of arguments in the call site. This is necessary because native
7 // methods can dispatch on the number of arguments. Passing null or undefined 7 // methods can dispatch on the number of arguments. Passing null or undefined
8 // as the last argument is not the same as passing one fewer argument. 8 // as the last argument is not the same as passing one fewer argument.
9 // 9 //
10 // * Named arguments are passed in the correct position, so require preceding 10 // * Named arguments are passed in the correct position, so require preceding
11 // arguments to be passed. 11 // arguments to be passed.
12 12
13 @native("*A") 13 import 'native_metadata.dart';
14
15 @Native("*A")
14 class A { 16 class A {
15 @native int foo(int x); 17 @native int foo(int x);
16 } 18 }
17 19
18 @native("*B") 20 @Native("*B")
19 class B { 21 class B {
20 @native int foo([x, y, z]); 22 @native int foo([x, y, z]);
21 } 23 }
22 24
23 // TODO(sra): Add a case where the parameters have default values. Wait until 25 // TODO(sra): Add a case where the parameters have default values. Wait until
24 // dart:html need non-null default values. 26 // dart:html need non-null default values.
25 27
26 @native A makeA() { return new A(); } 28 @native A makeA() { return new A(); }
27 @native B makeB() { return new B(); } 29 @native B makeB() { return new B(); }
28 30
29 @native(""" 31 @Native("""
30 function A() {} 32 function A() {}
31 A.prototype.foo = function () { return arguments.length; }; 33 A.prototype.foo = function () { return arguments.length; };
32 34
33 function B() {} 35 function B() {}
34 B.prototype.foo = function () { return arguments.length; }; 36 B.prototype.foo = function () { return arguments.length; };
35 37
36 makeA = function(){return new A;}; 38 makeA = function(){return new A;};
37 makeB = function(){return new B;}; 39 makeB = function(){return new B;};
38 """) 40 """)
39 void setup(); 41 void setup();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 Expect.equals(2, b.foo(y: 20)); 80 Expect.equals(2, b.foo(y: 20));
79 Expect.equals(3, b.foo(z: 30)); 81 Expect.equals(3, b.foo(z: 30));
80 Expect.throws(() => b.foo(10, 20, 30, 40)); 82 Expect.throws(() => b.foo(10, 20, 30, 40));
81 } 83 }
82 84
83 main() { 85 main() {
84 setup(); 86 setup();
85 testDynamicContext(); 87 testDynamicContext();
86 testStaticContext(); 88 testStaticContext();
87 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698