diff options
Diffstat (limited to 'deps/v8/test/cctest/test-ast.cc')
-rw-r--r-- | deps/v8/test/cctest/test-ast.cc | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/deps/v8/test/cctest/test-ast.cc b/deps/v8/test/cctest/test-ast.cc index dfb4d11236..c027e88a52 100644 --- a/deps/v8/test/cctest/test-ast.cc +++ b/deps/v8/test/cctest/test-ast.cc @@ -30,18 +30,24 @@ #include "src/v8.h" #include "src/ast/ast.h" +#include "src/isolate.h" +#include "src/objects-inl.h" #include "src/zone/accounting-allocator.h" #include "test/cctest/cctest.h" using namespace v8::internal; TEST(List) { + v8::V8::Initialize(); + Isolate* isolate = CcTest::i_isolate(); + List<AstNode*>* list = new List<AstNode*>(0); CHECK_EQ(0, list->length()); v8::internal::AccountingAllocator allocator; Zone zone(&allocator, ZONE_NAME); - AstValueFactory value_factory(&zone, 0); + AstValueFactory value_factory(&zone, isolate->ast_string_constants(), + isolate->heap()->HashSeed()); AstNodeFactory factory(&value_factory); AstNode* node = factory.NewEmptyStatement(kNoSourcePosition); list->Add(node); @@ -59,43 +65,3 @@ TEST(List) { CHECK_EQ(0, list->length()); delete list; } - -TEST(ConcatStrings) { - v8::internal::AccountingAllocator allocator; - Zone zone(&allocator, ZONE_NAME); - AstValueFactory value_factory(&zone, 0); - - const AstRawString* one_byte = value_factory.GetOneByteString("a"); - - uint16_t two_byte_buffer[] = { - 0x3b1, - }; - const AstRawString* two_byte = value_factory.GetTwoByteString( - Vector<const uint16_t>(two_byte_buffer, 1)); - - const AstRawString* expectation = value_factory.GetOneByteString("aa"); - const AstRawString* result = value_factory.ConcatStrings(one_byte, one_byte); - CHECK(result->is_one_byte()); - CHECK_EQ(expectation, result); - - uint16_t expectation_buffer_one_two[] = {'a', 0x3b1}; - expectation = value_factory.GetTwoByteString( - Vector<const uint16_t>(expectation_buffer_one_two, 2)); - result = value_factory.ConcatStrings(one_byte, two_byte); - CHECK(!result->is_one_byte()); - CHECK_EQ(expectation, result); - - uint16_t expectation_buffer_two_one[] = {0x3b1, 'a'}; - expectation = value_factory.GetTwoByteString( - Vector<const uint16_t>(expectation_buffer_two_one, 2)); - result = value_factory.ConcatStrings(two_byte, one_byte); - CHECK(!result->is_one_byte()); - CHECK_EQ(expectation, result); - - uint16_t expectation_buffer_two_two[] = {0x3b1, 0x3b1}; - expectation = value_factory.GetTwoByteString( - Vector<const uint16_t>(expectation_buffer_two_two, 2)); - result = value_factory.ConcatStrings(two_byte, two_byte); - CHECK(!result->is_one_byte()); - CHECK_EQ(expectation, result); -} |