Skip to content

Commit

Permalink
Revert "Remove string interpolator options from development spec + ad…
Browse files Browse the repository at this point in the history
…d `sep` function"
  • Loading branch information
mlin committed May 12, 2020
1 parent e44e872 commit bccb8dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 49 deletions.
4 changes: 0 additions & 4 deletions WDL/StdLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ def sub(input: Value.String, pattern: Value.String, replace: Value.String) -> Va
def defined(v: Value.Base):
return Value.Boolean(not isinstance(v, Value.Null))

@static([Type.String(), Type.Array(Type.String())], Type.String())
def sep(sep: Value.String, iterable: Value.Array) -> Value.String:
return Value.String(sep.value.join(v.value for v in iterable.value))

# write_*
static([Type.Array(Type.String())], Type.File(), "write_lines")(
self._write(_serialize_lines)
Expand Down
7 changes: 6 additions & 1 deletion WDL/_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,12 @@
output_decls: "output" "{" bound_decl* "}"
// WDL task commands: with {} and <<< >>> command and ${} and ~{} placeholder styles
placeholder: expr
!?placeholder_key: "default" | "false" | "true" | "sep"
?placeholder_value: string_literal
| INT -> int
| FLOAT -> float
placeholder_option: placeholder_key "=" placeholder_value
placeholder: placeholder_option* expr
?command: command1 | command2
Expand Down
44 changes: 0 additions & 44 deletions tests/test_5stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,50 +713,6 @@ def test_zip_cross(self):
}
""", expected_exception=WDL.Error.EvalError)

def test_sep(self):
outputs = self._test_task(R"""
version development
task SepTest {
input {
Array[String] inp = ["value1", "value2", "value3"]
}
command {}
output {
String out = sep(",", inp)
}
}
""")
self.assertEqual("value1,value2,value3", outputs["out"])

outputs = self._test_task(R"""
version development
task SepTest {
input {
Array[String] inp = ["value1", "value2", "value3"]
}
command <<<
echo ~{sep(",", inp)}
>>>
output {
String out = read_string(stdout())
}
}
""")
self.assertEqual("value1,value2,value3", outputs["out"])

self._test_task(R"""
version development
task SepTest {
input {
Array[String] inp = ["value1", "value2", "value3"]
}
command <<<
echo ~{sep="," inp}
>>>
}
""", expected_exception=WDL.Error.SyntaxError)


def test_suffix(self):
outputs = self._test_task(R"""
Expand Down

0 comments on commit bccb8dc

Please sign in to comment.