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

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

Issue 2383273002: Revert "Add native_testing library to mock @Native classes" (Closed)
Patch Set: Created 4 years, 2 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 "dart:_js_helper";
6 import "package:expect/expect.dart";
6 7
7 // Test similar to NativeCallArity1FrogTest, but with default values to 8 // Test similar to NativeCallArity1FrogTest, but with default values to
8 // parameters set to null. These parameters should be treated as if they 9 // parameters set to null. These parameters should be treated as if they
9 // do not have a default value for the native methods. 10 // do not have a default value for the native methods.
10 11
11 @Native("A") 12 @Native("A")
12 class A { 13 class A {
13 int foo(int x) native ; 14 int foo(int x) native ;
14 } 15 }
15 16
(...skipping 10 matching lines...) Expand all
26 27
27 void setup() native """ 28 void setup() native """
28 function A() {} 29 function A() {}
29 A.prototype.foo = function () { return arguments.length; }; 30 A.prototype.foo = function () { return arguments.length; };
30 31
31 function B() {} 32 function B() {}
32 B.prototype.foo = function () { return arguments.length; }; 33 B.prototype.foo = function () { return arguments.length; };
33 34
34 makeA = function(){return new A;}; 35 makeA = function(){return new A;};
35 makeB = function(){return new B;}; 36 makeB = function(){return new B;};
36
37 self.nativeConstructor(A);
38 self.nativeConstructor(B);
39 """; 37 """;
40 38
41 testDynamicContext() { 39 testDynamicContext() {
42 var a = confuse(makeA()); 40 var things = [makeA(), makeB()];
43 var b = confuse(makeB()); 41 var a = things[0];
42 var b = things[1];
44 43
45 Expect.throws(() => a.foo()); 44 Expect.throws(() => a.foo());
46 Expect.equals(1, a.foo(10)); 45 Expect.equals(1, a.foo(10));
47 Expect.throws(() => a.foo(10, 20)); 46 Expect.throws(() => a.foo(10, 20));
48 Expect.throws(() => a.foo(10, 20, 30)); 47 Expect.throws(() => a.foo(10, 20, 30));
49 48
50 Expect.equals(0, b.foo()); 49 Expect.equals(0, b.foo());
51 Expect.equals(1, b.foo(10)); 50 Expect.equals(1, b.foo(10));
52 Expect.equals(2, b.foo(10, 20)); 51 Expect.equals(2, b.foo(10, 20));
53 Expect.equals(3, b.foo(10, 20, 30)); 52 Expect.equals(3, b.foo(10, 20, 30));
(...skipping 18 matching lines...) Expand all
72 Expect.equals(2, b.foo(10, 20)); 71 Expect.equals(2, b.foo(10, 20));
73 Expect.equals(3, b.foo(10, 20, 30)); 72 Expect.equals(3, b.foo(10, 20, 30));
74 73
75 Expect.equals(1, b.foo(10)); 74 Expect.equals(1, b.foo(10));
76 Expect.equals(2, b.foo(null, 20)); 75 Expect.equals(2, b.foo(null, 20));
77 Expect.equals(3, b.foo(null, null, 30)); 76 Expect.equals(3, b.foo(null, null, 30));
78 Expect.throws(() => b.foo(10, 20, 30, 40)); 77 Expect.throws(() => b.foo(10, 20, 30, 40));
79 } 78 }
80 79
81 main() { 80 main() {
82 nativeTesting();
83 setup(); 81 setup();
84 testDynamicContext(); 82 testDynamicContext();
85 testStaticContext(); 83 testStaticContext();
86 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698