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 | |
titzer
2014/08/21 09:56:35
Why are these guarded with TURBOFAN_TARGET and the
sigurds
2014/08/21 12:29:00
Leftover, thanks. Removed guard.
| |
250 | |
251 TEST(ContextLoadedFromActivation) { | |
252 const char* script = | |
253 "var x = 42;" | |
254 "(function() {" | |
255 " return function () { return x };" | |
256 "})()"; | |
257 | |
258 // Disable context specialization. | |
259 FunctionTester T(script, false); | |
260 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | |
261 v8::Context::Scope scope(context); | |
262 v8::Local<v8::Value> value = CompileRun(script); | |
263 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); | |
264 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); | |
265 jsfun->set_code(T.function->code()); | |
266 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); | |
267 CompileRun("var x = 24;"); | |
268 ExpectInt32("foo();", 24); | |
269 } | |
270 | |
271 | |
272 TEST(BuiltinLoadedFromActivation) { | |
273 const char* script = | |
274 "var x = 42;" | |
275 "(function() {" | |
276 " return function () { return this; };" | |
277 "})()"; | |
278 | |
279 // Disable context specialization. | |
280 FunctionTester T(script, false); | |
281 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | |
282 v8::Context::Scope scope(context); | |
283 v8::Local<v8::Value> value = CompileRun(script); | |
284 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); | |
285 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); | |
286 jsfun->set_code(T.function->code()); | |
287 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); | |
288 CompileRun("var x = 24;"); | |
289 ExpectObject("foo()", context->Global()); | |
290 } | |
291 | |
292 #endif // V8_TURBO_TARGET | |
OLD | NEW |