(comments)
| 239 | } |
| 240 | |
| 241 | function buildGateCondition(comments) { |
| 242 | let conditions = null; |
| 243 | for (const line of comments) { |
| 244 | const commentStr = line.value.trim(); |
| 245 | if (commentStr.startsWith('@gate ')) { |
| 246 | const code = commentStr.slice(6); |
| 247 | const ctxIdentifier = t.identifier('ctx'); |
| 248 | const condition = parse(code, ctxIdentifier); |
| 249 | if (conditions === null) { |
| 250 | conditions = [condition]; |
| 251 | } else { |
| 252 | conditions.push(condition); |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | if (conditions !== null) { |
| 257 | let condition = conditions[0]; |
| 258 | for (let i = 1; i < conditions.length; i++) { |
| 259 | const right = conditions[i]; |
| 260 | condition = t.logicalExpression('&&', condition, right); |
| 261 | } |
| 262 | return condition; |
| 263 | } else { |
| 264 | return null; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | return { |
| 269 | name: 'test-gate-pragma', |
no test coverage detected