[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) { function unique(subject) {
var res = subject if (hasOwn.call(ctx, subject)) {
if (ctx.hasOwnProperty(subject)) {
console.warn("A test or a spec named `" + subject + "` was already defined") console.warn("A test or a spec named `" + subject + "` was already defined")
while (ctx.hasOwnProperty(res)) res = subject + ' (' + ++dedupeCounter + ')' while (hasOwn.call(ctx, subject)) subject += '*'
dedupeCounter = 0
} }
return res return subject
} }
function hook(name) { function hook(name) {
return function(predicate) { return function(predicate) {