Skip to content

Commit

Permalink
test: remove expectations based on v8 headers from types test
Browse files Browse the repository at this point in the history
PR-URL: #20003
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
devsnek authored and jasnell committed Apr 16, 2018
1 parent faf563e commit 8a0b994
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions test/parallel/test-util-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const { types, inspect } = require('util');
const path = require('path');
const fs = require('fs');
const vm = require('vm');
const { JSStream } = process.binding('js_stream');

Expand Down Expand Up @@ -128,38 +126,3 @@ for (const [ value, _method ] of [
assert.deepStrictEqual(yup, expected[testedFunc]);
}
}


// Try reading the v8.h header to verify completeness.

let v8_h;
try {
v8_h = fs.readFileSync(path.resolve(
__dirname, '..', '..', 'deps', 'v8', 'include', 'v8.h'), 'utf8');
} catch (e) {
// If loading the header fails, it should fail because we did not find it.
assert.strictEqual(e.code, 'ENOENT');
common.skip('Could not read v8.h');
return;
}

// Exclude a number of checks that make sense on the C++ side but have
// much faster/better JS equivalents, so they should not be exposed.
const exclude = [
'Undefined', 'Null', 'NullOrUndefined', 'True', 'False', 'Name', 'String',
'Symbol', 'Function', 'Array', 'Object', 'Boolean', 'Number', 'Int32',
'Uint32'
];

const start = v8_h.indexOf('Value : public Data');
const end = v8_h.indexOf('};', start);
const valueDefinition = v8_h.substr(start, end - start);

const re = /bool Is(\w+)\(\)/g;
let match;
while (match = re.exec(valueDefinition)) {
if (exclude.includes(match[1]))
continue;
assert(`is${match[1]}` in types,
`util.types should provide check for Is${match[1]}`);
}

0 comments on commit 8a0b994

Please sign in to comment.