1package # hide 2Data_Test_Readline; 3 4use 5.10.0; 5use warnings; 6use strict; 7 8 9sub key_seq { 10 return { 11 CONTROL_M => "\x{0d}", 12 ENTER => "\x{0d}", 13 14 RIGHT => "\e[C", 15 RIGHT_O => "\eOC", 16 CONTROL_F => "\x{06}", 17 18 LEFT => "\e[D", 19 LEFT_O => "\eOD", 20 CONTROL_B => "\x{02}", 21 22 CONTROL_A => "\x{01}", 23 HOME => "\e[H", 24 25 CONTROL_E => "\x{05}", 26 END => "\e[F", 27 28 CONTROL_H => "\x{08}", 29 BTAB => "\x{08}", 30 BSPACE => "\x{7f}", 31 BTAB_Z => "\e[Z", 32 BTAB_OZ => "\eOZ", 33 34 CONTROL_D => "\x{04}", 35 DELETE => "\e[3~", 36 37 CONTROL_K => "\x{0b}", 38 CONTROL_U => "\x{15}", 39 }; 40} 41 42sub return_test_data { 43 return [ 44 #{ 45 # used_keys => [ 'CONTROL_U', "a", 'ENTER'], 46 # expected => "<a>", 47 # arguments => [ 'Prompt: ', { default => "many words " x 100, no_echo => 0 } ], 48 #}, 49 { 50 used_keys => [ "-", 'ENTER' ], 51 expected => "<->", 52 arguments => [ 'Prompt: ' ], 53 }, 54 { 55 used_keys => [ 'ENTER' ], 56 expected => "<default>", 57 arguments => [ 'Prompt: ', "default" ], 58 }, 59 { 60 used_keys => [ ( 'LEFT' ) x 4, 'CONTROL_K', " ", 'ENTER' ], 61 expected => "<def >", 62 arguments => [ 'Prompt: ', 'default' ], 63 }, 64 { 65 used_keys => [ ( 'LEFT' ) x 5, "-", 'ENTER' ], 66 expected => "<de-fault>", 67 arguments => [ 'Prompt: ', "default" ], 68 }, 69 { 70 used_keys => [ ( 'BSPACE' ) x 7, "hello", " ", "world", 'ENTER' ], 71 expected => "<hello world>", 72 arguments => [ 'Prompt: ', { default => "default" } ], 73 }, 74 { 75 used_keys => [ "house", 'ENTER' ], 76 expected => "<The house>", 77 arguments => [ 'Prompt: ', { default => "The ", no_echo => 1 } ], 78 }, 79 { 80 used_keys => [ "0123456789", ( 'LEFT' ) x 5, 'CONTROL_U', 'ENTER' ], 81 expected => "<56789>", 82 arguments => [ ': ' ], 83 }, 84 85 { 86 used_keys => [ "abcde ", "XY " x 10, ( 'LEFT' ) x 36, ( 'RIGHT' ) x 8, 'CONTROL_K', 'ENTER' ], 87 expected => "<DEFAULT abcde XY>", 88 arguments => [ "Prompt: ", { default => "DEFAULT " } ], 89 }, 90 { 91 used_keys => [ "The black cat climbed the green tree", 'HOME', ( 'RIGHT' ) x 4, ( 'DELETE' ) x 6, 'END', ( 'LEFT' ) x 5, ( 'BSPACE' ) x 6, 'ENTER' ], 92 expected => "<The cat climbed the tree>", 93 arguments => [ 'Prompt: ' ], 94 }, 95 { 96 used_keys => [ qw( HOME RIGHT RIGHT_O DELETE CONTROL_D END LEFT LEFT_O BSPACE CONTROL_H CONTROL_A DELETE CONTROL_E BSPACE _ABC ENTER ) ], 97 expected => "<hblack cat climbed the green e_ABC>", 98 arguments => [ 'Prompt: ', { default => "The black cat climbed the green tree" } ], 99 }, 100 ]; 101} 102 103 104 105 1061; 107 108__END__ 109