Skip to content

Commit

Permalink
test number nodejs#13
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheus Marchini committed Nov 30, 2017
1 parent de26003 commit 66508cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,6 @@
'test/cctest/node_test_fixture.cc',
'test/cctest/test_aliased_buffer.cc',
'test/cctest/test_base64.cc',
'src/handle_wrap.cc', # TODO (mmarchini): remove, this causes undefined behavior
'<(SHARED_INTERMEDIATE_DIR)/test_node_debug_support.cc',
'test/cctest/test_environment.cc',
'test/cctest/test_util.cc',
Expand Down
21 changes: 13 additions & 8 deletions test/cctest/test_node_debug_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "node_internals.h"
#include "udp_wrap.h"
#include "v8.h"
#include "tracing/agent.h"

const int node::Environment::kContextEmbedderDataIndex;


class DebugSymbolsTest : public EnvironmentTestFixture {
};
Expand All @@ -25,11 +29,9 @@ class TestHandleWrap : public node::HandleWrap {
};


#ifndef DEBUG
TEST_F(DebugSymbolsTest, ContextEmbedderDataIndex) {
EXPECT_EQ(nodedbg_environment_context_idx_embedder_data, node::Environment::kContextEmbedderDataIndex);
}
#endif

TEST_F(DebugSymbolsTest, BaseObjectPersistentHandle) {
const v8::HandleScope handle_scope(isolate_);
Expand All @@ -39,7 +41,9 @@ TEST_F(DebugSymbolsTest, BaseObjectPersistentHandle) {
v8::Local<v8::Object> object = v8::Object::New(isolate_);
node::BaseObject *obj = new node::BaseObject(*env, object);

EXPECT_EQ((void *)&(obj->persistent()), (((void*)obj) + nodedbg_class__BaseObject__persistent_handle));
auto expected = (uintptr_t)&(obj->persistent());
auto calculated = (uintptr_t)((void*)obj) + nodedbg_class__BaseObject__persistent_handle;
EXPECT_EQ(expected, calculated);
}


Expand All @@ -48,20 +52,20 @@ TEST_F(DebugSymbolsTest, EnvironmentHandleWrapQueue) {
const Argv argv;
Env env {handle_scope, isolate_, argv, this};

EXPECT_EQ((void *)((*env)->handle_wrap_queue()), (((void*)(*env)) + nodedbg_class__Environment__handleWrapQueue));
auto expected = (uintptr_t)((*env)->handle_wrap_queue());
auto calculated = ((uintptr_t)(*env)) + + nodedbg_class__Environment__handleWrapQueue;
EXPECT_EQ(expected, calculated);
}

TEST_F(DebugSymbolsTest, EnvironmentReqWrapQueue) {
const v8::HandleScope handle_scope(isolate_);
const Argv argv;
Env env {handle_scope, isolate_, argv, this};

(*env)->req_wrap_queue();
// auto l = (*env)->req_wrap_queue();
// EXPECT_EQ((void *)((*env)->req_wrap_queue()), (((void*)(*env)) + nodedbg_class__Environment__reqWrapQueue));
}

// NOTE: this test is not working
#if 0
TEST_F(DebugSymbolsTest, HandleWrapList) {
v8::HandleScope handle_scope(isolate_);
auto context = node::NewContext(isolate_);
Expand All @@ -72,6 +76,8 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {

uv_handle_t handle_;

node::tracing::TraceEventHelper::SetTracingController(
new v8::TracingController());

auto obj_template = v8::FunctionTemplate::New(isolate_);
obj_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate_, "prop1"));
Expand All @@ -81,4 +87,3 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {
std::cout << "aaa 1" << std::endl;
auto *obj = new TestHandleWrap(env, object, &handle_);
}
#endif

0 comments on commit 66508cb

Please sign in to comment.