Skip to content

Commit

Permalink
accept for, case and quote expressions after version 1.13.0 or …
Browse files Browse the repository at this point in the history
…later

for

```
     left:  "for(x <- enum) do\n  x * 2\nend == [2, 4, 6]\n|\n[2, 4, 8]\n\nonly in lhs: '\\b'\nonly in rhs: [6]"
     right: "for x <- enum do\n  x * 2\nend == [2, 4, 6]\n|\n[2, 4, 8]\n\nonly in lhs: '\\b'\nonly in rhs: [6]"
```

case

```
     left:  "case x do\n  {:ok, right} ->\n    right\n  {_left, right} ->\n    case right do\n      {:ok, right} ->\n        right\n    end\nend == :doing\n|\n:done"
     right: "case x do\n  {:ok, right} ->\n    right\n\n  {_left, right} ->\n    case right do\n      {:ok, right} -> right\n    end\nend == :doing\n|\n:done"
```

quote

```
     left:  "quote(@opts) do\n  :hoge\nend == :fuga\n|\n:hoge"
     right: "quote @opts do\n  :hoge\nend == :fuga\n|\n:hoge"
```
  • Loading branch information
ma2gedev committed Jan 8, 2022
1 parent 2cec988 commit 90affb8
Showing 1 changed file with 66 additions and 30 deletions.
96 changes: 66 additions & 30 deletions test/power_assert_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -988,13 +988,22 @@ defmodule PowerAssertAssertionTest do

@opts [context: Elixir]
test "quote expr not supported" do
expect = """
quote(@opts) do
:hoge
end == :fuga
|
:hoge
"""
expect = expectation_by_version("1.13.0", %{
earlier: """
quote(@opts) do
:hoge
end == :fuga
|
:hoge
""",
later: """
quote @opts do
:hoge
end == :fuga
|
:hoge
"""
})
assert_helper(expect, fn () ->
Assertion.assert quote(@opts, do: :hoge) == :fuga
end)
Expand Down Expand Up @@ -1060,16 +1069,28 @@ defmodule PowerAssertAssertionTest do
end

test "for expr not supported" do
expect = """
for(x <- enum) do
x * 2
end == [2, 4, 6]
|
[2, 4, 8]
only in lhs: '\\b'
only in rhs: [6]
"""
expect = expectation_by_version("1.13.0", %{
earlier: """
for(x <- enum) do
x * 2
end == [2, 4, 6]
|
[2, 4, 8]
only in lhs: '\\b'
only in rhs: [6]
""",
later: """
for x <- enum do
x * 2
end == [2, 4, 6]
|
[2, 4, 8]
only in lhs: '\\b'
only in rhs: [6]
"""
})
assert_helper(expect, fn () ->
enum = [1,2,4]
Assertion.assert for(x <- enum, do: x * 2) == [2, 4, 6]
Expand All @@ -1093,19 +1114,34 @@ defmodule PowerAssertAssertionTest do
end

test "case expr not supported" do
expect = """
case(x) do
{:ok, right} ->
right
{_left, right} ->
case(right) do
{:ok, right} ->
right
end
end == :doing
|
:done
"""
expect = expectation_by_version("1.13.0", %{
earlier: """
case(x) do
{:ok, right} ->
right
{_left, right} ->
case(right) do
{:ok, right} ->
right
end
end == :doing
|
:done
""",
later: """
case x do
{:ok, right} ->
right
{_left, right} ->
case right do
{:ok, right} -> right
end
end == :doing
|
:done
"""
})
assert_helper(expect, fn () ->
x = {:error, {:ok, :done}}
Assertion.assert (case x do
Expand Down

0 comments on commit 90affb8

Please sign in to comment.