Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: test/cctest/test-api.cc

Issue 7535004: Merge bleeding edge up to 8774 into the GC branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/log-eq-of-logging-and-traversal.js ('k') | test/cctest/test-ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 v8::HandleScope scope; 1019 v8::HandleScope scope;
1020 LocalContext env; 1020 LocalContext env;
1021 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1; 1021 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1;
1022 uint32_t value = INT32_MAX_AS_UINT + 1; 1022 uint32_t value = INT32_MAX_AS_UINT + 1;
1023 CHECK(value > INT32_MAX_AS_UINT); // No overflow. 1023 CHECK(value > INT32_MAX_AS_UINT); // No overflow.
1024 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); 1024 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
1025 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); 1025 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value());
1026 } 1026 }
1027 1027
1028 1028
1029 THREADED_TEST(IsNativeError) {
1030 v8::HandleScope scope;
1031 LocalContext env;
1032 v8::Handle<Value> syntax_error = CompileRun(
1033 "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; ");
1034 CHECK(syntax_error->IsNativeError());
1035 v8::Handle<Value> not_error = CompileRun("{a:42}");
1036 CHECK(!not_error->IsNativeError());
1037 v8::Handle<Value> not_object = CompileRun("42");
1038 CHECK(!not_object->IsNativeError());
1039 }
1040
1041
1042 THREADED_TEST(StringObject) {
1043 v8::HandleScope scope;
1044 LocalContext env;
1045 v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")");
1046 CHECK(boxed_string->IsStringObject());
1047 v8::Handle<Value> unboxed_string = CompileRun("\"test\"");
1048 CHECK(!unboxed_string->IsStringObject());
1049 v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)");
1050 CHECK(!boxed_not_string->IsStringObject());
1051 v8::Handle<Value> not_object = CompileRun("0");
1052 CHECK(!not_object->IsStringObject());
1053 v8::Handle<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>();
1054 CHECK(!as_boxed.IsEmpty());
1055 Local<v8::String> the_string = as_boxed->StringValue();
1056 CHECK(!the_string.IsEmpty());
1057 ExpectObject("\"test\"", the_string);
1058 v8::Handle<v8::Value> new_boxed_string = v8::StringObject::New(the_string);
1059 CHECK(new_boxed_string->IsStringObject());
1060 as_boxed = new_boxed_string.As<v8::StringObject>();
1061 the_string = as_boxed->StringValue();
1062 CHECK(!the_string.IsEmpty());
1063 ExpectObject("\"test\"", the_string);
1064 }
1065
1066
1067 THREADED_TEST(NumberObject) {
1068 v8::HandleScope scope;
1069 LocalContext env;
1070 v8::Handle<Value> boxed_number = CompileRun("new Number(42)");
1071 CHECK(boxed_number->IsNumberObject());
1072 v8::Handle<Value> unboxed_number = CompileRun("42");
1073 CHECK(!unboxed_number->IsNumberObject());
1074 v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)");
1075 CHECK(!boxed_not_number->IsNumberObject());
1076 v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>();
1077 CHECK(!as_boxed.IsEmpty());
1078 double the_number = as_boxed->NumberValue();
1079 CHECK_EQ(42.0, the_number);
1080 v8::Handle<v8::Value> new_boxed_number = v8::NumberObject::New(43);
1081 CHECK(new_boxed_number->IsNumberObject());
1082 as_boxed = new_boxed_number.As<v8::NumberObject>();
1083 the_number = as_boxed->NumberValue();
1084 CHECK_EQ(43.0, the_number);
1085 }
1086
1087
1088 THREADED_TEST(BooleanObject) {
1089 v8::HandleScope scope;
1090 LocalContext env;
1091 v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)");
1092 CHECK(boxed_boolean->IsBooleanObject());
1093 v8::Handle<Value> unboxed_boolean = CompileRun("true");
1094 CHECK(!unboxed_boolean->IsBooleanObject());
1095 v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)");
1096 CHECK(!boxed_not_boolean->IsBooleanObject());
1097 v8::Handle<v8::BooleanObject> as_boxed =
1098 boxed_boolean.As<v8::BooleanObject>();
1099 CHECK(!as_boxed.IsEmpty());
1100 bool the_boolean = as_boxed->BooleanValue();
1101 CHECK_EQ(true, the_boolean);
1102 v8::Handle<v8::Value> boxed_true = v8::BooleanObject::New(true);
1103 v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false);
1104 CHECK(boxed_true->IsBooleanObject());
1105 CHECK(boxed_false->IsBooleanObject());
1106 as_boxed = boxed_true.As<v8::BooleanObject>();
1107 CHECK_EQ(true, as_boxed->BooleanValue());
1108 as_boxed = boxed_false.As<v8::BooleanObject>();
1109 CHECK_EQ(false, as_boxed->BooleanValue());
1110 }
1111
1112
1029 THREADED_TEST(Number) { 1113 THREADED_TEST(Number) {
1030 v8::HandleScope scope; 1114 v8::HandleScope scope;
1031 LocalContext env; 1115 LocalContext env;
1032 double PI = 3.1415926; 1116 double PI = 3.1415926;
1033 Local<v8::Number> pi_obj = v8::Number::New(PI); 1117 Local<v8::Number> pi_obj = v8::Number::New(PI);
1034 CHECK_EQ(PI, pi_obj->NumberValue()); 1118 CHECK_EQ(PI, pi_obj->NumberValue());
1035 } 1119 }
1036 1120
1037 1121
1038 THREADED_TEST(ToNumber) { 1122 THREADED_TEST(ToNumber) {
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 CHECK_EQ(32, context->Global()->Get(v8_num(16))->Int32Value()); 2125 CHECK_EQ(32, context->Global()->Get(v8_num(16))->Int32Value());
2042 CHECK_EQ(56, context->Global()->Get(v8::Integer::New(13))->Int32Value()); 2126 CHECK_EQ(56, context->Global()->Get(v8::Integer::New(13))->Int32Value());
2043 CHECK_EQ(56, context->Global()->Get(v8_str("13"))->Int32Value()); 2127 CHECK_EQ(56, context->Global()->Get(v8_str("13"))->Int32Value());
2044 CHECK_EQ(56, context->Global()->Get(v8_num(13))->Int32Value()); 2128 CHECK_EQ(56, context->Global()->Get(v8_num(13))->Int32Value());
2045 } 2129 }
2046 2130
2047 2131
2048 THREADED_TEST(PropertyAttributes) { 2132 THREADED_TEST(PropertyAttributes) {
2049 v8::HandleScope scope; 2133 v8::HandleScope scope;
2050 LocalContext context; 2134 LocalContext context;
2135 // none
2136 Local<String> prop = v8_str("none");
2137 context->Global()->Set(prop, v8_num(7));
2138 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop));
2051 // read-only 2139 // read-only
2052 Local<String> prop = v8_str("read_only"); 2140 prop = v8_str("read_only");
2053 context->Global()->Set(prop, v8_num(7), v8::ReadOnly); 2141 context->Global()->Set(prop, v8_num(7), v8::ReadOnly);
2054 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); 2142 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value());
2143 CHECK_EQ(v8::ReadOnly, context->Global()->GetPropertyAttributes(prop));
2055 Script::Compile(v8_str("read_only = 9"))->Run(); 2144 Script::Compile(v8_str("read_only = 9"))->Run();
2056 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); 2145 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value());
2057 context->Global()->Set(prop, v8_num(10)); 2146 context->Global()->Set(prop, v8_num(10));
2058 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); 2147 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value());
2059 // dont-delete 2148 // dont-delete
2060 prop = v8_str("dont_delete"); 2149 prop = v8_str("dont_delete");
2061 context->Global()->Set(prop, v8_num(13), v8::DontDelete); 2150 context->Global()->Set(prop, v8_num(13), v8::DontDelete);
2062 CHECK_EQ(13, context->Global()->Get(prop)->Int32Value()); 2151 CHECK_EQ(13, context->Global()->Get(prop)->Int32Value());
2063 Script::Compile(v8_str("delete dont_delete"))->Run(); 2152 Script::Compile(v8_str("delete dont_delete"))->Run();
2064 CHECK_EQ(13, context->Global()->Get(prop)->Int32Value()); 2153 CHECK_EQ(13, context->Global()->Get(prop)->Int32Value());
2154 CHECK_EQ(v8::DontDelete, context->Global()->GetPropertyAttributes(prop));
2155 // dont-enum
2156 prop = v8_str("dont_enum");
2157 context->Global()->Set(prop, v8_num(28), v8::DontEnum);
2158 CHECK_EQ(v8::DontEnum, context->Global()->GetPropertyAttributes(prop));
2159 // absent
2160 prop = v8_str("absent");
2161 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop));
2162 Local<Value> fake_prop = v8_num(1);
2163 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop));
2164 // exception
2165 TryCatch try_catch;
2166 Local<Value> exception =
2167 CompileRun("({ toString: function() { throw 'exception';} })");
2168 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception));
2169 CHECK(try_catch.HasCaught());
2170 String::AsciiValue exception_value(try_catch.Exception());
2171 CHECK_EQ("exception", *exception_value);
2172 try_catch.Reset();
2065 } 2173 }
2066 2174
2067 2175
2068 THREADED_TEST(Array) { 2176 THREADED_TEST(Array) {
2069 v8::HandleScope scope; 2177 v8::HandleScope scope;
2070 LocalContext context; 2178 LocalContext context;
2071 Local<v8::Array> array = v8::Array::New(); 2179 Local<v8::Array> array = v8::Array::New();
2072 CHECK_EQ(0, array->Length()); 2180 CHECK_EQ(0, array->Length());
2073 CHECK(array->Get(0)->IsUndefined()); 2181 CHECK(array->Get(0)->IsUndefined());
2074 CHECK(!array->Has(0)); 2182 CHECK(!array->Has(0));
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3445 CHECK_EQ(v8_num(5), result); 3553 CHECK_EQ(v8_num(5), result);
3446 result = setter_script->Run(); 3554 result = setter_script->Run();
3447 CHECK_EQ(v8_num(23), result); 3555 CHECK_EQ(v8_num(23), result);
3448 result = interceptor_setter_script->Run(); 3556 result = interceptor_setter_script->Run();
3449 CHECK_EQ(v8_num(23), result); 3557 CHECK_EQ(v8_num(23), result);
3450 result = interceptor_getter_script->Run(); 3558 result = interceptor_getter_script->Run();
3451 CHECK_EQ(v8_num(625), result); 3559 CHECK_EQ(v8_num(625), result);
3452 } 3560 }
3453 3561
3454 3562
3563 static v8::Handle<Value> UnboxedDoubleIndexedPropertyGetter(
3564 uint32_t index,
3565 const AccessorInfo& info) {
3566 ApiTestFuzzer::Fuzz();
3567 if (index < 25) {
3568 return v8::Handle<Value>(v8_num(index));
3569 }
3570 return v8::Handle<Value>();
3571 }
3572
3573
3574 static v8::Handle<Value> UnboxedDoubleIndexedPropertySetter(
3575 uint32_t index,
3576 Local<Value> value,
3577 const AccessorInfo& info) {
3578 ApiTestFuzzer::Fuzz();
3579 if (index < 25) {
3580 return v8::Handle<Value>(v8_num(index));
3581 }
3582 return v8::Handle<Value>();
3583 }
3584
3585
3586 Handle<v8::Array> UnboxedDoubleIndexedPropertyEnumerator(
3587 const AccessorInfo& info) {
3588 // Force the list of returned keys to be stored in a FastDoubleArray.
3589 Local<Script> indexed_property_names_script = Script::Compile(v8_str(
3590 "keys = new Array(); keys[125000] = 1;"
3591 "for(i = 0; i < 80000; i++) { keys[i] = i; };"
3592 "keys.length = 25; keys;"));
3593 Local<Value> result = indexed_property_names_script->Run();
3594 return Local<v8::Array>(::v8::Array::Cast(*result));
3595 }
3596
3597
3598 // Make sure that the the interceptor code in the runtime properly handles
3599 // merging property name lists for double-array-backed arrays.
3600 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) {
3601 v8::HandleScope scope;
3602 Local<ObjectTemplate> templ = ObjectTemplate::New();
3603 templ->SetIndexedPropertyHandler(UnboxedDoubleIndexedPropertyGetter,
3604 UnboxedDoubleIndexedPropertySetter,
3605 0,
3606 0,
3607 UnboxedDoubleIndexedPropertyEnumerator);
3608 LocalContext context;
3609 context->Global()->Set(v8_str("obj"), templ->NewInstance());
3610 // When obj is created, force it to be Stored in a FastDoubleArray.
3611 Local<Script> create_unboxed_double_script = Script::Compile(v8_str(
3612 "obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } "
3613 "key_count = 0; "
3614 "for (x in obj) {key_count++;};"
3615 "obj;"));
3616 Local<Value> result = create_unboxed_double_script->Run();
3617 CHECK(result->ToObject()->HasRealIndexedProperty(2000));
3618 Local<Script> key_count_check = Script::Compile(v8_str(
3619 "key_count;"));
3620 result = key_count_check->Run();
3621 CHECK_EQ(v8_num(40013), result);
3622 }
3623
3624
3455 static v8::Handle<Value> IdentityIndexedPropertyGetter( 3625 static v8::Handle<Value> IdentityIndexedPropertyGetter(
3456 uint32_t index, 3626 uint32_t index,
3457 const AccessorInfo& info) { 3627 const AccessorInfo& info) {
3458 return v8::Integer::NewFromUnsigned(index); 3628 return v8::Integer::NewFromUnsigned(index);
3459 } 3629 }
3460 3630
3461 3631
3462 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { 3632 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) {
3463 v8::HandleScope scope; 3633 v8::HandleScope scope;
3464 Local<ObjectTemplate> templ = ObjectTemplate::New(); 3634 Local<ObjectTemplate> templ = ObjectTemplate::New();
(...skipping 3413 matching lines...) Expand 10 before | Expand all | Expand 10 after
6878 Local<Value> proto1 = o1->GetPrototype(); 7048 Local<Value> proto1 = o1->GetPrototype();
6879 CHECK(proto1->IsObject()); 7049 CHECK(proto1->IsObject());
6880 CHECK_EQ(proto1.As<v8::Object>(), o2); 7050 CHECK_EQ(proto1.As<v8::Object>(), o2);
6881 7051
6882 Local<Value> proto2 = o2->GetPrototype(); 7052 Local<Value> proto2 = o2->GetPrototype();
6883 CHECK(proto2->IsObject()); 7053 CHECK(proto2->IsObject());
6884 CHECK_EQ(proto2.As<v8::Object>(), o3); 7054 CHECK_EQ(proto2.As<v8::Object>(), o3);
6885 } 7055 }
6886 7056
6887 7057
6888 THREADED_TEST(SetPrototypeProperties) { 7058 THREADED_TEST(FunctionReadOnlyPrototype) {
6889 v8::HandleScope handle_scope; 7059 v8::HandleScope handle_scope;
6890 LocalContext context; 7060 LocalContext context;
6891 7061
6892 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); 7062 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
6893 t1->SetPrototypeAttributes(v8::DontDelete); 7063 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
7064 t1->ReadOnlyPrototype();
6894 context->Global()->Set(v8_str("func1"), t1->GetFunction()); 7065 context->Global()->Set(v8_str("func1"), t1->GetFunction());
7066 // Configured value of ReadOnly flag.
6895 CHECK(CompileRun( 7067 CHECK(CompileRun(
6896 "(function() {" 7068 "(function() {"
6897 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" 7069 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
6898 " return (descriptor['writable'] == true) &&" 7070 " return (descriptor['writable'] == false);"
6899 " (descriptor['enumerable'] == true) &&"
6900 " (descriptor['configurable'] == false);"
6901 "})()")->BooleanValue()); 7071 "})()")->BooleanValue());
7072 CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value());
7073 CHECK_EQ(42,
7074 CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value());
6902 7075
6903 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); 7076 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
6904 t2->SetPrototypeAttributes(v8::DontEnum); 7077 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
6905 context->Global()->Set(v8_str("func2"), t2->GetFunction()); 7078 context->Global()->Set(v8_str("func2"), t2->GetFunction());
7079 // Default value of ReadOnly flag.
6906 CHECK(CompileRun( 7080 CHECK(CompileRun(
6907 "(function() {" 7081 "(function() {"
6908 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" 7082 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
6909 " return (descriptor['writable'] == true) &&" 7083 " return (descriptor['writable'] == true);"
6910 " (descriptor['enumerable'] == false) &&"
6911 " (descriptor['configurable'] == true);"
6912 "})()")->BooleanValue()); 7084 "})()")->BooleanValue());
6913 7085 CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value());
6914 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
6915 t3->SetPrototypeAttributes(v8::ReadOnly);
6916 context->Global()->Set(v8_str("func3"), t3->GetFunction());
6917 CHECK(CompileRun(
6918 "(function() {"
6919 " descriptor = Object.getOwnPropertyDescriptor(func3, 'prototype');"
6920 " return (descriptor['writable'] == false) &&"
6921 " (descriptor['enumerable'] == true) &&"
6922 " (descriptor['configurable'] == true);"
6923 "})()")->BooleanValue());
6924
6925 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New();
6926 t4->SetPrototypeAttributes(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
6927 context->Global()->Set(v8_str("func4"), t4->GetFunction());
6928 CHECK(CompileRun(
6929 "(function() {"
6930 " descriptor = Object.getOwnPropertyDescriptor(func4, 'prototype');"
6931 " return (descriptor['writable'] == false) &&"
6932 " (descriptor['enumerable'] == false) &&"
6933 " (descriptor['configurable'] == false);"
6934 "})()")->BooleanValue());
6935 } 7086 }
6936 7087
6937 7088
6938 THREADED_TEST(SetPrototypeThrows) { 7089 THREADED_TEST(SetPrototypeThrows) {
6939 v8::HandleScope handle_scope; 7090 v8::HandleScope handle_scope;
6940 LocalContext context; 7091 LocalContext context;
6941 7092
6942 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); 7093 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
6943 7094
6944 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); 7095 Local<v8::Object> o0 = t->GetFunction()->NewInstance();
(...skipping 5686 matching lines...) Expand 10 before | Expand all | Expand 10 after
12631 12782
12632 int testGroup = args[0]->Int32Value(); 12783 int testGroup = args[0]->Int32Value();
12633 if (testGroup == kOverviewTest) { 12784 if (testGroup == kOverviewTest) {
12634 v8::Handle<v8::StackTrace> stackTrace = 12785 v8::Handle<v8::StackTrace> stackTrace =
12635 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kOverview); 12786 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kOverview);
12636 CHECK_EQ(4, stackTrace->GetFrameCount()); 12787 CHECK_EQ(4, stackTrace->GetFrameCount());
12637 checkStackFrame(origin, "bar", 2, 10, false, false, 12788 checkStackFrame(origin, "bar", 2, 10, false, false,
12638 stackTrace->GetFrame(0)); 12789 stackTrace->GetFrame(0));
12639 checkStackFrame(origin, "foo", 6, 3, false, false, 12790 checkStackFrame(origin, "foo", 6, 3, false, false,
12640 stackTrace->GetFrame(1)); 12791 stackTrace->GetFrame(1));
12641 checkStackFrame(NULL, "", 1, 1, false, false, 12792 // This is the source string inside the eval which has the call to foo.
12793 checkStackFrame(NULL, "", 1, 5, false, false,
12642 stackTrace->GetFrame(2)); 12794 stackTrace->GetFrame(2));
12643 // The last frame is an anonymous function that has the initial call. 12795 // The last frame is an anonymous function which has the initial eval call.
12644 checkStackFrame(origin, "", 8, 7, false, false, 12796 checkStackFrame(origin, "", 8, 7, false, false,
12645 stackTrace->GetFrame(3)); 12797 stackTrace->GetFrame(3));
12646 12798
12647 CHECK(stackTrace->AsArray()->IsArray()); 12799 CHECK(stackTrace->AsArray()->IsArray());
12648 } else if (testGroup == kDetailedTest) { 12800 } else if (testGroup == kDetailedTest) {
12649 v8::Handle<v8::StackTrace> stackTrace = 12801 v8::Handle<v8::StackTrace> stackTrace =
12650 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); 12802 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed);
12651 CHECK_EQ(4, stackTrace->GetFrameCount()); 12803 CHECK_EQ(4, stackTrace->GetFrameCount());
12652 checkStackFrame(origin, "bat", 4, 22, false, false, 12804 checkStackFrame(origin, "bat", 4, 22, false, false,
12653 stackTrace->GetFrame(0)); 12805 stackTrace->GetFrame(0));
12654 checkStackFrame(origin, "baz", 8, 3, false, true, 12806 checkStackFrame(origin, "baz", 8, 3, false, true,
12655 stackTrace->GetFrame(1)); 12807 stackTrace->GetFrame(1));
12656 #ifdef ENABLE_DEBUGGER_SUPPORT 12808 #ifdef ENABLE_DEBUGGER_SUPPORT
12657 bool is_eval = true; 12809 bool is_eval = true;
12658 #else // ENABLE_DEBUGGER_SUPPORT 12810 #else // ENABLE_DEBUGGER_SUPPORT
12659 bool is_eval = false; 12811 bool is_eval = false;
12660 #endif // ENABLE_DEBUGGER_SUPPORT 12812 #endif // ENABLE_DEBUGGER_SUPPORT
12661 12813
12662 checkStackFrame(NULL, "", 1, 1, is_eval, false, 12814 // This is the source string inside the eval which has the call to baz.
12815 checkStackFrame(NULL, "", 1, 5, is_eval, false,
12663 stackTrace->GetFrame(2)); 12816 stackTrace->GetFrame(2));
12664 // The last frame is an anonymous function that has the initial call to foo. 12817 // The last frame is an anonymous function which has the initial eval call.
12665 checkStackFrame(origin, "", 10, 1, false, false, 12818 checkStackFrame(origin, "", 10, 1, false, false,
12666 stackTrace->GetFrame(3)); 12819 stackTrace->GetFrame(3));
12667 12820
12668 CHECK(stackTrace->AsArray()->IsArray()); 12821 CHECK(stackTrace->AsArray()->IsArray());
12669 } 12822 }
12670 return v8::Undefined(); 12823 return v8::Undefined();
12671 } 12824 }
12672 12825
12673 12826
12674 // Tests the C++ StackTrace API. 12827 // Tests the C++ StackTrace API.
(...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after
14682 } 14835 }
14683 14836
14684 i::Isolate::Current()->heap()->CollectAllGarbage(true); 14837 i::Isolate::Current()->heap()->CollectAllGarbage(true);
14685 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); 14838 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache();
14686 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { 14839 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) {
14687 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); 14840 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache);
14688 CHECK_GT(elements, map_cache->NumberOfElements()); 14841 CHECK_GT(elements, map_cache->NumberOfElements());
14689 } 14842 }
14690 } 14843 }
14691 } 14844 }
OLDNEW
« no previous file with comments | « test/cctest/log-eq-of-logging-and-traversal.js ('k') | test/cctest/test-ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698