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 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")"); | 1481 v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")"); |
1482 CHECK(boxed_string->IsStringObject()); | 1482 CHECK(boxed_string->IsStringObject()); |
1483 v8::Handle<Value> unboxed_string = CompileRun("\"test\""); | 1483 v8::Handle<Value> unboxed_string = CompileRun("\"test\""); |
1484 CHECK(!unboxed_string->IsStringObject()); | 1484 CHECK(!unboxed_string->IsStringObject()); |
1485 v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)"); | 1485 v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)"); |
1486 CHECK(!boxed_not_string->IsStringObject()); | 1486 CHECK(!boxed_not_string->IsStringObject()); |
1487 v8::Handle<Value> not_object = CompileRun("0"); | 1487 v8::Handle<Value> not_object = CompileRun("0"); |
1488 CHECK(!not_object->IsStringObject()); | 1488 CHECK(!not_object->IsStringObject()); |
1489 v8::Handle<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>(); | 1489 v8::Handle<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>(); |
1490 CHECK(!as_boxed.IsEmpty()); | 1490 CHECK(!as_boxed.IsEmpty()); |
1491 Local<v8::String> the_string = as_boxed->StringValue(); | 1491 Local<v8::String> the_string = as_boxed->ValueOf(); |
1492 CHECK(!the_string.IsEmpty()); | 1492 CHECK(!the_string.IsEmpty()); |
1493 ExpectObject("\"test\"", the_string); | 1493 ExpectObject("\"test\"", the_string); |
1494 v8::Handle<v8::Value> new_boxed_string = v8::StringObject::New(the_string); | 1494 v8::Handle<v8::Value> new_boxed_string = v8::StringObject::New(the_string); |
1495 CHECK(new_boxed_string->IsStringObject()); | 1495 CHECK(new_boxed_string->IsStringObject()); |
1496 as_boxed = new_boxed_string.As<v8::StringObject>(); | 1496 as_boxed = new_boxed_string.As<v8::StringObject>(); |
1497 the_string = as_boxed->StringValue(); | 1497 the_string = as_boxed->ValueOf(); |
1498 CHECK(!the_string.IsEmpty()); | 1498 CHECK(!the_string.IsEmpty()); |
1499 ExpectObject("\"test\"", the_string); | 1499 ExpectObject("\"test\"", the_string); |
1500 } | 1500 } |
1501 | 1501 |
1502 | 1502 |
1503 THREADED_TEST(NumberObject) { | 1503 THREADED_TEST(NumberObject) { |
1504 LocalContext env; | 1504 LocalContext env; |
1505 v8::HandleScope scope(env->GetIsolate()); | 1505 v8::HandleScope scope(env->GetIsolate()); |
1506 v8::Handle<Value> boxed_number = CompileRun("new Number(42)"); | 1506 v8::Handle<Value> boxed_number = CompileRun("new Number(42)"); |
1507 CHECK(boxed_number->IsNumberObject()); | 1507 CHECK(boxed_number->IsNumberObject()); |
1508 v8::Handle<Value> unboxed_number = CompileRun("42"); | 1508 v8::Handle<Value> unboxed_number = CompileRun("42"); |
1509 CHECK(!unboxed_number->IsNumberObject()); | 1509 CHECK(!unboxed_number->IsNumberObject()); |
1510 v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)"); | 1510 v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)"); |
1511 CHECK(!boxed_not_number->IsNumberObject()); | 1511 CHECK(!boxed_not_number->IsNumberObject()); |
1512 v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>(); | 1512 v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>(); |
1513 CHECK(!as_boxed.IsEmpty()); | 1513 CHECK(!as_boxed.IsEmpty()); |
1514 double the_number = as_boxed->NumberValue(); | 1514 double the_number = as_boxed->ValueOf(); |
1515 CHECK_EQ(42.0, the_number); | 1515 CHECK_EQ(42.0, the_number); |
1516 v8::Handle<v8::Value> new_boxed_number = v8::NumberObject::New(43); | 1516 v8::Handle<v8::Value> new_boxed_number = v8::NumberObject::New(43); |
1517 CHECK(new_boxed_number->IsNumberObject()); | 1517 CHECK(new_boxed_number->IsNumberObject()); |
1518 as_boxed = new_boxed_number.As<v8::NumberObject>(); | 1518 as_boxed = new_boxed_number.As<v8::NumberObject>(); |
1519 the_number = as_boxed->NumberValue(); | 1519 the_number = as_boxed->ValueOf(); |
1520 CHECK_EQ(43.0, the_number); | 1520 CHECK_EQ(43.0, the_number); |
1521 } | 1521 } |
1522 | 1522 |
1523 | 1523 |
1524 THREADED_TEST(BooleanObject) { | 1524 THREADED_TEST(BooleanObject) { |
1525 LocalContext env; | 1525 LocalContext env; |
1526 v8::HandleScope scope(env->GetIsolate()); | 1526 v8::HandleScope scope(env->GetIsolate()); |
1527 v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)"); | 1527 v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)"); |
1528 CHECK(boxed_boolean->IsBooleanObject()); | 1528 CHECK(boxed_boolean->IsBooleanObject()); |
1529 v8::Handle<Value> unboxed_boolean = CompileRun("true"); | 1529 v8::Handle<Value> unboxed_boolean = CompileRun("true"); |
1530 CHECK(!unboxed_boolean->IsBooleanObject()); | 1530 CHECK(!unboxed_boolean->IsBooleanObject()); |
1531 v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)"); | 1531 v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)"); |
1532 CHECK(!boxed_not_boolean->IsBooleanObject()); | 1532 CHECK(!boxed_not_boolean->IsBooleanObject()); |
1533 v8::Handle<v8::BooleanObject> as_boxed = | 1533 v8::Handle<v8::BooleanObject> as_boxed = |
1534 boxed_boolean.As<v8::BooleanObject>(); | 1534 boxed_boolean.As<v8::BooleanObject>(); |
1535 CHECK(!as_boxed.IsEmpty()); | 1535 CHECK(!as_boxed.IsEmpty()); |
1536 bool the_boolean = as_boxed->BooleanValue(); | 1536 bool the_boolean = as_boxed->ValueOf(); |
1537 CHECK_EQ(true, the_boolean); | 1537 CHECK_EQ(true, the_boolean); |
1538 v8::Handle<v8::Value> boxed_true = v8::BooleanObject::New(true); | 1538 v8::Handle<v8::Value> boxed_true = v8::BooleanObject::New(true); |
1539 v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false); | 1539 v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false); |
1540 CHECK(boxed_true->IsBooleanObject()); | 1540 CHECK(boxed_true->IsBooleanObject()); |
1541 CHECK(boxed_false->IsBooleanObject()); | 1541 CHECK(boxed_false->IsBooleanObject()); |
1542 as_boxed = boxed_true.As<v8::BooleanObject>(); | 1542 as_boxed = boxed_true.As<v8::BooleanObject>(); |
1543 CHECK_EQ(true, as_boxed->BooleanValue()); | 1543 CHECK_EQ(true, as_boxed->ValueOf()); |
1544 as_boxed = boxed_false.As<v8::BooleanObject>(); | 1544 as_boxed = boxed_false.As<v8::BooleanObject>(); |
1545 CHECK_EQ(false, as_boxed->BooleanValue()); | 1545 CHECK_EQ(false, as_boxed->ValueOf()); |
1546 } | 1546 } |
1547 | 1547 |
1548 | 1548 |
1549 THREADED_TEST(PrimitiveAndWrappedBooleans) { | 1549 THREADED_TEST(PrimitiveAndWrappedBooleans) { |
1550 LocalContext env; | 1550 LocalContext env; |
1551 v8::HandleScope scope(env->GetIsolate()); | 1551 v8::HandleScope scope(env->GetIsolate()); |
1552 | 1552 |
1553 Local<Value> primitive_false = Boolean::New(false); | 1553 Local<Value> primitive_false = Boolean::New(false); |
1554 CHECK(primitive_false->IsBoolean()); | 1554 CHECK(primitive_false->IsBoolean()); |
1555 CHECK(!primitive_false->IsBooleanObject()); | 1555 CHECK(!primitive_false->IsBooleanObject()); |
1556 CHECK(!primitive_false->BooleanValue()); | 1556 CHECK(!primitive_false->BooleanValue()); |
1557 CHECK(!primitive_false->IsTrue()); | 1557 CHECK(!primitive_false->IsTrue()); |
1558 CHECK(primitive_false->IsFalse()); | 1558 CHECK(primitive_false->IsFalse()); |
1559 | 1559 |
1560 Local<Value> false_value = BooleanObject::New(false); | 1560 Local<Value> false_value = BooleanObject::New(false); |
1561 CHECK(!false_value->IsBoolean()); | 1561 CHECK(!false_value->IsBoolean()); |
1562 CHECK(false_value->IsBooleanObject()); | 1562 CHECK(false_value->IsBooleanObject()); |
1563 CHECK(false_value->BooleanValue()); | 1563 CHECK(false_value->BooleanValue()); |
1564 CHECK(!false_value->IsTrue()); | 1564 CHECK(!false_value->IsTrue()); |
1565 CHECK(!false_value->IsFalse()); | 1565 CHECK(!false_value->IsFalse()); |
1566 | 1566 |
1567 Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>(); | 1567 Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>(); |
1568 CHECK(!false_boolean_object->IsBoolean()); | 1568 CHECK(!false_boolean_object->IsBoolean()); |
1569 CHECK(false_boolean_object->IsBooleanObject()); | 1569 CHECK(false_boolean_object->IsBooleanObject()); |
1570 CHECK(!false_boolean_object->BooleanValue()); | 1570 // TODO(svenpanne) Uncomment when BooleanObject::BooleanValue() is deleted. |
| 1571 // CHECK(false_boolean_object->BooleanValue()); |
| 1572 CHECK(!false_boolean_object->ValueOf()); |
1571 CHECK(!false_boolean_object->IsTrue()); | 1573 CHECK(!false_boolean_object->IsTrue()); |
1572 CHECK(!false_boolean_object->IsFalse()); | 1574 CHECK(!false_boolean_object->IsFalse()); |
1573 | 1575 |
1574 Local<Value> primitive_true = Boolean::New(true); | 1576 Local<Value> primitive_true = Boolean::New(true); |
1575 CHECK(primitive_true->IsBoolean()); | 1577 CHECK(primitive_true->IsBoolean()); |
1576 CHECK(!primitive_true->IsBooleanObject()); | 1578 CHECK(!primitive_true->IsBooleanObject()); |
1577 CHECK(primitive_true->BooleanValue()); | 1579 CHECK(primitive_true->BooleanValue()); |
1578 CHECK(primitive_true->IsTrue()); | 1580 CHECK(primitive_true->IsTrue()); |
1579 CHECK(!primitive_true->IsFalse()); | 1581 CHECK(!primitive_true->IsFalse()); |
1580 | 1582 |
1581 Local<Value> true_value = BooleanObject::New(true); | 1583 Local<Value> true_value = BooleanObject::New(true); |
1582 CHECK(!true_value->IsBoolean()); | 1584 CHECK(!true_value->IsBoolean()); |
1583 CHECK(true_value->IsBooleanObject()); | 1585 CHECK(true_value->IsBooleanObject()); |
1584 CHECK(true_value->BooleanValue()); | 1586 CHECK(true_value->BooleanValue()); |
1585 CHECK(!true_value->IsTrue()); | 1587 CHECK(!true_value->IsTrue()); |
1586 CHECK(!true_value->IsFalse()); | 1588 CHECK(!true_value->IsFalse()); |
1587 | 1589 |
1588 Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>(); | 1590 Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>(); |
1589 CHECK(!true_boolean_object->IsBoolean()); | 1591 CHECK(!true_boolean_object->IsBoolean()); |
1590 CHECK(true_boolean_object->IsBooleanObject()); | 1592 CHECK(true_boolean_object->IsBooleanObject()); |
1591 CHECK(true_boolean_object->BooleanValue()); | 1593 // TODO(svenpanne) Uncomment when BooleanObject::BooleanValue() is deleted. |
| 1594 // CHECK(true_boolean_object->BooleanValue()); |
| 1595 CHECK(true_boolean_object->ValueOf()); |
1592 CHECK(!true_boolean_object->IsTrue()); | 1596 CHECK(!true_boolean_object->IsTrue()); |
1593 CHECK(!true_boolean_object->IsFalse()); | 1597 CHECK(!true_boolean_object->IsFalse()); |
1594 } | 1598 } |
1595 | 1599 |
1596 | 1600 |
1597 THREADED_TEST(Number) { | 1601 THREADED_TEST(Number) { |
1598 LocalContext env; | 1602 LocalContext env; |
1599 v8::HandleScope scope(env->GetIsolate()); | 1603 v8::HandleScope scope(env->GetIsolate()); |
1600 double PI = 3.1415926; | 1604 double PI = 3.1415926; |
1601 Local<v8::Number> pi_obj = v8::Number::New(PI); | 1605 Local<v8::Number> pi_obj = v8::Number::New(PI); |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2609 CHECK(sym_val->StrictEquals(sym2)); | 2613 CHECK(sym_val->StrictEquals(sym2)); |
2610 CHECK(v8::Symbol::Cast(*sym_val)->Equals(sym2)); | 2614 CHECK(v8::Symbol::Cast(*sym_val)->Equals(sym2)); |
2611 | 2615 |
2612 v8::Local<v8::Value> sym_obj = v8::SymbolObject::New(isolate, sym2); | 2616 v8::Local<v8::Value> sym_obj = v8::SymbolObject::New(isolate, sym2); |
2613 CHECK(sym_obj->IsSymbolObject()); | 2617 CHECK(sym_obj->IsSymbolObject()); |
2614 CHECK(!sym2->IsSymbolObject()); | 2618 CHECK(!sym2->IsSymbolObject()); |
2615 CHECK(!obj->IsSymbolObject()); | 2619 CHECK(!obj->IsSymbolObject()); |
2616 CHECK(sym_obj->Equals(sym2)); | 2620 CHECK(sym_obj->Equals(sym2)); |
2617 CHECK(!sym_obj->StrictEquals(sym2)); | 2621 CHECK(!sym_obj->StrictEquals(sym2)); |
2618 CHECK(v8::SymbolObject::Cast(*sym_obj)->Equals(sym_obj)); | 2622 CHECK(v8::SymbolObject::Cast(*sym_obj)->Equals(sym_obj)); |
2619 CHECK(v8::SymbolObject::Cast(*sym_obj)->SymbolValue()->Equals(sym2)); | 2623 CHECK(v8::SymbolObject::Cast(*sym_obj)->ValueOf()->Equals(sym2)); |
2620 | 2624 |
2621 // Make sure delete of a non-existent symbol property works. | 2625 // Make sure delete of a non-existent symbol property works. |
2622 CHECK(obj->Delete(sym1)); | 2626 CHECK(obj->Delete(sym1)); |
2623 CHECK(!obj->Has(sym1)); | 2627 CHECK(!obj->Has(sym1)); |
2624 | 2628 |
2625 CHECK(obj->Set(sym1, v8::Integer::New(1503))); | 2629 CHECK(obj->Set(sym1, v8::Integer::New(1503))); |
2626 CHECK(obj->Has(sym1)); | 2630 CHECK(obj->Has(sym1)); |
2627 CHECK_EQ(1503, obj->Get(sym1)->Int32Value()); | 2631 CHECK_EQ(1503, obj->Get(sym1)->Int32Value()); |
2628 CHECK(obj->Set(sym1, v8::Integer::New(2002))); | 2632 CHECK(obj->Set(sym1, v8::Integer::New(2002))); |
2629 CHECK(obj->Has(sym1)); | 2633 CHECK(obj->Has(sym1)); |
(...skipping 10587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13217 v8::String::Utf8Value name(value); | 13221 v8::String::Utf8Value name(value); |
13218 CHECK_EQ("asdf", *name); | 13222 CHECK_EQ("asdf", *name); |
13219 } | 13223 } |
13220 | 13224 |
13221 | 13225 |
13222 THREADED_TEST(DateAccess) { | 13226 THREADED_TEST(DateAccess) { |
13223 LocalContext context; | 13227 LocalContext context; |
13224 v8::HandleScope scope(context->GetIsolate()); | 13228 v8::HandleScope scope(context->GetIsolate()); |
13225 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0); | 13229 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0); |
13226 CHECK(date->IsDate()); | 13230 CHECK(date->IsDate()); |
13227 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->NumberValue()); | 13231 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); |
13228 } | 13232 } |
13229 | 13233 |
13230 | 13234 |
13231 void CheckProperties(v8::Handle<v8::Value> val, int elmc, const char* elmv[]) { | 13235 void CheckProperties(v8::Handle<v8::Value> val, int elmc, const char* elmv[]) { |
13232 v8::Handle<v8::Object> obj = val.As<v8::Object>(); | 13236 v8::Handle<v8::Object> obj = val.As<v8::Object>(); |
13233 v8::Handle<v8::Array> props = obj->GetPropertyNames(); | 13237 v8::Handle<v8::Array> props = obj->GetPropertyNames(); |
13234 CHECK_EQ(elmc, props->Length()); | 13238 CHECK_EQ(elmc, props->Length()); |
13235 for (int i = 0; i < elmc; i++) { | 13239 for (int i = 0; i < elmc; i++) { |
13236 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); | 13240 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); |
13237 CHECK_EQ(elmv[i], *elm); | 13241 CHECK_EQ(elmv[i], *elm); |
(...skipping 6744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19982 CheckCorrectThrow("%HasProperty(other, 'x')"); | 19986 CheckCorrectThrow("%HasProperty(other, 'x')"); |
19983 CheckCorrectThrow("%HasElement(other, 1)"); | 19987 CheckCorrectThrow("%HasElement(other, 1)"); |
19984 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')"); | 19988 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')"); |
19985 CheckCorrectThrow("%GetPropertyNames(other)"); | 19989 CheckCorrectThrow("%GetPropertyNames(other)"); |
19986 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); | 19990 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); |
19987 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" | 19991 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" |
19988 "other, 'x', null, null, 1)"); | 19992 "other, 'x', null, null, 1)"); |
19989 } | 19993 } |
19990 | 19994 |
19991 #endif // WIN32 | 19995 #endif // WIN32 |
OLD | NEW |