Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 4296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4307 v8::ExtensionConfiguration extensions(1, extension_names); | 4307 v8::ExtensionConfiguration extensions(1, extension_names); |
| 4308 v8::Handle<Context> context = Context::New(&extensions); | 4308 v8::Handle<Context> context = Context::New(&extensions); |
| 4309 CHECK_EQ(0, *context); | 4309 CHECK_EQ(0, *context); |
| 4310 } | 4310 } |
| 4311 | 4311 |
| 4312 | 4312 |
| 4313 THREADED_TEST(ExtensionWithSourceLength) { | 4313 THREADED_TEST(ExtensionWithSourceLength) { |
| 4314 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; | 4314 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; |
| 4315 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { | 4315 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { |
| 4316 v8::HandleScope handle_scope; | 4316 v8::HandleScope handle_scope; |
| 4317 char extension_name[32]; | 4317 i::ScopedVector<char> extension_name(32); |
| 4318 snprintf(extension_name, sizeof(extension_name), "ext #%d", source_len); | 4318 i::OS::SNPrintF(extension_name, "ext #%d", source_len); |
| 4319 v8::RegisterExtension(new Extension(extension_name, | 4319 v8::RegisterExtension(new Extension(extension_name.start(), |
|
Vyacheslav Egorov (Chromium)
2011/09/21 14:12:08
This test is broken in a sense.
It leaves dangli
| |
| 4320 kEmbeddedExtensionSource, 0, 0, | 4320 kEmbeddedExtensionSource, 0, 0, |
| 4321 source_len)); | 4321 source_len)); |
| 4322 const char* extension_names[1] = { extension_name }; | 4322 const char* extension_names[1] = { extension_name.start() }; |
| 4323 v8::ExtensionConfiguration extensions(1, extension_names); | 4323 v8::ExtensionConfiguration extensions(1, extension_names); |
| 4324 v8::Handle<Context> context = Context::New(&extensions); | 4324 v8::Handle<Context> context = Context::New(&extensions); |
| 4325 if (source_len == kEmbeddedExtensionSourceValidLen) { | 4325 if (source_len == kEmbeddedExtensionSourceValidLen) { |
| 4326 Context::Scope lock(context); | 4326 Context::Scope lock(context); |
| 4327 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); | 4327 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); |
| 4328 CHECK_EQ(v8::Integer::New(54321), result); | 4328 CHECK_EQ(v8::Integer::New(54321), result); |
| 4329 } else { | 4329 } else { |
| 4330 // Anything but exactly the right length should fail to compile. | 4330 // Anything but exactly the right length should fail to compile. |
| 4331 CHECK_EQ(0, *context); | 4331 CHECK_EQ(0, *context); |
| 4332 } | 4332 } |
| (...skipping 10876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15209 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); | 15209 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); |
| 15210 | 15210 |
| 15211 // TODO(1547): Make the following also return "i". | 15211 // TODO(1547): Make the following also return "i". |
| 15212 // Calling with environment record as base. | 15212 // Calling with environment record as base. |
| 15213 TestReceiver(o, context->Global(), "func()"); | 15213 TestReceiver(o, context->Global(), "func()"); |
| 15214 // Calling with no base. | 15214 // Calling with no base. |
| 15215 TestReceiver(o, context->Global(), "(1,func)()"); | 15215 TestReceiver(o, context->Global(), "(1,func)()"); |
| 15216 | 15216 |
| 15217 foreign_context.Dispose(); | 15217 foreign_context.Dispose(); |
| 15218 } | 15218 } |
| OLD | NEW |