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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 TEST(CallEval) { | 238 TEST(CallEval) { | 
| 239 FunctionTester T( | 239 FunctionTester T( | 
| 240 "var x = 42;" | 240 "var x = 42;" | 
| 241 "(function () {" | 241 "(function () {" | 
| 242 "function bar() { return eval('x') };" | 242 "function bar() { return eval('x') };" | 
| 243 "return bar;" | 243 "return bar;" | 
| 244 "})();"); | 244 "})();"); | 
| 245 | 245 | 
| 246 T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); | 246 T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); | 
| 247 } | 247 } | 
| 248 | |
| 249 #if V8_TURBOFAN_TARGET | |
| 250 | |
| 251 TEST(ContextLoadedFromActivation) { | |
| 252 FLAG_context_specialization = false; | |
| 
 
sigurds
2014/08/20 07:53:22
I left this flag in here.
I could add it as a para
 
titzer
2014/08/21 08:12:06
Please add a TODO.
 
sigurds
2014/08/21 09:14:13
Implemented it.
 
 | |
| 253 const char* script = | |
| 254 "var x = 42;" | |
| 255 "(function() {" | |
| 256 " return function () { return x };" | |
| 257 "})()"; | |
| 258 FunctionTester T(script); | |
| 259 | |
| 260 v8::Isolate* isolate = CcTest::isolate(); | |
| 261 v8::HandleScope outer(isolate); | |
| 262 { | |
| 263 v8::Local<v8::Context> env = v8::Context::New(isolate); | |
| 
 
titzer
2014/08/21 08:12:06
Maybe you can factor this out into function-tester
 
sigurds
2014/08/21 09:14:13
Done.
 
 | |
| 264 env->Enter(); | |
| 265 v8::Local<v8::Value> fun = CompileRun(script); | |
| 266 i::Handle<i::Object> oifun = v8::Utils::OpenHandle(*fun); | |
| 267 i::Handle<i::JSFunction> ifun = Handle<JSFunction>::cast(oifun); | |
| 268 ifun->set_code(T.function->code()); | |
| 269 env->Global()->Set(v8_str("foo"), fun); | |
| 270 CompileRun("var x = 24;"); | |
| 271 ExpectInt32("foo();", 24); | |
| 272 env->Exit(); | |
| 273 } | |
| 274 } | |
| 275 | |
| 276 | |
| 277 TEST(BuiltinLoadedFromActivation) { | |
| 278 i::FLAG_context_specialization = false; | |
| 279 const char* script = | |
| 280 "var x = 42;" | |
| 281 "(function() {" | |
| 282 " return function () { return this; };" | |
| 283 "})()"; | |
| 284 | |
| 285 FunctionTester T(script); | |
| 286 | |
| 287 v8::Isolate* isolate = CcTest::isolate(); | |
| 288 v8::HandleScope outer(isolate); | |
| 289 { | |
| 290 v8::Local<v8::Context> env = v8::Context::New(isolate); | |
| 291 env->Enter(); | |
| 292 v8::Local<v8::Value> fun = CompileRun(script); | |
| 293 i::Handle<i::Object> oifun = v8::Utils::OpenHandle(*fun); | |
| 294 i::Handle<i::JSFunction> ifun = Handle<JSFunction>::cast(oifun); | |
| 295 ifun->set_code(T.function->code()); | |
| 296 env->Global()->Set(v8_str("foo"), fun); | |
| 297 CompileRun("var x = 24;"); | |
| 298 ExpectObject("foo()", env->Global()); | |
| 299 env->Exit(); | |
| 300 } | |
| 301 } | |
| 302 | |
| 303 #endif // V8_TURBO_TARGET | |
| OLD | NEW |