#! /usr/bin/python3 import pexpect import unittest import re import os import subprocess import signal import time keytab = { "": "\033[1~", "": "\033[1;2H", "": "\033[1;5H", "": "\033[4~", "": "\033[1;2F", "": "\033[1;5F", "": "\033[2~", "": "\033[2;2~", "": "\033[2;5~", "": "\033[3~", "": "\033[3;2~", "": "\033[3;5~", "": "\033[5~", "": "\033[5;5~", "": "\033[6~", "": "\033[6;5~", "": "", "": "\t", "": "\r", "": chr( 10 ), "": "\n", "": "\033[D", "": "\033[1;2D", "": "\033OD", "": "\033[C", "": "\033[1;2C", "": "\033OC", "": "\033[A", "": "\033[1;2A", "": "\033OA", "": "\033[B", "": "\033[1;2B", "": "\033OB", "": "\033[1;5D", "": "\033[1;5C", "": "\033[1;5A", "": "\033[1;5B", "": "\033[1;3D", "": "\033[1;3C", "": "\033[1;3A", "": "\033[1;3B", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": " ", "": " ", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": "\033b", "": "\033B", "": "\033c", "": "\033C", "": "\033d", "": "\033D", "": "\033f", "": "\033F", "": "\033g", "": "\033l", "": "\033L", "": "\033n", "": "\033p", "": "\033r", "": "\033u", "": "\033U", "": "\033w", "": "\033y", "": "\033.", "": "\033\177", "": "\033OP", "": "\033OQ", "": "\033OR", "": "\033OS", "": "\033[15~", "": "\033[17~", "": "\033[18~", "": "\033[19~", "": "\033[20~", "": "\033[21~", "": "\033[23~", "": "\033[24~", "": "\033[1;2P", "": "\033[1;2Q", "": "\033[1;2R", "": "\033[1;2S", "": "\033[15;2~", "": "\033[17;2~", "": "\033[18;2~", "": "\033[19;2~", "": "\033[20;2~", "": "\033[21;2~", "": "\033[23;2~", "": "\033[24;2~", "": "\033[1;5P", "": "\033[1;5Q", "": "\033[1;5R", "": "\033[1;5S", "": "\033[15;5~", "": "\033[17;5~", "": "\033[18;5~", "": "\033[19;5~", "": "\033[20;5~", "": "\033[21;5~", "": "\033[23;5~", "": "\033[24;5~", "": "\033[Z", "": "\033[200~", "": "\033[201~" } termseq = { "\x1bc": "", "\x1b[0m": "", "\x1b[H": "", "\x1b[2J": "", "\x1b[J": "", "\x1b[0;22;30m": "", "\x1b[0;22;31m": "", "\x1b[0;22;32m": "", "\x1b[0;22;33m": "", "\x1b[0;22;34m": "", "\x1b[0;22;35m": "", "\x1b[0;22;36m": "", "\x1b[0;22;37m": "", "\x1b[0;1;30m": "", "\x1b[0;1;31m": "", "\x1b[0;1;32m": "", "\x1b[0;1;33m": "", "\x1b[0;1;34m": "", "\x1b[0;1;35m": "", "\x1b[0;1;36m": "", "\x1b[0;1;37m": "", "\x1b[0;1m": "", "\x1b[0;4m": "", "\x1b[0;4;1m": "", "\x1b[0;22;31;1m": "", "\x1b[0;22;31;4m": "", "\x1b[0;1;31;1m": "", "\x1b[0;22;31;4;1m": "", "\x1b[40m": "", "\x1b[41m": "", "\x1b[42m": "", "\x1b[43m": "", "\x1b[44m": "", "\x1b[45m": "", "\x1b[46m": "", "\x1b[47m": "", "\x1b[100m": "", "\x1b[101m": "", "\x1b[102m": "", "\x1b[103m": "", "\x1b[104m": "", "\x1b[105m": "", "\x1b[106m": "", "\x1b[107m": "", "\x1b[1;32m": "", "\x07": "", "\x1b[2~": "", "\x1b[?2004h": "", "\x1b[?2004l": "" } colRe = re.compile( "\\x1b\\[(\\d+)G" ) upRe = re.compile( "\\x1b\\[(\\d+)A" ) downRe = re.compile( "\\x1b\\[(\\d+)B" ) colorRe = re.compile( "\\x1b\\[0;38;5;(\\d+)m" ) bgcolorRe = re.compile( "\\x1b\\[48;5;(\\d+)m" ) def sym_to_raw( str_ ): for sym, seq in keytab.items(): if isinstance( str_, Rapid ): str_ = Rapid( str_.replace( sym, seq ) ) else: str_ = str_.replace( sym, seq ) return str_ def seq_to_sym( str_ ): for seq, sym in termseq.items(): str_ = str_.replace( seq, sym ) str_ = colRe.sub( "", str_ ) str_ = upRe.sub( "", str_ ) str_ = downRe.sub( "", str_ ) str_ = colorRe.sub( "", str_ ) str_ = bgcolorRe.sub( "", str_ ) return str_ _words_ = [ "ada", "algol" "bash", "basic", "clojure", "cobol", "csharp", "eiffel", "erlang", "forth", "fortran", "fsharp", "go", "groovy", "haskell", "huginn", "java", "javascript", "julia", "kotlin", "lisp", "lua", "modula", "nemerle", "ocaml", "perl", "php", "prolog", "python", "rebol", "ruby", "rust", "scala", "scheme", "sql", "swift", "typescript" ] def skip( test_ ): return "SKIP" in os.environ and os.environ["SKIP"].find( test_ ) >= 0 verbosity = None class Rapid( str ): pass def rapid( item ): if isinstance( item, str ): r = Rapid( item ) return r return list( map( Rapid, item ) ) class ReplxxTests( unittest.TestCase ): _prompt_ = "\033\\[1;32mreplxx\033\\[0m> " _cxxSample_ = "./build/debug/replxx-example-cxx-api" _cSample_ = "./build/debug/replxx-example-c-api" _end_ = "\r\nExiting Replxx\r\n" def send_str( self_, str_, intraKeyDelay_ ): if isinstance(str_, Rapid): self_._replxx.send( str_ ) return for char in str_: self_._replxx.send( char ) time.sleep( intraKeyDelay_ ) def check_scenario( self_, seq_, expected_, history = "one\ntwo\nthree\n", term = "xterm", command = _cxxSample_, dimensions = ( 25, 80 ), prompt = _prompt_, end = None, encoding = "utf-8", pause = 0.25, intraKeyDelay = 0.002 ): if end is None: end = prompt + ReplxxTests._end_ with open( "replxx_history.txt", "wb" ) as f: f.write( history.encode( encoding ) ) f.close() os.environ["TERM"] = term if isinstance( command, str ): command = command.replace( "\n", "~" ) if verbosity >= 2: print( "\nTERM: {}, SIZE: {}, CMD: {}".format( term, dimensions, command ) ) prompt = prompt.replace( "\n", "\r\n" ).replace( "\r\r", "\r" ) end = end.replace( "\n", "\r\n" ).replace( "\r\r", "\r" ) if isinstance( command, str ): self_._replxx = pexpect.spawn( command, maxread = 1, encoding = encoding, dimensions = dimensions ) else: self_._replxx = pexpect.spawn( command[0], args = command[1:], maxread = 1, encoding = encoding, dimensions = dimensions ) self_._replxx.expect( prompt ) self_.maxDiff = None if isinstance( seq_, str ): if isinstance( seq_, Rapid ): seqs = rapid( seq_.split( "" ) ) else: seqs = seq_.split( "" ) for seq in seqs: last = seq is seqs[-1] if not last: seq += "" self_.send_str( sym_to_raw( seq ), intraKeyDelay ) if not last: time.sleep( pause ) self_._replxx.kill( signal.SIGCONT ) else: for seq in seq_: last = seq is seq_[-1] self_.send_str( sym_to_raw( seq ), intraKeyDelay ) if not last: time.sleep( pause ) self_._replxx.expect( end ) if isinstance( expected_, str ): self_.assertSequenceEqual( seq_to_sym( self_._replxx.before ), expected_ ) else: try: self_.assertIn( seq_to_sym( self_._replxx.before ), expected_ ) except: self_.assertSequenceEqual( seq_to_sym( self_._replxx.before ), "" ) def test_unicode( self_ ): self_.check_scenario( "", "a贸膮 熄 饟 髢攢 " "a贸膮 熄 饟 髢攢 \r\n" "a贸膮 熄 饟 髢攢 \r\n", "a贸膮 熄 饟 髢攢 \n" ) self_.check_scenario( "a贸膮 熄 饟 髢攢 ", "aa贸a贸膮a贸膮 " "a贸膮 熄a贸膮 熄 " "a贸膮 熄 饟a贸膮 熄 饟 " "a贸膮 熄 饟 " "a贸膮 熄 饟 髢攢a贸膮 熄 饟 髢攢 " "a贸膮 熄 饟 髢攢 " "a贸膮 熄 饟 髢攢 \r\n" "a贸膮 熄 饟 髢攢 \r\n" ) @unittest.skipIf( skip( "8bit_encoding" ), "broken platform" ) def test_8bit_encoding( self_ ): LC_CTYPE = "LC_CTYPE" exists = LC_CTYPE in os.environ lcCtype = None if exists: lcCtype = os.environ[LC_CTYPE] os.environ[LC_CTYPE] = "pl_PL.ISO-8859-2" self_.check_scenario( "", "text ~贸~text ~贸~\r\ntext ~贸~\r\n", "text ~贸~\n", encoding = "iso-8859-2" ) if exists: os.environ[LC_CTYPE] = lcCtype else: del os.environ[LC_CTYPE] def test_bad_term( self_ ): self_.check_scenario( "a line of text", "a line of text\r\na line of text\r\n", term = "dumb" ) def test_ctrl_c( self_ ): self_.check_scenario( "abc", "aababcabc^C\r" "\r\n" ) def test_ctrl_z( self_ ): self_.check_scenario( "", "threereplxx> " "threethree\r\n" "three\r\n" ) self_.check_scenario( "w", "(reverse-i-search)`': " "(reverse-i-search)`w': " "two(reverse-i-search)`w': " "tworeplxx> " "twotwotwo\r\n" "two\r\n" ) def test_ctrl_l( self_ ): self_.check_scenario( "", "\r\n" "replxx> \r\n" "replxx> \r\n" "replxx> replxx> " "", end = "\r\nExiting Replxx\r\n" ) self_.check_scenario( "", "\r\n" "replxx> first " "secondfirst " "secondreplxx> " "first secondfirst second\r\n" "first second\r\n", "first second\n" ) def test_backspace( self_ ): self_.check_scenario( "", "one two threeone two " "threeone tw threeone t " "threeone threeone " "threeone three\r\n" "one three\r\n", "one two three\n" ) def test_delete( self_ ): self_.check_scenario( "", "one two threeone two " "threeone wo " "threeone o threeone " "threeone threeone three\r\n" "one three\r\n", "one two three\n" ) def test_home_key( self_ ): self_.check_scenario( "abcz", "aababcabczabczabc\r\n" "zabc\r\n" ) def test_end_key( self_ ): self_.check_scenario( "abczq", "aababcabczabczabczabcqzabcq\r\n" "zabcq\r\n" ) def test_left_key( self_ ): self_.check_scenario( "abcxy", "aababcabcabxcaybxcaybxc\r\n" "aybxc\r\n" ) def test_right_key( self_ ): self_.check_scenario( "abcxy", "aababcabcaxbcaxbycaxbyc\r\n" "axbyc\r\n" ) def test_prev_word_key( self_ ): self_.check_scenario( "x", "abc def ghiabc def ghiabc " "xdef ghiabc xdef ghi\r\n" "abc xdef ghi\r\n", "abc def ghi\n" ) self_.check_scenario( "xxxx", "abc_def ghi_jkl mnl_opq rst_uvwabc_def ghi_jkl " "mnl_opq rst_uvwabc_def ghi_jkl mnl_opq " "rst_xuvw" "abc_def ghi_jkl mnl_opq " "xrst_xuvw" "abc_def ghi_jkl xmnl_opq " "xrst_xuvw" "abc_def ghi_xjkl xmnl_opq " "xrst_xuvwabc_def ghi_xjkl xmnl_opq " "xrst_xuvw\r\n" "abc_def ghi_xjkl xmnl_opq xrst_xuvw\r\n", "abc_def ghi_jkl mnl_opq rst_uvw\r\n" ) def test_next_word_key( self_ ): self_.check_scenario( "x", "abc def ghiabc def " "ghiabc defx ghiabc defx " "ghi\r\n" "abc defx ghi\r\n", "abc def ghi\n" ) self_.check_scenario( "xxxx", "abc_def ghi_jkl mno_pqr stu_vwxabc_def ghi_jkl " "mno_pqr stu_vwx" "abcx_def ghi_jkl mno_pqr " "stu_vwx" "abcx_defx ghi_jkl mno_pqr " "stu_vwx" "abcx_defx ghi_jklx mno_pqr " "stu_vwx" "abcx_defx ghi_jklx mnox_pqr " "stu_vwxabcx_defx ghi_jklx mnox_pqr " "stu_vwx\r\n" "abcx_defx ghi_jklx mnox_pqr stu_vwx\r\n", "abc_def ghi_jkl mno_pqr stu_vwx\r\n" ) def test_hint_show( self_ ): self_.check_scenario( "co\r", "cco\r\n" " color_black\r\n" " color_red\r\n" " color_greenco\r\n" "co\r\n" ) self_.check_scenario( "", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " "color_brightgreenzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " "color_brightgreen\r\n" "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz color_brightgreen\r\n", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz color_brightgreen\n", dimensions = ( 16, 64 ) ) def test_hint_scroll_down( self_ ): self_.check_scenario( "co", "cco\r\n" " color_black\r\n" " color_red\r\n" " " "color_greencolor_black\r\n" " color_red\r\n" " color_green\r\n" " " "color_browncolor_red\r\n" " color_green\r\n" " color_brown\r\n" " " "color_bluecolor_redcolor_red\r\n" "color_red\r\n" ) def test_hint_scroll_up( self_ ): self_.check_scenario( "co", "cco\r\n" " color_black\r\n" " color_red\r\n" " " "color_greencolor_white\r\n" " co\r\n" " color_black\r\n" " " "color_redcolor_brightcyan\r\n" " color_white\r\n" " co\r\n" " " "color_blackcolor_brightcyancolor_brightcyan\r\n" "color_brightcyan\r\n" ) def test_overlong_hint( self_ ): self_.check_scenario( "", "zzzzzzzzzzzzzzzzzzzzzzzzz color_br\r\n" " color_brown\r\n" " color_brightre\r\n" " color_brightgr\r\n" "zzzzzzzzzzzzzzzzzzzzzzzzz color_brown\r\n" " color_brightre\r\n" " color_brightgr\r\n" " color_brightbl\r\n" "zzzzzzzzzzzzzzzzzzzzzzzzz " "color_brightre\r\n" " color_brightgr\r\n" " color_brightbl\r\n" " color_brightma\r\n" "zzzzzzzzzzzzzzzzzzzzzzzzz " "color_brightredzzzzzzzzzzzzzzzzzzzzzzzzz " "color_brightred\r\n" "zzzzzzzzzzzzzzzzzzzzzzzzz color_brightred\r\n", #replxx> # "zzzzzzzzzzzzzzzzzzzzzzzzz color_br\n",################### dimensions = ( 16, 48 ) ) def test_history( self_ ): self_.check_scenario( "four", "threetwoonetwothreeffofoufourfour\r\n" "four\r\n" ) with open( "replxx_history.txt", "rb" ) as f: data = f.read().decode() self_.assertSequenceEqual( data[:-33], "### 0000-00-00 00:00:00.000\none\n### 0000-00-00 00:00:00.000\ntwo\n### 0000-00-00 00:00:00.000\nthree\n" ) self_.assertSequenceEqual( data[-5:], "four\n" ) def test_paren_matching( self_ ): self_.check_scenario( "ab(cd)ef", "aabab(ab(cab(cdab(cd)ab(cd)eab(cd)efab(cd)efab(cd)efab(cd)efab(cd)efab(cd)efab(cd)ef\r\n" "ab(cd)ef\r\n" ) def test_paren_not_matched( self_ ): self_.check_scenario( "a(b[c)d", "aa(a(ba(b[a(b[ca(b[c)a(b[c)da(b[c)da(b[c)da(b[c)da(b[c)da(b[c)da(b[c)da(b[c)da(b[c)d\r\n" "a(b[c)d\r\n" ) def test_tab_completion( self_ ): self_.check_scenario( "cobrib", "cco\r\n" " color_black\r\n" " color_red\r\n" " color_greencolor_\r\n" " color_black\r\n" " color_red\r\n" " color_greencolor_\r\n" "color_black " "color_cyan " "color_brightblue\r\n" "color_red " "color_lightgray " "color_brightmagenta\r\n" "color_green " "color_gray " "color_brightcyan\r\n" "color_brown " "color_brightred color_white\r\n" "color_blue " "color_brightgreen\r\n" "color_magenta color_yellow\r\n" "replxx> color_\r\n" " color_black\r\n" " color_red\r\n" " color_greencolor_b\r\n" " color_black\r\n" " color_brown\r\n" " color_bluecolor_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreencolor_bri\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluecolor_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluecolor_brightbluecolor_brightbluecolor_brightblue\r\n" "color_brightblue\r\n" ) self_.check_scenario( "n", "nn\r\nn\r\n", dimensions = ( 4, 32 ), command = [ ReplxxTests._cSample_, "q1", "e0" ] ) self_.check_scenario( "n", "\r\n" "db\r\n" "hello\r\n" "hallo\r\n" "--More--\r" "\t\t\t\t\r" "replxx> " "\r\n", dimensions = ( 4, 24 ), command = ReplxxTests._cSample_ + " q1 e1" ) self_.check_scenario( "co", "abcd()" "abcd()" "cabcd()" "coabcd()" "color_abcd()" "color_abcd()\r\n" "color_abcd()\r\n", "abcd()\n" ) def test_completion_shorter_result( self_ ): self_.check_scenario( "", "\\pi\r\n" "蟺\r\n", "\\pi\n" ) def test_completion_pager( self_ ): cmd = ReplxxTests._cSample_ + " q1 x" + ",".join( _words_ ) self_.check_scenario( "py", "\r\n" "ada groovy perl\r\n" "algolbash haskell php\r\n" "basic huginn prolog\r\n" "clojure java python\r\n" "cobol javascript rebol\r\n" "csharp julia ruby\r\n" "eiffel kotlin rust\r\n" "erlang lisp scala\r\n" "forth lua scheme\r\n" "--More--\r" "\t\t\t\t\r" "fortran modula sql\r\n" "fsharp nemerle swift\r\n" "go ocaml typescript\r\n" "replxx> " "\r\n", dimensions = ( 10, 40 ), command = cmd ) self_.check_scenario( "", "\r\n" "ada groovy perl\r\n" "algolbash haskell php\r\n" "basic huginn prolog\r\n" "clojure java python\r\n" "cobol javascript rebol\r\n" "csharp julia ruby\r\n" "eiffel kotlin rust\r\n" "erlang lisp scala\r\n" "forth lua scheme\r\n" "--More--\r" "\t\t\t\t\r" "fortran modula sql\r\n" "--More--\r" "\t\t\t\t\r" "fsharp nemerle swift\r\n" "--More--\r" "\t\t\t\t\r" "go ocaml typescript\r\n" "replxx> " "\r\n", dimensions = ( 10, 40 ), command = cmd ) self_.check_scenario( "", "\r\n" "ada kotlin\r\n" "algolbash lisp\r\n" "basic lua\r\n" "clojure modula\r\n" "cobol nemerle\r\n" "csharp ocaml\r\n" "eiffel perl\r\n" "--More--^C\r\n" "replxx> " "\r\n", dimensions = ( 8, 32 ), command = cmd ) self_.check_scenario( "q", "\r\n" "ada kotlin\r\n" "algolbash lisp\r\n" "basic lua\r\n" "clojure modula\r\n" "cobol nemerle\r\n" "csharp ocaml\r\n" "eiffel perl\r\n" "--More--\r" "\t\t\t\t\r" "replxx> " "\r\n", dimensions = ( 8, 32 ), command = cmd ) def test_double_tab_completion( self_ ): cmd = ReplxxTests._cSample_ + " d1 q1 x" + ",".join( _words_ ) self_.check_scenario( "for", "f\r\n" " forth\r\n" " fortran\r\n" " fsharpfo\r\n" " forth\r\n" " fortranfort\r\n" " forth\r\n" " " "fortranfortranfortranfortran\r\n" "fortran\r\n", command = cmd ) def test_beep_on_ambiguous_completion( self_ ): cmd = ReplxxTests._cSample_ + " b1 d1 q1 x" + ",".join( _words_ ) self_.check_scenario( "for", "f\r\n" " forth\r\n" " fortran\r\n" " fsharpfo\r\n" " forth\r\n" " fortranfort\r\n" " forth\r\n" " " "fortranfortranfortranfortran\r\n" "fortran\r\n", command = cmd ) def test_history_search_backward( self_ ): self_.check_scenario( "repl", "(reverse-i-search)`': " "(reverse-i-search)`r': echo repl " "golf(reverse-i-search)`re': echo repl " "golf(reverse-i-search)`rep': echo repl " "golf(reverse-i-search)`repl': echo repl " "golf(reverse-i-search)`repl': charlie repl " "deltareplxx> charlie repl " "deltacharlie repl deltacharlie repl " "delta\r\n" "charlie repl delta\r\n", "some command\n" "alfa repl bravo\n" "other request\n" "charlie repl delta\n" "misc input\n" "echo repl golf\n" "final thoughts\n" ) self_.check_scenario( "fors", "(reverse-i-search)`': " "(reverse-i-search)`f': " "swift(reverse-i-search)`fo': " "fortran(reverse-i-search)`for': " "fortran(reverse-i-search)`fo': " "fortran(reverse-i-search)`f': " "swift(reverse-i-search)`fs': " "fsharpreplxx> " "fsharpfsharpfsharp\r\n" "fsharp\r\n", "\n".join( _words_ ) + "\n" ) self_.check_scenario( "mod", "(reverse-i-search)`': " "(reverse-i-search)`m': " "scheme(reverse-i-search)`mo': " "modula(reverse-i-search)`mod': " "modulareplxx> " "replxx> " "\r\n", "\n".join( _words_ ) + "\n" ) def test_history_search_forward( self_ ): self_.check_scenario( "repl", "(i-search)`': (i-search)`r': " "(i-search)`re': (i-search)`rep': " "(i-search)`repl': " "(i-search)`repl': " "replxx> \r\n", "charlie repl delta\r\n", "some command\n" "alfa repl bravo\n" "other request\n" "charlie repl delta\n" "misc input\n" "echo repl golf\n" "final thoughts\n" ) self_.check_scenario( "repl", "final thoughts(i-search)`': final " "thoughts(i-search)`r': echo repl " "golf(i-search)`re': echo repl " "golf(i-search)`rep': echo repl " "golf(i-search)`repl': echo repl " "golf(i-search)`repl': alfa repl " "bravoreplxx> alfa repl bravoalfa " "repl bravoalfa repl bravo\r\n" "alfa repl bravo\r\n", "final thoughts\n" "echo repl golf\n" "misc input\n" "charlie repl delta\n" "other request\n" "alfa repl bravo\n" "some command\n" "charlie repl delta\r\n", ) self_.check_scenario( "fors", "(i-search)`': (i-search)`f': " "(i-search)`fo': (i-search)`for': " "(i-search)`fo': (i-search)`f': " "(i-search)`fs': " "replxx> \r\n", "\n".join( _words_[::-1] ) + "\n" ) self_.check_scenario( "fors", "typescript(i-search)`': " "typescript(i-search)`f': swift(i-search)`fo': " "fortran(i-search)`for': fortran(i-search)`fo': " "fortran(i-search)`f': swift(i-search)`fs': " "fsharpreplxx> " "fsharpfsharpfsharp\r\n" "fsharp\r\n", "\n".join( _words_[::-1] ) + "\n" ) self_.check_scenario( "mod", "(i-search)`': (i-search)`m': " "(i-search)`mo': (i-search)`mod': " "replxx> " "replxx> " "\r\n", "\n".join( _words_[::-1] ) + "\n" ) self_.check_scenario( "mod", "typescript(i-search)`': " "typescript(i-search)`m': scheme(i-search)`mo': " "modula(i-search)`mod': " "modulareplxx> " "typescriptreplxx> " "typescripttypescript\r\n" "typescript\r\n", "\n".join( _words_[::-1] ) + "\n" ) def test_history_search_backward_position( self_ ): self_.check_scenario( "req", "(reverse-i-search)`': " "(reverse-i-search)`r': echo repl " "golf(reverse-i-search)`re': echo repl " "golf(reverse-i-search)`req': other " "requestreplxx> other requestother " "requestalfa repl bravoalfa repl " "bravo\r\n" "alfa repl bravo\r\n", "some command\n" "alfa repl bravo\n" "other request\n" "charlie repl delta\n" "misc input\n" "echo repl golf\n" "final thoughts\n" ) def test_history_search_overlong_line( self_ ): self_.check_scenario( "lo", "(reverse-i-search)`': " "(reverse-i-search)`l': some very long line of text, much " "longer then a witdth of a terminal, " "seriously(reverse-i-search)`lo': some very long line of " "text, much longer then a witdth of a terminal, " "seriouslyreplxx> some very long line of " "text, much longer then a witdth of a terminal, seriouslysome " "very long line of text, much longer then a witdth of a terminal, " "seriouslysome very long line of text, much longer " "then a witdth of a terminal, seriously\r\n" "some very long line of text, much longer then a witdth of a terminal, " "seriously\r\n", "fake\nsome very long line of text, much longer then a witdth of a terminal, seriously\nanother fake", dimensions = ( 24, 64 ) ) def test_history_prefix_search_backward( self_ ): self_.check_scenario( "repl", "rrerepreplrepl_echo " "golfrepl_charlie " "deltarepl_charlie delta\r\n" "repl_charlie delta\r\n", "some command\n" "repl_alfa bravo\n" "other request\n" "repl_charlie delta\n" "misc input\n" "repl_echo golf\n" "final thoughts\n" ) def test_history_prefix_search_backward_position( self_ ): self_.check_scenario( "repl", "rrerepreplrepl_echo " "golfmisc inputmisc " "input\r\n" "misc input\r\n", "some command\n" "repl_alfa bravo\n" "other request\n" "repl_charlie delta\n" "misc input\n" "repl_echo golf\n" "final thoughts\n" ) def test_history_listing( self_ ): self_.check_scenario( "", ".history.history\r\n" " 0: some command\r\n" " 1: repl_alfa bravo\r\n" " 2: other request\r\n" " 3: repl_charlie delta\r\n" " 4: misc input\r\n" " 5: repl_echo golf\r\n" " 6: .history\r\n", "some command\n" "repl_alfa bravo\n" "other request\n" "repl_charlie delta\n" "misc input\n" "repl_echo golf\n" ".history\n" ) self_.check_scenario( "", "/history/history\r\n" " 0: some command\r\n" " 1: repl_alfa bravo\r\n" " 2: other request\r\n" " 3: repl_charlie delta\r\n" " 4: misc input\r\n" " 5: repl_echo golf\r\n" " 6: /history\r\n" "/history\r\n", "some command\n" "repl_alfa bravo\n" "other request\n" "repl_charlie delta\n" "misc input\n" "repl_echo golf\n" "/history\n", command = ReplxxTests._cSample_ + " q1" ) def test_history_browse( self_ ): self_.check_scenario( "", "twelve" "eleven" "one" "two" "one" "two" "" "twelve" "" "twelve" "twelve\r\n" "twelve\r\n", "one\n" "two\n" "three\n" "four\n" "five\n" "six\n" "seven\n" "eight\n" "nine\n" "ten\n" "eleven\n" "twelve\n" ) def test_history_max_size( self_ ): self_.check_scenario( "a", "threeaa\r\n" "a\r\n" "replxx> " "fourfour\r\n" "four\r\n", "one\n" "two\n" "three\n" "four\n" "five\n", command = ReplxxTests._cSample_ + " q1 s3" ) def test_history_unique( self_ ): self_.check_scenario( "abab", "aa\r\n" "a\r\n" "replxx> bb\r\n" "b\r\n" "replxx> aa\r\n" "a\r\n" "replxx> bb\r\n" "b\r\n" "replxx> " "bacc\r\n" "c\r\n", "a\nb\nc\n", command = ReplxxTests._cSample_ + " u1 q1" ) self_.check_scenario( "abab", "aa\r\n" "a\r\n" "replxx> bb\r\n" "b\r\n" "replxx> aa\r\n" "a\r\n" "replxx> bb\r\n" "b\r\n" "replxx> " "babb\r\n" "b\r\n", "a\nb\nc\n", command = ReplxxTests._cSample_ + " u0 q1" ) self_.check_scenario( rapid( "/history/unique/history" ), "//history\r\n" " 0: a\r\n" " 1: b\r\n" " 2: c\r\n" " 3: b\r\n" " 4: c\r\n" " 5: d\r\n" " 6: a\r\n" " 7: c\r\n" " 8: c\r\n" " 9: a\r\n" "/history\r\n" "replxx> /unique\r\n" "/unique\r\n" "replxx> /history\r\n" " 0: b\r\n" " 1: d\r\n" " 2: c\r\n" " 3: a\r\n" " 4: /history\r\n" " 5: /unique\r\n" "/history\r\n", "a\nb\nc\nb\nc\nd\na\nc\nc\na\n", command = ReplxxTests._cSample_ + " u0 q1" ) def test_history_recall_most_recent( self_ ): self_.check_scenario( "", "aaaabbbbbbbb\r\n" "bbbb\r\n" "replxx> " "cccccccc\r\n" "cccc\r\n", "aaaa\nbbbb\ncccc\ndddd\n" ) def test_history_abort_incremental_history_search_position( self_ ): self_.check_scenario( "cc", "hhhhgggg(reverse-i-search)`': " "gggg(reverse-i-search)`c': " "cccc(reverse-i-search)`cc': " "ccccreplxx> " "ggggggggffffffff\r\n" "ffff\r\n", "aaaa\nbbbb\ncccc\ndddd\neeee\nffff\ngggg\nhhhh\n" ) def test_capitalize( self_ ): self_.check_scenario( "", "abc defg ijklmn zzxqabc defg ijklmn " "zzxqaBc defg " "ijklmn zzxqaBc Defg ijklmn zzxq" "aBc Defg iJklmn zzxqaBc Defg " "iJklmn ZzxqaBc Defg iJklmn Zzxq\r\n" "aBc Defg iJklmn Zzxq\r\n", "abc defg ijklmn zzxq\n" ) self_.check_scenario( " ", "abc_def ghj_jkl mno_pqr stu_vwxabc_def ghj_jkl " "mno_pqr stu_vwx" "aBc_def ghj_jkl mno_pqr " "stu_vwxaBc_Def ghj_jkl mno_pqr " "stu_vwxaBc_Def Ghj_jkl mno_pqr " "stu_vwxaBc_Def Ghj_jkl Mno_pqr " "stu_vwx" "aBc_Def Ghj_jkl Mno_pQr " "stu_vwxaBc_Def Ghj_jkl Mno_pQr " "Stu_vwxaBc_Def Ghj_jkl Mno_pQr Stu " "_vwxaBc_Def Ghj_jkl Mno_pQr Stu _vwx\r\n" "aBc_Def Ghj_jkl Mno_pQr Stu _vwx\r\n", "abc_def ghj_jkl mno_pqr stu_vwx\n" ) def test_make_upper_case( self_ ): self_.check_scenario( "", "abcdefg hijklmno pqrstuvwabcdefg " "hijklmno pqrstuvw" "abcDEFG hijklmno " "pqrstuvwabcDEFG HIJKLMNO " "pqrstuvw" "abcDEFG HIJKLMNO " "PQRSTUVWabcDEFG HIJKLMNO " "PQRSTUVW\r\n" "abcDEFG HIJKLMNO PQRSTUVW\r\n", "abcdefg hijklmno pqrstuvw\n" ) self_.check_scenario( "", "abc_def ghi_jkl mno_pqr stu_vwxabc_def ghi_jkl " "mno_pqr stu_vwx" "aBC_def ghi_jkl mno_pqr " "stu_vwxaBC_DEF ghi_jkl mno_pqr " "stu_vwx" "aBC_DEF GHI_JKL mno_pqr " "stu_vwx" "aBC_DEF GHI_JKL mNO_pqr " "stu_vwxaBC_DEF GHI_JKL mNO_pqr " "stu_vwx\r\n" "aBC_DEF GHI_JKL mNO_pqr stu_vwx\r\n", "abc_def ghi_jkl mno_pqr stu_vwx\n" ) def test_make_lower_case( self_ ): self_.check_scenario( "", "ABCDEFG HIJKLMNO PQRSTUVWABCDEFG " "HIJKLMNO PQRSTUVW" "ABCdefg HIJKLMNO " "PQRSTUVWABCdefg hijklmno " "PQRSTUVW" "ABCdefg hijklmno " "pqrstuvwABCdefg hijklmno " "pqrstuvw\r\n" "ABCdefg hijklmno pqrstuvw\r\n", "ABCDEFG HIJKLMNO PQRSTUVW\n" ) self_.check_scenario( "", "ABC_DEF GHI_JKL MNO_PQR STU_VWXABC_DEF GHI_JKL " "MNO_PQR STU_VWX" "Abc_DEF GHI_JKL MNO_PQR " "STU_VWXAbc_def GHI_JKL MNO_PQR " "STU_VWX" "Abc_def ghi_jkl MNO_PQR " "STU_VWX" "Abc_def ghi_jkl Mno_PQR " "STU_VWXAbc_def ghi_jkl Mno_PQR " "STU_VWX\r\n" "Abc_def ghi_jkl Mno_PQR STU_VWX\r\n", "ABC_DEF GHI_JKL MNO_PQR STU_VWX\n" ) def test_transpose( self_ ): self_.check_scenario( "", "abcd" "abcd" "bacd" "bcad" "bcda" "bcad" "bcda" "bcda\r\n" "bcda\r\n", "abcd\n" ) def test_kill_to_beginning_of_line( self_ ): self_.check_scenario( "", "+abc defg--ijklmn " "zzxq++abc " "defg--ijklmn " "zzxq+" "-ijklmn " "zzxq+-ijklmn " "zzxq+-ijklmn " "zzxq++abc " "defg--ijklmn " "zzxq++abc defg-\r\n" "-ijklmn zzxq++abc defg-\r\n", "+abc defg--ijklmn zzxq+\n" ) def test_kill_to_end_of_line( self_ ): self_.check_scenario( "", "+abc defg--ijklmn " "zzxq++abc " "defg--ijklmn " "zzxq+" "+abc " "defg-+abc " "defg--ijklmn " "zzxq++abc " "defg--ijklmn " "zzxq++abc defg-\r\n" "-ijklmn zzxq++abc defg-\r\n", "+abc defg--ijklmn zzxq+\n" ) def test_kill_next_word( self_ ): self_.check_scenario( "", "alpha charlie bravo deltaalpha " "charlie bravo delta" "alpha bravo delta" "alpha bravo charlie deltaalpha " "bravo charlie delta\r\n" "alpha bravo charlie delta\r\n", "alpha charlie bravo delta\n" ) self_.check_scenario( "", "abc_ABC def_DEF ghi_GHI jkl_JKL XXXabc_ABC def_DEF " "ghi_GHI jkl_JKL XXX" "abc_ABC_DEF ghi_GHI jkl_JKL " "XXXabc_ABC ghi_GHI jkl_JKL " "XXXabc_ABC jkl_JKL XXXabc_ABC_JKL " "XXXabc_ABC_JKL " "def_DEF ghi_GHI jkl XXXabc_ABC_JKL def_DEF ghi_GHI jkl " "XXX\r\n" "abc_ABC_JKL def_DEF ghi_GHI jkl XXX\r\n", "abc_ABC def_DEF ghi_GHI jkl_JKL XXX\n" ) def test_kill_prev_word_to_white_space( self_ ): self_.check_scenario( "", "alpha charlie bravo deltaalpha " "charlie bravo deltaalpha charlie " "deltaalpha bravo " "charlie deltaalpha bravo charlie delta\r\n" "alpha bravo charlie delta\r\n", "alpha charlie bravo delta\n" ) def test_kill_prev_word( self_ ): self_.check_scenario( "", "alpha.charlie " "bravo.deltaalpha.charlie " "bravo.deltaalpha.charlie " "delta" "alpha.bravo.charlie " "deltaalpha.bravo.charlie " "delta\r\n" "alpha.bravo.charlie delta\r\n", "alpha.charlie bravo.delta\n" ) def test_kill_ring( self_ ): self_.check_scenario( " ", "delta charlie bravo alphadelta " "charlie bravo delta charlie " "bravodelta charlie " "delta " "charliedelta " "" "delta" "" "delta" "charlie" "bravo" "alpha" "alpha " "alpha " "alphaalpha " "deltaalpha " "charliealpha " "bravoalpha bravo " "alpha bravo " "bravoalpha bravo " "alphaalpha bravo " "deltaalpha bravo " "charliealpha bravo charlie " "alpha bravo charlie " "charliealpha bravo charlie " "bravoalpha bravo charlie " "alphaalpha bravo charlie " "deltaalpha bravo charlie delta\r\n" "alpha bravo charlie delta\r\n", "delta charlie bravo alpha\n" ) self_.check_scenario( " ", "charlie delta alpha bravocharlie " "delta alpha charlie delta " "charlie " "deltacharlie deltaalpha " "bravocharlie deltaalpha bravo charlie " "deltaalpha bravo charlie delta\r\n" "alpha bravo charlie delta\r\n", "charlie delta alpha bravo\n" ) self_.check_scenario( " ", "charlie delta alpha bravocharlie " "delta alpha bravo delta alpha bravo " "alpha bravoalpha bravoalpha " "bravoalpha bravo " "alpha bravo charlie " "deltaalpha bravo charlie delta\r\n" "alpha bravo charlie delta\r\n", "charlie delta alpha bravo\n" ) self_.check_scenario( "" "" "", "a b c d e f g h i j ka b c d e f g " "h i j a b c d e f g h i " "ja b c d e f g h i " "a b c d e f g h " "ia b c d e f g h " "a b c d e f g " "ha b c d e f g " "a b c d e f ga " "b c d e f a b c d e " "fa b c d e a b " "c d ea b c d a " "b c da b c a b " "ca b a " "ba " "" "a" "" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "a" "a\r\n" "a\r\n", "a b c d e f g h i j k\n" ) def test_yank_last_arg( self_ ): self_.check_scenario( "0123", "0" "01" "012" "0123" "0123" "01cat23" "01trillion23" "01twelve23" "01twelve23\r\n" "01twelve23\r\n", "one two three\nten eleven twelve\nmillion trillion\ndog cat\n" ) self_.check_scenario( " ", "dog catmillion trillionten " "eleven twelveten eleven twelve ten " "eleven twelve catten eleven twelve " "trillionten eleven twelve trillion\r\n" "ten eleven twelve trillion\r\n", "one two three\nten eleven twelve\nmillion trillion\ndog cat\n" ) def test_tab_completion_cutoff( self_ ): self_.check_scenario( "ny", "\r\n" "Display all 9 possibilities? (y or n)\r\n" "replxx> " "\r\n" "Display all 9 possibilities? (y or n)\r\n" "db hallo hansekogge quetzalcoatl power\r\n" "hello hans seamann quit\r\n" "replxx> " "\r\n", command = ReplxxTests._cSample_ + " q1 c3" ) self_.check_scenario( "n", "\r\n" "Display all 9 possibilities? (y or n)\r\n" "replxx> " "\r\n", command = ReplxxTests._cSample_ + " q1 c3" ) self_.check_scenario( "", "\r\n" "Display all 9 possibilities? (y or n)^C\r\n" "replxx> " "\r\n", command = ReplxxTests._cSample_ + " q1 c3" ) self_.check_scenario( ["", ""], "\r\n" "Display all 9 possibilities? (y or n)^C\r\n" "replxx> " "\r\n", command = ReplxxTests._cSample_ + " q1 c3 H200" ) def test_preload( self_ ): self_.check_scenario( "", "Alice has a cat." "Alice has a cat.\r\n" "Alice has a cat.\r\n", command = ReplxxTests._cSample_ + " q1 'PAlice has a cat.'" ) self_.check_scenario( "", "Cat eats mice. " "Cat eats mice. " "\r\n" "Cat eats mice. " "\r\n", command = ReplxxTests._cSample_ + " q1 'PCat\teats\tmice.\r\n'" ) self_.check_scenario( "", "Cat eats mice. " "Cat eats mice. " "\r\n" "Cat eats mice. " "\r\n", command = ReplxxTests._cSample_ + " q1 'PCat\teats\tmice.\r\n\r\n\n\n'" ) self_.check_scenario( "", "M Alice has a cat." "M Alice has a cat.\r\n" "M Alice has a cat.\r\n", command = ReplxxTests._cSample_ + " q1 'PMAlice has a cat.'" ) self_.check_scenario( "", "M Alice has a cat." "M Alice has a cat.\r\n" "M Alice has a cat.\r\n", command = ReplxxTests._cSample_ + " q1 'PM\t\t\t\tAlice has a cat.'" ) def test_prompt( self_ ): prompt = "date: now\nrepl> " self_.check_scenario( "", "threethree\r\n" "three\r\n" "date: now\r\n" "repl> " "threetwotwo\r\n" "two\r\n", command = ReplxxTests._cSample_ + " q1 'p{}'".format( prompt ), prompt = prompt, end = prompt + ReplxxTests._end_ ) prompt = "repl>\n" self_.check_scenario( "a", "aa\r\na\r\n", command = ReplxxTests._cSample_ + " q1 'p{}'".format( prompt ), prompt = prompt, end = prompt + ReplxxTests._end_ ) def test_long_line( self_ ): self_.check_scenario( "~~~~~~~~~~~~", "ada clojure eiffel fortran groovy java kotlin modula perl python " "rust sqlada clojure eiffel fortran groovy " "java kotlin modula perl python rust sqlada " "clojure eiffel fortran groovy java kotlin modula perl python rust " "~sqlada clojure " "eiffel fortran groovy java kotlin modula perl python ~rust " "~sqlada clojure " "eiffel fortran groovy java kotlin modula perl ~python ~rust " "~sqlada clojure " "eiffel fortran groovy java kotlin modula ~perl ~python ~rust " "~sqlada " "clojure eiffel fortran groovy java kotlin ~modula ~perl ~python ~rust " "~sqlada " "clojure eiffel fortran groovy java ~kotlin ~modula ~perl ~python ~rust " "~sqlada " "clojure eiffel fortran groovy ~java ~kotlin ~modula ~perl ~python ~rust " "~sqlada clojure " "eiffel fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " "~sqlada clojure eiffel " "~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " "~sqlada clojure " "~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " "~sqlada ~clojure " "~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " "~sql~ada ~clojure " "~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " "~sql~ada ~clojure " "~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " "~sql\r\n" "~ada ~clojure ~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python " "~rust ~sql\r\n", " ".join( _words_[::3] ) + "\n", dimensions = ( 10, 40 ) ) def test_colors( self_ ): self_.check_scenario( "", "color_black color_red " "color_green color_brown color_blue " "color_magenta color_cyan " "color_lightgray color_gray " "color_brightred color_brightgreen " "color_yellow color_brightblue " "color_brightmagenta color_brightcyan " "color_whitecolor_black " "color_red color_green color_brown " "color_blue color_magenta color_cyan " "color_lightgray color_gray " "color_brightred color_brightgreen " "color_yellow color_brightblue " "color_brightmagenta color_brightcyan " "color_white\r\n" "color_black color_red color_green color_brown color_blue color_magenta " "color_cyan color_lightgray color_gray color_brightred color_brightgreen " "color_yellow color_brightblue color_brightmagenta color_brightcyan " "color_white\r\n", "color_black color_red color_green color_brown color_blue color_magenta color_cyan color_lightgray" " color_gray color_brightred color_brightgreen color_yellow color_brightblue color_brightmagenta color_brightcyan color_white\n" ) def test_word_break_characters( self_ ): self_.check_scenario( "xxxxxx", "one_two three-four five_six " "seven-eightone_two three-four five_six " "seven-eightone_two three-four five_six " "seven-xeightone_two three-four five_six " "xseven-xeightone_two three-four xfive_six " "xseven-xeightone_two three-xfour xfive_six " "xseven-xeightone_two xthree-xfour xfive_six " "xseven-xeightxone_two xthree-xfour xfive_six " "xseven-xeightxone_two xthree-xfour xfive_six " "xseven-xeight\r\n" "xone_two xthree-xfour xfive_six xseven-xeight\r\n", "one_two three-four five_six seven-eight\n", command = ReplxxTests._cSample_ + " q1 'w \t-'" ) self_.check_scenario( "xxxxxx", "one_two three-four five_six " "seven-eightone_two three-four five_six " "seven-eightone_two three-four five_six " "xseven-eightone_two three-four five_xsix " "xseven-eightone_two three-four xfive_xsix " "xseven-eightone_two xthree-four xfive_xsix " "xseven-eightone_xtwo xthree-four xfive_xsix " "xseven-eightxone_xtwo xthree-four xfive_xsix " "xseven-eightxone_xtwo xthree-four xfive_xsix " "xseven-eight\r\n" "xone_xtwo xthree-four xfive_xsix xseven-eight\r\n", "one_two three-four five_six seven-eight\n", command = ReplxxTests._cSample_ + " q1 'w \t_'" ) def test_no_color( self_ ): self_.check_scenario( " X", "color_black color_red color_green color_brown color_blue " "color_magenta color_cyan color_lightgray color_gray color_brightred " "color_brightgreen color_yellow color_brightblue color_brightmagenta " "color_brightcyan color_whitecolor_black color_red " "color_green color_brown color_blue color_magenta color_cyan color_lightgray " "color_gray color_brightred color_brightgreen color_yellow color_brightblue " "color_brightmagenta color_brightcyan color_white " "color_black color_red color_green color_brown color_blue " "color_magenta color_cyan color_lightgray color_gray color_brightred " "color_brightgreen color_yellow color_brightblue color_brightmagenta " "color_brightcyan color_white Xcolor_black color_red " "color_green color_brown color_blue color_magenta color_cyan color_lightgray " "color_gray color_brightred color_brightgreen color_yellow color_brightblue " "color_brightmagenta color_brightcyan color_white X\r\n" "color_black color_red color_green color_brown color_blue color_magenta " "color_cyan color_lightgray color_gray color_brightred color_brightgreen " "color_yellow color_brightblue color_brightmagenta color_brightcyan " "color_white X\r\n", "color_black color_red color_green color_brown color_blue color_magenta color_cyan color_lightgray" " color_gray color_brightred color_brightgreen color_yellow color_brightblue color_brightmagenta color_brightcyan color_white\n", command = ReplxxTests._cSample_ + " q1 m1" ) def test_backspace_long_line_on_small_term( self_ ): self_.check_scenario( "", "\r\n" "replxx> \r\n" "replxx> \r\n" "replxx> " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", dimensions = ( 10, 40 ) ) self_.check_scenario( "", "\r\n" "replxx> \r\n" "replxx> \r\n" "replxx> a qu ite lo ng li ne of sh ort wo rds wi " "ll te st cu rs or mo ve me nta qu ite lo " "ng li ne of sh ort wo rds wi ll te st cu rs or mo ve me " "na qu ite lo ng li ne of sh ort wo rds wi " "ll te st cu rs or mo ve me a qu ite lo ng " "li ne of sh ort wo rds wi ll te st cu rs or mo ve " "mea qu ite lo ng li ne of sh ort wo rds " "wi ll te st cu rs or mo ve ma qu ite lo " "ng li ne of sh ort wo rds wi ll te st cu rs or mo ve " "a qu ite lo ng li ne of sh ort wo rds wi " "ll te st cu rs or mo vea qu ite lo ng li " "ne of sh ort wo rds wi ll te st cu rs or mo ve\r\n" "a qu ite lo ng li ne of sh ort wo rds wi ll te st cu rs or mo ve\r\n", "a qu ite lo ng li ne of sh ort wo rds wi ll te st cu rs or mo ve me nt\n", dimensions = ( 10, 40 ) ) def test_reverse_history_search_on_max_match( self_ ): self_.check_scenario( "", "aaaaaaaaaaaaaaaaaaaaa(reverse-i-search)`': " "aaaaaaaaaaaaaaaaaaaaareplxx> " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n" "aaaaaaaaaaaaaaaaaaaaa\r\n", "aaaaaaaaaaaaaaaaaaaaa\n" ) def test_no_terminal( self_ ): res = subprocess.run( [ ReplxxTests._cSample_, "q1" ], input = b"replxx FTW!\n", stdout = subprocess.PIPE, stderr = subprocess.PIPE ) self_.assertSequenceEqual( res.stdout, b"starting...\nreplxx FTW!\n\nExiting Replxx\n" ) def test_async_print( self_ ): self_.check_scenario( [ "a", "b", "c", "d", "e", "f" ], [ "0\r\n" "replxx> " "aab1\r\n" "replxx> " "ababcabcd2\r\n" "replxx> " "abcdabcdeabcdefabcdef\r\n" "abcdef\r\n", "0\r\n" "replxx> " "aab1\r\n" "replxx> " "ababcabcd2\r\n" "replxx> " "abcdabcdeabcdefabcdef\r\n" "abcdef\r\n", ], command = [ ReplxxTests._cxxSample_, "m" ], pause = 0.5 ) self_.check_scenario( [ "", "a", "b", "c", "d", "e", "f" ], [ "0\r\n" "replxx> a very long line of " "user input, wider then current terminal, the line is wrapped: " "a very long line of user input, wider then current " "terminal, the line is wrapped: a1\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, " "the line is wrapped: aa very long line of user " "input, wider then current terminal, the line is wrapped: " "aba very long line of user input, wider then current " "terminal, the line is wrapped: abc2\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, " "the line is wrapped: abca very long line of user " "input, wider then current terminal, the line is wrapped: " "abcda very long line of user input, wider then " "current terminal, the line is wrapped: abcde3\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, " "the line is wrapped: abcdea very long line of user " "input, wider then current terminal, the line is wrapped: " "abcdefa very long line of user input, wider then " "current terminal, the line is wrapped: abcdef\r\n" "a very long line of user input, wider then current terminal, the line is " "wrapped: abcdef\r\n", "0\r\n" "replxx> a very long line of user input, " "wider then current terminal, the line is wrapped: a " "very long line of user input, wider then current terminal, the line is " "wrapped: a1\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, the " "line is wrapped: aa very long line of user input, " "wider then current terminal, the line is wrapped: " "aba very long line of user input, wider then current " "terminal, the line is wrapped: abc2\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, the " "line is wrapped: abca very long line of user input, " "wider then current terminal, the line is wrapped: " "abcd3\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, the " "line is wrapped: abcda very long line of user input, " "wider then current terminal, the line is wrapped: " "abcdea very long line of user input, wider then " "current terminal, the line is wrapped: abcdefa very " "long line of user input, wider then current terminal, the line is wrapped: " "abcdef\r\n" "a very long line of user input, wider then current terminal, the line is " "wrapped: abcdef\r\n", "0\r\n" "replxx> a very long line of user input, wider then " "current terminal, the line is wrapped: a very long " "line of user input, wider then current terminal, the line is wrapped: " "a1\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, the " "line is wrapped: aa very long line of user input, " "wider then current terminal, the line is wrapped: " "aba very long line of user input, wider then current " "terminal, the line is wrapped: abc2\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, the " "line is wrapped: abca very long line of user input, " "wider then current terminal, the line is wrapped: " "abcd3\r\n" "replxx> \r\n" "\r\n" "a very long line of user input, wider then current terminal, the " "line is wrapped: abcda very long line of user input, " "wider then current terminal, the line is wrapped: " "abcdea very long line of user input, wider then " "current terminal, the line is wrapped: abcdefa very " "long line of user input, wider then current terminal, the line is wrapped: " "abcdef\r\n" "a very long line of user input, wider then current terminal, the line is " "wrapped: abcdef\r\n" ], "a very long line of user input, wider then current terminal, the line is wrapped: \n", command = [ ReplxxTests._cxxSample_, "m" ], dimensions = ( 10, 40 ), pause = 0.5 ) def test_async_emulate_key_press( self_ ): self_.check_scenario( [ "a", "b", "c", "d", "e", "f" ], [ "11a" "1ab1ab" "21ab2" "c1ab2" "cd1ab2cd3" "1ab2cd3e" "1ab2cd3ef" "1ab2cd3ef\r\n" "1ab2cd3ef\r\n", "1a1ab" "1ab21ab" "2c1ab2cd" "1ab2cd31ab" "2cd3e1ab2cd" "3ef1ab2cd3ef\r\n" "1ab2cd3ef\r\n" ], command = [ ReplxxTests._cxxSample_, "k123456" ], pause = 0.5 ) def test_special_keys( self_ ): self_.check_scenario( "" "" "" "" "" "", "\r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" "replxx> \r\n" ) def test_overwrite_mode( self_ ): self_.check_scenario( "XYZ012345", "abcdefghabcdefgh" "" "abXcdefghabXYcdefgh" "abXYZcdefghabXYZ0defgh" "abXYZ01efghabXYZ012fgh" "abXYZ0123fghabXYZ01234fgh" "abXYZ012345fghabXYZ012345fgh\r\n" "abXYZ012345fgh\r\n", "abcdefgh\n" ) def test_verbatim_insert( self_ ): self_.check_scenario( ["", rapid( "" ), ""], "^[[2~^[[2~\r\n" "\r\n" ) def test_hint_delay( self_ ): self_.check_scenario( ["han", ""], "hhahanhan\r\n" " hans\r\n" " hansekoggehan\r\n" "han\r\n", command = [ ReplxxTests._cSample_, "q1", "H200" ] ) def test_complete_next( self_ ): self_.check_scenario( "", "color_\r\n" " color_black\r\n" " color_red\r\n" " " "color_greencolor_black" "color_redcolor_blackcolor_\r\n" " color_black\r\n" " color_red\r\n" " " "color_greencolor_whitecolor_white\r\n" "color_white\r\n", "color_\n" ) self_.check_scenario( "l", "l\r\n" " lc_ctype\r\n" " lc_time\r\n" " lc_messageslc_\r\n" " lc_ctype\r\n" " lc_time\r\n" " " "lc_messageslc_ctypelc_timelc_ctypelc_\r\n" " lc_ctype\r\n" " lc_time\r\n" " lc_messageslc_\r\n" "lc_\r\n", command = [ ReplxxTests._cSample_, "xlc_ctype,lc_time,lc_messages,zoom", "I1", "q1" ] ) self_.check_scenario( "l", "l\r\n" " lc_ctype\r\n" " lc_time\r\n" " lc_messageslc_\r\n" " lc_ctype\r\n" " lc_time\r\n" " " "lc_messageslc_ctypelc_\r\n" " lc_ctype\r\n" " lc_time\r\n" " " "lc_messageslc_messageslc_messages\r\n" "lc_messages\r\n", command = [ ReplxxTests._cSample_, "xlc_ctype,lc_time,lc_messages,zoom", "I0", "q1" ] ) def test_disabled_handlers( self_ ): self_.check_scenario( "4", "(+ 1 2)(+ 1 " "2)(+ 1 " ")(+ 1 " "4)(+ 1 4)\r\n" "thanks for the input: (+ 1 4)\r\n", "(+ 1 2)\r\n", command = [ ReplxxTests._cSample_, "N", "S" ] ) def test_state_manipulation( self_ ): self_.check_scenario( "~", "replxxREPLXXREP~LXXREP~LXX\r\n" "REP~LXX\r\n", "replxx\n", command = [ ReplxxTests._cSample_, "q1" ] ) def test_modify_callback( self_ ): self_.check_scenario( "*", "abcd12abcd12" "" "ababcd12cd12" "ababcd12cd12\r\n" "ababcd12cd12\r\n", "abcd12\n", command = [ ReplxxTests._cSample_, "q1", "M1" ] ) def test_paste( self_ ): self_.check_scenario( rapid( "abcdef" ), "aabcdef\r\nabcdef\r\n" ) def test_history_merge( self_ ): with open( "replxx_history_alt.txt", "w" ) as f: f.write( "### 0000-00-00 00:00:00.001\n" "one\n" "### 0000-00-00 00:00:00.003\n" "three\n" "### 0000-00-00 00:00:00.005\n" "other\n" "### 0000-00-00 00:00:00.009\n" "same\n" "### 0000-00-00 00:00:00.017\n" "seven\n" ) f.close() self_.check_scenario( "", ".merge.merge\r\n", "### 0000-00-00 00:00:00.002\n" "two\n" "### 0000-00-00 00:00:00.004\n" "four\n" "### 0000-00-00 00:00:00.006\n" "same\n" "### 0000-00-00 00:00:00.008\n" "other\n" "### 0000-00-00 00:00:00.018\n" ".merge\n" ) with open( "replxx_history_alt.txt", "r" ) as f: data = f.read() expected = ( "### 0000-00-00 00:00:00.001\n" "one\n" "### 0000-00-00 00:00:00.002\n" "two\n" "### 0000-00-00 00:00:00.003\n" "three\n" "### 0000-00-00 00:00:00.004\n" "four\n" "### 0000-00-00 00:00:00.008\n" "other\n" "### 0000-00-00 00:00:00.009\n" "same\n" "### 0000-00-00 00:00:00.017\n" "seven\n" "### " ) self_.assertSequenceEqual( data[:-31], expected ) self_.assertSequenceEqual( data[-7:], ".merge\n" ) def test_history_save( self_ ): with open( "replxx_history_alt.txt", "w" ) as f: f.write( "### 0000-00-00 00:00:00.001\n" "one\n" "### 0000-00-00 00:00:00.003\n" "three\n" "### 3000-00-00 00:00:00.005\n" "other\n" "### 3000-00-00 00:00:00.009\n" "same\n" "### 3000-00-00 00:00:00.017\n" "seven\n" ) f.close() self_.check_scenario( "zoom.save", "zzozoozoomzoom\r\n" "zoom\r\n" "replxx> " "..s.sa.sav.save.save\r\n" "replxx> " "zoomzoom\r\n" "zoom\r\n" ) def test_bracketed_paste( self_ ): self_.check_scenario( "a0b1c2d3e4f", "a" "a0" "a0b1c2d3e" "a0b1c2d3e4" "a0b1c2d3e4f" "a0b1c2d3e4f\r\n" "a0b1c2d3e4f\r\n", command = [ ReplxxTests._cSample_, "q1" ] ) self_.check_scenario( "a0b1c2d3e4f", "a" "a0" "a0b1c2d3e" "a0b1c2d3e4" "a0b1c2d3e4f" "a0b1c2d3e4f\r\n" "a0b1c2d3e4f\r\n", command = [ ReplxxTests._cSample_, "q1", "B" ] ) self_.check_scenario( "a0/eb/dbx", "aa0a0" "a/eb0a/eb0\r\n" "a/eb0\r\n" "replxx> /db/db\r\n" "/db\r\n" "replxx> xx\r\n" "x\r\n", command = [ ReplxxTests._cSample_, "q1" ] ) self_.check_scenario( "aaa\n\tbbb", "\r\n", command = [ ReplxxTests._cxxSample_, "B" ] ) def test_embedded_newline( self_ ): self_.check_scenario( "", "color_blue " "color_redcolor_blue " "color_redcolor_blue \r\n" "color_redcolor_blue \r\n" "color_red\r\n" "color_blue \r\n" "color_red\r\n", "color_blue color_red\n" ) def test_move_up_in_multiline( self_ ): self_.check_scenario( " ", "color_blue\r\n" "color_redcolor_blue\r\n" "color_redc olor_blue\r\n" "color_redc olor_blue\r\n" "color_red\r\n" "c olor_blue\r\n" "color_red\r\n", "some other\ncolor_bluecolor_red\n" ) self_.check_scenario( " ", "color_brightblue\r\n" " " "color_redcolor_brightblue\r\n" " color_redcolor_bri ghtblue\r\n" " color_redcolor_bri ghtblue\r\n" " color_red\r\n" "color_bri ghtblue\r\n" "color_red\r\n", "some other\ncolor_brightbluecolor_red\n", command = [ ReplxxTests._cxxSample_, "I" ] ) self_.check_scenario( "x", "bbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbxbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n" "aaaaaaaaaaaaaaaaaaaa\r\n", "aaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" ) self_.check_scenario( "x", "bbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbb\r\n" " " "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbxbbb\r\n" " bbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbb\r\n" " " "bbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n" "aaaaaaaaaaaaaaaaaaaa\r\n", "aaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", command = [ ReplxxTests._cxxSample_, "I" ] ) def test_move_down_in_multiline( self_ ): self_.check_scenario( " ", "some othercolor_red\r\n" "color_bluecolor_red\r\n" "color_bluecolor_red\r\n" "color_bl uecolor_red\r\n" "color_bl ue\r\n" "color_red\r\n" "color_bl ue\r\n", "some other\ncolor_redcolor_blue\n" ) self_.check_scenario( " ", "some othercolor_red\r\n" " color_bluecolor_red\r\n" " " "color_bluecolor_red\r\n" " color_bluecolor_red\r\n" " color_blue\r\n" "color_red\r\n" " color_blue\r\n", "some other\ncolor_redcolor_blue\n", command = [ ReplxxTests._cxxSample_, "I" ] ) self_.check_scenario( "x", "bbbbbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbxbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n" "aaaaaaaaaaaaaaaaaaaa\r\n", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\naaaaaaaaaaaaaaaaaaaa\n" ) self_.check_scenario( "x", "bbbbbbbbbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbbbbbbbbb\r\n" " " "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbbbbbbbbb\r\n" " bbbbbbbbbbbbbbbbbbbb\r\n" " " "xbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n" "aaaaaaaaaaaaaaaaaaaa\r\n", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\naaaaaaaaaaaaaaaaaaaa\n", command = [ ReplxxTests._cxxSample_, "I" ] ) def test_go_to_beginning_of_multiline_entry( self_ ): self_.check_scenario( "x ", "color_red\r\n" "color_blue\r\n" "zzzzzzcolor_red\r\n" "color_blue\r\n" "zzzzzzxcolor_red\r\n" "color_blue\r\n" "zzzzzzx color_red\r\n" "color_blue\r\n" "zzzzzzsome othersome " "other\r\n" "some other\r\n", "some other\ncolor_redcolor_bluezzzzzz\n" ) def test_go_to_end_of_multiline_entry( self_ ): self_.check_scenario( "x ", "123color_red " "color_green\r\n" "color_blue color_yellow\r\n" "zzzzzzcolor_red color_green\r\n" "color_blue color_yellow\r\n" "zzzzzzxcolor_red color_green\r\n" "color_blue color_yellow\r\n" "zzzzzzx color_red " "color_green\r\n" "color_blue color_yellow\r\n" "zzzzzzx color_red " "color_green\r\n" "color_blue color_yellow\r\n" "zzzzzz\r\n", "some other\ncolor_red color_greencolor_blue color_yellowzzzzzz\n123\n" ) def test_move_to_beginning_of_line_in_multiline( self_ ): self_.check_scenario( "x x x ", "color_red more text\r\n" "color_blue 123\r\n" "color_green zzzcolor_red more " "text\r\n" "color_blue 123\r\n" "color_green zzzcolor_red more " "text\r\n" "color_blue 123\r\n" "xcolor_green zzzcolor_red more text\r\n" "color_blue 123\r\n" "x color_green " "zzzcolor_red more text\r\n" "xcolor_blue 123\r\n" "x color_green zzzcolor_red " "more text\r\n" "x color_blue 123\r\n" "x color_green " "zzzxcolor_red more text\r\n" "x color_blue 123\r\n" "x color_green zzzx color_red " "more text\r\n" "x color_blue 123\r\n" "x color_green zzzx color_red " "more text\r\n" "x color_blue 123\r\n" "x color_green zzz\r\n" "x color_red more text\r\n" "x color_blue 123\r\n" "x color_green zzz\r\n", "color_red more textcolor_blue 123color_green zzz\n" ) self_.check_scenario( "", "first line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a code\r\n" "first line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a code\r\n", "first line of textsecond verse of a poemnext passage of a scripturelast line of a code\n" ) def test_move_to_end_of_line_in_multiline( self_ ): self_.check_scenario( "x xxx", "color_red more text\r\n" "color_blue 123\r\n" "color_green zzzcolor_red more " "text\r\n" "color_blue 123\r\n" "color_green zzzxcolor_red more text\r\n" "color_blue 123\r\n" "color_green zzzx color_red " "more text\r\n" "color_blue 123\r\n" "color_green zzzx " "color_red more textx\r\n" "color_blue 123\r\n" "color_green zzzx " "color_red more textx\r\n" "color_blue 123x\r\n" "color_green zzzx " "color_red more textx\r\n" "color_blue 123x\r\n" "color_green zzzx color_red " "more textx\r\n" "color_blue 123x\r\n" "color_green zzzxx color_red " "more textx\r\n" "color_blue 123x\r\n" "color_green zzzx\r\n" "x color_red more textx\r\n" "color_blue 123x\r\n" "color_green zzzx\r\n", "color_red more textcolor_blue 123color_green zzz\n" ) self_.check_scenario( "", "first line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of " "text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a code\r\n" "first line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a code\r\n", "first line of textsecond verse of a poemnext passage of a scripturelast line of a code\n" ) def test_hints_in_multiline( self_ ): self_.check_scenario( "", "some text\r\n" "color_b\r\n" "color_black\r\n" "color_brown\r\n" "color_bluesome text\r\n" "color_black\r\n" "color_brown\r\n" "color_blue\r\n" "color_brightredsome text\r\n" "color_b\r\n" "some text\r\n" "color_b\r\n", "some textcolor_b\n" ) self_.check_scenario( "", "some long text\r\n" " color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " color_brightgreensome long text\r\n" " color_brown\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " color_brightbluesome long text\r\n" " color_br\r\n" "some long text\r\n" "color_br\r\n", "some long textcolor_br\n", command = [ ReplxxTests._cxxSample_, "I" ] ) self_.check_scenario( "", "some text\r\n" "not on start color_b\r\n" " color_black\r\n" " color_brown\r\n" " color_bluesome text\r\n" "not on start color_black\r\n" " color_brown\r\n" " color_blue\r\n" " color_brightredsome text\r\n" "not on start color_b\r\n" "some text\r\n" "not on start color_b\r\n", "some textnot on start color_b\n" ) self_.check_scenario( "", "some text\r\n" " not on start color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " color_brightgreensome " "text\r\n" " not on start color_brown\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " color_brightbluesome " "text\r\n" " not on start color_br\r\n" "some text\r\n" "not on start color_br\r\n", "some textnot on start color_br\n", command = [ ReplxxTests._cxxSample_, "I" ] ) def test_async_prompt( self_ ): self_.check_scenario( [ "", "r", "i", "g", "h", "t", "g" ], [ "replxx[-]> long line " "color_green and color_b\r\n" " color_black\r\n" " color_brown\r\n" " " "color_bluereplxx[\\]> " "long line color_green and color_b\r\n" " color_black\r\n" " color_brown\r\n" " " "color_bluereplxx[|]> " "long line color_green and color_b\r\n" " color_black\r\n" " color_brown\r\n" " color_bluelong " "line color_green and color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenreplxx[/]> " "long line color_green and color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenreplxx[-]> " "long line color_green and color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenreplxx[\\]> " "long line color_green and color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenlong line color_green " "and color_bri\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[|]> " "long line color_green and color_bri\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[/]> " "long line color_green and color_bri\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluelong line color_green " "and color_brig\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[-]> " "long line color_green and color_brig\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[\\]> " "long line color_green and color_brig\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluelong line color_green " "and color_brigh\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[|]> " "long line color_green and color_brigh\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[/]> " "long line color_green and color_brigh\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluelong line color_green " "and color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[-]> " "long line color_green and color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[\\]> " "long line color_green and color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluelong line color_green " "and " "color_brightgreenreplxx[|]> " "long line color_green and " "color_brightgreenlong line " "color_green and " "color_brightgreenlong line " "color_green and " "color_brightgreen\r\n" "long line color_green and color_brightgreen\r\n", "replxx[-]> long line " "color_green and color_b\r\n" " color_black\r\n" " color_brown\r\n" " " "color_bluereplxx[\\]> " "long line color_green and color_b\r\n" " color_black\r\n" " color_brown\r\n" " " "color_bluereplxx[|]> " "long line color_green and color_b\r\n" " color_black\r\n" " color_brown\r\n" " color_bluelong " "line color_green and color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenreplxx[/]> " "long line color_green and color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenreplxx[-]> " "long line color_green and color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenreplxx[\\]> " "long line color_green and color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenlong line color_green " "and color_bri\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[|]> " "long line color_green and color_bri\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[/]> " "long line color_green and color_bri\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluelong line color_green " "and color_brig\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[-]> " "long line color_green and color_brig\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[\\]> " "long line color_green and color_brig\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluelong line color_green " "and color_brigh\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[|]> " "long line color_green and color_brigh\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[/]> " "long line color_green and color_brigh\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluelong line color_green " "and color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[-]> " "long line color_green and color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[\\]> " "long line color_green and color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluelong line color_green " "and " "color_brightgreenreplxx[|]> " "long line color_green and " "color_brightgreenlong line " "color_green and " "color_brightgreenlong line " "color_green and " "color_brightgreen\r\n" "long line color_green and color_brightgreen\r\n" "replxx> \r\n" ], "long line color_green and color_b\n", command = [ ReplxxTests._cxxSample_, "F" ], pause = 0.5 ) self_.check_scenario( [ "a", "b", "c", "d", "e", "f", "g" ], [ "0\r\n" "replxx[-]> " "replxx[-]> " "areplxx[\\]> " "areplxx[|]> " "aabreplxx[/]> " "ab1\r\n" "replxx[-]> " "abreplxx[-]> " "ababcreplxx[\\]> " "abcreplxx[|]> " "abcreplxx[/]> " "abcabcd2\r\n" "replxx[-]> " "abcdreplxx[-]> " "abcdreplxx[\\]> " "abcdabcdereplxx[|]> " "abcdereplxx[/]> " "abcdeabcdef3\r\n" "replxx[-]> " "abcdefreplxx[-]> " "abcdefreplxx[\\]> " "abcdefabcdefgreplxx[|]> " "abcdefgabcdefg\r\n" "abcdefg\r\n" "replxx> \r\n", "0\r\n" "replxx[-]> " "replxx[-]> " "areplxx[\\]> " "areplxx[|]> " "aabreplxx[/]> " "ab1\r\n" "replxx[-]> " "abreplxx[-]> " "ababcreplxx[\\]> " "abcreplxx[|]> " "abcreplxx[/]> " "abcabcd2\r\n" "replxx[-]> " "abcdreplxx[-]> " "abcdreplxx[\\]> " "abcdabcdereplxx[|]> " "abcdereplxx[/]> " "abcdeabcdef3\r\n" "replxx[-]> " "abcdefreplxx[-]> " "abcdefreplxx[\\]> " "abcdefabcdefgreplxx[|]> " "abcdefgabcdefg\r\n" "abcdefg\r\n", "0\r\n" "replxx[-]> " "replxx[-]> " "areplxx[\\]> " "areplxx[|]> " "aabreplxx[/]> " "ab1\r\n" "replxx[-]> " "abreplxx[-]> " "abreplxx[\\]> " "ababcreplxx[|]> " "abcreplxx[/]> " "abcabcd2\r\n" "replxx[-]> " "abcdreplxx[-]> " "abcdreplxx[\\]> " "abcdabcdereplxx[|]> " "abcdereplxx[/]> " "abcdeabcdef3\r\n" "replxx[-]> " "abcdefreplxx[-]> " "abcdefreplxx[\\]> " "abcdefabcdefgreplxx[|]> " "abcdefgabcdefg\r\n" "abcdefg\r\n", "0\r\n" "replxx[-]> " "replxx[-]> " "areplxx[\\]> " "areplxx[|]> " "aabreplxx[/]> " "ab1\r\n" "replxx[-]> " "abreplxx[-]> " "abreplxx[\\]> " "ababcreplxx[|]> " "abcreplxx[/]> " "abcabcd2\r\n" "replxx[-]> " "abcdreplxx[-]> " "abcdreplxx[\\]> " "abcdabcdereplxx[|]> " "abcdereplxx[/]> " "abcdeabcdef3\r\n" "replxx[-]> " "abcdefreplxx[-]> " "abcdefreplxx[\\]> " "abcdefabcdefgreplxx[|]> " "abcdefgabcdefg\r\n" "abcdefg\r\n" "replxx> \r\n" ], command = [ ReplxxTests._cxxSample_, "m", "F" ], pause = 0.5 ) self_.check_scenario( [ "a", "b", "c", "d", "e", "f", "g" ], [ "0\r\n" "replxx[-]> " "replxx[-]> " "11areplxx[\\]> " "1areplxx[|]> " "1a1abreplxx[/]> " "1ab1\r\n" "replxx[-]> " "1abreplxx[-]> " "1ab1ab21ab2creplxx[\\]> " "1ab2creplxx[|]> " "1ab2creplxx[/]> " "1ab2c1ab2cd2\r\n" "replxx[-]> " "1ab2cdreplxx[-]> " "1ab2cd1ab2cd3replxx[\\]> " "1ab2cd31ab2cd3ereplxx[|]> " "1ab2cd3ereplxx[/]> " "1ab2cd3e1ab2cd3ef3\r\n" "replxx[-]> " "1ab2cd3efreplxx[-]> " "1ab2cd3ef1ab2cd3ef4replxx[\\]> " "1ab2cd3ef41ab2cd3ef4greplxx[|]> " "1ab2cd3ef4g1ab2cd3ef4g\r\n" "1ab2cd3ef4g\r\n", "10\r\n" "replxx[-]> " "11areplxx[-]> " "1areplxx[\\]> " "1areplxx[|]> " "1a1abreplxx[/]> " "1ab1\r\n" "replxx[-]> " "1abreplxx[-]> " "1ab1ab2replxx[\\]> " "1ab21ab2creplxx[|]> " "1ab2creplxx[/]> " "1ab2c1ab2cd2\r\n" "replxx[-]> " "1ab2cdreplxx[-]> " "1ab2cd1ab2cd3replxx[\\]> " "1ab2cd31ab2cd3ereplxx[|]> " "1ab2cd3ereplxx[/]> " "1ab2cd3e1ab2cd3ef3\r\n" "replxx[-]> " "1ab2cd3efreplxx[-]> " "1ab2cd3ef1ab2cd3ef4replxx[\\]> " "1ab2cd3ef41ab2cd3ef4greplxx[|]> " "1ab2cd3ef4g1ab2cd3ef4g\r\n" "1ab2cd3ef4g\r\n", "0\r\n" "replxx[-]> " "1areplxx[-]> " "1areplxx[\\]> " "1areplxx[|]> " "1a1abreplxx[/]> " "1ab1\r\n" "replxx[-]> " "1abreplxx[-]> " "1ab1ab2replxx[\\]> " "1ab21ab2creplxx[|]> " "1ab2creplxx[/]> " "1ab2c1ab2cd2\r\n" "replxx[-]> " "1ab2cdreplxx[-]> " "1ab2cd1ab2cd3replxx[\\]> " "1ab2cd31ab2cd3ereplxx[|]> " "1ab2cd3ereplxx[/]> " "1ab2cd3e1ab2cd3ef3\r\n" "replxx[-]> " "1ab2cd3efreplxx[-]> " "1ab2cd3ef1ab2cd3ef4replxx[\\]> " "1ab2cd3ef41ab2cd3ef4greplxx[|]> " "1ab2cd3ef4g1ab2cd3ef4g\r\n" "1ab2cd3ef4g\r\n", "0\r\n" "replxx> " "replxx[-]> " "11areplxx[\\]> " "1areplxx[|]> " "1a1abreplxx[/]> " "1ab1\r\n" "replxx[-]> " "1abreplxx[-]> " "1ab1ab2replxx[\\]> " "1ab21ab2creplxx[|]> " "1ab2creplxx[/]> " "1ab2c1ab2cd2\r\n" "replxx[-]> " "1ab2cdreplxx[-]> " "1ab2cd1ab2cd3replxx[\\]> " "1ab2cd31ab2cd3ereplxx[|]> " "1ab2cd3ereplxx[/]> " "1ab2cd3e1ab2cd3ef3\r\n" "replxx[-]> " "1ab2cd3efreplxx[-]> " "1ab2cd3ef1ab2cd3ef4replxx[\\]> " "1ab2cd3ef41ab2cd3ef4greplxx[|]> " "1ab2cd3ef4g1ab2cd3ef4g\r\n" "1ab2cd3ef4g\r\n", "0\r\n" "replxx[-]> " "replxx[-]> " "11areplxx[\\]> " "1areplxx[|]> " "1a1abreplxx[/]> " "1ab1\r\n" "replxx[-]> " "1abreplxx[-]> " "1ab1ab2replxx[\\]> " "1ab21ab2creplxx[|]> " "1ab2creplxx[/]> " "1ab2c1ab2cd2\r\n" "replxx[-]> " "1ab2cdreplxx[-]> " "1ab2cd1ab2cd3replxx[\\]> " "1ab2cd31ab2cd3ereplxx[|]> " "1ab2cd3ereplxx[/]> " "1ab2cd3e1ab2cd3ef3\r\n" "replxx[-]> " "1ab2cd3efreplxx[-]> " "1ab2cd3ef1ab2cd3ef4replxx[\\]> " "1ab2cd3ef41ab2cd3ef4greplxx[|]> " "1ab2cd3ef4g1ab2cd3ef4g\r\n" "1ab2cd3ef4g\r\n", "0\r\n" "replxx[-]> " "replxx[-]> " "11areplxx[\\]> " "1areplxx[|]> " "1a1abreplxx[/]> " "1ab1\r\n" "replxx[-]> " "1abreplxx[-]> " "1ab1ab21ab2creplxx[\\]> " "1ab2creplxx[|]> " "1ab2creplxx[/]> " "1ab2c1ab2cd2\r\n" "replxx[-]> " "1ab2cdreplxx[-]> " "1ab2cd1ab2cd3replxx[\\]> " "1ab2cd31ab2cd3ereplxx[|]> " "1ab2cd3ereplxx[/]> " "1ab2cd3e1ab2cd3ef3\r\n" "replxx[-]> " "1ab2cd3efreplxx[-]> " "1ab2cd3ef1ab2cd3ef4replxx[\\]> " "1ab2cd3ef41ab2cd3ef4g1ab2cd3ef4g\r\n" "1ab2cd3ef4g\r\n" "replxx> replxx[|]> " "\r\n", "0\r\n" "replxx[-]> " "1areplxx[-]> " "1areplxx[\\]> " "1areplxx[|]> " "1a1abreplxx[/]> " "1ab1\r\n" "replxx[-]> " "1abreplxx[-]> " "1ab1ab21ab2creplxx[\\]> " "1ab2creplxx[|]> " "1ab2creplxx[/]> " "1ab2c1ab2cd2\r\n" "replxx[-]> " "1ab2cdreplxx[-]> " "1ab2cd1ab2cd3replxx[\\]> " "1ab2cd31ab2cd3ereplxx[|]> " "1ab2cd3ereplxx[/]> " "1ab2cd3e1ab2cd3ef3\r\n" "replxx[-]> " "1ab2cd3efreplxx[-]> " "1ab2cd3ef1ab2cd3ef4replxx[\\]> " "1ab2cd3ef41ab2cd3ef4g1ab2cd3ef4g\r\n" "1ab2cd3ef4g\r\n" "replxx> replxx[|]> " "\r\n" ], command = [ ReplxxTests._cxxSample_, "m", "F", "k123456" ], pause = 0.487 ) def test_prompt_from_callback( self_ ): self_.check_scenario( "rib", "some text color_b\r\n" " color_black\r\n" " color_brown\r\n" " " "color_bluereplxx[17]> " "some text color_b\r\n" " color_black\r\n" " color_brown\r\n" " " "color_bluereplxx[18]> " "some text color_b\r\n" " color_black\r\n" " color_brown\r\n" " " "color_bluereplxx[18]> " "some text color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenreplxx[19]> " "some text color_br\r\n" " color_brown\r\n" " color_brightred\r\n" " " "color_brightgreenreplxx[19]> " "some text color_bri\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " color_brightbluesome text " "color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[22]> " "some text color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[23]> " "some text color_bright\r\n" " color_brightred\r\n" " color_brightgreen\r\n" " " "color_brightbluereplxx[23]> " "some text color_brightbluesome text " "color_brightbluereplxx[26]> " "some text color_brightbluesome text " "color_brightbluereplxx[26]> \r\n" "some text color_brightblue\r\n" "replxx> " "replxx[0]> " "\r\n", "some text color_b\n", command = [ ReplxxTests._cxxSample_, "P" ] ) def test_color_256( self_ ): self_.check_scenario( "", "x c_3_6 rgb123 " "fg513bg142 gs21 " "gs5 gs19gs5 " "xx c_3_6 " "rgb123 fg513bg142 " "gs21 gs5 " "gs19gs5 x\r\n" "x c_3_6 rgb123 fg513bg142 gs21 gs5 gs19gs5 x\r\n", "x c_3_6 rgb123 fg513bg142 gs21 gs5 gs19gs5 x\n" ) def test_bold_and_underline_attributes( self_ ): self_.check_scenario( "", "bold_color_brightred " "color_brightred bold_color_red " "color_red underline_color_red " "bold_underline_color_redbold_color_brightred " "color_brightred bold_color_red " "color_red underline_color_red " "bold_underline_color_red\r\n" "bold_color_brightred color_brightred bold_color_red color_red " "underline_color_red bold_underline_color_red\r\n", "bold_color_brightred color_brightred bold_color_red color_red underline_color_red bold_underline_color_red\n" ) self_.check_scenario( "", "normal_text bold_text underline_text " "bold_underline_textnormal_text " "bold_text underline_text " "bold_underline_text\r\n" "normal_text bold_text underline_text bold_underline_text\r\n", "normal_text bold_text underline_text bold_underline_text\n" ) def test_kill_to_begining_of_line_in_multiline( self_ ): self_.check_scenario( "", "first line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "cripture\r\n" "last line of a codecripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a code\r\n" "first line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a code\r\n", "first line of textsecond verse of a poemnext passage of a scripturelast line of a code\n" ) def test_kill_to_end_of_line_in_multiline( self_ ): self_.check_scenario( "", "first line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second v\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second vfirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a codefirst line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a code\r\n" "first line of text\r\n" "second verse of a poem\r\n" "next passage of a scripture\r\n" "last line of a code\r\n", "first line of textsecond verse of a poemnext passage of a scripturelast line of a code\n" ) def test_long_prompt_multiline_enabled_hints( self_ ): prompt = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> " self_.check_scenario( "", "co\r\n" " color_black\r\n" " color_red\r\n" " " "color_greenco\r\n" "co\r\n", "co\n", command = [ ReplxxTests._cxxSample_, "I", "p" + prompt ], dimensions = ( 24, 64 ), prompt = prompt ) def test_ignore_case_hints_completions( self_ ): self_.check_scenario( "dee", "dde\r\n" " determinANT\r\n" " determiNATION\r\n" " deterMINEdetermin\r\n" " determinANT\r\n" " determiNATION\r\n" " deterMINEdetermine\r\n" " deterMINE\r\n" " deTERMINEDdetermine\r\n" "deterMINE deTERMINED\r\n" "replxx> determine\r\n" " deterMINE\r\n" " deTERMINEDdetermine\r\n" " deTERMINED\r\n" " " "determinedeterMINEdeterMINE\r\n" "deterMINE\r\n", command = [ ReplxxTests._cxxSample_, "i" ] ) self_.check_scenario( "deed", "dde\r\n" " determinANT\r\n" " determiNATION\r\n" " deterMINEdetermin\r\n" " determinANT\r\n" " determiNATION\r\n" " deterMINEdetermine\r\n" " deterMINE\r\n" " deTERMINEDdetermine\r\n" "deterMINE deTERMINED\r\n" "replxx> determine\r\n" " deterMINE\r\n" " " "deTERMINEDdetermineddeTERMINEDdeTERMINED\r\n" "deTERMINED\r\n", command = [ ReplxxTests._cxxSample_, "i" ] ) def test_ignore_case_history_search( self_ ): self_.check_scenario( "erR", "(reverse-i-search)`': " "(reverse-i-search)`e': " "determinANT(reverse-i-search)`er': " "determinANT(reverse-i-search)`e': " "determinANT(reverse-i-search)`eR': " "deteRMINISMreplxx> " "deteRMINISMdeteRMINISMdeteRMINISM\r\n" "thanks for the input: deteRMINISM\r\n", "deTERMINED\ndetERMINISTIC\ndeteRMINISM\ndeterMINE\ndetermiNATION\ndeterminANT\n", command = [ ReplxxTests._cSample_, "i1" ] ) self_.check_scenario( "deter", "dbdedetdetedeterdeterminANTdeterminANT\r\n" "thanks for the input: determinANT\r\n", "deTERMINED\ndetERMINISTIC\ndeteRMINISM\ndeterMINE\ndetermiNATION\ndeterminANT\n", command = [ ReplxxTests._cSample_, "i1" ] ) self_.check_scenario( "deteR", "dbdedetdetedeteRdeteRMINISMdeteRMINISM\r\n" "thanks for the input: deteRMINISM\r\n", "deTERMINED\ndetERMINISTIC\ndeteRMINISM\ndeterMINE\ndetermiNATION\ndeterminANT\n", command = [ ReplxxTests._cSample_, "i1" ] ) def test_history_scratch( self_ ): self_.check_scenario( "xyzZ", "threethreex" "twotwoy" "oneonez" "twoyonez" "onezZ" "threexonezZ" "onezZ\r\n" "onezZ\r\n", "one\ntwo\nthree\n" ) with open( "replxx_history.txt", "rb" ) as f: data = f.read().decode() origHist = "### 0000-00-00 00:00:00.000\none\n### 0000-00-00 00:00:00.000\ntwo\n### 0000-00-00 00:00:00.000\nthree\n"; self_.assertSequenceEqual( data[:len(origHist)], origHist ) self_.assertSequenceEqual( data[-6:], "onezZ\n" ) self_.check_scenario( "xyz", "threethreex" "twotwoy" "oneonez" "twoytwo" "oneztwo" "two\r\n" "two\r\n", "one\ntwo\nthree\n" ) self_.check_scenario( "xyz", "threethreex" "twotwoy" "oneonez" "twoytwo" "onetwo" "threethree\r\n" "three\r\n", "one\ntwo\nthree\n" ) def test_move_up_over_multiline( self_ ): self_.check_scenario( "", "ZZZbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbbbbb123123\r\n" "123\r\n", "123\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\nZZZ\n" ) def test_move_down_over_multiline( self_ ): self_.check_scenario( "x", "123bbbbbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbbbbb\r\n" "bbbbbbbbbbbbbbbbZZZxx\r\n" "x\r\n", "123\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\nZZZ\n" ) def test_position_tracking_no_color( self_ ): self_.check_scenario( "abcdef", "abcdefabcdef\r\nthanks for the input: abcdef\r\n", command = [ ReplxxTests._cSample_, "m", "N", "S", "C", "M0" ] ) def test_seeded_incremental_history_search( self_ ): self_.check_scenario( "for", "ffofor(reverse-i-search)`for': " "for(reverse-i-search)`for': " "forth(reverse-i-search)`for': " "fortranreplxx> " "fortranfortranfortran\r\n" "fortran\r\n", "\n".join( _words_[::-1] ) + "\n" ) def parseArgs( self, func, argv ): global verbosity res = func( self, argv ) verbosity = self.verbosity return res if __name__ == "__main__": pa = unittest.TestProgram.parseArgs unittest.TestProgram.parseArgs = lambda self, argv: parseArgs( self, pa, argv ) unittest.main()