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

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

Issue 10823423: Change dart2js_foreign suite to use metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 months 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
« no previous file with comments | « no previous file | dart/tests/compiler/dart2js_foreign/native_call_arity2_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class A native "*A" { 13 @native("*A")
sra1 2012/08/21 00:56:14 @native_type_tag("*A") @nativeTypeTag("*A") The c
14 int foo(int x) native; 14 class A {
15 @native int foo(int x);
15 } 16 }
16 17
17 class B native "*B" { 18 @native("*B")
18 int foo([x, y, z]) native; 19 class B {
20 @native int foo([x, y, z]);
19 } 21 }
20 22
21 // TODO(sra): Add a case where the parameters have default values. Wait until 23 // TODO(sra): Add a case where the parameters have default values. Wait until
22 // dart:dom_deprecated / dart:html need non-null default values. 24 // dart:dom_deprecated / dart:html need non-null default values.
23 25
24 A makeA() native { return new A(); } 26 @native A makeA() { return new A(); }
25 B makeB() native { return new B(); } 27 @native B makeB() { return new B(); }
26 28
27 void setup() native """ 29 @native("""
sra1 2012/08/21 00:56:14 @native_body Although I would like to deprecate t
28 function A() {} 30 function A() {}
29 A.prototype.foo = function () { return arguments.length; }; 31 A.prototype.foo = function () { return arguments.length; };
30 32
31 function B() {} 33 function B() {}
32 B.prototype.foo = function () { return arguments.length; }; 34 B.prototype.foo = function () { return arguments.length; };
33 35
34 makeA = function(){return new A;}; 36 makeA = function(){return new A;};
35 makeB = function(){return new B;}; 37 makeB = function(){return new B;};
36 """; 38 """)
39 void setup();
37 40
38 41
39 testDynamicContext() { 42 testDynamicContext() {
40 var things = [makeA(), makeB()]; 43 var things = [makeA(), makeB()];
41 var a = things[0]; 44 var a = things[0];
42 var b = things[1]; 45 var b = things[1];
43 46
44 Expect.throws(() => a.foo()); 47 Expect.throws(() => a.foo());
45 Expect.equals(1, a.foo(10)); 48 Expect.equals(1, a.foo(10));
46 Expect.throws(() => a.foo(10, 20)); 49 Expect.throws(() => a.foo(10, 20));
(...skipping 28 matching lines...) Expand all
75 Expect.equals(2, b.foo(y: 20)); 78 Expect.equals(2, b.foo(y: 20));
76 Expect.equals(3, b.foo(z: 30)); 79 Expect.equals(3, b.foo(z: 30));
77 Expect.throws(() => b.foo(10, 20, 30, 40)); 80 Expect.throws(() => b.foo(10, 20, 30, 40));
78 } 81 }
79 82
80 main() { 83 main() {
81 setup(); 84 setup();
82 testDynamicContext(); 85 testDynamicContext();
83 testStaticContext(); 86 testStaticContext();
84 } 87 }
OLDNEW
« no previous file with comments | « no previous file | dart/tests/compiler/dart2js_foreign/native_call_arity2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698