diff options
author | Feng Qian <fqian@google.com> | 2009-06-30 15:26:06 -0700 |
---|---|---|
committer | Feng Qian <fqian@google.com> | 2009-06-30 15:26:06 -0700 |
commit | cedffe365f5cf0dfb63dc9d9c592a6ab6620bdcc (patch) | |
tree | a96ddd4a13a1ba4dbbc4693bceced74203f6dab7 /V8Binding/v8/test | |
parent | 67bf3b454483a7d8c1636969f4bb26c90c1ca8a2 (diff) | |
download | external_webkit-cedffe365f5cf0dfb63dc9d9c592a6ab6620bdcc.zip external_webkit-cedffe365f5cf0dfb63dc9d9c592a6ab6620bdcc.tar.gz external_webkit-cedffe365f5cf0dfb63dc9d9c592a6ab6620bdcc.tar.bz2 |
Pickup the latest V8 revision, prepare for snapshotting.
http://v8.googlecode.com/svn/branches/bleeding_edge@2313
Diffstat (limited to 'V8Binding/v8/test')
30 files changed, 2378 insertions, 385 deletions
diff --git a/V8Binding/v8/test/cctest/cctest.status b/V8Binding/v8/test/cctest/cctest.status index a8c2180..68aabb5 100644 --- a/V8Binding/v8/test/cctest/cctest.status +++ b/V8Binding/v8/test/cctest/cctest.status @@ -30,6 +30,10 @@ prefix cctest # BUG(281): This test fails on some Linuxes. test-debug/DebuggerAgent: PASS, (PASS || FAIL) if $system == linux +# BUG(382): Weird test. Can't guarantee that it never times out. +test-api/ApplyInterruption: PASS || TIMEOUT + + [ $arch == arm ] test-debug: SKIP diff --git a/V8Binding/v8/test/cctest/test-api.cc b/V8Binding/v8/test/cctest/test-api.cc index 48157d8..426b720 100644 --- a/V8Binding/v8/test/cctest/test-api.cc +++ b/V8Binding/v8/test/cctest/test-api.cc @@ -551,6 +551,7 @@ THREADED_TEST(UsingExternalString) { CHECK(isymbol->IsSymbol()); } i::Heap::CollectAllGarbage(); + i::Heap::CollectAllGarbage(); } @@ -568,6 +569,7 @@ THREADED_TEST(UsingExternalAsciiString) { CHECK(isymbol->IsSymbol()); } i::Heap::CollectAllGarbage(); + i::Heap::CollectAllGarbage(); } @@ -2281,7 +2283,7 @@ static v8::Handle<Value> XPropertyGetter(Local<String> property, } -THREADED_TEST(NamedInterceporPropertyRead) { +THREADED_TEST(NamedInterceptorPropertyRead) { v8::HandleScope scope; Local<ObjectTemplate> templ = ObjectTemplate::New(); templ->SetNamedPropertyHandler(XPropertyGetter); @@ -2294,6 +2296,58 @@ THREADED_TEST(NamedInterceporPropertyRead) { } } + +static v8::Handle<Value> IndexedPropertyGetter(uint32_t index, + const AccessorInfo& info) { + ApiTestFuzzer::Fuzz(); + if (index == 37) { + return v8::Handle<Value>(v8_num(625)); + } + return v8::Handle<Value>(); +} + + +static v8::Handle<Value> IndexedPropertySetter(uint32_t index, + Local<Value> value, + const AccessorInfo& info) { + ApiTestFuzzer::Fuzz(); + if (index == 39) { + return value; + } + return v8::Handle<Value>(); +} + + +THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { + v8::HandleScope scope; + Local<ObjectTemplate> templ = ObjectTemplate::New(); + templ->SetIndexedPropertyHandler(IndexedPropertyGetter, + IndexedPropertySetter); + LocalContext context; + context->Global()->Set(v8_str("obj"), templ->NewInstance()); + Local<Script> getter_script = Script::Compile(v8_str( + "obj.__defineGetter__(\"3\", function(){return 5;});obj[3];")); + Local<Script> setter_script = Script::Compile(v8_str( + "obj.__defineSetter__(\"17\", function(val){this.foo = val;});" + "obj[17] = 23;" + "obj.foo;")); + Local<Script> interceptor_setter_script = Script::Compile(v8_str( + "obj.__defineSetter__(\"39\", function(val){this.foo = \"hit\";});" + "obj[39] = 47;" + "obj.foo;")); // This setter should not run, due to the interceptor. + Local<Script> interceptor_getter_script = Script::Compile(v8_str( + "obj[37];")); + Local<Value> result = getter_script->Run(); + CHECK_EQ(v8_num(5), result); + result = setter_script->Run(); + CHECK_EQ(v8_num(23), result); + result = interceptor_setter_script->Run(); + CHECK_EQ(v8_num(23), result); + result = interceptor_getter_script->Run(); + CHECK_EQ(v8_num(625), result); +} + + THREADED_TEST(MultiContexts) { v8::HandleScope scope; v8::Handle<ObjectTemplate> templ = ObjectTemplate::New(); @@ -5008,6 +5062,22 @@ THREADED_TEST(InterceptorStoreIC) { } +THREADED_TEST(InterceptorStoreICWithNoSetter) { + v8::HandleScope scope; + v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); + templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); + LocalContext context; + context->Global()->Set(v8_str("o"), templ->NewInstance()); + v8::Handle<Value> value = CompileRun( + "for (var i = 0; i < 1000; i++) {" + " o.y = 239;" + "}" + "42 + o.y"); + CHECK_EQ(239 + 42, value->Int32Value()); +} + + + v8::Handle<Value> call_ic_function; v8::Handle<Value> call_ic_function2; @@ -5970,6 +6040,7 @@ THREADED_TEST(DisableAccessChecksWhileConfiguring) { CHECK(value->BooleanValue()); } + static bool NamedGetAccessBlocker(Local<v8::Object> obj, Local<Value> name, v8::AccessType type, @@ -6023,6 +6094,7 @@ THREADED_TEST(AccessChecksReenabledCorrectly) { CHECK(value_2->IsUndefined()); } + // This tests that access check information remains on the global // object template when creating contexts. THREADED_TEST(AccessControlRepeatedContextCreation) { @@ -6041,6 +6113,71 @@ THREADED_TEST(AccessControlRepeatedContextCreation) { } +THREADED_TEST(TurnOnAccessCheck) { + v8::HandleScope handle_scope; + + // Create an environment with access check to the global object disabled by + // default. + v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); + global_template->SetAccessCheckCallbacks(NamedGetAccessBlocker, + IndexedGetAccessBlocker, + v8::Handle<v8::Value>(), + false); + v8::Persistent<Context> context = Context::New(NULL, global_template); + Context::Scope context_scope(context); + + // Set up a property and a number of functions. + context->Global()->Set(v8_str("a"), v8_num(1)); + CompileRun("function f1() {return a;}" + "function f2() {return a;}" + "function g1() {return h();}" + "function g2() {return h();}" + "function h() {return 1;}"); + Local<Function> f1 = + Local<Function>::Cast(context->Global()->Get(v8_str("f1"))); + Local<Function> f2 = + Local<Function>::Cast(context->Global()->Get(v8_str("f2"))); + Local<Function> g1 = + Local<Function>::Cast(context->Global()->Get(v8_str("g1"))); + Local<Function> g2 = + Local<Function>::Cast(context->Global()->Get(v8_str("g2"))); + Local<Function> h = + Local<Function>::Cast(context->Global()->Get(v8_str("h"))); + + // Get the global object. + v8::Handle<v8::Object> global = context->Global(); + + // Call f1 one time and f2 a number of times. This will ensure that f1 still + // uses the runtime system to retreive property a whereas f2 uses global load + // inline cache. + CHECK(f1->Call(global, 0, NULL)->Equals(v8_num(1))); + for (int i = 0; i < 4; i++) { + CHECK(f2->Call(global, 0, NULL)->Equals(v8_num(1))); + } + + // Same for g1 and g2. + CHECK(g1->Call(global, 0, NULL)->Equals(v8_num(1))); + for (int i = 0; i < 4; i++) { + CHECK(g2->Call(global, 0, NULL)->Equals(v8_num(1))); + } + + // Detach the global and turn on access check. + context->DetachGlobal(); + context->Global()->TurnOnAccessCheck(); + + // Failing access check to property get results in undefined. + CHECK(f1->Call(global, 0, NULL)->IsUndefined()); + CHECK(f2->Call(global, 0, NULL)->IsUndefined()); + + // Failing access check to function call results in exception. + CHECK(g1->Call(global, 0, NULL).IsEmpty()); + CHECK(g2->Call(global, 0, NULL).IsEmpty()); + + // No failing access check when just returning a constant. + CHECK(h->Call(global, 0, NULL)->Equals(v8_num(1))); +} + + // This test verifies that pre-compilation (aka preparsing) can be called // without initializing the whole VM. Thus we cannot run this test in a // multi-threaded setup. diff --git a/V8Binding/v8/test/cctest/test-assembler-x64.cc b/V8Binding/v8/test/cctest/test-assembler-x64.cc index 43ba4e9..cd750c5 100644 --- a/V8Binding/v8/test/cctest/test-assembler-x64.cc +++ b/V8Binding/v8/test/cctest/test-assembler-x64.cc @@ -44,6 +44,7 @@ using v8::internal::Label; using v8::internal::rax; using v8::internal::rsi; using v8::internal::rdi; +using v8::internal::rdx; using v8::internal::rbp; using v8::internal::rsp; using v8::internal::FUNCTION_CAST; @@ -63,8 +64,8 @@ using v8::internal::greater; // with GCC. A different convention is used on 64-bit windows. typedef int (*F0)(); -typedef int (*F1)(int x); -typedef int (*F2)(int x, int y); +typedef int (*F1)(int64_t x); +typedef int (*F2)(int64_t x, int64_t y); #define __ assm. @@ -130,9 +131,9 @@ TEST(AssemblerX64ArithmeticOperations) { CHECK(buffer); Assembler assm(buffer, actual_size); - // Assemble a simple function that copies argument 2 and returns it. + // Assemble a simple function that adds arguments returning the sum. __ movq(rax, rsi); - __ add(rax, rdi); + __ addq(rax, rdi); __ ret(0); CodeDesc desc; @@ -142,6 +143,33 @@ TEST(AssemblerX64ArithmeticOperations) { CHECK_EQ(5, result); } +TEST(AssemblerX64ImulOperation) { + // Allocate an executable page of memory. + size_t actual_size; + byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, + &actual_size, + true)); + CHECK(buffer); + Assembler assm(buffer, actual_size); + + // Assemble a simple function that multiplies arguments returning the high + // word. + __ movq(rax, rsi); + __ imul(rdi); + __ movq(rax, rdx); + __ ret(0); + + CodeDesc desc; + assm.GetCode(&desc); + // Call the function from C++. + int result = FUNCTION_CAST<F2>(buffer)(3, 2); + CHECK_EQ(0, result); + result = FUNCTION_CAST<F2>(buffer)(0x100000000l, 0x100000000l); + CHECK_EQ(1, result); + result = FUNCTION_CAST<F2>(buffer)(-0x100000000l, 0x100000000l); + CHECK_EQ(-1, result); +} + TEST(AssemblerX64MemoryOperands) { // Allocate an executable page of memory. size_t actual_size; @@ -215,12 +243,12 @@ TEST(AssemblerX64LoopImmediates) { Label Loop1_body; __ jmp(&Loop1_test); __ bind(&Loop1_body); - __ add(rax, Immediate(7)); + __ addq(rax, Immediate(7)); __ bind(&Loop1_test); - __ cmp(rax, Immediate(20)); + __ cmpq(rax, Immediate(20)); __ j(less_equal, &Loop1_body); // Did the loop terminate with the expected value? - __ cmp(rax, Immediate(25)); + __ cmpq(rax, Immediate(25)); __ j(not_equal, &Fail); Label Loop2_test; @@ -228,12 +256,12 @@ TEST(AssemblerX64LoopImmediates) { __ movq(rax, Immediate(0x11FEED00)); __ jmp(&Loop2_test); __ bind(&Loop2_body); - __ add(rax, Immediate(-0x1100)); + __ addq(rax, Immediate(-0x1100)); __ bind(&Loop2_test); - __ cmp(rax, Immediate(0x11FE8000)); + __ cmpq(rax, Immediate(0x11FE8000)); __ j(greater, &Loop2_body); // Did the loop terminate with the expected value? - __ cmp(rax, Immediate(0x11FE7600)); + __ cmpq(rax, Immediate(0x11FE7600)); __ j(not_equal, &Fail); __ movq(rax, Immediate(1)); @@ -248,4 +276,5 @@ TEST(AssemblerX64LoopImmediates) { int result = FUNCTION_CAST<F0>(buffer)(); CHECK_EQ(1, result); } + #undef __ diff --git a/V8Binding/v8/test/cctest/test-debug.cc b/V8Binding/v8/test/cctest/test-debug.cc index 92f48e1..a884d77 100644 --- a/V8Binding/v8/test/cctest/test-debug.cc +++ b/V8Binding/v8/test/cctest/test-debug.cc @@ -2237,6 +2237,52 @@ TEST(DebugStepKeyedLoadLoop) { } +// Test of the stepping mechanism for keyed store in a loop. +TEST(DebugStepKeyedStoreLoop) { + v8::HandleScope scope; + DebugLocalContext env; + + // Create a function for testing stepping of keyed store. The statement 'y=1' + // is there to have more than one breakable statement in the loop, TODO(315). + v8::Local<v8::Function> foo = CompileFunction( + &env, + "function foo(a) {\n" + " var len = a.length;\n" + " for (var i = 0; i < len; i++) {\n" + " y = 1;\n" + " a[i] = 42;\n" + " }\n" + "}\n", + "foo"); + + // Create array [0,1,2,3,4,5,6,7,8,9] + v8::Local<v8::Array> a = v8::Array::New(10); + for (int i = 0; i < 10; i++) { + a->Set(v8::Number::New(i), v8::Number::New(i)); + } + + // Call function without any break points to ensure inlining is in place. + const int kArgc = 1; + v8::Handle<v8::Value> args[kArgc] = { a }; + foo->Call(env->Global(), kArgc, args); + + // Register a debug event listener which steps and counts. + v8::Debug::SetDebugEventListener(DebugEventStep); + + // Setup break point and step through the function. + SetBreakPoint(foo, 3); + step_action = StepNext; + break_point_hit_count = 0; + foo->Call(env->Global(), kArgc, args); + + // With stepping all break locations are hit. + CHECK_EQ(22, break_point_hit_count); + + v8::Debug::SetDebugEventListener(NULL); + CheckDebuggerUnloaded(); +} + + // Test the stepping mechanism with different ICs. TEST(DebugStepLinearMixedICs) { v8::HandleScope scope; @@ -4189,57 +4235,83 @@ TEST(CallFunctionInDebugger) { } +// Debugger message handler which counts the number of breaks. +static void SendContinueCommand(); +static void MessageHandlerBreakPointHitCount( + const v8::Debug::Message& message) { + if (message.IsEvent() && message.GetEvent() == v8::Break) { + // Count the number of breaks. + break_point_hit_count++; + + SendContinueCommand(); + } +} + + // Test that clearing the debug event listener actually clears all break points // and related information. TEST(DebuggerUnload) { - v8::HandleScope scope; DebugLocalContext env; // Check debugger is unloaded before it is used. CheckDebuggerUnloaded(); - // Add debug event listener. + // Set a debug event listener. + break_point_hit_count = 0; v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, v8::Undefined()); - // Create a couple of functions for the test. - v8::Local<v8::Function> foo = - CompileFunction(&env, "function foo(){x=1}", "foo"); - v8::Local<v8::Function> bar = - CompileFunction(&env, "function bar(){y=2}", "bar"); - - // Set some break points. - SetBreakPoint(foo, 0); - SetBreakPoint(foo, 4); - SetBreakPoint(bar, 0); - SetBreakPoint(bar, 4); - - // Make sure that the break points are there. - break_point_hit_count = 0; - foo->Call(env->Global(), 0, NULL); - CHECK_EQ(2, break_point_hit_count); - bar->Call(env->Global(), 0, NULL); - CHECK_EQ(4, break_point_hit_count); + { + v8::HandleScope scope; + // Create a couple of functions for the test. + v8::Local<v8::Function> foo = + CompileFunction(&env, "function foo(){x=1}", "foo"); + v8::Local<v8::Function> bar = + CompileFunction(&env, "function bar(){y=2}", "bar"); + + // Set some break points. + SetBreakPoint(foo, 0); + SetBreakPoint(foo, 4); + SetBreakPoint(bar, 0); + SetBreakPoint(bar, 4); + + // Make sure that the break points are there. + break_point_hit_count = 0; + foo->Call(env->Global(), 0, NULL); + CHECK_EQ(2, break_point_hit_count); + bar->Call(env->Global(), 0, NULL); + CHECK_EQ(4, break_point_hit_count); + } - // Remove the debug event listener without clearing breakpoints. + // Remove the debug event listener without clearing breakpoints. Do this + // outside a handle scope. v8::Debug::SetDebugEventListener(NULL); CheckDebuggerUnloaded(true); - // Set a new debug event listener. - v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, - v8::Undefined()); - // Check that the break points was actually cleared. + // Now set a debug message handler. break_point_hit_count = 0; - foo->Call(env->Global(), 0, NULL); - CHECK_EQ(0, break_point_hit_count); + v8::Debug::SetMessageHandler2(MessageHandlerBreakPointHitCount); + { + v8::HandleScope scope; - // Set break points and run again. - SetBreakPoint(foo, 0); - SetBreakPoint(foo, 4); - foo->Call(env->Global(), 0, NULL); - CHECK_EQ(2, break_point_hit_count); + // Get the test functions again. + v8::Local<v8::Function> foo = + v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); + v8::Local<v8::Function> bar = + v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); - // Remove the debug event listener without clearing breakpoints again. - v8::Debug::SetDebugEventListener(NULL); + foo->Call(env->Global(), 0, NULL); + CHECK_EQ(0, break_point_hit_count); + + // Set break points and run again. + SetBreakPoint(foo, 0); + SetBreakPoint(foo, 4); + foo->Call(env->Global(), 0, NULL); + CHECK_EQ(2, break_point_hit_count); + } + + // Remove the debug message handler without clearing breakpoints. Do this + // outside a handle scope. + v8::Debug::SetMessageHandler2(NULL); CheckDebuggerUnloaded(true); } @@ -5185,3 +5257,40 @@ TEST(ExceptionMessageWhenMessageHandlerIsReset) { CHECK_EQ(1, exception_event_count); } + + +// Tests after compile event is sent when there are some provisional +// breakpoints out of the scripts lines range. +TEST(ProvisionalBreakpointOnLineOutOfRange) { + v8::HandleScope scope; + DebugLocalContext env; + env.ExposeDebug(); + const char* script = "function f() {};"; + const char* resource_name = "test_resource"; + + // Set a couple of provisional breakpoint on lines out of the script lines + // range. + int sbp1 = SetScriptBreakPointByNameFromJS(resource_name, 3, + -1 /* no column */); + int sbp2 = SetScriptBreakPointByNameFromJS(resource_name, 5, 5); + + after_compile_message_count = 0; + v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); + + v8::ScriptOrigin origin( + v8::String::New(resource_name), + v8::Integer::New(10), + v8::Integer::New(1)); + // Compile a script whose first line number is greater than the breakpoints' + // lines. + v8::Script::Compile(v8::String::New(script), &origin)->Run(); + + // If the script is compiled successfully there is exactly one after compile + // event. In case of an exception in debugger code after compile event is not + // sent. + CHECK_EQ(1, after_compile_message_count); + + ClearBreakPointFromJS(sbp1); + ClearBreakPointFromJS(sbp2); + v8::Debug::SetMessageHandler2(NULL); +} diff --git a/V8Binding/v8/test/cctest/test-func-name-inference.cc b/V8Binding/v8/test/cctest/test-func-name-inference.cc index 1bfc883..28e8649 100644 --- a/V8Binding/v8/test/cctest/test-func-name-inference.cc +++ b/V8Binding/v8/test/cctest/test-func-name-inference.cc @@ -251,3 +251,17 @@ TEST(MultipleFuncsInLiteral) { CheckFunctionName(script, "return 1", "MyClass.method1"); CheckFunctionName(script, "return 2", "MyClass.method1"); } + + +// See http://code.google.com/p/v8/issues/detail?id=380 +TEST(Issue380) { + InitializeVM(); + v8::HandleScope scope; + + v8::Handle<v8::Script> script = Compile( + "function a() {\n" + "var result = function(p,a,c,k,e,d)" + "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n" + "}"); + CheckFunctionName(script, "return p", ""); +} diff --git a/V8Binding/v8/test/cctest/test-heap.cc b/V8Binding/v8/test/cctest/test-heap.cc index 515657f..396bcc5 100644 --- a/V8Binding/v8/test/cctest/test-heap.cc +++ b/V8Binding/v8/test/cctest/test-heap.cc @@ -208,7 +208,7 @@ TEST(GarbageCollection) { v8::HandleScope sc; // check GC when heap is empty - int free_bytes = Heap::MaxHeapObjectSize(); + int free_bytes = Heap::MaxObjectSizeInPagedSpace(); CHECK(Heap::CollectGarbage(free_bytes, NEW_SPACE)); // allocate a function and keep it in global object's property @@ -782,7 +782,7 @@ TEST(Iteration) { Factory::NewStringFromAscii(CStrVector("abcdefghij"), TENURED); // Allocate a large string (for large object space). - int large_size = Heap::MaxHeapObjectSize() + 1; + int large_size = Heap::MaxObjectSizeInPagedSpace() + 1; char* str = new char[large_size]; for (int i = 0; i < large_size - 1; ++i) str[i] = 'a'; str[large_size - 1] = '\0'; diff --git a/V8Binding/v8/test/cctest/test-log-utils.cc b/V8Binding/v8/test/cctest/test-log-utils.cc index 64e5900..a08a0a1 100644 --- a/V8Binding/v8/test/cctest/test-log-utils.cc +++ b/V8Binding/v8/test/cctest/test-log-utils.cc @@ -9,8 +9,12 @@ #include "log-utils.h" #include "cctest.h" +using v8::internal::CStrVector; using v8::internal::EmbeddedVector; using v8::internal::LogDynamicBuffer; +using v8::internal::LogRecordCompressor; +using v8::internal::MutableCStrVector; +using v8::internal::ScopedVector; using v8::internal::Vector; // Fills 'ref_buffer' with test data: a sequence of two-digit @@ -47,9 +51,13 @@ static inline void CheckEqualsHelper(const char* file, int line, const Vector<V>& value) { if (expected.length() != value.length()) { V8_Fatal(file, line, "CHECK_EQ(%s, %s) failed\n" - "# Vectors lengths differ: %d expected, %d found", + "# Vectors lengths differ: %d expected, %d found\n" + "# Expected: %.*s\n" + "# Found: %.*s", expected_source, value_source, - expected.length(), value.length()); + expected.length(), value.length(), + expected.length(), expected.start(), + value.length(), value.start()); } if (strncmp(expected.start(), value.start(), expected.length()) != 0) { V8_Fatal(file, line, "CHECK_EQ(%s, %s) failed\n" @@ -124,9 +132,178 @@ TEST(DynaBufSealing) { // Check the seal. EmbeddedVector<char, 50> seal_buf; CHECK_EQ(seal_size, ReadData(&dynabuf, 100, &seal_buf)); - CHECK_EQ(v8::internal::CStrVector(seal), seal_buf.SubVector(0, seal_size)); + CHECK_EQ(CStrVector(seal), seal_buf.SubVector(0, seal_size)); // Verify that there's no data beyond the seal. CHECK_EQ(0, ReadData(&dynabuf, 100 + seal_size, &buf)); } + +TEST(CompressorStore) { + LogRecordCompressor comp(2); + const Vector<const char> empty = CStrVector(""); + CHECK(comp.Store(empty)); + CHECK(!comp.Store(empty)); + CHECK(!comp.Store(empty)); + const Vector<const char> aaa = CStrVector("aaa"); + CHECK(comp.Store(aaa)); + CHECK(!comp.Store(aaa)); + CHECK(!comp.Store(aaa)); + CHECK(comp.Store(empty)); + CHECK(!comp.Store(empty)); + CHECK(!comp.Store(empty)); +} + + +void CheckCompression(LogRecordCompressor* comp, + const Vector<const char>& after) { + EmbeddedVector<char, 100> result; + CHECK(comp->RetrievePreviousCompressed(&result)); + CHECK_EQ(after, result); +} + + +void CheckCompression(LogRecordCompressor* comp, + const char* after) { + CheckCompression(comp, CStrVector(after)); +} + + +TEST(CompressorNonCompressed) { + LogRecordCompressor comp(0); + CHECK(!comp.RetrievePreviousCompressed(NULL)); + const Vector<const char> empty = CStrVector(""); + CHECK(comp.Store(empty)); + CHECK(!comp.RetrievePreviousCompressed(NULL)); + const Vector<const char> a_x_20 = CStrVector("aaaaaaaaaaaaaaaaaaaa"); + CHECK(comp.Store(a_x_20)); + CheckCompression(&comp, empty); + CheckCompression(&comp, empty); + CHECK(comp.Store(empty)); + CheckCompression(&comp, a_x_20); + CheckCompression(&comp, a_x_20); +} + + +TEST(CompressorSingleLine) { + LogRecordCompressor comp(1); + const Vector<const char> string_1 = CStrVector("eee,ddd,ccc,bbb,aaa"); + CHECK(comp.Store(string_1)); + const Vector<const char> string_2 = CStrVector("fff,ddd,ccc,bbb,aaa"); + CHECK(comp.Store(string_2)); + // string_1 hasn't been compressed. + CheckCompression(&comp, string_1); + CheckCompression(&comp, string_1); + const Vector<const char> string_3 = CStrVector("hhh,ggg,ccc,bbb,aaa"); + CHECK(comp.Store(string_3)); + // string_2 compressed using string_1. + CheckCompression(&comp, "fff#1:3"); + CheckCompression(&comp, "fff#1:3"); + CHECK(!comp.Store(string_3)); + // Expecting no changes. + CheckCompression(&comp, "fff#1:3"); + CHECK(!comp.Store(string_3)); + // Expecting no changes. + CheckCompression(&comp, "fff#1:3"); + const Vector<const char> string_4 = CStrVector("iii,hhh,ggg,ccc,bbb,aaa"); + CHECK(comp.Store(string_4)); + // string_3 compressed using string_2. + CheckCompression(&comp, "hhh,ggg#1:7"); + const Vector<const char> string_5 = CStrVector("nnn,mmm,lll,kkk,jjj"); + CHECK(comp.Store(string_5)); + // string_4 compressed using string_3. + CheckCompression(&comp, "iii,#1"); + const Vector<const char> string_6 = CStrVector("nnn,mmmmmm,lll,kkk,jjj"); + CHECK(comp.Store(string_6)); + // string_5 hasn't been compressed. + CheckCompression(&comp, string_5); + CHECK(comp.Store(string_5)); + // string_6 compressed using string_5. + CheckCompression(&comp, "nnn,mmm#1:4"); + const Vector<const char> string_7 = CStrVector("nnnnnn,mmm,lll,kkk,jjj"); + CHECK(comp.Store(string_7)); + // string_5 compressed using string_6. + CheckCompression(&comp, "nnn,#1:7"); + const Vector<const char> string_8 = CStrVector("xxn,mmm,lll,kkk,jjj"); + CHECK(comp.Store(string_8)); + // string_7 compressed using string_5. + CheckCompression(&comp, "nnn#1"); + const Vector<const char> string_9 = + CStrVector("aaaaaaaaaaaaa,bbbbbbbbbbbbbbbbb"); + CHECK(comp.Store(string_9)); + // string_8 compressed using string_7. + CheckCompression(&comp, "xx#1:5"); + const Vector<const char> string_10 = + CStrVector("aaaaaaaaaaaaa,cccccccbbbbbbbbbb"); + CHECK(comp.Store(string_10)); + // string_9 hasn't been compressed. + CheckCompression(&comp, string_9); + CHECK(comp.Store(string_1)); + // string_10 compressed using string_9. + CheckCompression(&comp, "aaaaaaaaaaaaa,ccccccc#1:21"); +} + + + +TEST(CompressorMultiLines) { + const int kWindowSize = 3; + LogRecordCompressor comp(kWindowSize); + const Vector<const char> string_1 = CStrVector("eee,ddd,ccc,bbb,aaa"); + CHECK(comp.Store(string_1)); + const Vector<const char> string_2 = CStrVector("iii,hhh,ggg,fff,aaa"); + CHECK(comp.Store(string_2)); + const Vector<const char> string_3 = CStrVector("mmm,lll,kkk,jjj,aaa"); + CHECK(comp.Store(string_3)); + const Vector<const char> string_4 = CStrVector("nnn,hhh,ggg,fff,aaa"); + CHECK(comp.Store(string_4)); + const Vector<const char> string_5 = CStrVector("ooo,lll,kkk,jjj,aaa"); + CHECK(comp.Store(string_5)); + // string_4 compressed using string_2. + CheckCompression(&comp, "nnn#2:3"); + CHECK(comp.Store(string_1)); + // string_5 compressed using string_3. + CheckCompression(&comp, "ooo#2:3"); + CHECK(comp.Store(string_4)); + // string_1 is out of buffer by now, so it shouldn't be compressed. + CHECK_GE(3, kWindowSize); + CheckCompression(&comp, string_1); + CHECK(comp.Store(string_2)); + // string_4 compressed using itself. + CheckCompression(&comp, "#3"); +} + + +TEST(CompressorBestSelection) { + LogRecordCompressor comp(3); + const Vector<const char> string_1 = CStrVector("eee,ddd,ccc,bbb,aaa"); + CHECK(comp.Store(string_1)); + const Vector<const char> string_2 = CStrVector("ddd,ccc,bbb,aaa"); + CHECK(comp.Store(string_2)); + const Vector<const char> string_3 = CStrVector("fff,eee,ddd,ccc,bbb,aaa"); + CHECK(comp.Store(string_3)); + // string_2 compressed using string_1. + CheckCompression(&comp, "#1:4"); + const Vector<const char> string_4 = CStrVector("nnn,hhh,ggg,fff,aaa"); + CHECK(comp.Store(string_4)); + // Compressing string_3 using string_1 gives a better compression than + // using string_2. + CheckCompression(&comp, "fff,#2"); +} + + +TEST(CompressorCompressibility) { + LogRecordCompressor comp(2); + const Vector<const char> string_1 = CStrVector("eee,ddd,ccc,bbb,aaa"); + CHECK(comp.Store(string_1)); + const Vector<const char> string_2 = CStrVector("ccc,bbb,aaa"); + CHECK(comp.Store(string_2)); + const Vector<const char> string_3 = CStrVector("aaa"); + CHECK(comp.Store(string_3)); + // string_2 compressed using string_1. + CheckCompression(&comp, "#1:8"); + const Vector<const char> string_4 = CStrVector("xxx"); + CHECK(comp.Store(string_4)); + // string_3 can't be compressed using string_2 --- too short. + CheckCompression(&comp, string_3); +} + #endif // ENABLE_LOGGING_AND_PROFILING diff --git a/V8Binding/v8/test/cctest/test-mark-compact.cc b/V8Binding/v8/test/cctest/test-mark-compact.cc index 53cff68..8db7339 100644 --- a/V8Binding/v8/test/cctest/test-mark-compact.cc +++ b/V8Binding/v8/test/cctest/test-mark-compact.cc @@ -86,8 +86,8 @@ TEST(Promotion) { v8::HandleScope sc; // Allocate a fixed array in the new space. - int array_size = - (Heap::MaxHeapObjectSize() - Array::kHeaderSize) / (kPointerSize * 4); + int array_size = (Heap::MaxObjectSizeInPagedSpace() - Array::kHeaderSize) / + (kPointerSize * 4); Object* obj = Heap::AllocateFixedArray(array_size); CHECK(!obj->IsFailure()); @@ -118,7 +118,8 @@ TEST(NoPromotion) { CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); // Allocate a big Fixed array in the new space. - int size = (Heap::MaxHeapObjectSize() - Array::kHeaderSize) / kPointerSize; + int size = (Heap::MaxObjectSizeInPagedSpace() - Array::kHeaderSize) / + kPointerSize; Object* obj = Heap::AllocateFixedArray(size); Handle<FixedArray> array(FixedArray::cast(obj)); diff --git a/V8Binding/v8/test/message/overwritten-builtins.js b/V8Binding/v8/test/message/overwritten-builtins.js new file mode 100644 index 0000000..8a838de --- /dev/null +++ b/V8Binding/v8/test/message/overwritten-builtins.js @@ -0,0 +1,31 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +String.prototype.split = function() { return "SPLIT ERROR"; }; +Array.prototype.join = function() { return []; }; + +undefined.x diff --git a/V8Binding/v8/test/message/overwritten-builtins.out b/V8Binding/v8/test/message/overwritten-builtins.out new file mode 100644 index 0000000..ccf2924 --- /dev/null +++ b/V8Binding/v8/test/message/overwritten-builtins.out @@ -0,0 +1,30 @@ +# Copyright 2009 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*%(basename)s:31: TypeError: Cannot read property 'x' of undefined +undefined.x + ^ diff --git a/V8Binding/v8/test/mjsunit/arguments-apply.js b/V8Binding/v8/test/mjsunit/arguments-apply.js new file mode 100644 index 0000000..5a91228 --- /dev/null +++ b/V8Binding/v8/test/mjsunit/arguments-apply.js @@ -0,0 +1,134 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function ReturnArguments() { + return arguments; +} + +function ReturnReceiver() { + return this; +} + + +function Global() { + return ReturnArguments.apply(this, arguments); +} + +assertEquals(0, Global().length); +assertEquals(1, Global(1).length); +assertEquals(2, Global(2)[0]); +assertEquals(2, Global(3, 4).length); +assertEquals(3, Global(3, 4)[0]); +assertEquals(4, Global(3, 4)[1]); + + +function Local() { + var object = { f: ReturnArguments }; + return object.f.apply(this, arguments); +} + +assertEquals(0, Local().length); +assertEquals(1, Local(1).length); +assertEquals(2, Local(2)[0]); +assertEquals(2, Local(3, 4).length); +assertEquals(3, Local(3, 4)[0]); +assertEquals(4, Local(3, 4)[1]); + + +function ShadowArguments() { + var arguments = [3, 4]; + return ReturnArguments.apply(this, arguments); +} + +assertEquals(2, ShadowArguments().length); +assertEquals(3, ShadowArguments()[0]); +assertEquals(4, ShadowArguments()[1]); + + +function NonObjectReceiver(receiver) { + return ReturnReceiver.apply(receiver, arguments); +} + +assertEquals(42, NonObjectReceiver(42)); +assertEquals("object", typeof NonObjectReceiver(42)); +assertTrue(NonObjectReceiver(42) instanceof Number); +assertTrue(this === NonObjectReceiver(null)); +assertTrue(this === NonObjectReceiver(void 0)); + + +function FunctionReceiver() { + return ReturnReceiver.apply(Object, arguments); +} + +assertTrue(Object === FunctionReceiver()); + + +function ShadowApply() { + function f() { return 42; } + f.apply = function() { return 87; } + return f.apply(this, arguments); +} + +assertEquals(87, ShadowApply()); +assertEquals(87, ShadowApply(1)); +assertEquals(87, ShadowApply(1, 2)); + + +function CallNonFunction() { + var object = { apply: Function.prototype.apply }; + return object.apply(this, arguments); +} + +assertThrows(CallNonFunction, TypeError); + + +// Make sure that the stack after the apply optimization is +// in a valid state. +function SimpleStackCheck() { + var sentinel = 42; + var result = ReturnArguments.apply(this, arguments); + assertTrue(result != null); + assertEquals(42, sentinel); +} + +SimpleStackCheck(); + + +function ShadowArgumentsWithConstant() { + var arguments = null; + return ReturnArguments.apply(this, arguments); +} + +assertEquals(0, ShadowArgumentsWithConstant().length); +assertEquals(0, ShadowArgumentsWithConstant(1).length); +assertEquals(0, ShadowArgumentsWithConstant(1, 2).length); + + +// Make sure we can deal with unfolding lots of arguments on the +// stack even in the presence of the apply optimizations. +var array = new Array(2048); +assertEquals(2048, Global.apply(this, array).length); diff --git a/V8Binding/v8/test/mjsunit/arguments-lazy.js b/V8Binding/v8/test/mjsunit/arguments-lazy.js new file mode 100644 index 0000000..794afc3 --- /dev/null +++ b/V8Binding/v8/test/mjsunit/arguments-lazy.js @@ -0,0 +1,47 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Make sure we don't allocate the arguments object over and +// over again. +function SharedLazyArguments() { + return arguments === arguments; +} + +assertTrue(SharedLazyArguments()); + + +// Make sure that accessing arguments doesn't clobber any +// local variables called arguments. +function ArgumentsOverride(x) { + var arguments = 42; + x = x ? x : 0; + return x + arguments; +} + +assertEquals(42, ArgumentsOverride()); +assertEquals(43, ArgumentsOverride(1)); +assertEquals(44, ArgumentsOverride(2,3)); diff --git a/V8Binding/v8/test/mjsunit/array-sort.js b/V8Binding/v8/test/mjsunit/array-sort.js index ef75dcc..a082abc 100644 --- a/V8Binding/v8/test/mjsunit/array-sort.js +++ b/V8Binding/v8/test/mjsunit/array-sort.js @@ -214,6 +214,30 @@ TestNonArrayLongerLength(500000); TestNonArrayLongerLength(Math.pow(2,32) - 1); +function TestNonArrayWithAccessors() { + // Regression test for issue 346, more info at URL + // http://code.google.com/p/v8/issues/detail?id=346 + // Reported by nth10sd, test based on this report. + var x = {}; + x[0] = 42; + x.__defineGetter__("1", function(){return this.foo;}); + x.__defineSetter__("1", function(val){this.foo = val;}); + x[1] = 49 + x[3] = 37; + x.length = 4; + Array.prototype.sort.call(x); + // Behavior of sort with accessors is undefined. This accessor is + // well-behaved (acts like a normal property), so it should work. + assertEquals(4, x.length, "sortaccessors length"); + assertEquals(37, x[0], "sortaccessors first"); + assertEquals(42, x[1], "sortaccessors second"); + assertEquals(49, x[2], "sortaccessors third") + assertFalse(3 in x, "sortaccessors fourth"); +} + +TestNonArrayWithAccessors(); + + function TestInheritedElementSort(depth) { var length = depth * 2 + 3; var obj = {length: length}; @@ -268,7 +292,7 @@ function TestSparseInheritedElementSort(scale) { assertEquals(i, y[i], name + "value" + i); } for (var i = 10; i < length; i++) { - assertEquals(x.hasOwnProperty(i), y.hasOwnProperty(i), + assertEquals(x.hasOwnProperty(i), y.hasOwnProperty(i), name + "hasundef" + i); assertEquals(undefined, y[i], name+"undefined"+i); if (x.hasOwnProperty(i)) { @@ -282,7 +306,7 @@ TestSparseInheritedElementSort(100); TestSparseInheritedElementSort(1000); function TestSpecialCasesInheritedElementSort() { - + var x = { 1:"d1", 2:"c1", @@ -309,11 +333,11 @@ function TestSpecialCasesInheritedElementSort() { } }; Array.prototype.sort.call(x); - + var name = "SpecialInherit-"; - + assertEquals(10000, x.length, name + "length"); - var sorted = ["a2", "a3", "b1", "b2", "c1", "c2", "d1", "d2", "e3", + var sorted = ["a2", "a3", "b1", "b2", "c1", "c2", "d1", "d2", "e3", undefined, undefined, undefined]; for (var i = 0; i < sorted.length; i++) { assertTrue(x.hasOwnProperty(i), name + "has" + i) @@ -321,7 +345,6 @@ function TestSpecialCasesInheritedElementSort() { } assertFalse(x.hasOwnProperty(sorted.length), name + "haspost"); assertFalse(sorted.length in x, name + "haspost2"); - assertTrue(x.hasOwnProperty(10), name + "hasundefined10"); assertEquals(undefined, x[10], name + "undefined10"); assertTrue(x.hasOwnProperty(100), name + "hasundefined100"); @@ -332,11 +355,8 @@ function TestSpecialCasesInheritedElementSort() { assertEquals(undefined, x[2000], name + "undefined2000"); assertTrue(x.hasOwnProperty(8000), name + "hasundefined8000"); assertEquals(undefined, x[8000], name + "undefined8000"); - assertFalse(x.hasOwnProperty(12000), name + "has12000"); assertEquals("XX", x[12000], name + "XX12000"); - } TestSpecialCasesInheritedElementSort(); - diff --git a/V8Binding/v8/test/mjsunit/big-object-literal.js b/V8Binding/v8/test/mjsunit/big-object-literal.js index 0099ce9..8417951 100644 --- a/V8Binding/v8/test/mjsunit/big-object-literal.js +++ b/V8Binding/v8/test/mjsunit/big-object-literal.js @@ -84,7 +84,7 @@ function testLiteral(size, array_in_middle) { } // The sizes to test. -var sizes = [1, 2, 100, 200, 400]; +var sizes = [1, 2, 100, 200, 350]; // Run the test. for (var i = 0; i < sizes.length; i++) { diff --git a/V8Binding/v8/test/mjsunit/compare-nan.js b/V8Binding/v8/test/mjsunit/compare-nan.js index 29818c8..fc40acc 100644 --- a/V8Binding/v8/test/mjsunit/compare-nan.js +++ b/V8Binding/v8/test/mjsunit/compare-nan.js @@ -28,17 +28,17 @@ var a = [NaN, -1, 0, 1, 1.2, -7.9, true, false, 'foo', '0', 'NaN' ]; for (var i in a) { var x = a[i]; - assertFalse(NaN == x); - assertFalse(NaN === x); - assertFalse(NaN < x); - assertFalse(NaN > x); - assertFalse(NaN <= x); - assertFalse(NaN >= x); + assertFalse(NaN == x, "NaN == " + x); + assertFalse(NaN === x, "NaN === " + x); + assertFalse(NaN < x, "NaN < " + x); + assertFalse(NaN > x, "NaN > " + x); + assertFalse(NaN <= x, "NaN <= " + x); + assertFalse(NaN >= x, "NaN >= " + x); - assertFalse(x == NaN); - assertFalse(x === NaN); - assertFalse(x < NaN); - assertFalse(x > NaN); - assertFalse(x <= NaN); - assertFalse(x >= NaN); + assertFalse(x == NaN, "" + x + " == NaN"); + assertFalse(x === NaN, "" + x + " === NaN"); + assertFalse(x < NaN, "" + x + " < NaN"); + assertFalse(x > NaN, "" + x + " > NaN"); + assertFalse(x <= NaN, "" + x + " <= NaN"); + assertFalse(x >= NaN, "" + x + " >= NaN"); } diff --git a/V8Binding/v8/test/mjsunit/date-parse.js b/V8Binding/v8/test/mjsunit/date-parse.js index 4464727..56ceba3 100644 --- a/V8Binding/v8/test/mjsunit/date-parse.js +++ b/V8Binding/v8/test/mjsunit/date-parse.js @@ -254,7 +254,7 @@ testCasesMisc.forEach(testDateParseMisc); for (var i = 0; i < 24 * 365 * 100; i += 95) { var ms = i * (3600 * 1000); var s = (new Date(ms)).toString(); - assertEquals(ms, Date.parse(s), s); + assertEquals(ms, Date.parse(s), "parse own: " + s); } // Negative tests. diff --git a/V8Binding/v8/test/mjsunit/debug-scopes.js b/V8Binding/v8/test/mjsunit/debug-scopes.js new file mode 100644 index 0000000..7b477e1 --- /dev/null +++ b/V8Binding/v8/test/mjsunit/debug-scopes.js @@ -0,0 +1,660 @@ +// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --expose-debug-as debug +// The functions used for testing backtraces. They are at the top to make the +// testing of source line/column easier. + + +// Get the Debug object exposed from the debug context global object. +Debug = debug.Debug + +var name; +var listener_delegate; +var listener_called; +var exception; +var begin_test_count = 0; +var end_test_count = 0; +var break_count = 0; + + +// Debug event listener which delegates. +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Break) { + break_count++; + listener_called = true; + listener_delegate(exec_state) + } + } catch (e) { + exception = e; + } +} + +// Add the debug event listener. +Debug.setListener(listener); + + +// Initialize for a noew test. +function BeginTest(name) { + test_name = name; + listener_delegate = null; + listener_called = false; + exception = null; + begin_test_count++; +} + + +// Check result of a test. +function EndTest() { + assertTrue(listener_called, "listerner not called for " + test_name); + assertNull(exception, test_name) + end_test_count++; +} + + +// Check that the scope chain contains the expected types of scopes. +function CheckScopeChain(scopes, exec_state) { + assertEquals(scopes.length, exec_state.frame().scopeCount()); + for (var i = 0; i < scopes.length; i++) { + var scope = exec_state.frame().scope(i); + assertTrue(scope.isScope()); + assertEquals(scopes[i], scope.scopeType()); + + // Check the global object when hitting the global scope. + if (scopes[i] == debug.ScopeType.Global) { + assertEquals(this, scope.scopeObject().value()); + } + } + + // Get the debug command processor. + var dcp = exec_state.debugCommandProcessor(); + + // Send a scopes request and check the result. + var json; + request_json = '{"seq":0,"type":"request","command":"scopes"}' + var response_json = dcp.processDebugJSONRequest(request_json); + var response = JSON.parse(response_json); + assertEquals(scopes.length, response.body.scopes.length); + for (var i = 0; i < scopes.length; i++) { + assertEquals(i, response.body.scopes[i].index); + assertEquals(scopes[i], response.body.scopes[i].type); + if (scopes[i] == debug.ScopeType.Local || + scopes[i] == debug.ScopeType.Closure) { + assertTrue(response.body.scopes[i].object.ref < 0); + } else { + assertTrue(response.body.scopes[i].object.ref >= 0); + } + var found = false; + for (var j = 0; j < response.refs.length && !found; j++) { + found = response.refs[j].handle == response.body.scopes[i].object.ref; + } + assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " not found"); + } +} + + +// Check that the content of the scope is as expected. For functions just check +// that there is a function. +function CheckScopeContent(content, number, exec_state) { + var scope = exec_state.frame().scope(number) + var count = 0; + for (var p in content) { + var property_mirror = scope.scopeObject().property(p); + assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in scope'); + if (typeof(content[p]) === 'function') { + assertTrue(property_mirror.value().isFunction()); + } else { + assertEquals(content[p], property_mirror.value().value(), 'property ' + p + ' has unexpected value'); + } + count++; + } + + // 'arguments' and might be exposed in the local and closure scope. Just + // ignore this. + var scope_size = scope.scopeObject().properties().length; + if (!scope.scopeObject().property('arguments').isUndefined()) { + scope_size--; + } + if (count != scope_size) { + print('Names found in scope:'); + var names = scope.scopeObject().propertyNames(); + for (var i = 0; i < names.length; i++) { + print(names[i]); + } + } + assertEquals(count, scope_size); + + // Get the debug command processor. + var dcp = exec_state.debugCommandProcessor(); + + // Send a scope request for information on a single scope and check the + // result. + request_json = '{"seq":0,"type":"request","command":"scope","arguments":{"number":' + request_json += scope.scopeIndex(); + request_json += '}}' + var response_json = dcp.processDebugJSONRequest(request_json); + var response = JSON.parse(response_json); + assertEquals(scope.scopeType(), response.body.type); + assertEquals(number, response.body.index); + if (scope.scopeType() == debug.ScopeType.Local || + scope.scopeType() == debug.ScopeType.Closure) { + assertTrue(response.body.object.ref < 0); + } else { + assertTrue(response.body.object.ref >= 0); + } + var found = false; + for (var i = 0; i < response.refs.length && !found; i++) { + found = response.refs[i].handle == response.body.object.ref; + } + assertTrue(found, "Scope object " + response.body.object.ref + " not found"); +} + + +// Simple empty local scope. +BeginTest("Local 1"); + +function local_1() { + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); +} +local_1() +EndTest(); + + +// Local scope with a parameter. +BeginTest("Local 2"); + +function local_2(a) { + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1}, 0, exec_state); +} +local_2(1) +EndTest(); + + +// Local scope with a parameter and a local variable. +BeginTest("Local 3"); + +function local_3(a) { + var x = 3; + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,x:3}, 0, exec_state); +} +local_3(1) +EndTest(); + + +// Local scope with parameters and local variables. +BeginTest("Local 4"); + +function local_4(a, b) { + var x = 3; + var y = 4; + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); +} +local_4(1, 2) +EndTest(); + + +// Empty local scope with use of eval. +BeginTest("Local 5"); + +function local_5() { + eval(''); + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); +} +local_5() +EndTest(); + + +// Local introducing local variable using eval. +BeginTest("Local 6"); + +function local_6() { + eval('var i = 5'); + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({i:5}, 0, exec_state); +} +local_6() +EndTest(); + + +// Local scope with parameters, local variables and local variable introduced +// using eval. +BeginTest("Local 7"); + +function local_7(a, b) { + var x = 3; + var y = 4; + eval('var i = 5'); + eval('var j = 6'); + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 0, exec_state); +} +local_7(1, 2) +EndTest(); + + +// Single empty with block. +BeginTest("With 1"); + +function with_1() { + with({}) { + debugger; + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.With, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); +} +with_1() +EndTest(); + + +// Nested empty with blocks. +BeginTest("With 2"); + +function with_2() { + with({}) { + with({}) { + debugger; + } + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.With, + debug.ScopeType.With, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); + CheckScopeContent({}, 1, exec_state); +} +with_2() +EndTest(); + + +// With block using an in-place object literal. +BeginTest("With 3"); + +function with_3() { + with({a:1,b:2}) { + debugger; + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.With, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2}, 0, exec_state); +} +with_3() +EndTest(); + + +// Nested with blocks using in-place object literals. +BeginTest("With 4"); + +function with_4() { + with({a:1,b:2}) { + with({a:2,b:1}) { + debugger; + } + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.With, + debug.ScopeType.With, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:2,b:1}, 0, exec_state); + CheckScopeContent({a:1,b:2}, 1, exec_state); +} +with_4() +EndTest(); + + +// Nested with blocks using existing object. +BeginTest("With 5"); + +var with_object = {c:3,d:4}; +function with_5() { + with(with_object) { + with(with_object) { + debugger; + } + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.With, + debug.ScopeType.With, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent(with_object, 0, exec_state); + CheckScopeContent(with_object, 1, exec_state); + assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().scope(1).scopeObject()); + assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); +} +with_5() +EndTest(); + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. +BeginTest("Closure 1"); + +function closure_1(a) { + function f() { + debugger; + return a; + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1}, 1, exec_state); +} +closure_1(1)() +EndTest(); + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. Due to VM optimizations parts of the actual closure is +// missing from the debugger information. +BeginTest("Closure 2"); + +function closure_2(a, b) { + var x = a + 2; + var y = b + 2; + function f() { + debugger; + return a + x; + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,x:3}, 1, exec_state); +} +closure_2(1, 2)() +EndTest(); + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. Using all arguments and locals from the outer function +// in the inner function makes these part of the debugger information on the +// closure. +BeginTest("Closure 3"); + +function closure_3(a, b) { + var x = a + 2; + var y = b + 2; + function f() { + debugger; + return a + b + x + y; + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); +} +closure_3(1, 2)() +EndTest(); + + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. Using all arguments and locals from the outer function +// in the inner function makes these part of the debugger information on the +// closure. Use the inner function as well... +BeginTest("Closure 4"); + +function closure_4(a, b) { + var x = a + 2; + var y = b + 2; + function f() { + debugger; + if (f) { + return a + b + x + y; + } + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); +} +closure_4(1, 2)() +EndTest(); + + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. In the presence of eval all arguments and locals +// (including the inner function itself) from the outer function becomes part of +// the debugger infformation on the closure. +BeginTest("Closure 5"); + +function closure_5(a, b) { + var x = 3; + var y = 4; + function f() { + eval(''); + debugger; + return 1; + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); +} +closure_5(1, 2)() +EndTest(); + + +// Two closures. Due to optimizations only the parts actually used are provided +// through the debugger information. +BeginTest("Closure 6"); +function closure_6(a, b) { + function f(a, b) { + var x = 3; + var y = 4; + return function() { + var x = 3; + var y = 4; + debugger; + some_global = a; + return f; + } + } + return f(a, b); +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Closure, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1}, 1, exec_state); + CheckScopeContent({f:function(){}}, 2, exec_state); +} +closure_6(1, 2)() +EndTest(); + + +// Two closures. In the presence of eval all information is provided as the +// compiler cannot determine which parts are used. +BeginTest("Closure 7"); +function closure_7(a, b) { + var x = 3; + var y = 4; + eval('var i = 5'); + eval('var j = 6'); + function f(a, b) { + var x = 3; + var y = 4; + eval('var i = 5'); + eval('var j = 6'); + return function() { + debugger; + some_global = a; + return f; + } + } + return f(a, b); +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Closure, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); +} +closure_7(1, 2)() +EndTest(); + + +// Test a mixture of scopes. +BeginTest("The full monty"); +function the_full_monty(a, b) { + var x = 3; + var y = 4; + eval('var i = 5'); + eval('var j = 6'); + function f(a, b) { + var x = 9; + var y = 10; + eval('var i = 11'); + eval('var j = 12'); + with ({j:13}){ + return function() { + var x = 14; + with ({a:15}) { + with ({b:16}) { + debugger; + some_global = a; + return f; + } + } + } + } + } + return f(a, b); +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.With, + debug.ScopeType.With, + debug.ScopeType.Local, + debug.ScopeType.With, + debug.ScopeType.Closure, + debug.ScopeType.Closure, + debug.ScopeType.Global], exec_state); + CheckScopeContent({b:16}, 0, exec_state); + CheckScopeContent({a:15}, 1, exec_state); + CheckScopeContent({x:14}, 2, exec_state); + CheckScopeContent({j:13}, 3, exec_state); + CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); +} +the_full_monty(1, 2)() +EndTest(); + +// Test global scope. +BeginTest("Global"); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Global], exec_state); +} +debugger; +EndTest(); + +assertEquals(begin_test_count, break_count, 'one or more tests did not enter the debugger'); +assertEquals(begin_test_count, end_test_count, 'one or more tests did not have its result checked'); diff --git a/V8Binding/v8/test/mjsunit/debug-sourceinfo.js b/V8Binding/v8/test/mjsunit/debug-sourceinfo.js index 36e9f03..0235796 100644 --- a/V8Binding/v8/test/mjsunit/debug-sourceinfo.js +++ b/V8Binding/v8/test/mjsunit/debug-sourceinfo.js @@ -1,276 +1,352 @@ -// Copyright 2008 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Flags: --expose-debug-as debug
-// For this test to work this file MUST have CR LF line endings.
-function a() { b(); };
-function b() {
- c(true);
-};
- function c(x) {
- if (x) {
- return 1;
- } else {
- return 1;
- }
- };
-
-// Get the Debug object exposed from the debug context global object.
-Debug = debug.Debug
-
-// This is the number of comment lines above the first test function.
-var comment_lines = 29;
-
-// This magic number is the length or the first line comment (actually number
-// of characters before 'function a(...'.
-var comment_line_length = 1726;
-var start_a = 10 + comment_line_length;
-var start_b = 37 + comment_line_length;
-var start_c = 71 + comment_line_length;
-
-assertEquals(start_a, Debug.sourcePosition(a));
-assertEquals(start_b, Debug.sourcePosition(b));
-assertEquals(start_c, Debug.sourcePosition(c));
-
-var script = Debug.findScript(a);
-assertTrue(script.data === Debug.findScript(b).data);
-assertTrue(script.data === Debug.findScript(c).data);
-assertTrue(script.source === Debug.findScript(b).source);
-assertTrue(script.source === Debug.findScript(c).source);
-
-// Test that when running through source positions the position, line and
-// column progresses as expected.
-var position;
-var line;
-var column;
-for (var p = 0; p < 100; p++) {
- var location = script.locationFromPosition(p);
- if (p > 0) {
- assertEquals(position + 1, location.position);
- if (line == location.line) {
- assertEquals(column + 1, location.column);
- } else {
- assertEquals(line + 1, location.line);
- assertEquals(0, location.column);
- }
- } else {
- assertEquals(0, location.position);
- assertEquals(0, location.line);
- assertEquals(0, location.column);
- }
-
- // Remember the location.
- position = location.position;
- line = location.line;
- column = location.column;
-}
-
-// Test first position.
-assertEquals(0, script.locationFromPosition(0).position);
-assertEquals(0, script.locationFromPosition(0).line);
-assertEquals(0, script.locationFromPosition(0).column);
-
-// Test second position.
-assertEquals(1, script.locationFromPosition(1).position);
-assertEquals(0, script.locationFromPosition(1).line);
-assertEquals(1, script.locationFromPosition(1).column);
-
-// Test first position in finction a.
-assertEquals(start_a, script.locationFromPosition(start_a).position);
-assertEquals(0, script.locationFromPosition(start_a).line - comment_lines);
-assertEquals(10, script.locationFromPosition(start_a).column);
-
-// Test first position in finction b.
-assertEquals(start_b, script.locationFromPosition(start_b).position);
-assertEquals(1, script.locationFromPosition(start_b).line - comment_lines);
-assertEquals(13, script.locationFromPosition(start_b).column);
-
-// Test first position in finction b.
-assertEquals(start_c, script.locationFromPosition(start_c).position);
-assertEquals(4, script.locationFromPosition(start_c).line - comment_lines);
-assertEquals(12, script.locationFromPosition(start_c).column);
-
-// Test first line.
-assertEquals(0, script.locationFromLine().position);
-assertEquals(0, script.locationFromLine().line);
-assertEquals(0, script.locationFromLine().column);
-assertEquals(0, script.locationFromLine(0).position);
-assertEquals(0, script.locationFromLine(0).line);
-assertEquals(0, script.locationFromLine(0).column);
-
-// Test first line column 1
-assertEquals(1, script.locationFromLine(0, 1).position);
-assertEquals(0, script.locationFromLine(0, 1).line);
-assertEquals(1, script.locationFromLine(0, 1).column);
-
-// Test first line offset 1
-assertEquals(1, script.locationFromLine(0, 0, 1).position);
-assertEquals(0, script.locationFromLine(0, 0, 1).line);
-assertEquals(1, script.locationFromLine(0, 0, 1).column);
-
-// Test offset function a
-assertEquals(start_a, script.locationFromLine(void 0, void 0, start_a).position);
-assertEquals(0, script.locationFromLine(void 0, void 0, start_a).line - comment_lines);
-assertEquals(10, script.locationFromLine(void 0, void 0, start_a).column);
-assertEquals(start_a, script.locationFromLine(0, void 0, start_a).position);
-assertEquals(0, script.locationFromLine(0, void 0, start_a).line - comment_lines);
-assertEquals(10, script.locationFromLine(0, void 0, start_a).column);
-assertEquals(start_a, script.locationFromLine(0, 0, start_a).position);
-assertEquals(0, script.locationFromLine(0, 0, start_a).line - comment_lines);
-assertEquals(10, script.locationFromLine(0, 0, start_a).column);
-
-// Test second line offset function a
-assertEquals(start_a + 14, script.locationFromLine(1, 0, start_a).position);
-assertEquals(1, script.locationFromLine(1, 0, start_a).line - comment_lines);
-assertEquals(0, script.locationFromLine(1, 0, start_a).column);
-
-// Test second line column 2 offset function a
-assertEquals(start_a + 14 + 2, script.locationFromLine(1, 2, start_a).position);
-assertEquals(1, script.locationFromLine(1, 2, start_a).line - comment_lines);
-assertEquals(2, script.locationFromLine(1, 2, start_a).column);
-
-// Test offset function b
-assertEquals(start_b, script.locationFromLine(0, 0, start_b).position);
-assertEquals(1, script.locationFromLine(0, 0, start_b).line - comment_lines);
-assertEquals(13, script.locationFromLine(0, 0, start_b).column);
-
-// Test second line offset function b
-assertEquals(start_b + 6, script.locationFromLine(1, 0, start_b).position);
-assertEquals(2, script.locationFromLine(1, 0, start_b).line - comment_lines);
-assertEquals(0, script.locationFromLine(1, 0, start_b).column);
-
-// Test second line column 11 offset function b
-assertEquals(start_b + 6 + 11, script.locationFromLine(1, 11, start_b).position);
-assertEquals(2, script.locationFromLine(1, 11, start_b).line - comment_lines);
-assertEquals(11, script.locationFromLine(1, 11, start_b).column);
-
-// Test second line column 12 offset function b. Second line in b is 11 long
-// using column 12 wraps to next line.
-assertEquals(start_b + 6 + 12, script.locationFromLine(1, 12, start_b).position);
-assertEquals(3, script.locationFromLine(1, 12, start_b).line - comment_lines);
-assertEquals(0, script.locationFromLine(1, 12, start_b).column);
-
-// Test the Debug.findSourcePosition which wraps SourceManager.
-assertEquals(0 + start_a, Debug.findFunctionSourceLocation(a, 0, 0).position);
-assertEquals(0 + start_b, Debug.findFunctionSourceLocation(b, 0, 0).position);
-assertEquals(6 + start_b, Debug.findFunctionSourceLocation(b, 1, 0).position);
-assertEquals(8 + start_b, Debug.findFunctionSourceLocation(b, 1, 2).position);
-assertEquals(18 + start_b, Debug.findFunctionSourceLocation(b, 2, 0).position);
-assertEquals(0 + start_c, Debug.findFunctionSourceLocation(c, 0, 0).position);
-assertEquals(7 + start_c, Debug.findFunctionSourceLocation(c, 1, 0).position);
-assertEquals(21 + start_c, Debug.findFunctionSourceLocation(c, 2, 0).position);
-assertEquals(38 + start_c, Debug.findFunctionSourceLocation(c, 3, 0).position);
-assertEquals(52 + start_c, Debug.findFunctionSourceLocation(c, 4, 0).position);
-assertEquals(69 + start_c, Debug.findFunctionSourceLocation(c, 5, 0).position);
-assertEquals(76 + start_c, Debug.findFunctionSourceLocation(c, 6, 0).position);
-
-// Test source line and restriction. All the following tests start from line 1
-// column 2 in function b, which is the call to c.
-// c(true);
-// ^
-
-var location;
-
-location = script.locationFromLine(1, 0, start_b);
-assertEquals(' c(true);', location.sourceText());
-
-result = ['c', ' c', ' c(', ' c(', ' c(t']
-for (var i = 1; i <= 5; i++) {
- location = script.locationFromLine(1, 2, start_b);
- location.restrict(i);
- assertEquals(result[i - 1], location.sourceText());
-}
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(1, 0);
-assertEquals('c', location.sourceText());
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(2, 0);
-assertEquals('c(', location.sourceText());
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(2, 1);
-assertEquals(' c', location.sourceText());
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(2, 2);
-assertEquals(' c', location.sourceText());
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(2, 3);
-assertEquals(' c', location.sourceText());
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(3, 1);
-assertEquals(' c(', location.sourceText());
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(5, 0);
-assertEquals('c(tru', location.sourceText());
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(5, 2);
-assertEquals(' c(t', location.sourceText());
-
-location = script.locationFromLine(1, 2, start_b);
-location.restrict(5, 4);
-assertEquals(' c(t', location.sourceText());
-
-// All the following tests start from line 1 column 10 in function b, which is
-// the final character.
-// c(true);
-// ^
-
-location = script.locationFromLine(1, 10, start_b);
-location.restrict(5, 0);
-assertEquals('rue);', location.sourceText());
-
-location = script.locationFromLine(1, 10, start_b);
-location.restrict(7, 0);
-assertEquals('(true);', location.sourceText());
-
-// All the following tests start from line 1 column 0 in function b, which is
-// the first character.
-// c(true);
-//^
-
-location = script.locationFromLine(1, 0, start_b);
-location.restrict(5, 0);
-assertEquals(' c(t', location.sourceText());
-
-location = script.locationFromLine(1, 0, start_b);
-location.restrict(5, 4);
-assertEquals(' c(t', location.sourceText());
-
-location = script.locationFromLine(1, 0, start_b);
-location.restrict(7, 0);
-assertEquals(' c(tru', location.sourceText());
-
-location = script.locationFromLine(1, 0, start_b);
-location.restrict(7, 6);
-assertEquals(' c(tru', location.sourceText());
+// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --expose-debug-as debug +// For this test to work this file MUST have CR LF line endings. +function a() { b(); }; +function b() { + c(true); +}; + function c(x) { + if (x) { + return 1; + } else { + return 1; + } + }; +function d(x) { + x = 1 ; + x = 2 ; + x = 3 ; + x = 4 ; + x = 5 ; + x = 6 ; + x = 7 ; + x = 8 ; + x = 9 ; + x = 10; + x = 11; + x = 12; + x = 13; + x = 14; + x = 15; +} + +// Get the Debug object exposed from the debug context global object. +Debug = debug.Debug + +// This is the number of comment lines above the first test function. +var comment_lines = 29; + +// This is the last position in the entire file (note: this equals +// file size of <debug-sourceinfo.js> - 1, since starting at 0). +var last_position = 14312; +// This is the last line of entire file (note: starting at 0). +var last_line = 351; +// This is the last column of last line (note: starting at 0 and +2, due +// to trailing <CR><LF>). +var last_column = 2; + +// This magic number is the length or the first line comment (actually number +// of characters before 'function a(...'. +var comment_line_length = 1726; +var start_a = 10 + comment_line_length; +var start_b = 37 + comment_line_length; +var start_c = 71 + comment_line_length; +var start_d = 163 + comment_line_length; + +// The position of the first line of d(), i.e. "x = 1 ;". +var start_code_d = start_d + 7; +// The line # of the first line of d() (note: starting at 0). +var start_line_d = 41; +var line_length_d = 11; +var num_lines_d = 15; + +assertEquals(start_a, Debug.sourcePosition(a)); +assertEquals(start_b, Debug.sourcePosition(b)); +assertEquals(start_c, Debug.sourcePosition(c)); +assertEquals(start_d, Debug.sourcePosition(d)); + +var script = Debug.findScript(a); +assertTrue(script.data === Debug.findScript(b).data); +assertTrue(script.data === Debug.findScript(c).data); +assertTrue(script.data === Debug.findScript(d).data); +assertTrue(script.source === Debug.findScript(b).source); +assertTrue(script.source === Debug.findScript(c).source); +assertTrue(script.source === Debug.findScript(d).source); + +// Test that when running through source positions the position, line and +// column progresses as expected. +var position; +var line; +var column; +for (var p = 0; p < 100; p++) { + var location = script.locationFromPosition(p); + if (p > 0) { + assertEquals(position + 1, location.position); + if (line == location.line) { + assertEquals(column + 1, location.column); + } else { + assertEquals(line + 1, location.line); + assertEquals(0, location.column); + } + } else { + assertEquals(0, location.position); + assertEquals(0, location.line); + assertEquals(0, location.column); + } + + // Remember the location. + position = location.position; + line = location.line; + column = location.column; +} + +// Every line of d() is the same length. Verify we can loop through all +// positions and find the right line # for each. +var p = start_code_d; +for (line = 0; line < num_lines_d; line++) { + for (column = 0; column < line_length_d; column++) { + var location = script.locationFromPosition(p); + assertEquals(p, location.position); + assertEquals(start_line_d + line, location.line); + assertEquals(column, location.column); + p++; + } +} + +// Test first position. +assertEquals(0, script.locationFromPosition(0).position); +assertEquals(0, script.locationFromPosition(0).line); +assertEquals(0, script.locationFromPosition(0).column); + +// Test second position. +assertEquals(1, script.locationFromPosition(1).position); +assertEquals(0, script.locationFromPosition(1).line); +assertEquals(1, script.locationFromPosition(1).column); + +// Test first position in function a(). +assertEquals(start_a, script.locationFromPosition(start_a).position); +assertEquals(0, script.locationFromPosition(start_a).line - comment_lines); +assertEquals(10, script.locationFromPosition(start_a).column); + +// Test first position in function b(). +assertEquals(start_b, script.locationFromPosition(start_b).position); +assertEquals(1, script.locationFromPosition(start_b).line - comment_lines); +assertEquals(13, script.locationFromPosition(start_b).column); + +// Test first position in function c(). +assertEquals(start_c, script.locationFromPosition(start_c).position); +assertEquals(4, script.locationFromPosition(start_c).line - comment_lines); +assertEquals(12, script.locationFromPosition(start_c).column); + +// Test first position in function d(). +assertEquals(start_d, script.locationFromPosition(start_d).position); +assertEquals(11, script.locationFromPosition(start_d).line - comment_lines); +assertEquals(10, script.locationFromPosition(start_d).column); + +// Test first line. +assertEquals(0, script.locationFromLine().position); +assertEquals(0, script.locationFromLine().line); +assertEquals(0, script.locationFromLine().column); +assertEquals(0, script.locationFromLine(0).position); +assertEquals(0, script.locationFromLine(0).line); +assertEquals(0, script.locationFromLine(0).column); + +// Test first line column 1. +assertEquals(1, script.locationFromLine(0, 1).position); +assertEquals(0, script.locationFromLine(0, 1).line); +assertEquals(1, script.locationFromLine(0, 1).column); + +// Test first line offset 1. +assertEquals(1, script.locationFromLine(0, 0, 1).position); +assertEquals(0, script.locationFromLine(0, 0, 1).line); +assertEquals(1, script.locationFromLine(0, 0, 1).column); + +// Test offset function a(). +assertEquals(start_a, script.locationFromLine(void 0, void 0, start_a).position); +assertEquals(0, script.locationFromLine(void 0, void 0, start_a).line - comment_lines); +assertEquals(10, script.locationFromLine(void 0, void 0, start_a).column); +assertEquals(start_a, script.locationFromLine(0, void 0, start_a).position); +assertEquals(0, script.locationFromLine(0, void 0, start_a).line - comment_lines); +assertEquals(10, script.locationFromLine(0, void 0, start_a).column); +assertEquals(start_a, script.locationFromLine(0, 0, start_a).position); +assertEquals(0, script.locationFromLine(0, 0, start_a).line - comment_lines); +assertEquals(10, script.locationFromLine(0, 0, start_a).column); + +// Test second line offset function a(). +assertEquals(start_a + 14, script.locationFromLine(1, 0, start_a).position); +assertEquals(1, script.locationFromLine(1, 0, start_a).line - comment_lines); +assertEquals(0, script.locationFromLine(1, 0, start_a).column); + +// Test second line column 2 offset function a(). +assertEquals(start_a + 14 + 2, script.locationFromLine(1, 2, start_a).position); +assertEquals(1, script.locationFromLine(1, 2, start_a).line - comment_lines); +assertEquals(2, script.locationFromLine(1, 2, start_a).column); + +// Test offset function b(). +assertEquals(start_b, script.locationFromLine(0, 0, start_b).position); +assertEquals(1, script.locationFromLine(0, 0, start_b).line - comment_lines); +assertEquals(13, script.locationFromLine(0, 0, start_b).column); + +// Test second line offset function b(). +assertEquals(start_b + 6, script.locationFromLine(1, 0, start_b).position); +assertEquals(2, script.locationFromLine(1, 0, start_b).line - comment_lines); +assertEquals(0, script.locationFromLine(1, 0, start_b).column); + +// Test second line column 11 offset function b(). +assertEquals(start_b + 6 + 11, script.locationFromLine(1, 11, start_b).position); +assertEquals(2, script.locationFromLine(1, 11, start_b).line - comment_lines); +assertEquals(11, script.locationFromLine(1, 11, start_b).column); + +// Test second line column 12 offset function b. Second line in b is 11 long +// using column 12 wraps to next line. +assertEquals(start_b + 6 + 12, script.locationFromLine(1, 12, start_b).position); +assertEquals(3, script.locationFromLine(1, 12, start_b).line - comment_lines); +assertEquals(0, script.locationFromLine(1, 12, start_b).column); + +// Test the Debug.findSourcePosition which wraps SourceManager. +assertEquals(0 + start_a, Debug.findFunctionSourceLocation(a, 0, 0).position); +assertEquals(0 + start_b, Debug.findFunctionSourceLocation(b, 0, 0).position); +assertEquals(6 + start_b, Debug.findFunctionSourceLocation(b, 1, 0).position); +assertEquals(8 + start_b, Debug.findFunctionSourceLocation(b, 1, 2).position); +assertEquals(18 + start_b, Debug.findFunctionSourceLocation(b, 2, 0).position); +assertEquals(0 + start_c, Debug.findFunctionSourceLocation(c, 0, 0).position); +assertEquals(7 + start_c, Debug.findFunctionSourceLocation(c, 1, 0).position); +assertEquals(21 + start_c, Debug.findFunctionSourceLocation(c, 2, 0).position); +assertEquals(38 + start_c, Debug.findFunctionSourceLocation(c, 3, 0).position); +assertEquals(52 + start_c, Debug.findFunctionSourceLocation(c, 4, 0).position); +assertEquals(69 + start_c, Debug.findFunctionSourceLocation(c, 5, 0).position); +assertEquals(76 + start_c, Debug.findFunctionSourceLocation(c, 6, 0).position); +assertEquals(0 + start_d, Debug.findFunctionSourceLocation(d, 0, 0).position); +assertEquals(7 + start_d, Debug.findFunctionSourceLocation(d, 1, 0).position); +for (i = 1; i <= num_lines_d; i++) { + assertEquals(7 + (i * line_length_d) + start_d, Debug.findFunctionSourceLocation(d, (i + 1), 0).position); +} +assertEquals(175 + start_d, Debug.findFunctionSourceLocation(d, 17, 0).position); + +// Make sure invalid inputs work properly. +assertEquals(0, script.locationFromPosition(-1).line); +assertEquals(null, script.locationFromPosition(last_position + 1)); + +// Test last position. +assertEquals(last_position, script.locationFromPosition(last_position).position); +assertEquals(last_line, script.locationFromPosition(last_position).line); +assertEquals(last_column, script.locationFromPosition(last_position).column); + +// Test source line and restriction. All the following tests start from line 1 +// column 2 in function b, which is the call to c. +// c(true); +// ^ + +var location; + +location = script.locationFromLine(1, 0, start_b); +assertEquals(' c(true);', location.sourceText()); + +result = ['c', ' c', ' c(', ' c(', ' c(t'] +for (var i = 1; i <= 5; i++) { + location = script.locationFromLine(1, 2, start_b); + location.restrict(i); + assertEquals(result[i - 1], location.sourceText()); +} + +location = script.locationFromLine(1, 2, start_b); +location.restrict(1, 0); +assertEquals('c', location.sourceText()); + +location = script.locationFromLine(1, 2, start_b); +location.restrict(2, 0); +assertEquals('c(', location.sourceText()); + +location = script.locationFromLine(1, 2, start_b); +location.restrict(2, 1); +assertEquals(' c', location.sourceText()); + +location = script.locationFromLine(1, 2, start_b); +location.restrict(2, 2); +assertEquals(' c', location.sourceText()); + +location = script.locationFromLine(1, 2, start_b); +location.restrict(2, 3); +assertEquals(' c', location.sourceText()); + +location = script.locationFromLine(1, 2, start_b); +location.restrict(3, 1); +assertEquals(' c(', location.sourceText()); + +location = script.locationFromLine(1, 2, start_b); +location.restrict(5, 0); +assertEquals('c(tru', location.sourceText()); + +location = script.locationFromLine(1, 2, start_b); +location.restrict(5, 2); +assertEquals(' c(t', location.sourceText()); + +location = script.locationFromLine(1, 2, start_b); +location.restrict(5, 4); +assertEquals(' c(t', location.sourceText()); + +// All the following tests start from line 1 column 10 in function b, which is +// the final character. +// c(true); +// ^ + +location = script.locationFromLine(1, 10, start_b); +location.restrict(5, 0); +assertEquals('rue);', location.sourceText()); + +location = script.locationFromLine(1, 10, start_b); +location.restrict(7, 0); +assertEquals('(true);', location.sourceText()); + +// All the following tests start from line 1 column 0 in function b, which is +// the first character. +// c(true); +//^ + +location = script.locationFromLine(1, 0, start_b); +location.restrict(5, 0); +assertEquals(' c(t', location.sourceText()); + +location = script.locationFromLine(1, 0, start_b); +location.restrict(5, 4); +assertEquals(' c(t', location.sourceText()); + +location = script.locationFromLine(1, 0, start_b); +location.restrict(7, 0); +assertEquals(' c(tru', location.sourceText()); + +location = script.locationFromLine(1, 0, start_b); +location.restrict(7, 6); +assertEquals(' c(tru', location.sourceText()); + +// Test that script.sourceLine(line) works. +for (line = 0; line < num_lines_d; line++) { + var line_content_regexp = new RegExp(" x = " + (line + 1)); + assertTrue(line_content_regexp.test(script.sourceLine(start_line_d + line))); +} diff --git a/V8Binding/v8/test/mjsunit/html-comments.js b/V8Binding/v8/test/mjsunit/html-comments.js index f39271a..cc2315b 100644 --- a/V8Binding/v8/test/mjsunit/html-comments.js +++ b/V8Binding/v8/test/mjsunit/html-comments.js @@ -32,26 +32,26 @@ var x = 1; --> so must this... --> and this. x-->0; -assertEquals(0, x); +assertEquals(0, x, 'a'); var x = 0; x <!-- x -assertEquals(0, x); +assertEquals(0, x, 'b'); var x = 1; x <!--x -assertEquals(1, x); +assertEquals(1, x, 'c'); var x = 2; x <!-- x; x = 42; -assertEquals(2, x); +assertEquals(2, x, 'd'); var x = 1; x <! x--; -assertEquals(0, x); +assertEquals(0, x, 'e'); var x = 1; x <!- x--; -assertEquals(0, x); +assertEquals(0, x, 'f'); var b = true <! true; -assertFalse(b); +assertFalse(b, 'g'); var b = true <!- true; -assertFalse(b); +assertFalse(b, 'h'); diff --git a/V8Binding/v8/test/mjsunit/regexp-captures.js b/V8Binding/v8/test/mjsunit/regexp-captures.js new file mode 100644 index 0000000..91548d6 --- /dev/null +++ b/V8Binding/v8/test/mjsunit/regexp-captures.js @@ -0,0 +1,31 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +var re = /^(((N({)?)|(R)|(U)|(V)|(B)|(H)|(n((n)|(r)|(v)|(h))?)|(r(r)?)|(v)|(b((n)|(b))?)|(h))|((Y)|(A)|(E)|(o(u)?)|(p(u)?)|(q(u)?)|(s)|(t)|(u)|(w)|(x(u)?)|(y)|(z)|(a((T)|(A)|(L))?)|(c)|(e)|(f(u)?)|(g(u)?)|(i)|(j)|(l)|(m(u)?)))+/; +var r = new RegExp(re) +var str = "Avtnennan gunzvmu pubExnY nEvln vaTxh rmuhguhaTxnY" +assertTrue(r.test(str)); diff --git a/V8Binding/v8/test/mjsunit/regress/regress-1919169.js b/V8Binding/v8/test/mjsunit/regress/regress-1919169.js new file mode 100644 index 0000000..774f265 --- /dev/null +++ b/V8Binding/v8/test/mjsunit/regress/regress-1919169.js @@ -0,0 +1,40 @@ +// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +function test() { + var s2 = "s2"; + for (var i = 0; i < 2; i++) { + // Crashes in round i==1 with IllegalAccess in %StringAdd(x,y) + var res = 1 + s2; + s2 = 2; + } +} + +// Crash does not occur when code is run at the top level. +test(); + diff --git a/V8Binding/v8/test/mjsunit/regress/regress-386.js b/V8Binding/v8/test/mjsunit/regress/regress-386.js new file mode 100644 index 0000000..06e4b8e --- /dev/null +++ b/V8Binding/v8/test/mjsunit/regress/regress-386.js @@ -0,0 +1,47 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +// Test for http://code.google.com/p/v8/issues/detail?id=386 +// This test creates enough properties in A so that adding i as +// a constant function, in the first call to the constructor, leaves +// the object's map in the fast case and adds a constant function map +// transition. +// Adding i in the second call to the constructor creates a real property, +// and simultaneously converts the object from fast case to slow case +// and changes i from a map transition to a real property. There was +// a flaw in the code that handled this combination of events. + +function A() { + for (var i = 0; i < 13; i++) { + this['a' + i] = i; + } + this.i = function(){}; +}; + +new A(); +new A(); diff --git a/V8Binding/v8/test/mjsunit/regress/regress-392.js b/V8Binding/v8/test/mjsunit/regress/regress-392.js new file mode 100644 index 0000000..3cabcac --- /dev/null +++ b/V8Binding/v8/test/mjsunit/regress/regress-392.js @@ -0,0 +1,34 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Regression test for issue 392 reported by nth10sd; see +// http://code.google.com/p/v8/issues/detail?id=392 + +assertTrue(isNaN((function(){return arguments++})())); +assertTrue(isNaN((function(){return ++arguments})())); +assertTrue(isNaN((function(){return arguments--})())); +assertTrue(isNaN((function(){return --arguments})())); diff --git a/V8Binding/v8/test/mjsunit/regress/regress-6-9-regexp.js b/V8Binding/v8/test/mjsunit/regress/regress-6-9-regexp.js new file mode 100644 index 0000000..c73b37d --- /dev/null +++ b/V8Binding/v8/test/mjsunit/regress/regress-6-9-regexp.js @@ -0,0 +1,30 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Check that the perfect mask check isn't overly optimistic. + +assertFalse(/[6-9]/.test('2')); diff --git a/V8Binding/v8/test/mjsunit/sin-cos.js b/V8Binding/v8/test/mjsunit/sin-cos.js new file mode 100644 index 0000000..ae02451 --- /dev/null +++ b/V8Binding/v8/test/mjsunit/sin-cos.js @@ -0,0 +1,45 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Test Math.sin and Math.cos. + +var input_sin = [0, Math.PI / 2]; +var input_cos = [0, Math.PI]; + +var output_sin = input_sin.map(Math.sin); +var output_cos = input_cos.map(Math.cos); + +var expected_sin = [0, 1]; +var expected_cos = [1, -1]; + +assertArrayEquals(expected_sin, output_sin, "sine"); +assertArrayEquals(expected_cos, output_cos, "cosine"); + +// By accident, the slow case for sine and cosine were both sine at +// some point. This is a regression test for that issue. +var x = Math.pow(2, 70); +assertTrue(Math.sin(x) != Math.cos(x)); diff --git a/V8Binding/v8/test/mjsunit/smi-ops.js b/V8Binding/v8/test/mjsunit/smi-ops.js index 7e57136..5520327 100644 --- a/V8Binding/v8/test/mjsunit/smi-ops.js +++ b/V8Binding/v8/test/mjsunit/smi-ops.js @@ -196,6 +196,54 @@ assertEquals(78, Xor100Reversed(OBJ_42)); var x = 0x23; var y = 0x35; assertEquals(0x16, x ^ y); + +// Bitwise not. +var v = 0; +assertEquals(-1, ~v); +v = SMI_MIN; +assertEquals(0x3fffffff, ~v); +v = SMI_MAX; +assertEquals(-0x40000000, ~v); + +// Overflowing ++ and --. +v = SMI_MAX; +v++; +assertEquals(0x40000000, v); +v = SMI_MIN; +v--; +assertEquals(-0x40000001, v); + +// Not actually Smi operations. +// Check that relations on unary ops work. +var v = -1.2; +assertTrue(v == v); +assertTrue(v === v); +assertTrue(v <= v); +assertTrue(v >= v); +assertFalse(v < v); +assertFalse(v > v); +assertFalse(v != v); +assertFalse(v !== v); + +// Right hand side of unary minus is overwritable. +v = 1.5 +assertEquals(-2.25, -(v * v)); + +// Smi input to bitop gives non-smi result where the rhs is a float that +// can be overwritten. +var x1 = 0x10000000; +var x2 = 0x40000002; +var x3 = 0x40000000; +assertEquals(0x40000000, x1 << (x2 - x3)); + +// Smi input to bitop gives non-smi result where the rhs could be overwritten +// if it were a float, but it isn't. +x1 = 0x10000000 +x2 = 4 +x3 = 2 +assertEquals(0x40000000, x1 << (x2 - x3)); + + // Test shift operators on non-smi inputs, giving smi and non-smi results. function testShiftNonSmis() { var pos_non_smi = 2000000000; @@ -585,3 +633,10 @@ function testShiftNonSmis() { } testShiftNonSmis(); + + +// Verify that we handle the (optimized) corner case of shifting by +// zero even for non-smis. +function shiftByZero(n) { return n << 0; } + +assertEquals(3, shiftByZero(3.1415)); diff --git a/V8Binding/v8/test/mjsunit/stack-traces.js b/V8Binding/v8/test/mjsunit/stack-traces.js new file mode 100644 index 0000000..6ac8b0a --- /dev/null +++ b/V8Binding/v8/test/mjsunit/stack-traces.js @@ -0,0 +1,160 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Error.captureStackTraces = true; + +function testMethodNameInference() { + function Foo() { } + Foo.prototype.bar = function () { FAIL; }; + (new Foo).bar(); +} + +function testNested() { + function one() { + function two() { + function three() { + FAIL; + } + three(); + } + two(); + } + one(); +} + +function testArrayNative() { + [1, 2, 3].map(function () { FAIL; }); +} + +function testImplicitConversion() { + function Nirk() { } + Nirk.prototype.valueOf = function () { FAIL; }; + return 1 + (new Nirk); +} + +function testEval() { + eval("function Doo() { FAIL; }; Doo();"); +} + +function testNestedEval() { + var x = "FAIL"; + eval("function Outer() { eval('function Inner() { eval(x); }'); Inner(); }; Outer();"); +} + +function testValue() { + Number.prototype.causeError = function () { FAIL; }; + (1).causeError(); +} + +function testConstructor() { + function Plonk() { FAIL; } + new Plonk(); +} + +// Utility function for testing that the expected strings occur +// in the stack trace produced when running the given function. +function testTrace(fun, expected) { + var threw = false; + try { + fun(); + } catch (e) { + for (var i = 0; i < expected.length; i++) { + assertTrue(e.stack.indexOf(expected[i]) != -1); + } + threw = true; + } + assertTrue(threw); +} + +// Test that the error constructor is not shown in the trace +function testCallerCensorship() { + var threw = false; + try { + FAIL; + } catch (e) { + assertEquals(-1, e.stack.indexOf('at new ReferenceError')); + threw = true; + } + assertTrue(threw); +} + +// Test that the explicit constructor call is shown in the trace +function testUnintendedCallerCensorship() { + var threw = false; + try { + new ReferenceError({ + toString: function () { + FAIL; + } + }); + } catch (e) { + assertTrue(e.stack.indexOf('at new ReferenceError') != -1); + threw = true; + } + assertTrue(threw); +} + +// If an error occurs while the stack trace is being formatted it should +// be handled gracefully. +function testErrorsDuringFormatting() { + function Nasty() { } + Nasty.prototype.foo = function () { throw new RangeError(); }; + var n = new Nasty(); + n.__defineGetter__('constructor', function () { CONS_FAIL; }); + var threw = false; + try { + n.foo(); + } catch (e) { + threw = true; + assertTrue(e.stack.indexOf('<error: ReferenceError') != -1); + } + assertTrue(threw); + threw = false; + // Now we can't even format the message saying that we couldn't format + // the stack frame. Put that in your pipe and smoke it! + ReferenceError.prototype.toString = function () { NESTED_FAIL; }; + try { + n.foo(); + } catch (e) { + threw = true; + assertTrue(e.stack.indexOf('<error>') != -1); + } + assertTrue(threw); +} + +testTrace(testArrayNative, ["Array.map (native)"]); +testTrace(testNested, ["at one", "at two", "at three"]); +testTrace(testMethodNameInference, ["at Foo.bar"]); +testTrace(testImplicitConversion, ["at Nirk.valueOf"]); +testTrace(testEval, ["at Doo (eval at testEval"]); +testTrace(testNestedEval, ["at eval (eval at Inner (eval at Outer"]); +testTrace(testValue, ["at Number.causeError"]); +testTrace(testConstructor, ["new Plonk"]); + +testCallerCensorship(); +testUnintendedCallerCensorship(); +testErrorsDuringFormatting(); diff --git a/V8Binding/v8/test/mjsunit/toint32.js b/V8Binding/v8/test/mjsunit/toint32.js index a558295..9dad9c9 100644 --- a/V8Binding/v8/test/mjsunit/toint32.js +++ b/V8Binding/v8/test/mjsunit/toint32.js @@ -29,19 +29,19 @@ function toInt32(x) { return x | 0; } -assertEquals(0, toInt32(Infinity)); -assertEquals(0, toInt32(-Infinity)); -assertEquals(0, toInt32(NaN)); -assertEquals(0, toInt32(0.0)); -assertEquals(0, toInt32(-0.0)); +assertEquals(0, toInt32(Infinity), "Inf"); +assertEquals(0, toInt32(-Infinity), "-Inf"); +assertEquals(0, toInt32(NaN), "NaN"); +assertEquals(0, toInt32(0.0), "zero"); +assertEquals(0, toInt32(-0.0), "-zero"); assertEquals(0, toInt32(Number.MIN_VALUE)); assertEquals(0, toInt32(-Number.MIN_VALUE)); assertEquals(0, toInt32(0.1)); assertEquals(0, toInt32(-0.1)); -assertEquals(1, toInt32(1)); -assertEquals(1, toInt32(1.1)); -assertEquals(-1, toInt32(-1)); +assertEquals(1, toInt32(1), "one"); +assertEquals(1, toInt32(1.1), "onepointone"); +assertEquals(-1, toInt32(-1), "-one"); assertEquals(0, toInt32(0.6), "truncate positive (0.6)"); assertEquals(1, toInt32(1.6), "truncate positive (1.6)"); assertEquals(0, toInt32(-0.6), "truncate negative (-0.6)"); diff --git a/V8Binding/v8/test/mjsunit/tools/logreader.js b/V8Binding/v8/test/mjsunit/tools/logreader.js new file mode 100644 index 0000000..dfd7f9f --- /dev/null +++ b/V8Binding/v8/test/mjsunit/tools/logreader.js @@ -0,0 +1,82 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Load CSV Parser and Log Reader implementations from <project root>/tools. +// Files: tools/csvparser.js tools/logreader.js + + +(function testAddressParser() { + var reader = new devtools.profiler.LogReader({}); + var parser = reader.createAddressParser('test'); + + // Test that 0x values are parsed, and prevAddresses_ are untouched. + assertFalse('test' in reader.prevAddresses_); + assertEquals(0, parser('0x0')); + assertFalse('test' in reader.prevAddresses_); + assertEquals(0x100, parser('0x100')); + assertFalse('test' in reader.prevAddresses_); + assertEquals(0xffffffff, parser('0xffffffff')); + assertFalse('test' in reader.prevAddresses_); + + // Test that values that has no '+' or '-' prefix are parsed + // and saved to prevAddresses_. + assertEquals(0, parser('0')); + assertEquals(0, reader.prevAddresses_.test); + assertEquals(0x100, parser('100')); + assertEquals(0x100, reader.prevAddresses_.test); + assertEquals(0xffffffff, parser('ffffffff')); + assertEquals(0xffffffff, reader.prevAddresses_.test); + + // Test that values prefixed with '+' or '-' are treated as deltas, + // and prevAddresses_ is updated. + // Set base value. + assertEquals(0x100, parser('100')); + assertEquals(0x100, reader.prevAddresses_.test); + assertEquals(0x200, parser('+100')); + assertEquals(0x200, reader.prevAddresses_.test); + assertEquals(0x100, parser('-100')); + assertEquals(0x100, reader.prevAddresses_.test); +})(); + + +(function testAddressParser() { + var reader = new devtools.profiler.LogReader({}); + + assertEquals([0x10000000, 0x10001000, 0xffff000, 0x10000000], + reader.processStack(0x10000000, ['overflow', + '+1000', '-2000', '+1000'])); +})(); + + +(function testExpandBackRef() { + var reader = new devtools.profiler.LogReader({}); + + assertEquals('aaaaaaaa', reader.expandBackRef_('aaaaaaaa')); + assertEquals('aaaaaaaa', reader.expandBackRef_('#1')); + assertEquals('bbbbaaaa', reader.expandBackRef_('bbbb#2:4')); + assertEquals('"#1:1"', reader.expandBackRef_('"#1:1"')); +})(); diff --git a/V8Binding/v8/test/mozilla/mozilla.status b/V8Binding/v8/test/mozilla/mozilla.status index 97182f3..760ed41 100644 --- a/V8Binding/v8/test/mozilla/mozilla.status +++ b/V8Binding/v8/test/mozilla/mozilla.status @@ -88,17 +88,18 @@ js1_5/GC/regress-348532: SLOW ##################### FLAKY TESTS ##################### # These tests time out in debug mode but pass in product mode +js1_5/Regress/regress-360969-03: PASS || TIMEOUT if $mode == debug +js1_5/Regress/regress-360969-04: PASS || TIMEOUT if $mode == debug +js1_5/Regress/regress-360969-05: PASS || TIMEOUT if $mode == debug +js1_5/Regress/regress-360969-06: PASS || TIMEOUT if $mode == debug +js1_5/extensions/regress-365527: PASS || TIMEOUT if $mode == debug + js1_5/Regress/regress-280769-3: PASS || FAIL if $mode == debug js1_5/Regress/regress-203278-1: PASS || FAIL if $mode == debug js1_5/GC/regress-203278-2: PASS || FAIL if $mode == debug js1_5/Regress/regress-244470: PASS || FAIL if $mode == debug ecma_3/RegExp/regress-209067: PASS || FAIL if $mode == debug js1_5/GC/regress-278725: PASS || FAIL if $mode == debug -js1_5/Regress/regress-360969-03: PASS || FAIL if $mode == debug -js1_5/Regress/regress-360969-04: PASS || FAIL if $mode == debug -js1_5/Regress/regress-360969-05: PASS || FAIL if $mode == debug -js1_5/Regress/regress-360969-06: PASS || FAIL if $mode == debug -js1_5/extensions/regress-365527: PASS || FAIL if $mode == debug # http://b/issue?id=1206983 js1_5/Regress/regress-367561-03: PASS || FAIL if $mode == debug ecma/Date/15.9.5.10-2: PASS || FAIL if $mode == debug @@ -148,7 +149,7 @@ js1_5/String/regress-322772: PASS || FAIL js1_5/Array/regress-99120-01: PASS || FAIL js1_5/Array/regress-99120-02: PASS || FAIL js1_5/Regress/regress-347306-01: PASS || FAIL -js1_5/Regress/regress-416628: PASS || FAIL +js1_5/Regress/regress-416628: PASS || FAIL || TIMEOUT if $mode == debug # The following two tests assume that daylight savings time starts first Sunday @@ -203,7 +204,7 @@ ecma/String/15.5.4.12-4: FAIL_OK ecma/String/15.5.4.12-5: FAIL_OK # Creates a linked list of arrays until we run out of memory or timeout. -js1_5/Regress/regress-312588: FAIL_OK +js1_5/Regress/regress-312588: FAIL || TIMEOUT # Runs out of memory because it compiles huge functions. @@ -247,14 +248,14 @@ js1_5/extensions/regress-459606: PASS || FAIL_OK # PCRE's match limit is reached. SpiderMonkey hangs on the first one, # JSC returns true somehow. Maybe they up the match limit? There is # an open V8 bug 676063 about this. -ecma_3/RegExp/regress-330684: FAIL_OK +ecma_3/RegExp/regress-330684: TIMEOUT # This test contains a regexp that runs exponentially long. Spidermonkey # standalone will hang, though apparently inside Firefox it will trigger a # long-running-script timeout. JSCRE passes by hitting the matchLimit and # just pretending that an exhaustive search found no match. -ecma_3/RegExp/regress-307456: PASS || FAIL_OK +ecma_3/RegExp/regress-307456: PASS || TIMEOUT # We do not detect overflow in bounds for back references and {} @@ -594,7 +595,7 @@ js1_5/Regress/regress-306633: FAIL # This test seems designed to fail (it produces a 700Mbyte string). # We fail on out of memory. The important thing is not to crash. -js1_5/Regress/regress-303213: FAIL +js1_5/Regress/regress-303213: FAIL || TIMEOUT if $mode == debug # Bug 1202592: New ecma_3/String/15.5.4.11 is failing. @@ -630,7 +631,6 @@ js1_5/extensions/regress-313803: FAIL_OK js1_5/extensions/regress-314874: FAIL_OK js1_5/extensions/regress-322957: FAIL_OK js1_5/extensions/regress-328556: FAIL_OK -js1_5/extensions/regress-330569: FAIL_OK js1_5/extensions/regress-333541: FAIL_OK js1_5/extensions/regress-335700: FAIL_OK js1_5/extensions/regress-336409-1: FAIL_OK @@ -640,7 +640,6 @@ js1_5/extensions/regress-336410-2: FAIL_OK js1_5/extensions/regress-341956-01: FAIL_OK js1_5/extensions/regress-341956-02: FAIL_OK js1_5/extensions/regress-341956-03: FAIL_OK -js1_5/extensions/regress-342960: FAIL_OK js1_5/extensions/regress-345967: FAIL_OK js1_5/extensions/regress-346494-01: FAIL_OK js1_5/extensions/regress-346494: FAIL_OK @@ -653,7 +652,6 @@ js1_5/extensions/regress-350531: FAIL_OK js1_5/extensions/regress-351102-01: FAIL_OK js1_5/extensions/regress-351102-02: FAIL_OK js1_5/extensions/regress-351102-06: FAIL_OK -js1_5/extensions/regress-351448: FAIL_OK js1_5/extensions/regress-351973: FAIL_OK js1_5/extensions/regress-352060: FAIL_OK js1_5/extensions/regress-352094: FAIL_OK @@ -716,6 +714,10 @@ js1_5/extensions/scope-001: FAIL_OK js1_5/extensions/toLocaleFormat-01: FAIL_OK js1_5/extensions/toLocaleFormat-02: FAIL_OK +js1_5/extensions/regress-330569: TIMEOUT +js1_5/extensions/regress-351448: TIMEOUT +js1_5/extensions/regress-342960: FAIL_OK || TIMEOUT if $mode == debug + ##################### DECOMPILATION TESTS ##################### @@ -776,13 +778,11 @@ js1_5/decompilation/regress-383721: PASS || FAIL js1_5/decompilation/regress-406555: PASS || FAIL -[ $FAST == yes ] - # These tests take an unreasonable amount of time so we skip them # in fast mode. -js1_5/Regress/regress-312588: SKIP -js1_5/Regress/regress-271716-n: SKIP +js1_5/Regress/regress-312588: TIMEOUT || SKIP if $FAST == yes +js1_5/Regress/regress-271716-n: PASS || SKIP if $FAST == yes [ $FAST == yes && $ARCH == arm ] |