Chromium Code Reviews| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 | 148 |
| 149 T.CheckCall(T.Val("23"), T.Val(23), T.undefined()); | 149 T.CheckCall(T.Val("23"), T.Val(23), T.undefined()); |
| 150 T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined()); | 150 T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined()); |
| 151 T.CheckCall(T.Val("str"), T.Val("str"), T.undefined()); | 151 T.CheckCall(T.Val("str"), T.Val("str"), T.undefined()); |
| 152 T.CheckCall(T.Val("true"), T.true_value(), T.undefined()); | 152 T.CheckCall(T.Val("true"), T.true_value(), T.undefined()); |
| 153 T.CheckCall(T.Val("false"), T.false_value(), T.undefined()); | 153 T.CheckCall(T.Val("false"), T.false_value(), T.undefined()); |
| 154 T.CheckCall(T.Val("undefined"), T.undefined(), T.undefined()); | 154 T.CheckCall(T.Val("undefined"), T.undefined(), T.undefined()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 TEST(RuntimeCallInline) { | |
| 159 FLAG_allow_natives_syntax = true; | |
| 160 FunctionTester T("(function(a) { return %_IsObject(a); })"); | |
|
Michael Starzinger
2015/08/26 10:47:10
nit: We might want to preserve this test for anoth
Benedikt Meurer
2015/08/26 10:50:42
Done.
| |
| 161 | |
| 162 T.CheckCall(T.false_value(), T.Val(23), T.undefined()); | |
| 163 T.CheckCall(T.false_value(), T.Val(4.2), T.undefined()); | |
| 164 T.CheckCall(T.false_value(), T.Val("str"), T.undefined()); | |
| 165 T.CheckCall(T.false_value(), T.true_value(), T.undefined()); | |
| 166 T.CheckCall(T.false_value(), T.false_value(), T.undefined()); | |
| 167 T.CheckCall(T.false_value(), T.undefined(), T.undefined()); | |
| 168 T.CheckCall(T.true_value(), T.NewObject("({})"), T.undefined()); | |
| 169 T.CheckCall(T.true_value(), T.NewObject("([])"), T.undefined()); | |
| 170 } | |
| 171 | |
| 172 | |
| 173 TEST(EvalCall) { | 158 TEST(EvalCall) { |
| 174 FunctionTester T("(function(a,b) { return eval(a); })"); | 159 FunctionTester T("(function(a,b) { return eval(a); })"); |
| 175 Handle<JSObject> g(T.function->context()->global_object()->global_proxy()); | 160 Handle<JSObject> g(T.function->context()->global_object()->global_proxy()); |
| 176 | 161 |
| 177 T.CheckCall(T.Val(23), T.Val("17 + 6"), T.undefined()); | 162 T.CheckCall(T.Val(23), T.Val("17 + 6"), T.undefined()); |
| 178 T.CheckCall(T.Val("'Y'; a"), T.Val("'Y'; a"), T.Val("b-val")); | 163 T.CheckCall(T.Val("'Y'; a"), T.Val("'Y'; a"), T.Val("b-val")); |
| 179 T.CheckCall(T.Val("b-val"), T.Val("'Y'; b"), T.Val("b-val")); | 164 T.CheckCall(T.Val("b-val"), T.Val("'Y'; b"), T.Val("b-val")); |
| 180 T.CheckCall(g, T.Val("this"), T.undefined()); | 165 T.CheckCall(g, T.Val("this"), T.undefined()); |
| 181 T.CheckCall(g, T.Val("'use strict'; this"), T.undefined()); | 166 T.CheckCall(g, T.Val("'use strict'; this"), T.undefined()); |
| 182 | 167 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 v8::Context::Scope scope(context); | 233 v8::Context::Scope scope(context); |
| 249 v8::Local<v8::Value> value = CompileRun(script); | 234 v8::Local<v8::Value> value = CompileRun(script); |
| 250 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); | 235 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); |
| 251 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); | 236 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); |
| 252 jsfun->set_code(T.function->code()); | 237 jsfun->set_code(T.function->code()); |
| 253 jsfun->set_shared(T.function->shared()); | 238 jsfun->set_shared(T.function->shared()); |
| 254 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); | 239 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); |
| 255 CompileRun("var x = 24;"); | 240 CompileRun("var x = 24;"); |
| 256 ExpectObject("foo()", context->Global()); | 241 ExpectObject("foo()", context->Global()); |
| 257 } | 242 } |
| OLD | NEW |