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

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

Issue 113634: Propagate information on whether a non function was called as constructor or not (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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/runtime.js ('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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 4626 matching lines...) Expand 10 before | Expand all | Expand 10 after
4637 // Trigger lazy loading in other context. 4637 // Trigger lazy loading in other context.
4638 Local<Script> script = 4638 Local<Script> script =
4639 Script::Compile(v8_str("other.eval('new Date(42)')")); 4639 Script::Compile(v8_str("other.eval('new Date(42)')"));
4640 Local<Value> value = script->Run(); 4640 Local<Value> value = script->Run();
4641 CHECK_EQ(42.0, value->NumberValue()); 4641 CHECK_EQ(42.0, value->NumberValue());
4642 } 4642 }
4643 4643
4644 4644
4645 static v8::Handle<Value> call_as_function(const v8::Arguments& args) { 4645 static v8::Handle<Value> call_as_function(const v8::Arguments& args) {
4646 ApiTestFuzzer::Fuzz(); 4646 ApiTestFuzzer::Fuzz();
4647 if (args.IsConstructCall()) {
4648 if (args[0]->IsInt32()) {
4649 return v8_num(-args[0]->Int32Value());
4650 }
4651 }
4652
4647 return args[0]; 4653 return args[0];
4648 } 4654 }
4649 4655
4650 4656
4651 // Test that a call handler can be set for objects which will allow 4657 // Test that a call handler can be set for objects which will allow
4652 // non-function objects created through the API to be called as 4658 // non-function objects created through the API to be called as
4653 // functions. 4659 // functions.
4654 THREADED_TEST(CallAsFunction) { 4660 THREADED_TEST(CallAsFunction) {
4655 v8::HandleScope scope; 4661 v8::HandleScope scope;
4656 LocalContext context; 4662 LocalContext context;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4690 CHECK_EQ(99, value->Int32Value()); 4696 CHECK_EQ(99, value->Int32Value());
4691 4697
4692 const char* call_17 = "Function.prototype.call.call(obj, this, 17)"; 4698 const char* call_17 = "Function.prototype.call.call(obj, this, 17)";
4693 value = CompileRun(call_17); 4699 value = CompileRun(call_17);
4694 CHECK(!try_catch.HasCaught()); 4700 CHECK(!try_catch.HasCaught());
4695 CHECK_EQ(17, value->Int32Value()); 4701 CHECK_EQ(17, value->Int32Value());
4696 4702
4697 // Check that the call-as-function handler can be called through 4703 // Check that the call-as-function handler can be called through
4698 // new. Currently, there is no way to check in the call-as-function 4704 // new. Currently, there is no way to check in the call-as-function
4699 // handler if it has been called through new or not. 4705 // handler if it has been called through new or not.
4700 value = CompileRun("new obj(42)"); 4706 value = CompileRun("new obj(43)");
4701 CHECK(!try_catch.HasCaught()); 4707 CHECK(!try_catch.HasCaught());
4702 CHECK_EQ(42, value->Int32Value()); 4708 CHECK_EQ(-43, value->Int32Value());
4703 } 4709 }
4704 4710
4705 4711
4706 static int CountHandles() { 4712 static int CountHandles() {
4707 return v8::HandleScope::NumberOfHandles(); 4713 return v8::HandleScope::NumberOfHandles();
4708 } 4714 }
4709 4715
4710 4716
4711 static int Recurse(int depth, int iterations) { 4717 static int Recurse(int depth, int iterations) {
4712 v8::HandleScope scope; 4718 v8::HandleScope scope;
(...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after
6665 calling_context2->Exit(); 6671 calling_context2->Exit();
6666 6672
6667 // Dispose the contexts to allow them to be garbage collected. 6673 // Dispose the contexts to allow them to be garbage collected.
6668 calling_context0.Dispose(); 6674 calling_context0.Dispose();
6669 calling_context1.Dispose(); 6675 calling_context1.Dispose();
6670 calling_context2.Dispose(); 6676 calling_context2.Dispose();
6671 calling_context0.Clear(); 6677 calling_context0.Clear();
6672 calling_context1.Clear(); 6678 calling_context1.Clear();
6673 calling_context2.Clear(); 6679 calling_context2.Clear();
6674 } 6680 }
OLDNEW
« no previous file with comments | « src/runtime.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698