Skip to content

Commit

Permalink
fixed repl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wildart authored and jakebolewski committed Sep 29, 2015
1 parent 50b81f6 commit c9fcd0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ build_script:
test_script:
- usr\bin\julia -e "versioninfo()"
- copy usr\lib\julia\sys.ji local.ji && usr\bin\julia -J local.ji -e "true" && del local.ji
- cd test && ..\usr\bin\julia runtests.jl all
- cd test && ..\usr\bin\julia runtests.jl libgit2 repl pkg
24 changes: 19 additions & 5 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ fakehistory = """
\tls
# time: 2014-06-30 20:44:29 EDT
# mode: julia
\t2 + 2"""
\t2 + 2
# time: 2014-06-30 20:44:29 EDT
# mode: git
\tinit"""

# Test various history related issues
begin
Expand All @@ -211,24 +214,29 @@ begin
repl_mode = repl.interface.modes[1]
shell_mode = repl.interface.modes[2]
help_mode = repl.interface.modes[3]
histp = repl.interface.modes[4]
prefix_mode = repl.interface.modes[5]
git_mode = repl.interface.modes[4]
histp = repl.interface.modes[5]
prefix_mode = repl.interface.modes[6]

hp = REPL.REPLHistoryProvider(Dict{Symbol,Any}(:julia => repl_mode,
:shell => shell_mode,
:help => help_mode))
:help => help_mode,
:git => git_mode))

REPL.hist_from_file(hp, IOBuffer(fakehistory))
REPL.history_reset_state(hp)

histp.hp = repl_mode.hist = shell_mode.hist = help_mode.hist = hp
histp.hp = repl_mode.hist = shell_mode.hist = help_mode.hist = git_mode.hist = hp

# Some manual setup
s = LineEdit.init_state(repl.t, repl.interface)

# Test that navigating history skips invalid modes
# (in both directions)
LineEdit.history_prev(s, hp)
@test LineEdit.mode(s) == git_mode
@test buffercontents(LineEdit.buffer(s)) == "init"
LineEdit.history_prev(s, hp)
@test LineEdit.mode(s) == repl_mode
@test buffercontents(LineEdit.buffer(s)) == "2 + 2"
LineEdit.history_prev(s, hp)
Expand All @@ -244,10 +252,16 @@ begin
@test LineEdit.mode(s) == repl_mode
@test buffercontents(LineEdit.buffer(s)) == "2 + 2"
LineEdit.history_next(s, hp)
@test LineEdit.mode(s) == git_mode
@test buffercontents(LineEdit.buffer(s)) == "init"
LineEdit.history_next(s, hp)

# Test that the same holds for prefix search
ps = LineEdit.state(s, prefix_mode)
LineEdit.history_prev_prefix(ps, hp, "")
@test ps.parent == git_mode
@test LineEdit.input_string(ps) == "init"
LineEdit.history_prev_prefix(ps, hp, "")
@test ps.parent == repl_mode
@test LineEdit.input_string(ps) == "2 + 2"
LineEdit.history_prev_prefix(ps, hp, "")
Expand Down

0 comments on commit c9fcd0b

Please sign in to comment.