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

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

Issue 177683002: Mode clean-up pt 1: rename classic/non-strict mode to sloppy mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 5932 matching lines...) Expand 10 before | Expand all | Expand 10 after
5943 "obj;")); 5943 "obj;"));
5944 Local<Value> result = create_unboxed_double_script->Run(); 5944 Local<Value> result = create_unboxed_double_script->Run();
5945 CHECK(result->ToObject()->HasRealIndexedProperty(2000)); 5945 CHECK(result->ToObject()->HasRealIndexedProperty(2000));
5946 Local<Script> key_count_check = Script::Compile(v8_str( 5946 Local<Script> key_count_check = Script::Compile(v8_str(
5947 "key_count;")); 5947 "key_count;"));
5948 result = key_count_check->Run(); 5948 result = key_count_check->Run();
5949 CHECK_EQ(v8_num(40013), result); 5949 CHECK_EQ(v8_num(40013), result);
5950 } 5950 }
5951 5951
5952 5952
5953 void NonStrictArgsIndexedPropertyEnumerator( 5953 void SloppyArgsIndexedPropertyEnumerator(
5954 const v8::PropertyCallbackInfo<v8::Array>& info) { 5954 const v8::PropertyCallbackInfo<v8::Array>& info) {
5955 // Force the list of returned keys to be stored in a Arguments object. 5955 // Force the list of returned keys to be stored in a Arguments object.
5956 Local<Script> indexed_property_names_script = Script::Compile(v8_str( 5956 Local<Script> indexed_property_names_script = Script::Compile(v8_str(
5957 "function f(w,x) {" 5957 "function f(w,x) {"
5958 " return arguments;" 5958 " return arguments;"
5959 "}" 5959 "}"
5960 "keys = f(0, 1, 2, 3);" 5960 "keys = f(0, 1, 2, 3);"
5961 "keys;")); 5961 "keys;"));
5962 Local<Object> result = 5962 Local<Object> result =
5963 Local<Object>::Cast(indexed_property_names_script->Run()); 5963 Local<Object>::Cast(indexed_property_names_script->Run());
5964 // Have to populate the handle manually, as it's not Cast-able. 5964 // Have to populate the handle manually, as it's not Cast-able.
5965 i::Handle<i::JSObject> o = 5965 i::Handle<i::JSObject> o =
5966 v8::Utils::OpenHandle<Object, i::JSObject>(result); 5966 v8::Utils::OpenHandle<Object, i::JSObject>(result);
5967 i::Handle<i::JSArray> array(reinterpret_cast<i::JSArray*>(*o)); 5967 i::Handle<i::JSArray> array(reinterpret_cast<i::JSArray*>(*o));
5968 info.GetReturnValue().Set(v8::Utils::ToLocal(array)); 5968 info.GetReturnValue().Set(v8::Utils::ToLocal(array));
5969 } 5969 }
5970 5970
5971 5971
5972 static void NonStrictIndexedPropertyGetter( 5972 static void SloppyIndexedPropertyGetter(
5973 uint32_t index, 5973 uint32_t index,
5974 const v8::PropertyCallbackInfo<v8::Value>& info) { 5974 const v8::PropertyCallbackInfo<v8::Value>& info) {
5975 ApiTestFuzzer::Fuzz(); 5975 ApiTestFuzzer::Fuzz();
5976 if (index < 4) { 5976 if (index < 4) {
5977 info.GetReturnValue().Set(v8_num(index)); 5977 info.GetReturnValue().Set(v8_num(index));
5978 } 5978 }
5979 } 5979 }
5980 5980
5981 5981
5982 // Make sure that the the interceptor code in the runtime properly handles 5982 // Make sure that the the interceptor code in the runtime properly handles
5983 // merging property name lists for non-string arguments arrays. 5983 // merging property name lists for non-string arguments arrays.
5984 THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) { 5984 THREADED_TEST(IndexedInterceptorSloppyArgsWithIndexedAccessor) {
5985 v8::Isolate* isolate = CcTest::isolate(); 5985 v8::Isolate* isolate = CcTest::isolate();
5986 v8::HandleScope scope(isolate); 5986 v8::HandleScope scope(isolate);
5987 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 5987 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
5988 templ->SetIndexedPropertyHandler(NonStrictIndexedPropertyGetter, 5988 templ->SetIndexedPropertyHandler(SloppyIndexedPropertyGetter,
5989 0, 5989 0,
5990 0, 5990 0,
5991 0, 5991 0,
5992 NonStrictArgsIndexedPropertyEnumerator); 5992 SloppyArgsIndexedPropertyEnumerator);
5993 LocalContext context; 5993 LocalContext context;
5994 context->Global()->Set(v8_str("obj"), templ->NewInstance()); 5994 context->Global()->Set(v8_str("obj"), templ->NewInstance());
5995 Local<Script> create_args_script = 5995 Local<Script> create_args_script =
5996 Script::Compile(v8_str( 5996 Script::Compile(v8_str(
5997 "var key_count = 0;" 5997 "var key_count = 0;"
5998 "for (x in obj) {key_count++;} key_count;")); 5998 "for (x in obj) {key_count++;} key_count;"));
5999 Local<Value> result = create_args_script->Run(); 5999 Local<Value> result = create_args_script->Run();
6000 CHECK_EQ(v8_num(4), result); 6000 CHECK_EQ(v8_num(4), result);
6001 } 6001 }
6002 6002
(...skipping 9667 matching lines...) Expand 10 before | Expand all | Expand 10 after
15670 "for (var i = 0; i < 8; i++) {" 15670 "for (var i = 0; i < 8; i++) {"
15671 " sum += pixels[i];" 15671 " sum += pixels[i];"
15672 "}" 15672 "}"
15673 "sum;"); 15673 "sum;");
15674 CHECK_EQ(28, result->Int32Value()); 15674 CHECK_EQ(28, result->Int32Value());
15675 15675
15676 i::Handle<i::Smi> value(i::Smi::FromInt(2), 15676 i::Handle<i::Smi> value(i::Smi::FromInt(2),
15677 reinterpret_cast<i::Isolate*>(context->GetIsolate())); 15677 reinterpret_cast<i::Isolate*>(context->GetIsolate()));
15678 i::Handle<i::Object> no_failure; 15678 i::Handle<i::Object> no_failure;
15679 no_failure = 15679 no_failure =
15680 i::JSObject::SetElement(jsobj, 1, value, NONE, i::kNonStrictMode); 15680 i::JSObject::SetElement(jsobj, 1, value, NONE, i::kSloppyMode);
15681 ASSERT(!no_failure.is_null()); 15681 ASSERT(!no_failure.is_null());
15682 i::USE(no_failure); 15682 i::USE(no_failure);
15683 CheckElementValue(isolate, 2, jsobj, 1); 15683 CheckElementValue(isolate, 2, jsobj, 1);
15684 *value.location() = i::Smi::FromInt(256); 15684 *value.location() = i::Smi::FromInt(256);
15685 no_failure = 15685 no_failure =
15686 i::JSObject::SetElement(jsobj, 1, value, NONE, i::kNonStrictMode); 15686 i::JSObject::SetElement(jsobj, 1, value, NONE, i::kSloppyMode);
15687 ASSERT(!no_failure.is_null()); 15687 ASSERT(!no_failure.is_null());
15688 i::USE(no_failure); 15688 i::USE(no_failure);
15689 CheckElementValue(isolate, 255, jsobj, 1); 15689 CheckElementValue(isolate, 255, jsobj, 1);
15690 *value.location() = i::Smi::FromInt(-1); 15690 *value.location() = i::Smi::FromInt(-1);
15691 no_failure = 15691 no_failure =
15692 i::JSObject::SetElement(jsobj, 1, value, NONE, i::kNonStrictMode); 15692 i::JSObject::SetElement(jsobj, 1, value, NONE, i::kSloppyMode);
15693 ASSERT(!no_failure.is_null()); 15693 ASSERT(!no_failure.is_null());
15694 i::USE(no_failure); 15694 i::USE(no_failure);
15695 CheckElementValue(isolate, 0, jsobj, 1); 15695 CheckElementValue(isolate, 0, jsobj, 1);
15696 15696
15697 result = CompileRun("for (var i = 0; i < 8; i++) {" 15697 result = CompileRun("for (var i = 0; i < 8; i++) {"
15698 " pixels[i] = (i * 65) - 109;" 15698 " pixels[i] = (i * 65) - 109;"
15699 "}" 15699 "}"
15700 "pixels[1] + pixels[6];"); 15700 "pixels[1] + pixels[6];");
15701 CHECK_EQ(255, result->Int32Value()); 15701 CHECK_EQ(255, result->Int32Value());
15702 CheckElementValue(isolate, 0, jsobj, 0); 15702 CheckElementValue(isolate, 0, jsobj, 0);
(...skipping 6403 matching lines...) Expand 10 before | Expand all | Expand 10 after
22106 Local<Object> ApiCallOptimizationChecker::holder; 22106 Local<Object> ApiCallOptimizationChecker::holder;
22107 Local<Object> ApiCallOptimizationChecker::callee; 22107 Local<Object> ApiCallOptimizationChecker::callee;
22108 int ApiCallOptimizationChecker::count = 0; 22108 int ApiCallOptimizationChecker::count = 0;
22109 22109
22110 22110
22111 TEST(TestFunctionCallOptimization) { 22111 TEST(TestFunctionCallOptimization) {
22112 i::FLAG_allow_natives_syntax = true; 22112 i::FLAG_allow_natives_syntax = true;
22113 ApiCallOptimizationChecker checker; 22113 ApiCallOptimizationChecker checker;
22114 checker.RunAll(); 22114 checker.RunAll();
22115 } 22115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698