Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-rust-mirrors-rustyline
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-rust-mirrors-rustyline
Commits
7de3709f
Commit
7de3709f
authored
6 years ago
by
gwenn
Browse files
Options
Downloads
Patches
Plain Diff
Tests: vi command mode with common keys
parent
bea8644b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/common.rs
+138
-0
138 additions, 0 deletions
src/test/common.rs
with
138 additions
and
0 deletions
src/test/common.rs
+
138
−
0
View file @
7de3709f
...
...
@@ -19,6 +19,15 @@ fn home_key() {
&
[
KeyPress
::
Home
,
KeyPress
::
Enter
],
(
""
,
"Hi"
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
"Hi"
,
""
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Home
,
KeyPress
::
Enter
],
(
""
,
"Hi"
),
);
}
}
}
...
...
@@ -38,6 +47,15 @@ fn end_key() {
&
[
KeyPress
::
End
,
KeyPress
::
Enter
],
(
"Hi"
,
""
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
""
,
"Hi"
),
&
[
KeyPress
::
Esc
,
KeyPress
::
End
,
KeyPress
::
Enter
],
(
"Hi"
,
""
),
);
}
}
}
...
...
@@ -62,6 +80,15 @@ fn left_key() {
&
[
KeyPress
::
Left
,
KeyPress
::
Enter
],
(
""
,
"Hi"
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
"Bye"
,
""
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Left
,
KeyPress
::
Enter
],
(
"B"
,
"ye"
),
);
}
}
}
...
...
@@ -92,6 +119,15 @@ fn right_key() {
&
[
KeyPress
::
Right
,
KeyPress
::
Enter
],
(
"Hi"
,
""
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
""
,
"Hi"
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Right
,
KeyPress
::
Enter
],
(
"H"
,
"i"
),
);
}
}
}
...
...
@@ -103,6 +139,18 @@ fn enter_key() {
assert_line_with_initial
(
*
mode
,
(
"Hi"
,
""
),
&
[
KeyPress
::
Enter
],
"Hi"
);
assert_line_with_initial
(
*
mode
,
(
""
,
"Hi"
),
&
[
KeyPress
::
Enter
],
"Hi"
);
assert_line_with_initial
(
*
mode
,
(
"H"
,
"i"
),
&
[
KeyPress
::
Enter
],
"Hi"
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_line
(
*
mode
,
&
[
KeyPress
::
Esc
,
KeyPress
::
Enter
],
""
);
assert_line
(
*
mode
,
&
[
KeyPress
::
Char
(
'a'
),
KeyPress
::
Esc
,
KeyPress
::
Enter
],
"a"
,
);
assert_line_with_initial
(
*
mode
,
(
"Hi"
,
""
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Enter
],
"Hi"
);
assert_line_with_initial
(
*
mode
,
(
""
,
"Hi"
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Enter
],
"Hi"
);
assert_line_with_initial
(
*
mode
,
(
"H"
,
"i"
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Enter
],
"Hi"
);
}
}
}
...
...
@@ -111,6 +159,15 @@ fn newline_key() {
for
mode
in
&
[
EditMode
::
Emacs
,
EditMode
::
Vi
]
{
assert_line
(
*
mode
,
&
[
KeyPress
::
Ctrl
(
'J'
)],
""
);
assert_line
(
*
mode
,
&
[
KeyPress
::
Char
(
'a'
),
KeyPress
::
Ctrl
(
'J'
)],
"a"
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_line
(
*
mode
,
&
[
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'J'
)],
""
);
assert_line
(
*
mode
,
&
[
KeyPress
::
Char
(
'a'
),
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'J'
)],
"a"
,
);
}
}
}
...
...
@@ -131,6 +188,11 @@ fn eof_key() {
&
[
KeyPress
::
Char
(
'a'
),
KeyPress
::
Ctrl
(
'D'
)],
"a"
,
);
assert_line
(
EditMode
::
Vi
,
&
[
KeyPress
::
Char
(
'a'
),
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'D'
)],
"a"
,
);
assert_line_with_initial
(
EditMode
::
Emacs
,
(
""
,
"Hi"
),
...
...
@@ -138,6 +200,12 @@ fn eof_key() {
"i"
,
);
assert_line_with_initial
(
EditMode
::
Vi
,
(
""
,
"Hi"
),
&
[
KeyPress
::
Ctrl
(
'D'
)],
"Hi"
);
assert_line_with_initial
(
EditMode
::
Vi
,
(
""
,
"Hi"
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'D'
)],
"Hi"
,
);
}
#[test]
...
...
@@ -150,6 +218,12 @@ fn interrupt_key() {
let
mut
editor
=
init_editor
(
*
mode
,
&
[
KeyPress
::
Ctrl
(
'C'
)]);
let
err
=
editor
.readline_with_initial
(
">>"
,
(
"Hi"
,
""
));
assert_matches!
(
err
,
Err
(
ReadlineError
::
Interrupted
));
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
let
mut
editor
=
init_editor
(
*
mode
,
&
[
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'C'
)]);
let
err
=
editor
.readline_with_initial
(
">>"
,
(
"Hi"
,
""
));
assert_matches!
(
err
,
Err
(
ReadlineError
::
Interrupted
));
}
}
}
...
...
@@ -168,6 +242,15 @@ fn delete_key() {
&
[
KeyPress
::
Delete
,
KeyPress
::
Enter
],
(
""
,
""
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
""
,
"a"
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Delete
,
KeyPress
::
Enter
],
(
""
,
""
),
);
}
}
}
...
...
@@ -186,6 +269,15 @@ fn ctrl_t() {
&
[
KeyPress
::
Ctrl
(
'T'
),
KeyPress
::
Enter
],
(
"acb"
,
"d"
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
"ab"
,
""
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'T'
),
KeyPress
::
Enter
],
(
"ba"
,
""
),
);
}
}
}
...
...
@@ -204,6 +296,15 @@ fn ctrl_u() {
&
[
KeyPress
::
Ctrl
(
'U'
),
KeyPress
::
Enter
],
(
""
,
"end"
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
"start of line "
,
"end"
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'U'
),
KeyPress
::
Enter
],
(
""
,
" end"
),
);
}
}
}
...
...
@@ -216,6 +317,20 @@ fn ctrl_v() {
&
[
KeyPress
::
Ctrl
(
'V'
),
KeyPress
::
Char
(
'\t'
),
KeyPress
::
Enter
],
(
"
\t
"
,
""
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
""
,
""
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'V'
),
KeyPress
::
Char
(
'\t'
),
KeyPress
::
Enter
,
],
(
"
\t
"
,
""
),
);
}
}
}
...
...
@@ -234,6 +349,15 @@ fn ctrl_w() {
&
[
KeyPress
::
Ctrl
(
'W'
),
KeyPress
::
Enter
],
(
"Hello, "
,
""
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
"Hello, world."
,
""
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'W'
),
KeyPress
::
Enter
],
(
"Hello, "
,
"."
),
);
}
}
}
...
...
@@ -258,5 +382,19 @@ fn ctrl__() {
&
[
KeyPress
::
Ctrl
(
'W'
),
KeyPress
::
Ctrl
(
'_'
),
KeyPress
::
Enter
],
(
"Hello, "
,
"world"
),
);
if
*
mode
==
EditMode
::
Vi
{
// vi command mode
assert_cursor
(
*
mode
,
(
"Hello, "
,
"world"
),
&
[
KeyPress
::
Esc
,
KeyPress
::
Ctrl
(
'W'
),
KeyPress
::
Ctrl
(
'_'
),
KeyPress
::
Enter
,
],
(
"Hello,"
,
" world"
),
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment