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

Commit

Permalink
test: update areAllValuesEqual to use strings
Browse files Browse the repository at this point in the history
This allows it to compare regular expressions as well.

PR-URL: #358
Reviewed-By: Kunal Pathak <kunal.pathak@microsoft.com>
Reviewed-By: Jimmy Thomson <jithomso@microsoft.com>
  • Loading branch information
kfarnung committed Aug 14, 2017
1 parent a41c632 commit f11801b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,12 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {
}
};

function areAllValuesEqual(obj) {
function areAllValuesStringEqual(obj) {
let exemplar;
for (const key of Object.keys(obj)) {
if (exemplar === undefined) {
exemplar = obj[key];
} else if (exemplar !== obj[key]) {
exemplar = obj[key].toString();
} else if (exemplar !== obj[key].toString()) {
return false;
}
}
Expand All @@ -637,7 +637,11 @@ function areAllValuesEqual(obj) {
}

exports.engineSpecificMessage = function(messageObject) {
assert.ok(!areAllValuesEqual(messageObject),
// This will compare the fields of the messageObject as strings which should
// cover both literal strings and regexps. Nothing else is currently expected
// to be passed to this method and at worst case it will generate a false
// positive that can be addressed as necessary.
assert.ok(!areAllValuesStringEqual(messageObject),
'Unnecessary usage of \'engineSpecificMessage\'');

const jsEngine = process.jsEngine || 'v8'; //default is 'v8'
Expand Down

0 comments on commit f11801b

Please sign in to comment.