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

Side by Side Diff: tests/compiler/dart2js_native/native_call_arity3_frog_test.dart

Issue 2984403002: dart2js_native tests: Migrate 'native STRING' to JS-calls (Closed)
Patch Set: the rest of the files Created 3 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
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 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() {
28 function A() {} 28 JS('', r"""
29 A.prototype.foo = function () { return arguments.length; }; 29 (function(){
30 function A() {}
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
37 self.nativeConstructor(A); 39 self.nativeConstructor(A);
38 self.nativeConstructor(B); 40 self.nativeConstructor(B);
39 """; 41 })()""");
42 }
40 43
41 testDynamicContext() { 44 testDynamicContext() {
42 var a = confuse(makeA()); 45 var a = confuse(makeA());
43 var b = confuse(makeB()); 46 var b = confuse(makeB());
44 47
45 Expect.throws(() => a.foo()); 48 Expect.throws(() => a.foo());
46 Expect.equals(1, a.foo(10)); 49 Expect.equals(1, a.foo(10));
47 Expect.throws(() => a.foo(10, 20)); 50 Expect.throws(() => a.foo(10, 20));
48 Expect.throws(() => a.foo(10, 20, 30)); 51 Expect.throws(() => a.foo(10, 20, 30));
49 52
(...skipping 27 matching lines...) Expand all
77 Expect.equals(3, b.foo(null, null, 30)); 80 Expect.equals(3, b.foo(null, null, 30));
78 Expect.throws(() => b.foo(10, 20, 30, 40)); 81 Expect.throws(() => b.foo(10, 20, 30, 40));
79 } 82 }
80 83
81 main() { 84 main() {
82 nativeTesting(); 85 nativeTesting();
83 setup(); 86 setup();
84 testDynamicContext(); 87 testDynamicContext();
85 testStaticContext(); 88 testStaticContext();
86 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698