Begin adding tests
parent
49870831ab
commit
ce98193a24
|
@ -7,15 +7,19 @@ function commandBind(ed::Editor, args::String)
|
|||
elseif !( length(arg_arr[1]) == 1 && isalpha(arg_arr[1][1]) )
|
||||
setStatusMessage(ed, "bind: first arg must be a letter")
|
||||
return
|
||||
# elseif !Base.isidentifier(arg_arr[2])
|
||||
# setStatusMessage(ed, "bind: command $(arg_arr[2]) is invalid")
|
||||
# return
|
||||
end
|
||||
|
||||
key = lowercase(arg_arr[1][1])
|
||||
command = join(arg_arr[2])
|
||||
|
||||
# If command is '~', unbind the key
|
||||
if command == "~"
|
||||
rmKeyBinding(key)
|
||||
else
|
||||
setKeyBinding(key, join(arg_arr[2]))
|
||||
end
|
||||
|
||||
setKeyBinding(key, join(arg_arr[2]))
|
||||
end
|
||||
|
||||
addCommand(:bind, commandBind,
|
||||
help="bind <C> <CMD>: bind ctrl-<C> to command <CMD>")
|
||||
help="bind <C> <CMD>: bind ctrl-<C> to command <CMD>. <CMD> = ~, unbind")
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
import Acorn.EditorConfig
|
||||
|
||||
ed = Acorn.Editor()
|
||||
|
||||
Acorn.commandBind(ed, "h help")
|
||||
@test EditorConfig.isKeyBound('h') == true
|
||||
@test EditorConfig.getKeyBinding('h') == "help"
|
||||
|
||||
Acorn.commandBind(ed, "h ~")
|
||||
@test EditorConfig.isKeyBound('h') == false
|
||||
|
||||
EditorConfig.rmKeyBinding('c')
|
||||
Acorn.commandBind(ed, "c")
|
||||
@test EditorConfig.isKeyBound('c') == false
|
||||
|
||||
Acorn.commandBind(ed, "a echo a b c d")
|
||||
@test EditorConfig.isKeyBound('a') == true
|
|
@ -1,5 +1,11 @@
|
|||
using Acorn
|
||||
using Base.Test
|
||||
|
||||
# write your own tests here
|
||||
@test 1 == 2
|
||||
# Tests for commands
|
||||
include("cmds/test_bind.jl")
|
||||
# TODO: include tests for all commands
|
||||
|
||||
# TODO: Include additional tests
|
||||
# rows.jl
|
||||
# editor.jl
|
||||
# EditorCOnfig.jl
|
||||
|
|
Loading…
Reference in New Issue