aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYonatan Goldschmidt2019-12-14 23:42:03 +0200
committerDamien George2020-01-12 13:09:27 +1100
commit853aaa06f24c98191a44a38eedd4ec2a0e63d3eb (patch)
tree8ea2c47102ae540789b481f665518d898f79c61b /tests
parentdce590c29dbefea253f4034c4bde3508f205364e (diff)
lib/mp-readline: Add word-based move/delete EMACS key sequences.
This commit adds backward-word, backward-kill-word, forward-word, forward-kill-word sequences for the REPL, with bindings to Alt+F, Alt+B, Alt+D and Alt+Backspace respectively. It is disabled by default and can be enabled via MICROPY_REPL_EMACS_WORDS_MOVE. Further enabling MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE adds extra bindings for these new sequences: Ctrl+Right, Ctrl+Left and Ctrl+W. The features are enabled on unix micropython-coverage and micropython-dev.
Diffstat (limited to 'tests')
-rw-r--r--tests/cmdline/repl_words_move.py31
-rw-r--r--tests/cmdline/repl_words_move.py.exp47
-rw-r--r--tests/feature_check/repl_words_move_check.py4
-rw-r--r--tests/feature_check/repl_words_move_check.py.exp7
-rwxr-xr-xtests/run-tests7
5 files changed, 95 insertions, 1 deletions
diff --git a/tests/cmdline/repl_words_move.py b/tests/cmdline/repl_words_move.py
new file mode 100644
index 000000000..e1eb52953
--- /dev/null
+++ b/tests/cmdline/repl_words_move.py
@@ -0,0 +1,31 @@
+# word movement
+# backward-word, start in word
+234b1
+# backward-word, don't start in word
+234 b1
+# backward-word on start of line. if cursor is moved, this will result in a SyntaxError
+1 2 + 3b+
+# forward-word, start in word
+1+2 12+f+3
+# forward-word, don't start in word
+1+ 12 3f+
+# forward-word on eol. if cursor is moved, this will result in a SyntaxError
+1 + 2 3f+
+
+# kill word
+# backward-kill-word, start in word
+100 + 45623
+# backward-kill-word, don't start in word
+100 + 456231
+# forward-kill-word, start in word
+100 + 256d3
+# forward-kill-word, don't start in word
+1 + 256d2
+
+# extra move/kill shortcuts
+# ctrl-left
+2341
+# ctrl-right
+123
+# ctrl-w
+1231
diff --git a/tests/cmdline/repl_words_move.py.exp b/tests/cmdline/repl_words_move.py.exp
new file mode 100644
index 000000000..86f6b7788
--- /dev/null
+++ b/tests/cmdline/repl_words_move.py.exp
@@ -0,0 +1,47 @@
+MicroPython \.\+ version
+Use \.\+
+>>> # word movement
+>>> # backward-word, start in word
+>>> \.\+
+1234
+>>> # backward-word, don't start in word
+>>> \.\+
+1234
+>>> # backward-word on start of line. if cursor is moved, this will result in a SyntaxError
+>>> \.\+
+6
+>>> # forward-word, start in word
+>>> \.\+
+18
+>>> # forward-word, don't start in word
+>>> \.\+
+16
+>>> # forward-word on eol. if cursor is moved, this will result in a SyntaxError
+>>> \.\+
+6
+>>>
+>>> # kill word
+>>> # backward-kill-word, start in word
+>>> \.\+
+123
+>>> # backward-kill-word, don't start in word
+>>> \.\+
+101
+>>> # forward-kill-word, start in word
+>>> \.\+
+123
+>>> # forward-kill-word, don't start in word
+>>> \.\+
+3
+>>>
+>>> # extra move/kill shortcuts
+>>> # ctrl-left
+>>> \.\+
+1234
+>>> # ctrl-right
+>>> \.\+
+123
+>>> # ctrl-w
+>>> \.\+
+1
+>>>
diff --git a/tests/feature_check/repl_words_move_check.py b/tests/feature_check/repl_words_move_check.py
new file mode 100644
index 000000000..e74615e98
--- /dev/null
+++ b/tests/feature_check/repl_words_move_check.py
@@ -0,0 +1,4 @@
+# just check if ctrl+w is supported, because it makes sure that
+# both MICROPY_REPL_EMACS_WORDS_MOVE and MICROPY_REPL_EXTRA_WORDS_MOVE are enabled.
+t = 1231
+t == 1
diff --git a/tests/feature_check/repl_words_move_check.py.exp b/tests/feature_check/repl_words_move_check.py.exp
new file mode 100644
index 000000000..82a4e28ee
--- /dev/null
+++ b/tests/feature_check/repl_words_move_check.py.exp
@@ -0,0 +1,7 @@
+MicroPython \.\+ version
+Use \.\+
+>>> # Check for emacs keys in REPL
+>>> t = \.\+
+>>> t == 2
+True
+>>>
diff --git a/tests/run-tests b/tests/run-tests
index b02463dc3..b8f5b6b7a 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -284,9 +284,14 @@ def run_tests(pyb, tests, args, base_path="."):
# Check if emacs repl is supported, and skip such tests if it's not
t = run_feature_check(pyb, args, base_path, 'repl_emacs_check.py')
- if not 'True' in str(t, 'ascii'):
+ if 'True' not in str(t, 'ascii'):
skip_tests.add('cmdline/repl_emacs_keys.py')
+ # Check if words movement in repl is supported, and skip such tests if it's not
+ t = run_feature_check(pyb, args, base_path, 'repl_words_move_check.py')
+ if 'True' not in str(t, 'ascii'):
+ skip_tests.add('cmdline/repl_words_move.py')
+
upy_byteorder = run_feature_check(pyb, args, base_path, 'byteorder.py')
upy_float_precision = run_feature_check(pyb, args, base_path, 'float.py')
if upy_float_precision == b'CRASH':