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

Side by Side Diff: dart/tests/compiler/dart2js_foreign/native_call_arity3_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
OLDNEW
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 class A native "*A" { 9 @native("*A")
10 int foo(int x) native; 10 class A {
11 @native int foo(int x);
11 } 12 }
12 13
13 class B native "*B" { 14 @native("*B")
14 int foo([x = null, y, z = null]) native; 15 class B {
16 @native int foo([x = null, y, z = null]);
15 } 17 }
16 18
17 // 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
18 // dart:dom_deprecated / dart:html need non-null default values. 20 // dart:dom_deprecated / dart:html need non-null default values.
19 21
20 A makeA() native { return new A(); } 22 @native A makeA() { return new A(); }
21 B makeB() native { return new B(); } 23 @native B makeB() { return new B(); }
22 24
23 void setup() native """ 25 @native("""
24 function A() {} 26 function A() {}
25 A.prototype.foo = function () { return arguments.length; }; 27 A.prototype.foo = function () { return arguments.length; };
26 28
27 function B() {} 29 function B() {}
28 B.prototype.foo = function () { return arguments.length; }; 30 B.prototype.foo = function () { return arguments.length; };
29 31
30 makeA = function(){return new A;}; 32 makeA = function(){return new A;};
31 makeB = function(){return new B;}; 33 makeB = function(){return new B;};
32 """; 34 """)
35 void setup();
33 36
34 37
35 testDynamicContext() { 38 testDynamicContext() {
36 var things = [makeA(), makeB()]; 39 var things = [makeA(), makeB()];
37 var a = things[0]; 40 var a = things[0];
38 var b = things[1]; 41 var b = things[1];
39 42
40 Expect.throws(() => a.foo()); 43 Expect.throws(() => a.foo());
41 Expect.equals(1, a.foo(10)); 44 Expect.equals(1, a.foo(10));
42 Expect.throws(() => a.foo(10, 20)); 45 Expect.throws(() => a.foo(10, 20));
(...skipping 28 matching lines...) Expand all
71 Expect.equals(2, b.foo(y: 20)); 74 Expect.equals(2, b.foo(y: 20));
72 Expect.equals(3, b.foo(z: 30)); 75 Expect.equals(3, b.foo(z: 30));
73 Expect.throws(() => b.foo(10, 20, 30, 40)); 76 Expect.throws(() => b.foo(10, 20, 30, 40));
74 } 77 }
75 78
76 main() { 79 main() {
77 setup(); 80 setup();
78 testDynamicContext(); 81 testDynamicContext();
79 testStaticContext(); 82 testStaticContext();
80 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698