-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] port tests to run completely in vim #582
Draft
jbodah
wants to merge
2
commits into
master
Choose a base branch
from
vimtest-indent
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /usr/bin/env sh | ||
set +xe | ||
vim -c ":so test.vim" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
" TODO: @jbodah 2024-09-17: setup path to lookup local git plugin | ||
|
||
let s:results = [] | ||
|
||
func s:assert_equal(testcase, expected, actual) | ||
if (a:actual == a:expected) == 1 | ||
" let s:results = s:results + [printf("PASS %s", a:testcase['name'])] | ||
else | ||
let s:results = s:results + [printf("FAIL %s\nwant\n%s\ngot\n\%s\n", a:testcase['name'], a:expected, a:actual)] | ||
end | ||
endfunction | ||
|
||
func s:paste(text) | ||
let @p = a:text | ||
normal V"pP | ||
call setreg("p", []) | ||
endfunction | ||
|
||
func s:copy_buffer() | ||
normal ggVG"yy | ||
let l:copied = @y | ||
call setreg("y", []) | ||
return l:copied | ||
endfunction | ||
|
||
func s:clear_buffer() | ||
normal ggVGD | ||
endfunction | ||
|
||
func s:indent_buffer() | ||
normal ggVG= | ||
endfunction | ||
|
||
func s:load_file(name) | ||
return join(readfile(a:name), "\n") | ||
endfunction | ||
|
||
let s:testcases = map(readdir("vimtest/indent"), {_, val -> {'name': "vimtest/indent/" . val, 'expected': s:load_file("vimtest/indent/" . val)}}) | ||
" Pin a test by uncommenting the following: | ||
" let s:testcases = [ | ||
" \ {'name': "vimtest/indent/indent110.ex", 'expected': s:load_file("vimtest/indent/indent110.ex")} | ||
" \ ] | ||
|
||
function s:test_indent(testcase) | ||
set ft=elixir | ||
call s:paste(a:testcase['expected']) | ||
let s:expected = s:copy_buffer() | ||
|
||
call s:indent_buffer() | ||
let s:actual = s:copy_buffer() | ||
|
||
call s:assert_equal(a:testcase, s:expected, s:actual) | ||
endfunction | ||
|
||
function s:paste_results() | ||
set ft=none | ||
call s:paste(join(s:results, "")) | ||
endfunction | ||
|
||
for tc in s:testcases | ||
call s:test_indent(tc) | ||
call s:clear_buffer() | ||
endfor | ||
call s:paste_results() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def do | ||
some_func = fn x -> x end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def do | ||
some_func = function do x -> x end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
defmodule Hello do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule Test do | ||
def lol do | ||
IO.inspect :end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
defmodule Hello do | ||
def name, do: IO.puts "bobmarley" | ||
# expect next line starting here | ||
|
||
def name(param) do | ||
param | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule Hello do | ||
def name, do: IO.puts "bobmarley" | ||
|
||
def name(param) do | ||
param | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def f do | ||
if true, do: 42 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def f do | ||
x = :do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule Test do | ||
def test do | ||
one = | ||
user | ||
|> build_assoc(:videos) | ||
|> Video.changeset() | ||
|
||
other = | ||
user2 | ||
|> build_assoc(:videos) | ||
|> Video.changeset() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
defmodule MyMod do | ||
def how_are_you do | ||
IO.puts "I'm filling bad :(" | ||
IO.puts "really bad" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule MyMod do | ||
def how_are_you do | ||
"function return" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
scope "/", API do | ||
pipe_through :api # Use the default browser stack | ||
|
||
get "/url", Controller, :index | ||
post "/url", Controller, :create | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def hello do | ||
{:ok, _} = TaskRunner.TaskStore.start_link(name: @task_store) | ||
{:ok, _} = Workspace.start_link | ||
{:ok, pending_task_sup} = TaskRunner.PendingTaskSupervisor.start_link | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
defmodule Hello do | ||
def some_func do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def handle_info(:tick, state = %{policy_iteration: []}) do | ||
state = put_in(state[:policy_iteration], state.policy) | ||
{:noreply, state} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
case some_function do | ||
:ok -> | ||
:ok | ||
{ :error, :message } -> | ||
{ :error, :message } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
case Connection.open(rabbitmq) do | ||
{:ok, conn} -> | ||
Woody.info "CONNECTION_SUCCESSFUL" | ||
{:ok, chan} = Channel.open(conn) | ||
{:error, error} -> | ||
Woody.info "CONNECTION_FAILED" | ||
:timer.sleep(10000) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
defmodule M do | ||
defp _fetch(result, key, deep_key) do | ||
case _fetch(result, key) do | ||
{:ok, val} -> | ||
case _fetch(val, deep_key) do | ||
:error -> {:error, :deep} | ||
res -> res | ||
end | ||
|
||
:error -> {:error, :shallow} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
case Connection.open(rabbitmq) do | ||
{:ok, conn} -> | ||
Woody.info "CONNECTION_SUCCESSFUL" | ||
{:ok, chan} = Channel.open(conn) | ||
{:error, error} -> | ||
Woody.info "CONNECTION_FAILED" | ||
:timer.sleep(10000) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
decoded_msg = case JSON.decode(msg) do | ||
{:error, _} -> | ||
a = "a" | ||
b = "dasdas" | ||
">#{a}<>#{b}<" | ||
{:ok, decoded} -> decoded | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
case Repo.insert(changeset) do | ||
{:ok, user} -> | ||
conn | ||
|> put_flash(:info, "%{user.name} created!") | ||
|> redirect(to: user_path(conn, :index)) | ||
{:error, changeset} -> | ||
render(conn, "new.html", changeset: changeset) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
case st do | ||
sym -> | ||
code = if true do | ||
:ok | ||
else | ||
:error | ||
end | ||
Logger.info(code) | ||
st | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
case world do | ||
"apple" -> | ||
IO.puts "its an apple" | ||
|
||
IO.puts "no really, its an apple" | ||
"orange" -> | ||
IO.puts "its not an apple" | ||
IO.puts "believe it or not" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
case o do | ||
a -> | ||
e(fn -> f end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
defmodule Hello do | ||
def some_func do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
case pattern do | ||
:* -> :ok | ||
_ -> :error | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# do | ||
IO.puts :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
defmodule Foo do | ||
def run do | ||
list = | ||
File.read!("/path/to/file") | ||
|> String.split() | ||
# now start a new line | ||
# used to start here | ||
# but now starts here | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
defmodule Foo do | ||
def run(task) when task in [:t1, :t2] do | ||
end | ||
|
||
# now starts a new line | ||
# use to start here | ||
# but now starts here | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
receive do | ||
{{:lock_ready, ^key}, ^pid} -> | ||
after | ||
# NOTE: @jbodah 2017-03-28: we should do some math to adjust the timeout | ||
timeout -> | ||
{:error, :timed_out_waiting_for_lock} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cond do | ||
foo -> 1 | ||
bar -> 2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def handle_call({:release_lock, key}, _from, state) do | ||
case get_lock(state, key) do | ||
nil -> | ||
{:reply, {:error, :already_unlocked}, state} | ||
|
||
_ -> | ||
new_state = delete_lock(state, key) | ||
{:reply, :ok, new_state} | ||
end | ||
end | ||
|
||
def |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
defmodule Hello do | ||
def hello do | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
def world do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule Test do | ||
@doc """ | ||
end | ||
""" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
defmodule Test do | ||
@doc """ | ||
it should | ||
have reasonable | ||
default start indent when typed | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
defmodule Hello do | ||
def some_func do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule New do | ||
def do_query do | ||
from user in Users, | ||
select: user.name, | ||
join: signup in Signups, where: user.id == signup.user_id | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def smth do | ||
from = 1 | ||
to = 7 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fromin, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
query = from u in query, select: u.city |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def do_query do | ||
where = [category: "fresh and new"] | ||
order_by = [desc: :published_at] | ||
select = [:id, :title, :body] | ||
from Post, where: ^where, order_by: ^order_by, select: ^select | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def alphabetical(query) do | ||
from c in query, order_by: c.name | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to initialize with clean vimrc