OLD | NEW |
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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 result = v8_compile("(new obj()).m")->Run(); | 816 result = v8_compile("(new obj()).m")->Run(); |
817 CHECK_EQ(239, result->Int32Value()); | 817 CHECK_EQ(239, result->Int32Value()); |
818 } | 818 } |
819 } | 819 } |
820 | 820 |
821 | 821 |
822 static void* expected_ptr; | 822 static void* expected_ptr; |
823 static v8::Handle<v8::Value> callback(const v8::Arguments& args) { | 823 static v8::Handle<v8::Value> callback(const v8::Arguments& args) { |
824 void* ptr = v8::External::Unwrap(args.Data()); | 824 void* ptr = v8::External::Unwrap(args.Data()); |
825 CHECK_EQ(expected_ptr, ptr); | 825 CHECK_EQ(expected_ptr, ptr); |
826 return v8::Boolean::New(true); | 826 return v8::True(); |
827 } | 827 } |
828 | 828 |
829 | 829 |
830 static void TestExternalPointerWrapping() { | 830 static void TestExternalPointerWrapping() { |
831 v8::HandleScope scope; | 831 v8::HandleScope scope; |
832 LocalContext env; | 832 LocalContext env; |
833 | 833 |
834 v8::Handle<v8::Value> data = v8::External::Wrap(expected_ptr); | 834 v8::Handle<v8::Value> data = v8::External::Wrap(expected_ptr); |
835 | 835 |
836 v8::Handle<v8::Object> obj = v8::Object::New(); | 836 v8::Handle<v8::Object> obj = v8::Object::New(); |
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 } | 2602 } |
2603 | 2603 |
2604 | 2604 |
2605 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) { | 2605 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) { |
2606 ApiTestFuzzer::Fuzz(); | 2606 ApiTestFuzzer::Fuzz(); |
2607 return v8::ThrowException(v8_str("konto")); | 2607 return v8::ThrowException(v8_str("konto")); |
2608 } | 2608 } |
2609 | 2609 |
2610 | 2610 |
2611 v8::Handle<Value> CCatcher(const v8::Arguments& args) { | 2611 v8::Handle<Value> CCatcher(const v8::Arguments& args) { |
2612 if (args.Length() < 1) return v8::Boolean::New(false); | 2612 if (args.Length() < 1) return v8::False(); |
2613 v8::HandleScope scope; | 2613 v8::HandleScope scope; |
2614 v8::TryCatch try_catch; | 2614 v8::TryCatch try_catch; |
2615 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); | 2615 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); |
2616 CHECK(!try_catch.HasCaught() || result.IsEmpty()); | 2616 CHECK(!try_catch.HasCaught() || result.IsEmpty()); |
2617 return v8::Boolean::New(try_catch.HasCaught()); | 2617 return v8::Boolean::New(try_catch.HasCaught()); |
2618 } | 2618 } |
2619 | 2619 |
2620 | 2620 |
2621 THREADED_TEST(APICatch) { | 2621 THREADED_TEST(APICatch) { |
2622 v8::HandleScope scope; | 2622 v8::HandleScope scope; |
(...skipping 4666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7289 CHECK(value->IsString()); | 7289 CHECK(value->IsString()); |
7290 String::AsciiValue string_value2(value->ToString()); | 7290 String::AsciiValue string_value2(value->ToString()); |
7291 CHECK_EQ("tipli", *string_value2); | 7291 CHECK_EQ("tipli", *string_value2); |
7292 | 7292 |
7293 // Call the Object's constructor with a Boolean. | 7293 // Call the Object's constructor with a Boolean. |
7294 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); | 7294 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); |
7295 CHECK(!try_catch.HasCaught()); | 7295 CHECK(!try_catch.HasCaught()); |
7296 CHECK(value->IsBoolean()); | 7296 CHECK(value->IsBoolean()); |
7297 CHECK_EQ(true, value->BooleanValue()); | 7297 CHECK_EQ(true, value->BooleanValue()); |
7298 | 7298 |
7299 Handle<Value> args3[] = { v8::Boolean::New(true) }; | 7299 Handle<Value> args3[] = { v8::True() }; |
7300 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); | 7300 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); |
7301 CHECK(value_obj3->IsObject()); | 7301 CHECK(value_obj3->IsObject()); |
7302 Local<Object> object3 = Local<Object>::Cast(value_obj3); | 7302 Local<Object> object3 = Local<Object>::Cast(value_obj3); |
7303 value = object3->Get(v8_str("a")); | 7303 value = object3->Get(v8_str("a")); |
7304 CHECK(!try_catch.HasCaught()); | 7304 CHECK(!try_catch.HasCaught()); |
7305 CHECK(value->IsBoolean()); | 7305 CHECK(value->IsBoolean()); |
7306 CHECK_EQ(true, value->BooleanValue()); | 7306 CHECK_EQ(true, value->BooleanValue()); |
7307 | 7307 |
7308 // Call the Object's constructor with undefined. | 7308 // Call the Object's constructor with undefined. |
7309 Handle<Value> args4[] = { v8::Undefined() }; | 7309 Handle<Value> args4[] = { v8::Undefined() }; |
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9560 CHECK_EQ(3, value->Int32Value()); | 9560 CHECK_EQ(3, value->Int32Value()); |
9561 | 9561 |
9562 // Check 'i' is cannot be shadowed or changed. | 9562 // Check 'i' is cannot be shadowed or changed. |
9563 value = v8_compile("o.i = 3; o.i")->Run(); | 9563 value = v8_compile("o.i = 3; o.i")->Run(); |
9564 CHECK_EQ(42, value->Int32Value()); | 9564 CHECK_EQ(42, value->Int32Value()); |
9565 } | 9565 } |
9566 | 9566 |
9567 | 9567 |
9568 static v8::Handle<Value> IsConstructHandler(const v8::Arguments& args) { | 9568 static v8::Handle<Value> IsConstructHandler(const v8::Arguments& args) { |
9569 ApiTestFuzzer::Fuzz(); | 9569 ApiTestFuzzer::Fuzz(); |
9570 if (args.IsConstructCall()) { | 9570 return v8::Boolean::New(args.IsConstructCall()); |
9571 return v8::Boolean::New(true); | |
9572 } | |
9573 return v8::Boolean::New(false); | |
9574 } | 9571 } |
9575 | 9572 |
9576 | 9573 |
9577 THREADED_TEST(IsConstructCall) { | 9574 THREADED_TEST(IsConstructCall) { |
9578 v8::HandleScope scope; | 9575 v8::HandleScope scope; |
9579 | 9576 |
9580 // Function template with call handler. | 9577 // Function template with call handler. |
9581 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 9578 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
9582 templ->SetCallHandler(IsConstructHandler); | 9579 templ->SetCallHandler(IsConstructHandler); |
9583 | 9580 |
(...skipping 5559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15143 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); | 15140 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); |
15144 | 15141 |
15145 // TODO(1547): Make the following also return "i". | 15142 // TODO(1547): Make the following also return "i". |
15146 // Calling with environment record as base. | 15143 // Calling with environment record as base. |
15147 TestReceiver(o, context->Global(), "func()"); | 15144 TestReceiver(o, context->Global(), "func()"); |
15148 // Calling with no base. | 15145 // Calling with no base. |
15149 TestReceiver(o, context->Global(), "(1,func)()"); | 15146 TestReceiver(o, context->Global(), "(1,func)()"); |
15150 | 15147 |
15151 foreign_context.Dispose(); | 15148 foreign_context.Dispose(); |
15152 } | 15149 } |
OLD | NEW |