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

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

Issue 7657011: Implement UnionOfKeys for NonStrictArguments (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback 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 | « src/elements.cc ('k') | no next file » | 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 3599 matching lines...) Expand 10 before | Expand all | Expand 10 after
3610 "obj;")); 3610 "obj;"));
3611 Local<Value> result = create_unboxed_double_script->Run(); 3611 Local<Value> result = create_unboxed_double_script->Run();
3612 CHECK(result->ToObject()->HasRealIndexedProperty(2000)); 3612 CHECK(result->ToObject()->HasRealIndexedProperty(2000));
3613 Local<Script> key_count_check = Script::Compile(v8_str( 3613 Local<Script> key_count_check = Script::Compile(v8_str(
3614 "key_count;")); 3614 "key_count;"));
3615 result = key_count_check->Run(); 3615 result = key_count_check->Run();
3616 CHECK_EQ(v8_num(40013), result); 3616 CHECK_EQ(v8_num(40013), result);
3617 } 3617 }
3618 3618
3619 3619
3620 Handle<v8::Array> NonStrictArgsIndexedPropertyEnumerator(
3621 const AccessorInfo& info) {
3622 // Force the list of returned keys to be stored in a Arguments object.
3623 Local<Script> indexed_property_names_script = Script::Compile(v8_str(
3624 "function f(w,x) {"
3625 " return arguments;"
3626 "}"
3627 "keys = f(0, 1, 2, 3);"
3628 "keys;"));
3629 Local<Value> result = indexed_property_names_script->Run();
3630 return Local<v8::Array>(static_cast<v8::Array*>(::v8::Object::Cast(*result)));
3631 }
3632
3633
3634 static v8::Handle<Value> NonStrictIndexedPropertyGetter(
3635 uint32_t index,
3636 const AccessorInfo& info) {
3637 ApiTestFuzzer::Fuzz();
3638 if (index < 4) {
3639 return v8::Handle<Value>(v8_num(index));
3640 }
3641 return v8::Handle<Value>();
3642 }
3643
3644
3645 // Make sure that the the interceptor code in the runtime properly handles
3646 // merging property name lists for non-string arguments arrays.
3647 THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) {
3648 v8::HandleScope scope;
3649 Local<ObjectTemplate> templ = ObjectTemplate::New();
3650 templ->SetIndexedPropertyHandler(NonStrictIndexedPropertyGetter,
3651 0,
3652 0,
3653 0,
3654 NonStrictArgsIndexedPropertyEnumerator);
3655 LocalContext context;
3656 context->Global()->Set(v8_str("obj"), templ->NewInstance());
3657 Local<Script> create_args_script =
3658 Script::Compile(v8_str(
3659 "var key_count = 0;"
3660 "for (x in obj) {key_count++;} key_count;"));
3661 Local<Value> result = create_args_script->Run();
3662 CHECK_EQ(v8_num(4), result);
3663 }
3664
3665
3620 static v8::Handle<Value> IdentityIndexedPropertyGetter( 3666 static v8::Handle<Value> IdentityIndexedPropertyGetter(
3621 uint32_t index, 3667 uint32_t index,
3622 const AccessorInfo& info) { 3668 const AccessorInfo& info) {
3623 return v8::Integer::NewFromUnsigned(index); 3669 return v8::Integer::NewFromUnsigned(index);
3624 } 3670 }
3625 3671
3626 3672
3627 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { 3673 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) {
3628 v8::HandleScope scope; 3674 v8::HandleScope scope;
3629 Local<ObjectTemplate> templ = ObjectTemplate::New(); 3675 Local<ObjectTemplate> templ = ObjectTemplate::New();
(...skipping 11213 matching lines...) Expand 10 before | Expand all | Expand 10 after
14843 } 14889 }
14844 14890
14845 i::Isolate::Current()->heap()->CollectAllGarbage(true); 14891 i::Isolate::Current()->heap()->CollectAllGarbage(true);
14846 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); 14892 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache();
14847 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { 14893 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) {
14848 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); 14894 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache);
14849 CHECK_GT(elements, map_cache->NumberOfElements()); 14895 CHECK_GT(elements, map_cache->NumberOfElements());
14850 } 14896 }
14851 } 14897 }
14852 } 14898 }
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698