feat(comment): add comment on on interface method
This commit is contained in:
parent
26207b1928
commit
3cd45c45a3
9 changed files with 91 additions and 13 deletions
6
spec/fixtures/comment/interface_many_method_input.go
vendored
Normal file
6
spec/fixtures/comment/interface_many_method_input.go
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package main
|
||||
|
||||
type Testinger interface {
|
||||
Get(id string) int
|
||||
Set(id string, val int)
|
||||
}
|
||||
7
spec/fixtures/comment/interface_many_method_output.go
vendored
Normal file
7
spec/fixtures/comment/interface_many_method_output.go
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
type Testinger interface {
|
||||
Get(id string) int
|
||||
// Set
|
||||
Set(id string, val int)
|
||||
}
|
||||
5
spec/fixtures/comment/interface_method_input.go
vendored
Normal file
5
spec/fixtures/comment/interface_method_input.go
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package main
|
||||
|
||||
type Testinger interface {
|
||||
Method(input string) error
|
||||
}
|
||||
6
spec/fixtures/comment/interface_method_output.go
vendored
Normal file
6
spec/fixtures/comment/interface_method_output.go
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package main
|
||||
|
||||
type Testinger interface {
|
||||
// Method
|
||||
Method(input string) error
|
||||
}
|
||||
|
|
@ -30,6 +30,14 @@ comment["should add comment to interface"] = function()
|
|||
do_the_test("interface", { 3, 6 })
|
||||
end
|
||||
|
||||
comment["should add comment on interface method"] = function()
|
||||
do_the_test("interface_method", { 4, 2 })
|
||||
end
|
||||
|
||||
comment["should add a comment on interface with many method"] = function()
|
||||
do_the_test("interface_many_method", { 5, 2 })
|
||||
end
|
||||
|
||||
comment["otherwise should add // above cursor"] = function()
|
||||
do_the_test("empty", { 1, 1 })
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,4 +22,28 @@ utils["should .trimend()"] = function()
|
|||
t.eq(u.trimend " hi ", " hi")
|
||||
end
|
||||
|
||||
utils["should add .indent() spaces"] = function()
|
||||
local u = require "gopher._utils"
|
||||
local line = " func Test() error {"
|
||||
local indent = 4
|
||||
|
||||
t.eq(" ", u.indent(line, indent))
|
||||
end
|
||||
|
||||
utils["should add .indent() a tab"] = function()
|
||||
local u = require "gopher._utils"
|
||||
local line = "\tfunc Test() error {"
|
||||
local indent = 1
|
||||
|
||||
t.eq("\t", u.indent(line, indent))
|
||||
end
|
||||
|
||||
utils["should add .indent() 2 tabs"] = function()
|
||||
local u = require "gopher._utils"
|
||||
local line = "\t\tfunc Test() error {"
|
||||
local indent = 2
|
||||
|
||||
t.eq("\t\t", u.indent(line, indent))
|
||||
end
|
||||
|
||||
return T
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue