elixir-lang/elixir — pull request #941 by yrashk (2013-04-11 14:26:08+00:00)
Title: Improve elixir application doctest coverage

Do not merge until we fix these problems:

```
Failures:

1) test doc at Enum.split_with/2 (49) (KernelTest)
** (ExUnit.ExpectationError)
expected doctest: Enum.split_with [1,2,3,4], fn x -> x == 2 end
to evaluate to: {[1,3,4],[2]}
instead got: {[],[1,2,3,4]}
stacktrace:
lib/enum.ex:811: Enum (module)

2) test doc at OptionParser.parse/2 (5) (KernelTest)
** (ExUnit.ExpectationError)
expected doctest: OptionParser.parse(["--unlock path/to/file"], switches: [unlock: :boolean])
to evaluate to: {[unlock: true],["path/to/file"]}
instead got: {["unlock path/to/file": true, unlock: false],[]}
stacktrace:
lib/option_parser.ex:57: OptionParser (module)

3) test doc at OptionParser.parse/2 (6) (KernelTest)
** (ExUnit.ExpectationError)
expected doctest: OptionParser.parse(["--unlock false path/to/file"], switches: [unlock: :boolean])
to evaluate to: {[unlock: false],["path/to/file"]}
instead got: {["unlock false path/to/file": true, unlock: false],[]}
stacktrace:
lib/option_parser.ex:57: OptionParser (module)

4) test doc at OptionParser.parse/2 (7) (KernelTest)
** (ExUnit.ExpectationError)
expected doctest: OptionParser.parse(["--no-op path/to/file"])
to evaluate to: {[no_op: true],["path/to/file"]}
instead got: {["no_op path/to/file": true],[]}
stacktrace:
lib/option_parser.ex:57: OptionParser (module)

5) test doc at String.split/1 (55) (KernelTest)
** (ExUnit.ExpectationError)
expected doctest: String.split("a,b", %r{.})
to evaluate to: ["a,b"]
instead got: ["","","",""]
stacktrace:
lib/string.ex:184: String (module)

Finished in 0.05 seconds
427 tests, 5 failures
```

The insight on (5) is that it seems to lose the backslash:

```elixir
iex(9)> Macro.to_binary Code.string_to_ast! %b/String.split("a,b", %r{\.})/
"String.split(\"a,b\", __r__(<<\".\">>, []))"
```

The rest is (I hope) self-explanatory. Note about (1): it expects `{[1,3,4],[2]}` as per 1ffda62f2ec478093001dfe8c05b9232d5839466 but I don't understand why. I thought it should be `{[1], [2,3,4]}`