Skip to content

Commit

Permalink
feat: Add lua tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Jun 4, 2019
1 parent cfc8b2e commit a4251c3
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
50 changes: 50 additions & 0 deletions test/languages/lua/functions.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ==============================================================================
# Functions without parameters.
# ==============================================================================
Given lua (function without parameters):
function myFunc()
end

Do (trigger doge):
\<C-d>

Expect lua (generated comment with nothing but the text 'TODO'):
-- TODO
function myFunc()
end

# ==============================================================================
# Functions with parameters.
# ==============================================================================
Given lua (function with parameters):
function myFunc(arg1, arg2, arg3, arg4)
end

Do (trigger doge):
\<C-d>

Expect lua (generated comment with @param tags):
-- TODO
-- @param arg1 TODO
-- @param arg2 TODO
-- @param arg3 TODO
-- @param arg4 TODO
function myFunc(arg1, arg2, arg3, arg4)
end

# ==============================================================================
# Functions as a variable value.
# ==============================================================================
Given lua (function as a variable value with parameters):
local myFunc = function(arg1, arg2)
end

Do (trigger doge):
\<C-d>

Expect lua (generated comment with @param tags):
-- TODO
-- @param arg1 TODO
-- @param arg2 TODO
local myFunc = function(arg1, arg2)
end
57 changes: 57 additions & 0 deletions test/languages/lua/object-methods.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# ==============================================================================
# Methods declared with a ':'.
# ==============================================================================
Given lua (method declared with a ':' with parameters):
function a.b:c (arg1, arg2)
end

Do (trigger doge):
\<C-d>

Expect lua (generated comment with @param tags):
-- TODO
-- @param arg1 TODO
-- @param arg2 TODO
function a.b:c (arg1, arg2)
end

# ==============================================================================
# Methods declared with a '.'.
# ==============================================================================
Given lua (method declared with a '.' with parameters):
a.b.c = function (self, arg1, arg2)
end

Do (trigger doge):
\<C-d>

Expect lua (generated comment with @param tags):
-- TODO
-- @param self TODO
-- @param arg1 TODO
-- @param arg2 TODO
a.b.c = function (self, arg1, arg2)
end

# ==============================================================================
# Method calls that should not generate anything.
# ==============================================================================
Given lua (method with parameters called with ':' syntax):
myobj:foo(n)

Do (trigger doge):
\<C-d>

Expect lua (no changes):
myobj:foo(n)

# ------------------------------------------------------------------------------

Given lua (method with parameters called with '.' syntax):
myobj.foo(myobj, n)

Do (trigger doge):
\<C-d>

Expect lua (generated comment with @param tags):
myobj.foo(myobj, n)
2 changes: 1 addition & 1 deletion test/languages/ruby/functions.vader
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Given ruby (function without parameters):
Do (trigger doge):
\<C-d>

Expect ruby (no changes):
Expect ruby (generated comment with nothing but the text 'TODO'):
# TODO
def myFunc()
end
Expand Down

0 comments on commit a4251c3

Please sign in to comment.