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

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

Issue 7167006: Merge arguments branch to bleeding merge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix test arguments.js." Created 9 years, 6 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 | « src/x64/stub-cache-x64.cc ('k') | test/cctest/test-heap.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 3021 matching lines...) Expand 10 before | Expand all | Expand 10 after
3032 result = script_define->Run(); 3032 result = script_define->Run();
3033 CHECK_EQ(result, v8_num(43)); 3033 CHECK_EQ(result, v8_num(43));
3034 result = script_desc->Run(); 3034 result = script_desc->Run();
3035 CHECK_EQ(result->BooleanValue(), false); 3035 CHECK_EQ(result->BooleanValue(), false);
3036 3036
3037 // Make sure that it is not possible to redefine again 3037 // Make sure that it is not possible to redefine again
3038 v8::TryCatch try_catch; 3038 v8::TryCatch try_catch;
3039 result = script_define->Run(); 3039 result = script_define->Run();
3040 CHECK(try_catch.HasCaught()); 3040 CHECK(try_catch.HasCaught());
3041 String::AsciiValue exception_value(try_catch.Exception()); 3041 String::AsciiValue exception_value(try_catch.Exception());
3042 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); 3042 CHECK_EQ(*exception_value,
3043 "TypeError: Cannot redefine property: defineProperty");
3043 } 3044 }
3044 3045
3045 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { 3046 THREADED_TEST(DefinePropertyOnDefineGetterSetter) {
3046 v8::HandleScope scope; 3047 v8::HandleScope scope;
3047 Local<ObjectTemplate> templ = ObjectTemplate::New(); 3048 Local<ObjectTemplate> templ = ObjectTemplate::New();
3048 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); 3049 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"));
3049 LocalContext context; 3050 LocalContext context;
3050 context->Global()->Set(v8_str("obj"), templ->NewInstance()); 3051 context->Global()->Set(v8_str("obj"), templ->NewInstance());
3051 3052
3052 Local<Script> script_desc = Script::Compile(v8_str("var prop =" 3053 Local<Script> script_desc = Script::Compile(v8_str("var prop ="
(...skipping 24 matching lines...) Expand all
3077 result = script_define->Run(); 3078 result = script_define->Run();
3078 CHECK_EQ(result, v8_num(43)); 3079 CHECK_EQ(result, v8_num(43));
3079 result = script_desc->Run(); 3080 result = script_desc->Run();
3080 3081
3081 CHECK_EQ(result->BooleanValue(), false); 3082 CHECK_EQ(result->BooleanValue(), false);
3082 3083
3083 v8::TryCatch try_catch; 3084 v8::TryCatch try_catch;
3084 result = script_define->Run(); 3085 result = script_define->Run();
3085 CHECK(try_catch.HasCaught()); 3086 CHECK(try_catch.HasCaught());
3086 String::AsciiValue exception_value(try_catch.Exception()); 3087 String::AsciiValue exception_value(try_catch.Exception());
3087 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); 3088 CHECK_EQ(*exception_value,
3089 "TypeError: Cannot redefine property: defineProperty");
3088 } 3090 }
3089 3091
3090 3092
3091 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, 3093 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context,
3092 char const* name) { 3094 char const* name) {
3093 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name))); 3095 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name)));
3094 } 3096 }
3095 3097
3096 3098
3097 THREADED_TEST(DefineAPIAccessorOnObject) { 3099 THREADED_TEST(DefineAPIAccessorOnObject) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); 3197 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
3196 CHECK(!GetGlobalProperty(&context, "obj2")-> 3198 CHECK(!GetGlobalProperty(&context, "obj2")->
3197 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); 3199 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
3198 3200
3199 { 3201 {
3200 v8::TryCatch try_catch; 3202 v8::TryCatch try_catch;
3201 CompileRun("Object.defineProperty(obj1, 'x'," 3203 CompileRun("Object.defineProperty(obj1, 'x',"
3202 "{get: function() { return 'func'; }})"); 3204 "{get: function() { return 'func'; }})");
3203 CHECK(try_catch.HasCaught()); 3205 CHECK(try_catch.HasCaught());
3204 String::AsciiValue exception_value(try_catch.Exception()); 3206 String::AsciiValue exception_value(try_catch.Exception());
3205 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); 3207 CHECK_EQ(*exception_value,
3208 "TypeError: Cannot redefine property: defineProperty");
3206 } 3209 }
3207 { 3210 {
3208 v8::TryCatch try_catch; 3211 v8::TryCatch try_catch;
3209 CompileRun("Object.defineProperty(obj2, 'x'," 3212 CompileRun("Object.defineProperty(obj2, 'x',"
3210 "{get: function() { return 'func'; }})"); 3213 "{get: function() { return 'func'; }})");
3211 CHECK(try_catch.HasCaught()); 3214 CHECK(try_catch.HasCaught());
3212 String::AsciiValue exception_value(try_catch.Exception()); 3215 String::AsciiValue exception_value(try_catch.Exception());
3213 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); 3216 CHECK_EQ(*exception_value,
3217 "TypeError: Cannot redefine property: defineProperty");
3214 } 3218 }
3215 } 3219 }
3216 3220
3217 3221
3218 static v8::Handle<Value> Get239Value(Local<String> name, 3222 static v8::Handle<Value> Get239Value(Local<String> name,
3219 const AccessorInfo& info) { 3223 const AccessorInfo& info) {
3220 ApiTestFuzzer::Fuzz(); 3224 ApiTestFuzzer::Fuzz();
3221 CHECK_EQ(info.Data(), v8_str("donut")); 3225 CHECK_EQ(info.Data(), v8_str("donut"));
3222 CHECK_EQ(name, v8_str("239")); 3226 CHECK_EQ(name, v8_str("239"));
3223 return name; 3227 return name;
(...skipping 6340 matching lines...) Expand 10 before | Expand all | Expand 10 after
9564 return count; 9568 return count;
9565 } 9569 }
9566 9570
9567 9571
9568 static void CheckSurvivingGlobalObjectsCount(int expected) { 9572 static void CheckSurvivingGlobalObjectsCount(int expected) {
9569 // We need to collect all garbage twice to be sure that everything 9573 // We need to collect all garbage twice to be sure that everything
9570 // has been collected. This is because inline caches are cleared in 9574 // has been collected. This is because inline caches are cleared in
9571 // the first garbage collection but some of the maps have already 9575 // the first garbage collection but some of the maps have already
9572 // been marked at that point. Therefore some of the maps are not 9576 // been marked at that point. Therefore some of the maps are not
9573 // collected until the second garbage collection. 9577 // collected until the second garbage collection.
9578 HEAP->global_context_map();
9574 HEAP->CollectAllGarbage(false); 9579 HEAP->CollectAllGarbage(false);
9575 HEAP->CollectAllGarbage(false); 9580 HEAP->CollectAllGarbage(false);
9576 int count = GetGlobalObjectsCount(); 9581 int count = GetGlobalObjectsCount();
9577 #ifdef DEBUG 9582 #ifdef DEBUG
9578 if (count != expected) HEAP->TracePathToGlobal(); 9583 if (count != expected) HEAP->TracePathToGlobal();
9579 #endif 9584 #endif
9580 CHECK_EQ(expected, count); 9585 CHECK_EQ(expected, count);
9581 } 9586 }
9582 9587
9583 9588
(...skipping 4889 matching lines...) Expand 10 before | Expand all | Expand 10 after
14473 14478
14474 THREADED_TEST(CallAPIFunctionOnNonObject) { 14479 THREADED_TEST(CallAPIFunctionOnNonObject) {
14475 v8::HandleScope scope; 14480 v8::HandleScope scope;
14476 LocalContext context; 14481 LocalContext context;
14477 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); 14482 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis);
14478 Handle<Function> function = templ->GetFunction(); 14483 Handle<Function> function = templ->GetFunction();
14479 context->Global()->Set(v8_str("f"), function); 14484 context->Global()->Set(v8_str("f"), function);
14480 TryCatch try_catch; 14485 TryCatch try_catch;
14481 CompileRun("f.call(2)"); 14486 CompileRun("f.call(2)");
14482 } 14487 }
14483
14484
14485 // Regression test for issue 1470.
14486 THREADED_TEST(ReadOnlyIndexedProperties) {
14487 v8::HandleScope scope;
14488 Local<ObjectTemplate> templ = ObjectTemplate::New();
14489
14490 LocalContext context;
14491 Local<v8::Object> obj = templ->NewInstance();
14492 context->Global()->Set(v8_str("obj"), obj);
14493 obj->Set(v8_str("1"), v8_str("DONT_CHANGE"), v8::ReadOnly);
14494 obj->Set(v8_str("1"), v8_str("foobar"));
14495 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1")));
14496 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly);
14497 obj->Set(v8_num(2), v8_str("foobar"));
14498 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2)));
14499
14500 // Test non-smi case.
14501 obj->Set(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly);
14502 obj->Set(v8_str("2000000000"), v8_str("foobar"));
14503 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000")));
14504 }
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698