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

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

Issue 1467473002: Install ConstructNonConstructable as construct stub for non-constructables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years 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
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/mjsunit/regress/regress-inline-arrow-as-construct.js » ('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 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 9840 matching lines...) Expand 10 before | Expand all | Expand 10 after
9851 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); 9851 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
9852 Local<Object> instance = instance_template->NewInstance(); 9852 Local<Object> instance = instance_template->NewInstance();
9853 context->Global()->Set(v8_str("obj2"), instance); 9853 context->Global()->Set(v8_str("obj2"), instance);
9854 v8::TryCatch try_catch(isolate); 9854 v8::TryCatch try_catch(isolate);
9855 Local<Value> value; 9855 Local<Value> value;
9856 CHECK(!try_catch.HasCaught()); 9856 CHECK(!try_catch.HasCaught());
9857 9857
9858 value = CompileRun("new obj2(28)"); 9858 value = CompileRun("new obj2(28)");
9859 CHECK(try_catch.HasCaught()); 9859 CHECK(try_catch.HasCaught());
9860 String::Utf8Value exception_value1(try_catch.Exception()); 9860 String::Utf8Value exception_value1(try_catch.Exception());
9861 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); 9861 CHECK_EQ(0,
9862 strcmp("TypeError: obj2 is not a constructor", *exception_value1));
9862 try_catch.Reset(); 9863 try_catch.Reset();
9863 9864
9864 Local<Value> args[] = {v8_num(29)}; 9865 Local<Value> args[] = {v8_num(29)};
9865 value = instance->CallAsConstructor(1, args); 9866 value = instance->CallAsConstructor(1, args);
9866 CHECK(try_catch.HasCaught()); 9867 CHECK(try_catch.HasCaught());
9867 String::Utf8Value exception_value2(try_catch.Exception()); 9868 String::Utf8Value exception_value2(try_catch.Exception());
9868 CHECK_EQ(0, 9869 CHECK_EQ(
9869 strcmp("TypeError: object is not a function", *exception_value2)); 9870 0, strcmp("TypeError: object is not a constructor", *exception_value2));
9870 try_catch.Reset(); 9871 try_catch.Reset();
9871 } 9872 }
9872 9873
9873 // Check the case when constructor throws exception. 9874 // Check the case when constructor throws exception.
9874 { 9875 {
9875 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); 9876 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
9876 instance_template->SetCallAsFunctionHandler(ThrowValue); 9877 instance_template->SetCallAsFunctionHandler(ThrowValue);
9877 Local<Object> instance = instance_template->NewInstance(); 9878 Local<Object> instance = instance_template->NewInstance();
9878 context->Global()->Set(v8_str("obj3"), instance); 9879 context->Global()->Set(v8_str("obj3"), instance);
9879 v8::TryCatch try_catch(isolate); 9880 v8::TryCatch try_catch(isolate);
(...skipping 12344 matching lines...) Expand 10 before | Expand all | Expand 10 after
22224 env2->Global()->Set(v8_str("obj2"), object2); 22225 env2->Global()->Set(v8_str("obj2"), object2);
22225 ExpectString("typeof obj2.values", "function"); 22226 ExpectString("typeof obj2.values", "function");
22226 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); 22227 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values")));
22227 22228
22228 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); 22229 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values")));
22229 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); 22230 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2));
22230 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); 22231 auto ctx2 = v8::Utils::OpenHandle(*env2.local());
22231 CHECK_EQ(fn2->GetCreationContext(), *ctx2); 22232 CHECK_EQ(fn2->GetCreationContext(), *ctx2);
22232 } 22233 }
22233 } 22234 }
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/mjsunit/regress/regress-inline-arrow-as-construct.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698