From 396a7ff4e4b84a6909ab090c9bfe5ab2829eaf9d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gerardy Date: Mon, 9 Jan 2017 10:17:38 +0100 Subject: [PATCH] [ospec] Simplify the dupe checker --- ospec/ospec.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ospec/ospec.js b/ospec/ospec.js index eb11629c..05b64f98 100644 --- a/ospec/ospec.js +++ b/ospec/ospec.js @@ -110,15 +110,12 @@ module.exports = new function init() { } } } - var dedupeCounter = 0 function unique(subject) { - var res = subject - if (ctx.hasOwnProperty(subject)) { + if (hasOwn.call(ctx, subject)) { console.warn("A test or a spec named `" + subject + "` was already defined") - while (ctx.hasOwnProperty(res)) res = subject + ' (' + ++dedupeCounter + ')' - dedupeCounter = 0 + while (hasOwn.call(ctx, subject)) subject += '*' } - return res + return subject } function hook(name) { return function(predicate) {