Skip to content

Commit

Permalink
feat: Add tests for python filetype
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Jun 8, 2019
1 parent d2000be commit f02d075
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 9 deletions.
7 changes: 7 additions & 0 deletions playground/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
to generate the examples below.
"""

def myFunc():
"""
TODO
"""
pass

def myFunc(param1: str = 'string', param2: int = 5):
"""
TODO
Expand Down
18 changes: 9 additions & 9 deletions test/languages/php/class-properties.vader
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Should resolve its corresponding type defined in the constructor.
# ==============================================================================
Given php (class property above the constructor should should resolve its corresponding type via the constructor):
Given php (class properties above and below the constructor should should resolve its corresponding type via the constructor):
use Symfony\Component\HttpFoundation\Response;

class Test {
Expand All @@ -12,14 +12,14 @@ Given php (class property above the constructor should should resolve its corres

protected $migration;

private $response;

public function __construct(string $name, Migration $migration, Response $response) {
$this->migrationName = $name;
$this->migration = $migration;
$this->response = $response;
}

private $response;

}

Do (trigger doge):
Expand All @@ -29,7 +29,7 @@ Do (trigger doge):
\<C-d>
:15\<CR>
\<C-d>
:20\<CR>
:28\<CR>
\<C-d>

Expect php (generated comments at all properties and constructor function):
Expand All @@ -47,11 +47,6 @@ Expect php (generated comments at all properties and constructor function):
*/
protected $migration;

/**
* @var \Symfony\Component\HttpFoundation\Response
*/
private $response;

/**
* TODO
*
Expand All @@ -65,4 +60,9 @@ Expect php (generated comments at all properties and constructor function):
$this->response = $response;
}

/**
* @var \Symfony\Component\HttpFoundation\Response
*/
private $response;

}
75 changes: 75 additions & 0 deletions test/languages/python/class-methods.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# ==============================================================================
# Class method __init__().
# ==============================================================================
Given python (class method __init__() with parameters):
class MyClass(object):

def __init__(self: MyClass):
pass

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

Expect python (generated comment with :param tags):
class MyClass(object):

def __init__(self: MyClass):
"""
TODO

:param self MyClass: TODO
"""
pass
# ==============================================================================
# Class method with advanced type hints.
# ==============================================================================
Given python (class method with advanced type hints):
class MyClass(object):

def myMethod(self: MyClass, param1: Sequence[T]) -> Generator[int, float, str]:
pass

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

Expect python (generated comment with :param tags):
class MyClass(object):

def myMethod(self: MyClass, param1: Sequence[T]) -> Generator[int, float, str]:
"""
TODO

:param self MyClass: TODO
:param param1 Sequence[T]: TODO
:rtype Generator[int, float, str]: TODO
"""
pass

# ==============================================================================
# Class method parameters with *args and **kwargs.
# ==============================================================================
Given python (class method parameters with *args and **kwargs):
class MyClass(object):

def call(self, *args: str, **kwargs: str) -> str:
pass

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

Expect python (generated comment with :param tags):
class MyClass(object):

def call(self, *args: str, **kwargs: str) -> str:
"""
TODO

:param self any: TODO
:param args str: TODO
:param kwargs str: TODO
:rtype str: TODO
"""
pass
94 changes: 94 additions & 0 deletions test/languages/python/functions.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# ==============================================================================
# Functions without parameters.
# ==============================================================================
Given python (function without parameters):
def myFunc():
pass

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

Expect python (no changes):
def myFunc():
"""
TODO

"""
pass

# ==============================================================================
# Functions without type hints.
# ==============================================================================
Given python (function without type hints):
def myFunc(param1 = 'string', param2 = 5, param3, param4):
pass

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

Expect python (generated comment with :param tags):
def myFunc(param1 = 'string', param2 = 5, param3, param4):
"""
TODO

:param param1 any: TODO
:param param2 any: TODO
:param param3 any: TODO
:param param4 any: TODO
"""
pass

# ==============================================================================
# Functions with parameters.
# ==============================================================================
Given python (function with parameters):
def myFunc(param1: str = 'string', param2: int = 5):
pass

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

Expect python (generated comment with :param tags):
def myFunc(param1: str = 'string', param2: int = 5):
"""
TODO

:param param1 str: TODO
:param param2 int: TODO
"""
pass

# ==============================================================================
# Functions with advanced type hint parameters.
# ==============================================================================
Given python (functions with advanced type hint parameters):
def myFunc(param1: Callable[[int], None] = False, param2: Callable[[int, Exception], None] = {}) -> Sequence[T]:
pass

def myFunc(param1: Sequence[T]) -> Generator[int, float, str]:
pass

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

Expect python (generated comments with :param tags):
def myFunc(param1: Callable[[int], None] = False, param2: Callable[[int, Exception], None] = {}) -> Sequence[T]:
"""
TODO

:param param1 Callable[[int], None]: TODO
:param param2 Callable[[int, Exception], None]: TODO
:rtype Sequence[T]: TODO
"""
pass

def myFunc(param1: Sequence[T]) -> Generator[int, float, str]:
"""
TODO

:param param1 Sequence[T]: TODO
:rtype Generator[int, float, str]: TODO
"""
pass

0 comments on commit f02d075

Please sign in to comment.