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

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

Issue 2990083002: dart2js_native tests: Migrate 'native STRING' to JS-calls - part 2/2 (Closed)
Patch Set: remove defunct comments 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) 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 AND the call site is inlined. 6 // number of arguments in the call site AND the call site is inlined.
7 7
8 import 'native_testing.dart'; 8 import 'native_testing.dart';
9 9
10 typedef int Int2Int(int x); 10 typedef int Int2Int(int x);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 var r1 = x.callFun((x) => x * 2); // Can't be inlined due to conversion. 46 var r1 = x.callFun((x) => x * 2); // Can't be inlined due to conversion.
47 var r2 = x.callFun((x) => x * 0); 47 var r2 = x.callFun((x) => x * 0);
48 return r1 + r2; 48 return r1 + r2;
49 } 49 }
50 } 50 }
51 51
52 A makeA() native; 52 A makeA() native;
53 53
54 String findMethodTextContaining(instance, string) native; 54 String findMethodTextContaining(instance, string) native;
55 55
56 void setup() native r""" 56 void setup() {
57 function A() {} 57 JS('', r"""
58 A.prototype.foo = function () { return arguments.length; }; 58 (function(){
59 A.prototype.callFun = function (fn) { return fn ? fn(123) : 1; }; 59 function A() {}
60 A.prototype.foo = function () { return arguments.length; };
61 A.prototype.callFun = function (fn) { return fn ? fn(123) : 1; };
60 62
61 makeA = function(){return new A;}; 63 makeA = function(){return new A()};
62 64
63 findMethodTextContaining = function (instance, string) { 65 findMethodTextContaining = function (instance, string) {
64 var proto = Object.getPrototypeOf(instance); 66 var proto = Object.getPrototypeOf(instance);
65 var keys = Object.keys(proto); 67 var keys = Object.keys(proto);
66 for (var i = 0; i < keys.length; i++) { 68 for (var i = 0; i < keys.length; i++) {
67 var name = keys[i]; 69 var name = keys[i];
68 var member = proto[name]; 70 var member = proto[name];
69 var s = String(member); 71 var s = String(member);
70 if (s.indexOf(string)>0) return s; 72 if (s.indexOf(string)>0) return s;
71 } 73 }
72 }; 74 };
73 75
74 self.nativeConstructor(A); 76 self.nativeConstructor(A);
75 """; 77 })()""");
78 }
76 79
77 bool get isCheckedMode { 80 bool get isCheckedMode {
78 int i = 0; 81 int i = 0;
79 try { 82 try {
80 i = 'a'; 83 i = 'a';
81 } catch (e) { 84 } catch (e) {
82 return true; 85 return true;
83 } 86 }
84 return false; 87 return false;
85 } 88 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 Expect.equals(2, b.method2()); 150 Expect.equals(2, b.method2());
148 Expect.equals(246, b.method3()); 151 Expect.equals(246, b.method3());
149 } 152 }
150 153
151 main() { 154 main() {
152 nativeTesting(); 155 nativeTesting();
153 setup(); 156 setup();
154 test1(); 157 test1();
155 test2(); 158 test2();
156 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698