Skip to content

Commit

Permalink
doc,tools,test: lint doc-based addon tests
Browse files Browse the repository at this point in the history
PR-URL: #5427
Fixes: #5424
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information
Trott authored and Myles Borins committed Mar 1, 2016
1 parent 2043e6a commit e703b18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
22 changes: 11 additions & 11 deletions doc/api/addons.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Once compiled, the example Addon can be required and used from within Node.js:
// test.js
const addon = require('./build/Release/addon');
console.log('This should be eight:', addon.add(3,5));
console.log('This should be eight:', addon.add(3, 5));
```


Expand Down Expand Up @@ -422,7 +422,7 @@ const addon = require('./build/Release/addon');
var obj1 = addon('hello');
var obj2 = addon('world');
console.log(obj1.msg+' '+obj2.msg); // 'hello world'
console.log(obj1.msg + ' ' + obj2.msg); // 'hello world'
```


Expand Down Expand Up @@ -637,9 +637,9 @@ Test it with:
const addon = require('./build/Release/addon');

var obj = new addon.MyObject(10);
console.log( obj.plusOne() ); // 11
console.log( obj.plusOne() ); // 12
console.log( obj.plusOne() ); // 13
console.log(obj.plusOne()); // 11
console.log(obj.plusOne()); // 12
console.log(obj.plusOne()); // 13
```

### Factory of wrapped objects
Expand Down Expand Up @@ -823,14 +823,14 @@ Test it with:
const createObject = require('./build/Release/addon');

var obj = createObject(10);
console.log( obj.plusOne() ); // 11
console.log( obj.plusOne() ); // 12
console.log( obj.plusOne() ); // 13
console.log(obj.plusOne()); // 11
console.log(obj.plusOne()); // 12
console.log(obj.plusOne()); // 13

var obj2 = createObject(20);
console.log( obj2.plusOne() ); // 21
console.log( obj2.plusOne() ); // 22
console.log( obj2.plusOne() ); // 23
console.log(obj2.plusOne()); // 21
console.log(obj2.plusOne()); // 22
console.log(obj2.plusOne()); // 23
```


Expand Down
6 changes: 6 additions & 0 deletions tools/doc/addon-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ function verifyFiles(files, blockName, onprogress, ondone) {
);

files = Object.keys(files).map(function(name) {
if (name === 'test.js') {
files[name] = `'use strict';
require('../../common');
${files[name]}
`;
}
return {
path: path.resolve(dir, name),
name: name,
Expand Down

0 comments on commit e703b18

Please sign in to comment.