Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 46cdb2f

Browse filesBrowse files
bnoordhuisFishrock123
authored andcommitted
test: lint addon tests
Add files in test/addon to the `make cpplint` rule and fix up existing style issues. Tests scraped from doc/api/addon.md are filtered out because those are predominantly for illustrative purposes. PR-URL: #2427 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
1 parent 6483bc2 commit 46cdb2f
Copy full SHA for 46cdb2f

File tree

Expand file treeCollapse file tree

5 files changed

+40
-35
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+40
-35
lines changed
Open diff view settings
Collapse file

‎Makefile‎

Copy file name to clipboardExpand all lines: Makefile
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,19 @@ CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
483483
CPPLINT_EXCLUDE += src/queue.h
484484
CPPLINT_EXCLUDE += src/tree.h
485485
CPPLINT_EXCLUDE += src/v8abbr.h
486-
487-
CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard src/*.cc src/*.h src/*.c tools/icu/*.h tools/icu/*.cc deps/debugger-agent/include/* deps/debugger-agent/src/*))
486+
CPPLINT_EXCLUDE += $(wildcard test/addons/doc-*/*.cc test/addons/doc-*/*.h)
487+
488+
CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
489+
deps/debugger-agent/include/* \
490+
deps/debugger-agent/src/* \
491+
src/*.c \
492+
src/*.cc \
493+
src/*.h \
494+
test/addons/*/*.cc \
495+
test/addons/*/*.h \
496+
tools/icu/*.cc \
497+
tools/icu/*.h \
498+
))
488499

489500
cpplint:
490501
@$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
Collapse file

‎test/addons/async-hello-world/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/async-hello-world/binding.cc
+16-18Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,55 @@
33
#include <v8.h>
44
#include <uv.h>
55

6-
using namespace v8;
7-
using namespace node;
8-
96
struct async_req {
107
uv_work_t req;
118
int input;
129
int output;
13-
Persistent<Function> callback;
10+
v8::Persistent<v8::Function> callback;
1411
};
1512

1613
void DoAsync(uv_work_t* r) {
1714
async_req* req = reinterpret_cast<async_req*>(r->data);
18-
sleep(1); // simulate CPU intensive process...
15+
sleep(1); // Simulate CPU intensive process...
1916
req->output = req->input * 2;
2017
}
2118

2219
void AfterAsync(uv_work_t* r) {
23-
Isolate* isolate = Isolate::GetCurrent();
24-
HandleScope scope(isolate);
20+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
21+
v8::HandleScope scope(isolate);
2522
async_req* req = reinterpret_cast<async_req*>(r->data);
2623

27-
Handle<Value> argv[2] = {
28-
Null(isolate),
29-
Integer::New(isolate, req->output)
24+
v8::Handle<v8::Value> argv[2] = {
25+
v8::Null(isolate),
26+
v8::Integer::New(isolate, req->output)
3027
};
3128

32-
TryCatch try_catch;
29+
v8::TryCatch try_catch(isolate);
3330

34-
Local<Function> callback = Local<Function>::New(isolate, req->callback);
31+
v8::Local<v8::Function> callback =
32+
v8::Local<v8::Function>::New(isolate, req->callback);
3533
callback->Call(isolate->GetCurrentContext()->Global(), 2, argv);
3634

3735
// cleanup
3836
req->callback.Reset();
3937
delete req;
4038

4139
if (try_catch.HasCaught()) {
42-
FatalException(isolate, try_catch);
40+
node::FatalException(isolate, try_catch);
4341
}
4442
}
4543

46-
void Method(const FunctionCallbackInfo<Value>& args) {
47-
Isolate* isolate = Isolate::GetCurrent();
48-
HandleScope scope(isolate);
44+
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
45+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
46+
v8::HandleScope scope(isolate);
4947

5048
async_req* req = new async_req;
5149
req->req.data = req;
5250

5351
req->input = args[0]->IntegerValue();
5452
req->output = 0;
5553

56-
Local<Function> callback = Local<Function>::Cast(args[1]);
54+
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(args[1]);
5755
req->callback.Reset(isolate, callback);
5856

5957
uv_queue_work(uv_default_loop(),
@@ -62,7 +60,7 @@ void Method(const FunctionCallbackInfo<Value>& args) {
6260
(uv_after_work_cb)AfterAsync);
6361
}
6462

65-
void init(Handle<Object> exports, Handle<Object> module) {
63+
void init(v8::Handle<v8::Object> exports, v8::Handle<v8::Object> module) {
6664
NODE_SET_METHOD(module, "exports", Method);
6765
}
6866

Collapse file

‎test/addons/at-exit/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/at-exit/binding.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static void at_exit_cb1(void* arg) {
2121
HandleScope handle_scope(isolate);
2222
assert(arg == 0);
2323
Local<Object> obj = Object::New(isolate);
24-
assert(!obj.IsEmpty()); // assert VM is still alive
24+
assert(!obj.IsEmpty()); // Assert VM is still alive.
2525
assert(obj->IsObject());
2626
at_exit_cb1_called++;
2727
}
Collapse file

‎test/addons/hello-world-function-export/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/hello-world-function-export/binding.cc
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#include <node.h>
22
#include <v8.h>
33

4-
using namespace v8;
5-
6-
void Method(const FunctionCallbackInfo<Value>& args) {
7-
Isolate* isolate = Isolate::GetCurrent();
8-
HandleScope scope(isolate);
9-
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
4+
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
5+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
6+
v8::HandleScope scope(isolate);
7+
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "world"));
108
}
119

12-
void init(Handle<Object> exports, Handle<Object> module) {
10+
void init(v8::Handle<v8::Object> exports, v8::Handle<v8::Object> module) {
1311
NODE_SET_METHOD(module, "exports", Method);
1412
}
1513

Collapse file

‎test/addons/hello-world/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/hello-world/binding.cc
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#include <node.h>
22
#include <v8.h>
33

4-
using namespace v8;
5-
6-
void Method(const FunctionCallbackInfo<Value>& args) {
7-
Isolate* isolate = Isolate::GetCurrent();
8-
HandleScope scope(isolate);
9-
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
4+
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
5+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
6+
v8::HandleScope scope(isolate);
7+
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "world"));
108
}
119

12-
void init(Handle<Object> target) {
10+
void init(v8::Handle<v8::Object> target) {
1311
NODE_SET_METHOD(target, "hello", Method);
1412
}
1513

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.