| OLD | NEW |
| 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 "package:expect/expect.dart"; |
| 9 import 'dart:_js_helper' show Native, NoInline; |
| 9 | 10 |
| 10 typedef int Int2Int(int x); | 11 typedef int Int2Int(int x); |
| 11 | 12 |
| 12 @Native("A") | 13 @Native("A") |
| 13 class A { | 14 class A { |
| 14 int foo([x, y, z]) native ; | 15 int foo([x, y, z]) native ; |
| 15 | 16 |
| 16 // Calls can be inlined provided they don't pass an argument. | 17 // Calls can be inlined provided they don't pass an argument. |
| 17 int callFun([Int2Int fn]) native ; | 18 int callFun([Int2Int fn]) native ; |
| 18 } | 19 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 findMethodTextContaining = function (instance, string) { | 64 findMethodTextContaining = function (instance, string) { |
| 64 var proto = Object.getPrototypeOf(instance); | 65 var proto = Object.getPrototypeOf(instance); |
| 65 var keys = Object.keys(proto); | 66 var keys = Object.keys(proto); |
| 66 for (var i = 0; i < keys.length; i++) { | 67 for (var i = 0; i < keys.length; i++) { |
| 67 var name = keys[i]; | 68 var name = keys[i]; |
| 68 var member = proto[name]; | 69 var member = proto[name]; |
| 69 var s = String(member); | 70 var s = String(member); |
| 70 if (s.indexOf(string)>0) return s; | 71 if (s.indexOf(string)>0) return s; |
| 71 } | 72 } |
| 72 }; | 73 }; |
| 73 | |
| 74 self.nativeConstructor(A); | |
| 75 """; | 74 """; |
| 76 | 75 |
| 77 bool get isCheckedMode { | 76 bool get isCheckedMode { |
| 78 int i = 0; | 77 int i = 0; |
| 79 try { | 78 try { |
| 80 i = 'a'; | 79 i = 'a'; |
| 81 } catch (e) { | 80 } catch (e) { |
| 82 return true; | 81 return true; |
| 83 } | 82 } |
| 84 return false; | 83 return false; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Ensure the methods are compiled by calling them. | 141 // Ensure the methods are compiled by calling them. |
| 143 var a = makeA(); | 142 var a = makeA(); |
| 144 Expect.equals(369, a.callFun((i) => 3 * i)); | 143 Expect.equals(369, a.callFun((i) => 3 * i)); |
| 145 | 144 |
| 146 var b = new B(); | 145 var b = new B(); |
| 147 Expect.equals(2, b.method2()); | 146 Expect.equals(2, b.method2()); |
| 148 Expect.equals(246, b.method3()); | 147 Expect.equals(246, b.method3()); |
| 149 } | 148 } |
| 150 | 149 |
| 151 main() { | 150 main() { |
| 152 nativeTesting(); | |
| 153 setup(); | 151 setup(); |
| 154 test1(); | 152 test1(); |
| 155 test2(); | 153 test2(); |
| 156 } | 154 } |
| OLD | NEW |