Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 81x 81x 75x 75x 75x 90x 90x 90x 77x 77x 1x | const { CucumberExpressionError } = require('./errors')
class Argument {
static build(treeRegexp, text, parameterTypes) {
const group = treeRegexp.match(text)
if (!group) return null
const argGroups = group.children
Iif (argGroups.length !== parameterTypes.length) {
throw new CucumberExpressionError(
`Expression ${treeRegexp.regexp} has ${
argGroups.length
} capture groups (${argGroups.map(g => g.value)}), but there were ${
parameterTypes.length
} parameter types (${parameterTypes.map(p => p.name)})`
)
}
return parameterTypes.map(
(parameterType, i) => new Argument(argGroups[i], parameterType)
)
}
constructor(group, parameterType) {
this._group = group
this._parameterType = parameterType
}
get group() {
return this._group
}
/**
* Get the value returned by the parameter type's transformer function.
*
* @param thisObj the object in which the transformer function is applied.
*/
getValue(thisObj) {
let groupValues = this._group ? this._group.values : null
return this._parameterType.transform(thisObj, groupValues)
}
}
module.exports = Argument
|