Repository navigation
Expand file tree
/
Copy pathjavascript.py
More file actions
132 lines (113 loc) · 2.77 KB
/
Copy pathjavascript.py
File metadata and controls
132 lines (113 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
syntax = "Packages/JavaScript/JavaScript.tmLanguage"
def test_basic_block_opening(helper):
"Test that empty doc blocks are created"
helper.insert('/**')
helper.run()
return [
"/**",
" * |",
" */"
]
def test_basic_function(helper):
"Test that function template is added"
helper.insert('/**|\nfunction foo () {')
helper.run()
return [
'/**',
' * |[foo description]|',
' * @return {[type]}',
' */',
'function foo () {'
]
def test_parameters(helper):
"Parameters are added to function templates"
helper.insert('/**|\nfunction foo (bar, baz) {')
helper.run()
return [
'/**',
' * |[foo description]|',
' * @param {[type]} bar [description]',
' * @param {[type]} baz [description]',
' * @return {[type]}',
' */',
'function foo (bar, baz) {'
]
def test_multi_line_parameters(helper):
"Parameters across multiple lines should be identified"
helper.insert([
'/**|',
'function foo(bar,',
' baz,',
' quux',
' ) {'
])
helper.run()
return [
'/**',
' * |[foo description]|',
' * @param {[type]} bar [description]',
' * @param {[type]} baz [description]',
' * @param {[type]} quux [description]',
' * @return {[type]}',
' */',
'function foo(bar,',
' baz,',
' quux',
' ) {'
]
def test_vars_number(helper):
"Variables initialised to number get placeholders"
helper.insert([
'/**|',
'var foo = 1;'
])
helper.run()
return [
'/**',
' * |[foo description]|',
' * @type {Number}',
' */',
'var foo = 1;'
]
def test_vars_string_double_quotes(helper):
"Variables initialised to string get placeholders"
helper.insert([
'/**|',
'var foo = "a";'
])
helper.run()
return [
'/**',
' * |[foo description]|',
' * @type {String}',
' */',
'var foo = "a";'
]
def test_vars_string_single_quotes(helper):
"Variables initialised to string get placeholders"
helper.insert([
'/**|',
'var foo = \'a\';'
])
helper.run()
return [
'/**',
' * |[foo description]|',
' * @type {String}',
' */',
'var foo = \'a\';'
]
def test_vars_unknown_type(helper):
"Variables initialised to unknown variables get placeholders"
helper.insert([
'/**|',
'var foo = bar;'
])
helper.run()
return [
'/**',
' * |[foo description]|',
' * @type {[type]}',
' */',
'var foo = bar;'
]