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

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

Issue 21013003: Added unit tests for the slightly confusing Boolean/BooleanObject API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed copy-n-paste typo Created 7 years, 4 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 | « no previous file | 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 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "platform.h" 48 #include "platform.h"
49 #include "snapshot.h" 49 #include "snapshot.h"
50 #include "unicode-inl.h" 50 #include "unicode-inl.h"
51 #include "utils.h" 51 #include "utils.h"
52 #include "vm-state.h" 52 #include "vm-state.h"
53 53
54 static const bool kLogThreading = false; 54 static const bool kLogThreading = false;
55 55
56 using ::v8::AccessorInfo; 56 using ::v8::AccessorInfo;
57 using ::v8::Arguments; 57 using ::v8::Arguments;
58 using ::v8::Boolean;
59 using ::v8::BooleanObject;
58 using ::v8::Context; 60 using ::v8::Context;
59 using ::v8::Extension; 61 using ::v8::Extension;
60 using ::v8::Function; 62 using ::v8::Function;
61 using ::v8::FunctionTemplate; 63 using ::v8::FunctionTemplate;
62 using ::v8::Handle; 64 using ::v8::Handle;
63 using ::v8::HandleScope; 65 using ::v8::HandleScope;
64 using ::v8::Local; 66 using ::v8::Local;
65 using ::v8::Message; 67 using ::v8::Message;
66 using ::v8::MessageCallback; 68 using ::v8::MessageCallback;
67 using ::v8::Object; 69 using ::v8::Object;
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false); 1539 v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false);
1538 CHECK(boxed_true->IsBooleanObject()); 1540 CHECK(boxed_true->IsBooleanObject());
1539 CHECK(boxed_false->IsBooleanObject()); 1541 CHECK(boxed_false->IsBooleanObject());
1540 as_boxed = boxed_true.As<v8::BooleanObject>(); 1542 as_boxed = boxed_true.As<v8::BooleanObject>();
1541 CHECK_EQ(true, as_boxed->BooleanValue()); 1543 CHECK_EQ(true, as_boxed->BooleanValue());
1542 as_boxed = boxed_false.As<v8::BooleanObject>(); 1544 as_boxed = boxed_false.As<v8::BooleanObject>();
1543 CHECK_EQ(false, as_boxed->BooleanValue()); 1545 CHECK_EQ(false, as_boxed->BooleanValue());
1544 } 1546 }
1545 1547
1546 1548
1549 THREADED_TEST(PrimitiveAndWrappedBooleans) {
1550 LocalContext env;
1551 v8::HandleScope scope(env->GetIsolate());
1552
1553 Local<Value> primitive_false = Boolean::New(false);
1554 CHECK(primitive_false->IsBoolean());
1555 CHECK(!primitive_false->IsBooleanObject());
1556 CHECK(!primitive_false->BooleanValue());
1557 CHECK(!primitive_false->IsTrue());
1558 CHECK(primitive_false->IsFalse());
1559
1560 Local<Value> false_value = BooleanObject::New(false);
1561 CHECK(!false_value->IsBoolean());
1562 CHECK(false_value->IsBooleanObject());
1563 CHECK(false_value->BooleanValue());
1564 CHECK(!false_value->IsTrue());
1565 CHECK(!false_value->IsFalse());
1566
1567 Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>();
1568 CHECK(!false_boolean_object->IsBoolean());
1569 CHECK(false_boolean_object->IsBooleanObject());
1570 CHECK(!false_boolean_object->BooleanValue());
1571 CHECK(!false_boolean_object->IsTrue());
1572 CHECK(!false_boolean_object->IsFalse());
1573
1574 Local<Value> primitive_true = Boolean::New(true);
1575 CHECK(primitive_true->IsBoolean());
1576 CHECK(!primitive_true->IsBooleanObject());
1577 CHECK(primitive_true->BooleanValue());
1578 CHECK(primitive_true->IsTrue());
1579 CHECK(!primitive_true->IsFalse());
1580
1581 Local<Value> true_value = BooleanObject::New(true);
1582 CHECK(!true_value->IsBoolean());
1583 CHECK(true_value->IsBooleanObject());
1584 CHECK(true_value->BooleanValue());
1585 CHECK(!true_value->IsTrue());
1586 CHECK(!true_value->IsFalse());
1587
1588 Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>();
1589 CHECK(!true_boolean_object->IsBoolean());
1590 CHECK(true_boolean_object->IsBooleanObject());
1591 CHECK(true_boolean_object->BooleanValue());
1592 CHECK(!true_boolean_object->IsTrue());
1593 CHECK(!true_boolean_object->IsFalse());
1594 }
1595
1596
1547 THREADED_TEST(Number) { 1597 THREADED_TEST(Number) {
1548 LocalContext env; 1598 LocalContext env;
1549 v8::HandleScope scope(env->GetIsolate()); 1599 v8::HandleScope scope(env->GetIsolate());
1550 double PI = 3.1415926; 1600 double PI = 3.1415926;
1551 Local<v8::Number> pi_obj = v8::Number::New(PI); 1601 Local<v8::Number> pi_obj = v8::Number::New(PI);
1552 CHECK_EQ(PI, pi_obj->NumberValue()); 1602 CHECK_EQ(PI, pi_obj->NumberValue());
1553 } 1603 }
1554 1604
1555 1605
1556 THREADED_TEST(ToNumber) { 1606 THREADED_TEST(ToNumber) {
(...skipping 18375 matching lines...) Expand 10 before | Expand all | Expand 10 after
19932 CheckCorrectThrow("%HasProperty(other, 'x')"); 19982 CheckCorrectThrow("%HasProperty(other, 'x')");
19933 CheckCorrectThrow("%HasElement(other, 1)"); 19983 CheckCorrectThrow("%HasElement(other, 1)");
19934 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')"); 19984 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')");
19935 CheckCorrectThrow("%GetPropertyNames(other)"); 19985 CheckCorrectThrow("%GetPropertyNames(other)");
19936 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); 19986 CheckCorrectThrow("%GetLocalPropertyNames(other, true)");
19937 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" 19987 CheckCorrectThrow("%DefineOrRedefineAccessorProperty("
19938 "other, 'x', null, null, 1)"); 19988 "other, 'x', null, null, 1)");
19939 } 19989 }
19940 19990
19941 #endif // WIN32 19991 #endif // WIN32
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698