Skip to content

Commit

Permalink
allow one column data-table to be passed as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuud committed Aug 30, 2014
1 parent d8d4576 commit 104c084
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -238,6 +238,9 @@ private void turnIntoSimpleParameterization(List<Expression> column) throws Inva
if (varExpr == null)
throw new InvalidSpecCompileException(column.get(0),
"Header of data table may only contain variable names");
if (AstUtil.isWildcardRef(varExpr)){
return; // ignore wildcards - _ can be used as placeholder for pseudo-second-column in one-column data
}

ListExpression listExpr = new ListExpression(column.subList(1, column.size()));
BinaryExpression binExpr = new BinaryExpression(varExpr, Token.newSymbol(Types.LEFT_SHIFT, -1, -1), listExpr);
Expand Down
9 changes: 9 additions & 0 deletions spock-specs/src/test/groovy/org/spockframework/smoke/parameterization/DataTables.groovy 100644 → 100755
Expand Up @@ -138,6 +138,15 @@ a | a
3 | "wow"
}

def "allow one column to be passed as parameter"(a) {
expect:
a == 3

where:
a | _
3 | _
}

def "tables can be mixed with other parameterizations"() {
expect:
[a, b, c, d] == [1, 2, 3, 4]
Expand Down

0 comments on commit 104c084

Please sign in to comment.