| OLD | NEW |
| 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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 TestAsciiResourceWithDisposeControl::dispose_count = 0; | 671 TestAsciiResourceWithDisposeControl::dispose_count = 0; |
| 672 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 672 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 673 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); | 673 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); |
| 674 { | 674 { |
| 675 v8::HandleScope scope; | 675 v8::HandleScope scope; |
| 676 LocalContext env; | 676 LocalContext env; |
| 677 Local<String> source = String::NewExternal(&res_stack); | 677 Local<String> source = String::NewExternal(&res_stack); |
| 678 Local<Script> script = Script::Compile(source); | 678 Local<Script> script = Script::Compile(source); |
| 679 Local<Value> value = script->Run(); | 679 Local<Value> value = script->Run(); |
| 680 CHECK(value->IsNumber()); | 680 CHECK(value->IsNumber()); |
| 681 CHECK(!value->IsNumberObject()); |
| 681 CHECK_EQ(7, value->Int32Value()); | 682 CHECK_EQ(7, value->Int32Value()); |
| 682 HEAP->CollectAllAvailableGarbage(); | 683 HEAP->CollectAllAvailableGarbage(); |
| 683 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 684 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 684 } | 685 } |
| 685 i::Isolate::Current()->compilation_cache()->Clear(); | 686 i::Isolate::Current()->compilation_cache()->Clear(); |
| 686 HEAP->CollectAllAvailableGarbage(); | 687 HEAP->CollectAllAvailableGarbage(); |
| 687 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 688 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
| 688 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 689 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 689 | 690 |
| 690 // Use a heap allocated external string resource allocated object. | 691 // Use a heap allocated external string resource allocated object. |
| 691 TestAsciiResourceWithDisposeControl::dispose_count = 0; | 692 TestAsciiResourceWithDisposeControl::dispose_count = 0; |
| 692 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 693 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 693 TestAsciiResource* res_heap = | 694 TestAsciiResource* res_heap = |
| 694 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); | 695 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); |
| 695 { | 696 { |
| 696 v8::HandleScope scope; | 697 v8::HandleScope scope; |
| 697 LocalContext env; | 698 LocalContext env; |
| 698 Local<String> source = String::NewExternal(res_heap); | 699 Local<String> source = String::NewExternal(res_heap); |
| 699 Local<Script> script = Script::Compile(source); | 700 Local<Script> script = Script::Compile(source); |
| 700 Local<Value> value = script->Run(); | 701 Local<Value> value = script->Run(); |
| 701 CHECK(value->IsNumber()); | 702 CHECK(value->IsNumber()); |
| 703 CHECK(!value->IsNumberObject()); |
| 702 CHECK_EQ(7, value->Int32Value()); | 704 CHECK_EQ(7, value->Int32Value()); |
| 703 HEAP->CollectAllAvailableGarbage(); | 705 HEAP->CollectAllAvailableGarbage(); |
| 704 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 706 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 705 } | 707 } |
| 706 i::Isolate::Current()->compilation_cache()->Clear(); | 708 i::Isolate::Current()->compilation_cache()->Clear(); |
| 707 HEAP->CollectAllAvailableGarbage(); | 709 HEAP->CollectAllAvailableGarbage(); |
| 708 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 710 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
| 709 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); | 711 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); |
| 710 } | 712 } |
| 711 | 713 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 CHECK(!not_error->IsNativeError()); | 1040 CHECK(!not_error->IsNativeError()); |
| 1039 v8::Handle<Value> not_object = CompileRun("42"); | 1041 v8::Handle<Value> not_object = CompileRun("42"); |
| 1040 CHECK(!not_object->IsNativeError()); | 1042 CHECK(!not_object->IsNativeError()); |
| 1041 } | 1043 } |
| 1042 | 1044 |
| 1043 | 1045 |
| 1044 THREADED_TEST(StringObject) { | 1046 THREADED_TEST(StringObject) { |
| 1045 v8::HandleScope scope; | 1047 v8::HandleScope scope; |
| 1046 LocalContext env; | 1048 LocalContext env; |
| 1047 v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")"); | 1049 v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")"); |
| 1050 CHECK(boxed_string->IsObject()); |
| 1048 CHECK(boxed_string->IsStringObject()); | 1051 CHECK(boxed_string->IsStringObject()); |
| 1052 CHECK(!boxed_string->IsString()); |
| 1049 v8::Handle<Value> unboxed_string = CompileRun("\"test\""); | 1053 v8::Handle<Value> unboxed_string = CompileRun("\"test\""); |
| 1054 CHECK(!unboxed_string->IsObject()); |
| 1050 CHECK(!unboxed_string->IsStringObject()); | 1055 CHECK(!unboxed_string->IsStringObject()); |
| 1056 CHECK(unboxed_string->IsString()); |
| 1051 v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)"); | 1057 v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)"); |
| 1052 CHECK(!boxed_not_string->IsStringObject()); | 1058 CHECK(!boxed_not_string->IsStringObject()); |
| 1053 v8::Handle<Value> not_object = CompileRun("0"); | 1059 v8::Handle<Value> not_object = CompileRun("0"); |
| 1054 CHECK(!not_object->IsStringObject()); | 1060 CHECK(!not_object->IsStringObject()); |
| 1055 v8::Handle<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>(); | 1061 v8::Handle<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>(); |
| 1056 CHECK(!as_boxed.IsEmpty()); | 1062 CHECK(!as_boxed.IsEmpty()); |
| 1057 Local<v8::String> the_string = as_boxed->StringValue(); | 1063 Local<v8::String> the_string = as_boxed->StringValue(); |
| 1058 CHECK(!the_string.IsEmpty()); | 1064 CHECK(!the_string.IsEmpty()); |
| 1059 ExpectObject("\"test\"", the_string); | 1065 ExpectObject("\"test\"", the_string); |
| 1060 v8::Handle<v8::Value> new_boxed_string = v8::StringObject::New(the_string); | 1066 v8::Handle<v8::Value> new_boxed_string = v8::StringObject::New(the_string); |
| 1061 CHECK(new_boxed_string->IsStringObject()); | 1067 CHECK(new_boxed_string->IsStringObject()); |
| 1062 as_boxed = new_boxed_string.As<v8::StringObject>(); | 1068 as_boxed = new_boxed_string.As<v8::StringObject>(); |
| 1063 the_string = as_boxed->StringValue(); | 1069 the_string = as_boxed->StringValue(); |
| 1064 CHECK(!the_string.IsEmpty()); | 1070 CHECK(!the_string.IsEmpty()); |
| 1065 ExpectObject("\"test\"", the_string); | 1071 ExpectObject("\"test\"", the_string); |
| 1066 } | 1072 } |
| 1067 | 1073 |
| 1068 | 1074 |
| 1069 THREADED_TEST(NumberObject) { | 1075 THREADED_TEST(NumberObject) { |
| 1070 v8::HandleScope scope; | 1076 v8::HandleScope scope; |
| 1071 LocalContext env; | 1077 LocalContext env; |
| 1072 v8::Handle<Value> boxed_number = CompileRun("new Number(42)"); | 1078 v8::Handle<Value> boxed_number = CompileRun("new Number(42)"); |
| 1079 CHECK(boxed_number->IsObject()); |
| 1073 CHECK(boxed_number->IsNumberObject()); | 1080 CHECK(boxed_number->IsNumberObject()); |
| 1081 CHECK(!boxed_number->IsNumber()); |
| 1074 v8::Handle<Value> unboxed_number = CompileRun("42"); | 1082 v8::Handle<Value> unboxed_number = CompileRun("42"); |
| 1083 CHECK(!unboxed_number->IsObject()); |
| 1075 CHECK(!unboxed_number->IsNumberObject()); | 1084 CHECK(!unboxed_number->IsNumberObject()); |
| 1085 CHECK(unboxed_number->IsNumber()); |
| 1076 v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)"); | 1086 v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)"); |
| 1077 CHECK(!boxed_not_number->IsNumberObject()); | 1087 CHECK(!boxed_not_number->IsNumberObject()); |
| 1078 v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>(); | 1088 v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>(); |
| 1079 CHECK(!as_boxed.IsEmpty()); | 1089 CHECK(!as_boxed.IsEmpty()); |
| 1080 double the_number = as_boxed->NumberValue(); | 1090 double the_number = as_boxed->NumberValue(); |
| 1081 CHECK_EQ(42.0, the_number); | 1091 CHECK_EQ(42.0, the_number); |
| 1082 v8::Handle<v8::Value> new_boxed_number = v8::NumberObject::New(43); | 1092 v8::Handle<v8::Value> new_boxed_number = v8::NumberObject::New(43); |
| 1083 CHECK(new_boxed_number->IsNumberObject()); | 1093 CHECK(new_boxed_number->IsNumberObject()); |
| 1084 as_boxed = new_boxed_number.As<v8::NumberObject>(); | 1094 as_boxed = new_boxed_number.As<v8::NumberObject>(); |
| 1085 the_number = as_boxed->NumberValue(); | 1095 the_number = as_boxed->NumberValue(); |
| 1086 CHECK_EQ(43.0, the_number); | 1096 CHECK_EQ(43.0, the_number); |
| 1087 } | 1097 } |
| 1088 | 1098 |
| 1089 | 1099 |
| 1090 THREADED_TEST(BooleanObject) { | 1100 THREADED_TEST(BooleanObject) { |
| 1091 v8::HandleScope scope; | 1101 v8::HandleScope scope; |
| 1092 LocalContext env; | 1102 LocalContext env; |
| 1093 v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)"); | 1103 v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)"); |
| 1104 CHECK(boxed_boolean->IsObject()); |
| 1094 CHECK(boxed_boolean->IsBooleanObject()); | 1105 CHECK(boxed_boolean->IsBooleanObject()); |
| 1106 CHECK(!boxed_boolean->IsTrue()); |
| 1107 CHECK(!boxed_boolean->IsFalse()); |
| 1108 CHECK(!boxed_boolean->IsBoolean()); |
| 1095 v8::Handle<Value> unboxed_boolean = CompileRun("true"); | 1109 v8::Handle<Value> unboxed_boolean = CompileRun("true"); |
| 1096 CHECK(!unboxed_boolean->IsBooleanObject()); | 1110 CHECK(!unboxed_boolean->IsBooleanObject()); |
| 1111 CHECK(unboxed_boolean->IsBoolean()); |
| 1097 v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)"); | 1112 v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)"); |
| 1098 CHECK(!boxed_not_boolean->IsBooleanObject()); | 1113 CHECK(!boxed_not_boolean->IsBooleanObject()); |
| 1099 v8::Handle<v8::BooleanObject> as_boxed = | 1114 v8::Handle<v8::BooleanObject> as_boxed = |
| 1100 boxed_boolean.As<v8::BooleanObject>(); | 1115 boxed_boolean.As<v8::BooleanObject>(); |
| 1101 CHECK(!as_boxed.IsEmpty()); | 1116 CHECK(!as_boxed.IsEmpty()); |
| 1102 bool the_boolean = as_boxed->BooleanValue(); | 1117 bool the_boolean = as_boxed->BooleanValue(); |
| 1103 CHECK_EQ(true, the_boolean); | 1118 CHECK_EQ(true, the_boolean); |
| 1104 v8::Handle<v8::Value> boxed_true = v8::BooleanObject::New(true); | 1119 v8::Handle<v8::Value> boxed_true = v8::BooleanObject::New(true); |
| 1105 v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false); | 1120 v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false); |
| 1106 CHECK(boxed_true->IsBooleanObject()); | 1121 CHECK(boxed_true->IsBooleanObject()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1131 v8::Handle<v8::Boolean> f = v8::False(); | 1146 v8::Handle<v8::Boolean> f = v8::False(); |
| 1132 CHECK_EQ(0.0, f->NumberValue()); | 1147 CHECK_EQ(0.0, f->NumberValue()); |
| 1133 } | 1148 } |
| 1134 | 1149 |
| 1135 | 1150 |
| 1136 THREADED_TEST(Date) { | 1151 THREADED_TEST(Date) { |
| 1137 v8::HandleScope scope; | 1152 v8::HandleScope scope; |
| 1138 LocalContext env; | 1153 LocalContext env; |
| 1139 double PI = 3.1415926; | 1154 double PI = 3.1415926; |
| 1140 Local<Value> date = v8::Date::New(PI); | 1155 Local<Value> date = v8::Date::New(PI); |
| 1156 CHECK(date->IsObject()); |
| 1157 CHECK(date->IsDate()); |
| 1141 CHECK_EQ(3.0, date->NumberValue()); | 1158 CHECK_EQ(3.0, date->NumberValue()); |
| 1142 date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42)); | 1159 date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42)); |
| 1143 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value()); | 1160 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value()); |
| 1144 } | 1161 } |
| 1145 | 1162 |
| 1146 | 1163 |
| 1147 THREADED_TEST(Boolean) { | 1164 THREADED_TEST(Boolean) { |
| 1148 v8::HandleScope scope; | 1165 v8::HandleScope scope; |
| 1149 LocalContext env; | 1166 LocalContext env; |
| 1150 v8::Handle<v8::Boolean> t = v8::True(); | 1167 v8::Handle<v8::Boolean> t = v8::True(); |
| 1151 CHECK(t->Value()); | 1168 CHECK(t->Value()); |
| 1169 CHECK(t->IsTrue()); |
| 1170 CHECK(!t->IsFalse()); |
| 1171 CHECK(t->IsBoolean()); |
| 1172 CHECK(!t->IsObject()); |
| 1173 CHECK(!t->IsBooleanObject()); |
| 1152 v8::Handle<v8::Boolean> f = v8::False(); | 1174 v8::Handle<v8::Boolean> f = v8::False(); |
| 1153 CHECK(!f->Value()); | 1175 CHECK(!f->Value()); |
| 1176 CHECK(!f->IsTrue()); |
| 1177 CHECK(f->IsFalse()); |
| 1178 CHECK(f->IsBoolean()); |
| 1179 CHECK(!f->IsObject()); |
| 1180 CHECK(!f->IsBooleanObject()); |
| 1154 v8::Handle<v8::Primitive> u = v8::Undefined(); | 1181 v8::Handle<v8::Primitive> u = v8::Undefined(); |
| 1155 CHECK(!u->BooleanValue()); | 1182 CHECK(!u->BooleanValue()); |
| 1156 v8::Handle<v8::Primitive> n = v8::Null(); | 1183 v8::Handle<v8::Primitive> n = v8::Null(); |
| 1157 CHECK(!n->BooleanValue()); | 1184 CHECK(!n->BooleanValue()); |
| 1158 v8::Handle<String> str1 = v8_str(""); | 1185 v8::Handle<String> str1 = v8_str(""); |
| 1159 CHECK(!str1->BooleanValue()); | 1186 CHECK(!str1->BooleanValue()); |
| 1160 v8::Handle<String> str2 = v8_str("x"); | 1187 v8::Handle<String> str2 = v8_str("x"); |
| 1161 CHECK(str2->BooleanValue()); | 1188 CHECK(str2->BooleanValue()); |
| 1162 CHECK(!v8::Number::New(0)->BooleanValue()); | 1189 CHECK(!v8::Number::New(0)->BooleanValue()); |
| 1163 CHECK(v8::Number::New(-1)->BooleanValue()); | 1190 CHECK(v8::Number::New(-1)->BooleanValue()); |
| (...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2486 String::AsciiValue exception_value(try_catch.Exception()); | 2513 String::AsciiValue exception_value(try_catch.Exception()); |
| 2487 CHECK_EQ("exception", *exception_value); | 2514 CHECK_EQ("exception", *exception_value); |
| 2488 try_catch.Reset(); | 2515 try_catch.Reset(); |
| 2489 } | 2516 } |
| 2490 | 2517 |
| 2491 | 2518 |
| 2492 THREADED_TEST(Array) { | 2519 THREADED_TEST(Array) { |
| 2493 v8::HandleScope scope; | 2520 v8::HandleScope scope; |
| 2494 LocalContext context; | 2521 LocalContext context; |
| 2495 Local<v8::Array> array = v8::Array::New(); | 2522 Local<v8::Array> array = v8::Array::New(); |
| 2523 CHECK(array->IsObject()); |
| 2524 CHECK(array->IsArray()); |
| 2496 CHECK_EQ(0, array->Length()); | 2525 CHECK_EQ(0, array->Length()); |
| 2497 CHECK(array->Get(0)->IsUndefined()); | 2526 CHECK(array->Get(0)->IsUndefined()); |
| 2498 CHECK(!array->Has(0)); | 2527 CHECK(!array->Has(0)); |
| 2499 CHECK(array->Get(100)->IsUndefined()); | 2528 CHECK(array->Get(100)->IsUndefined()); |
| 2500 CHECK(!array->Has(100)); | 2529 CHECK(!array->Has(100)); |
| 2501 array->Set(2, v8_num(7)); | 2530 array->Set(2, v8_num(7)); |
| 2502 CHECK_EQ(3, array->Length()); | 2531 CHECK_EQ(3, array->Length()); |
| 2503 CHECK(!array->Has(0)); | 2532 CHECK(!array->Has(0)); |
| 2504 CHECK(!array->Has(1)); | 2533 CHECK(!array->Has(1)); |
| 2505 CHECK(array->Has(2)); | 2534 CHECK(array->Has(2)); |
| 2506 CHECK_EQ(7, array->Get(2)->Int32Value()); | 2535 CHECK_EQ(7, array->Get(2)->Int32Value()); |
| 2507 Local<Value> obj = Script::Compile(v8_str("[1, 2, 3]"))->Run(); | 2536 Local<Value> obj = Script::Compile(v8_str("[1, 2, 3]"))->Run(); |
| 2508 Local<v8::Array> arr = obj.As<v8::Array>(); | 2537 Local<v8::Array> arr = obj.As<v8::Array>(); |
| 2538 CHECK(arr->IsObject()); |
| 2539 CHECK(arr->IsArray()); |
| 2509 CHECK_EQ(3, arr->Length()); | 2540 CHECK_EQ(3, arr->Length()); |
| 2510 CHECK_EQ(1, arr->Get(0)->Int32Value()); | 2541 CHECK_EQ(1, arr->Get(0)->Int32Value()); |
| 2511 CHECK_EQ(2, arr->Get(1)->Int32Value()); | 2542 CHECK_EQ(2, arr->Get(1)->Int32Value()); |
| 2512 CHECK_EQ(3, arr->Get(2)->Int32Value()); | 2543 CHECK_EQ(3, arr->Get(2)->Int32Value()); |
| 2513 array = v8::Array::New(27); | 2544 array = v8::Array::New(27); |
| 2514 CHECK_EQ(27, array->Length()); | 2545 CHECK_EQ(27, array->Length()); |
| 2515 array = v8::Array::New(-27); | 2546 array = v8::Array::New(-27); |
| 2516 CHECK_EQ(0, array->Length()); | 2547 CHECK_EQ(0, array->Length()); |
| 2517 } | 2548 } |
| 2518 | 2549 |
| (...skipping 12627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15146 "})()", | 15177 "})()", |
| 15147 "ReferenceError: cell is not defined"); | 15178 "ReferenceError: cell is not defined"); |
| 15148 } | 15179 } |
| 15149 | 15180 |
| 15150 | 15181 |
| 15151 TEST(RegExp) { | 15182 TEST(RegExp) { |
| 15152 v8::HandleScope scope; | 15183 v8::HandleScope scope; |
| 15153 LocalContext context; | 15184 LocalContext context; |
| 15154 | 15185 |
| 15155 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); | 15186 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); |
| 15187 CHECK(re->IsObject()); |
| 15156 CHECK(re->IsRegExp()); | 15188 CHECK(re->IsRegExp()); |
| 15157 CHECK(re->GetSource()->Equals(v8_str("foo"))); | 15189 CHECK(re->GetSource()->Equals(v8_str("foo"))); |
| 15158 CHECK_EQ(v8::RegExp::kNone, re->GetFlags()); | 15190 CHECK_EQ(v8::RegExp::kNone, re->GetFlags()); |
| 15159 | 15191 |
| 15160 re = v8::RegExp::New(v8_str("bar"), | 15192 re = v8::RegExp::New(v8_str("bar"), |
| 15161 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | | 15193 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | |
| 15162 v8::RegExp::kGlobal)); | 15194 v8::RegExp::kGlobal)); |
| 15195 CHECK(re->IsObject()); |
| 15163 CHECK(re->IsRegExp()); | 15196 CHECK(re->IsRegExp()); |
| 15164 CHECK(re->GetSource()->Equals(v8_str("bar"))); | 15197 CHECK(re->GetSource()->Equals(v8_str("bar"))); |
| 15165 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal, | 15198 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal, |
| 15166 static_cast<int>(re->GetFlags())); | 15199 static_cast<int>(re->GetFlags())); |
| 15167 | 15200 |
| 15168 re = v8::RegExp::New(v8_str("baz"), | 15201 re = v8::RegExp::New(v8_str("baz"), |
| 15169 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | | 15202 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | |
| 15170 v8::RegExp::kMultiline)); | 15203 v8::RegExp::kMultiline)); |
| 15204 CHECK(re->IsObject()); |
| 15171 CHECK(re->IsRegExp()); | 15205 CHECK(re->IsRegExp()); |
| 15172 CHECK(re->GetSource()->Equals(v8_str("baz"))); | 15206 CHECK(re->GetSource()->Equals(v8_str("baz"))); |
| 15173 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, | 15207 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, |
| 15174 static_cast<int>(re->GetFlags())); | 15208 static_cast<int>(re->GetFlags())); |
| 15175 | 15209 |
| 15176 re = CompileRun("/quux/").As<v8::RegExp>(); | 15210 re = CompileRun("/quux/").As<v8::RegExp>(); |
| 15211 CHECK(re->IsObject()); |
| 15177 CHECK(re->IsRegExp()); | 15212 CHECK(re->IsRegExp()); |
| 15178 CHECK(re->GetSource()->Equals(v8_str("quux"))); | 15213 CHECK(re->GetSource()->Equals(v8_str("quux"))); |
| 15179 CHECK_EQ(v8::RegExp::kNone, re->GetFlags()); | 15214 CHECK_EQ(v8::RegExp::kNone, re->GetFlags()); |
| 15180 | 15215 |
| 15181 re = CompileRun("/quux/gm").As<v8::RegExp>(); | 15216 re = CompileRun("/quux/gm").As<v8::RegExp>(); |
| 15217 CHECK(re->IsObject()); |
| 15182 CHECK(re->IsRegExp()); | 15218 CHECK(re->IsRegExp()); |
| 15183 CHECK(re->GetSource()->Equals(v8_str("quux"))); | 15219 CHECK(re->GetSource()->Equals(v8_str("quux"))); |
| 15184 CHECK_EQ(v8::RegExp::kGlobal | v8::RegExp::kMultiline, | 15220 CHECK_EQ(v8::RegExp::kGlobal | v8::RegExp::kMultiline, |
| 15185 static_cast<int>(re->GetFlags())); | 15221 static_cast<int>(re->GetFlags())); |
| 15186 | 15222 |
| 15187 // Override the RegExp constructor and check the API constructor | 15223 // Override the RegExp constructor and check the API constructor |
| 15188 // still works. | 15224 // still works. |
| 15189 CompileRun("RegExp = function() {}"); | 15225 CompileRun("RegExp = function() {}"); |
| 15190 | 15226 |
| 15191 re = v8::RegExp::New(v8_str("foobar"), v8::RegExp::kNone); | 15227 re = v8::RegExp::New(v8_str("foobar"), v8::RegExp::kNone); |
| 15228 CHECK(re->IsObject()); |
| 15192 CHECK(re->IsRegExp()); | 15229 CHECK(re->IsRegExp()); |
| 15193 CHECK(re->GetSource()->Equals(v8_str("foobar"))); | 15230 CHECK(re->GetSource()->Equals(v8_str("foobar"))); |
| 15194 CHECK_EQ(v8::RegExp::kNone, re->GetFlags()); | 15231 CHECK_EQ(v8::RegExp::kNone, re->GetFlags()); |
| 15195 | 15232 |
| 15196 re = v8::RegExp::New(v8_str("foobarbaz"), | 15233 re = v8::RegExp::New(v8_str("foobarbaz"), |
| 15197 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | | 15234 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | |
| 15198 v8::RegExp::kMultiline)); | 15235 v8::RegExp::kMultiline)); |
| 15236 CHECK(re->IsObject()); |
| 15199 CHECK(re->IsRegExp()); | 15237 CHECK(re->IsRegExp()); |
| 15200 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); | 15238 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); |
| 15201 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, | 15239 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, |
| 15202 static_cast<int>(re->GetFlags())); | 15240 static_cast<int>(re->GetFlags())); |
| 15203 | 15241 |
| 15204 context->Global()->Set(v8_str("re"), re); | 15242 context->Global()->Set(v8_str("re"), re); |
| 15205 ExpectTrue("re.test('FoobarbaZ')"); | 15243 ExpectTrue("re.test('FoobarbaZ')"); |
| 15206 | 15244 |
| 15207 // RegExps are objects on which you can set properties. | 15245 // RegExps are objects on which you can set properties. |
| 15208 re->Set(v8_str("property"), v8::Integer::New(32)); | 15246 re->Set(v8_str("property"), v8::Integer::New(32)); |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15941 CompileRun("throw 'exception';"); | 15979 CompileRun("throw 'exception';"); |
| 15942 } | 15980 } |
| 15943 | 15981 |
| 15944 | 15982 |
| 15945 TEST(CallCompletedCallbackTwoExceptions) { | 15983 TEST(CallCompletedCallbackTwoExceptions) { |
| 15946 v8::HandleScope scope; | 15984 v8::HandleScope scope; |
| 15947 LocalContext env; | 15985 LocalContext env; |
| 15948 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); | 15986 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); |
| 15949 CompileRun("throw 'first exception';"); | 15987 CompileRun("throw 'first exception';"); |
| 15950 } | 15988 } |
| OLD | NEW |