[ospec] Simplify the dupe checker

This commit is contained in:
Pierre-Yves Gerardy 2017-01-09 10:17:38 +01:00
parent a7ea060a64
commit 396a7ff4e4

View file

@ -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) {