Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
test: prefer common.isChakraEngine
Browse files Browse the repository at this point in the history
Replace usages of `process.jsEngine` in tests with
`common.isChakraEngine` checks.

PR-URL: #493
Reviewed-By: Jack Horton <Jack.Horton@microsoft.com>
  • Loading branch information
kfarnung committed Mar 9, 2018
1 parent b27fa80 commit 17b469b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions test/addons-napi/test_buffer/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ assert.strictEqual(binding.newBuffer().toString(), binding.theText);
assert.strictEqual(binding.newExternalBuffer().toString(), binding.theText);

// Don't rely on Chakra's GC to behave the same as v8's.
if (process.jsEngine !== 'chakracore') {
if (!common.isChakraEngine) {
console.log('gc1');
global.gc();
assert.strictEqual(binding.getDeleterCallCount(), 1);
Expand All @@ -23,7 +23,7 @@ assert.strictEqual(binding.bufferInfo(buffer), true);
buffer = null;

// Don't rely on Chakra's GC to behave the same as v8's.
if (process.jsEngine !== 'chakracore') {
if (!common.isChakraEngine) {
global.gc();
console.log('gc2');
assert.strictEqual(binding.getDeleterCallCount(), 2);
Expand Down
2 changes: 1 addition & 1 deletion test/common/inspector-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class InspectorSession {
if (!Array.isArray(values))
values = [ values ];

if (process.jsEngine === 'chakracore') {
if (common.isChakraEngine) {
// Only the first parameter is returned by ChakraCore
values = values.slice(0, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ common.expectsError(
// Test caching.
const fs = process.binding('fs');
const tmp = fs.close;
fs.close = common.mustCall(tmp, process.jsEngine === 'chakracore' ? 0 : 1);
fs.close = common.mustCall(tmp, common.isChakraEngine ? 0 : 1);
function throwErr() {
// eslint-disable-next-line prefer-assert-methods
assert(
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-buffer-writedouble.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Tests to verify doubles are correctly written

require('../common');
const common = require('../common');
const assert = require('assert');

const buffer = Buffer.allocUnsafe(16);
Expand Down Expand Up @@ -67,7 +67,7 @@ assert.strictEqual(buffer.readDoubleLE(8), -Infinity);
buffer.writeDoubleBE(NaN, 0);
buffer.writeDoubleLE(NaN, 8);

if (process.jsEngine === 'chakracore') {
if (common.isChakraEngine) {
assert.ok(buffer.equals(new Uint8Array([
0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-buffer-writefloat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Tests to verify floats are correctly written

require('../common');
const common = require('../common');
const assert = require('assert');

const buffer = Buffer.allocUnsafe(8);
Expand Down Expand Up @@ -51,7 +51,7 @@ assert.strictEqual(buffer.readFloatLE(4), -Infinity);
buffer.writeFloatBE(NaN, 0);
buffer.writeFloatLE(NaN, 4);
assert.ok(buffer.equals(
process.jsEngine === 'chakracore' ?
common.isChakraEngine ?
new Uint8Array([ 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF ]) :
new Uint8Array([ 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7F ])));

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cli-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ syntaxArgs.forEach(function(args) {
const c = spawnSync(node, args, { encoding: 'utf8', input: stdin });

// stderr should include '[stdin]' as the filename
if (process.jsEngine === 'v8') {
if (!common.isChakraEngine) {
assert(c.stderr.startsWith('[stdin]'), `${c.stderr} starts with ${stdin}`);
}

Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-inspector-debug-brk-flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function testBreakpointOnStart(session) {
'params': { 'maxDepth': 0 } }
];

if (process.jsEngine !== 'chakracore') {
if (!common.isChakraEngine) {
commands.push(
{ 'method': 'Profiler.enable' },
{ 'method': 'Profiler.setSamplingInterval',
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-inspector-exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function testBreakpointOnStart(session) {
'params': { 'maxDepth': 0 } }
];

if (process.jsEngine !== 'chakracore') {
if (!common.isChakraEngine) {
commands.push(
{ 'method': 'Profiler.enable' },
{ 'method': 'Profiler.setSamplingInterval',
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function testBreakpointOnStart(session) {
'params': { 'maxDepth': 0 } }
];

if (process.jsEngine !== 'chakracore') {
if (!common.isChakraEngine) {
commands.push(
{ 'method': 'Profiler.enable' },
{ 'method': 'Profiler.setSamplingInterval',
Expand Down

0 comments on commit 17b469b

Please sign in to comment.