| 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
| 8 | 8 |
| 9 using namespace v8::internal; | 9 using namespace v8::internal; |
| 10 using namespace v8::internal::compiler; | 10 using namespace v8::internal::compiler; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 T.CheckCall(T.Val(32), T.Val(4), T.Val(5)); | 128 T.CheckCall(T.Val(32), T.Val(4), T.Val(5)); |
| 129 T.CheckCall(T.Val("xy23"), T.Val("x"), T.Val("y")); | 129 T.CheckCall(T.Val("xy23"), T.Val("x"), T.Val("y")); |
| 130 T.CheckCall(T.nan(), T.undefined(), T.Val(3)); | 130 T.CheckCall(T.nan(), T.undefined(), T.Val(3)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 | 133 |
| 134 // TODO(titzer): factor these out into test-runtime-calls.cc | 134 // TODO(titzer): factor these out into test-runtime-calls.cc |
| 135 TEST(RuntimeCallCPP2) { | 135 TEST(RuntimeCallCPP2) { |
| 136 FLAG_allow_natives_syntax = true; | 136 FLAG_allow_natives_syntax = true; |
| 137 FunctionTester T("(function(a,b) { return %NumberAdd(a, b); })"); | 137 FunctionTester T("(function(a,b) { return %NumberImul(a, b); })"); |
| 138 | 138 |
| 139 T.CheckCall(T.Val(65), T.Val(42), T.Val(23)); | 139 T.CheckCall(T.Val(2730), T.Val(42), T.Val(65)); |
| 140 T.CheckCall(T.Val(19), T.Val(42), T.Val(-23)); | 140 T.CheckCall(T.Val(798), T.Val(42), T.Val(19)); |
| 141 T.CheckCall(T.Val(6.5), T.Val(4.2), T.Val(2.3)); | |
| 142 } | 141 } |
| 143 | 142 |
| 144 | 143 |
| 145 TEST(RuntimeCallJS) { | 144 TEST(RuntimeCallJS) { |
| 146 FLAG_allow_natives_syntax = true; | 145 FLAG_allow_natives_syntax = true; |
| 147 FunctionTester T("(function(a) { return %to_string_fun(a); })"); | 146 FunctionTester T("(function(a) { return %to_string_fun(a); })"); |
| 148 | 147 |
| 149 T.CheckCall(T.Val("23"), T.Val(23), T.undefined()); | 148 T.CheckCall(T.Val("23"), T.Val(23), T.undefined()); |
| 150 T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined()); | 149 T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined()); |
| 151 T.CheckCall(T.Val("str"), T.Val("str"), T.undefined()); | 150 T.CheckCall(T.Val("str"), T.Val("str"), T.undefined()); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 v8::Context::Scope scope(context); | 247 v8::Context::Scope scope(context); |
| 249 v8::Local<v8::Value> value = CompileRun(script); | 248 v8::Local<v8::Value> value = CompileRun(script); |
| 250 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); | 249 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); |
| 251 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); | 250 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); |
| 252 jsfun->set_code(T.function->code()); | 251 jsfun->set_code(T.function->code()); |
| 253 jsfun->set_shared(T.function->shared()); | 252 jsfun->set_shared(T.function->shared()); |
| 254 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); | 253 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); |
| 255 CompileRun("var x = 24;"); | 254 CompileRun("var x = 24;"); |
| 256 ExpectObject("foo()", context->Global()); | 255 ExpectObject("foo()", context->Global()); |
| 257 } | 256 } |
| OLD | NEW |