OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/cctest/compiler/function-tester.h" | 5 #include "test/cctest/compiler/function-tester.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 FunctionTester T("(function(a,b) { return new foo(a,b).value; })"); | 122 FunctionTester T("(function(a,b) { return new foo(a,b).value; })"); |
123 CompileRun("function foo(a,b) { return { value: a + b + this.c }; }"); | 123 CompileRun("function foo(a,b) { return { value: a + b + this.c }; }"); |
124 CompileRun("foo.prototype.c = 23;"); | 124 CompileRun("foo.prototype.c = 23;"); |
125 | 125 |
126 T.CheckCall(T.Val(32), T.Val(4), T.Val(5)); | 126 T.CheckCall(T.Val(32), T.Val(4), T.Val(5)); |
127 T.CheckCall(T.Val("xy23"), T.Val("x"), T.Val("y")); | 127 T.CheckCall(T.Val("xy23"), T.Val("x"), T.Val("y")); |
128 T.CheckCall(T.nan(), T.undefined(), T.Val(3)); | 128 T.CheckCall(T.nan(), T.undefined(), T.Val(3)); |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 TEST(RuntimeCallCPP2) { | 132 TEST(RuntimeCall) { |
133 FLAG_allow_natives_syntax = true; | 133 FLAG_allow_natives_syntax = true; |
134 FunctionTester T("(function(a,b) { return %NumberImul(a, b); })"); | 134 FunctionTester T("(function(a) { return %IsJSReceiver(a); })"); |
135 | 135 |
136 T.CheckCall(T.Val(2730), T.Val(42), T.Val(65)); | 136 T.CheckCall(T.false_value(), T.Val(23), T.undefined()); |
137 T.CheckCall(T.Val(798), T.Val(42), T.Val(19)); | 137 T.CheckCall(T.false_value(), T.Val(4.2), T.undefined()); |
| 138 T.CheckCall(T.false_value(), T.Val("str"), T.undefined()); |
| 139 T.CheckCall(T.false_value(), T.true_value(), T.undefined()); |
| 140 T.CheckCall(T.false_value(), T.false_value(), T.undefined()); |
| 141 T.CheckCall(T.false_value(), T.undefined(), T.undefined()); |
| 142 T.CheckCall(T.true_value(), T.NewObject("({})"), T.undefined()); |
| 143 T.CheckCall(T.true_value(), T.NewObject("([])"), T.undefined()); |
138 } | 144 } |
139 | 145 |
140 | 146 |
141 TEST(RuntimeCallInline) { | 147 TEST(RuntimeCallInline) { |
142 FLAG_allow_natives_syntax = true; | 148 FLAG_allow_natives_syntax = true; |
143 FunctionTester T("(function(a) { return %_IsJSReceiver(a); })"); | 149 FunctionTester T("(function(a) { return %_IsJSReceiver(a); })"); |
144 | 150 |
145 T.CheckCall(T.false_value(), T.Val(23), T.undefined()); | 151 T.CheckCall(T.false_value(), T.Val(23), T.undefined()); |
146 T.CheckCall(T.false_value(), T.Val(4.2), T.undefined()); | 152 T.CheckCall(T.false_value(), T.Val(4.2), T.undefined()); |
147 T.CheckCall(T.false_value(), T.Val("str"), T.undefined()); | 153 T.CheckCall(T.false_value(), T.Val("str"), T.undefined()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 CHECK(context->Global() | 245 CHECK(context->Global() |
240 ->Set(context, v8_str("foo"), v8::Utils::CallableToLocal(jsfun)) | 246 ->Set(context, v8_str("foo"), v8::Utils::CallableToLocal(jsfun)) |
241 .FromJust()); | 247 .FromJust()); |
242 CompileRun("var x = 24;"); | 248 CompileRun("var x = 24;"); |
243 ExpectObject("foo()", context->Global()); | 249 ExpectObject("foo()", context->Global()); |
244 } | 250 } |
245 | 251 |
246 } // namespace compiler | 252 } // namespace compiler |
247 } // namespace internal | 253 } // namespace internal |
248 } // namespace v8 | 254 } // namespace v8 |
OLD | NEW |