1
0
Fork 0
mirror of synced 2024-06-29 20:11:09 -04:00
ultimate-vim/sources_non_forked/vim-elixir/spec/indent/anonymous_functions_spec.rb
2022-05-19 01:31:41 +08:00

90 lines
1.3 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe 'Indenting anonymous functions' do
i <<~EOF
def do
some_func = fn x -> x end
end
EOF
i <<~EOF
def do
some_func = function do x -> x end
end
EOF
i <<~EOF
def test do
assert_raise Queue.Empty, fn ->
Q.new |> Q.deq!
end
end
EOF
i <<~EOF
defmodule Test do
def lol do
Enum.map([1,2,3], fn x ->
x * 3
end)
end
end
EOF
i <<~EOF
fizzbuzz = fn
0, 0, _ -> "FizzBuzz"
0, _, _ -> "Fizz"
_, 0, _ -> "Buzz"
_, _, x -> x
end
EOF
i <<~EOF
fizzbuzz = function do
0, 0, _ -> "FizzBuzz"
0, _, _ -> "Fizz"
_, 0, _ -> "Buzz"
_, _, x -> x
end
EOF
i <<~EOF
{:ok, 0} = Mod.exec!(cmd, fn progress ->
if event_handler do
event_handler.({:progress_updated, progress})
end
end
)
EOF
i <<~EOF
defp handle_chunk(:err, line, state) do
update_in(state[:stderr], fn
true -> true
false -> false
end)
Map.update(state, :stderr, [line], &(&1 ++ [line]))
end
EOF
i <<~EOF
defp handle_chunk(:err, line, state) do
update_in(state[:stderr], fn
hello -> :ok
world -> :ok
end)
Map.update(state, :stderr, [line], &(&1 ++ [line]))
end
EOF
i <<~EOF
fn ->
end
EOF
end