| 1 | # Vi Mode Tests |
| 2 | # Tests vi-style line editing commands |
| 3 | |
| 4 | metadata: |
| 5 | category: "Vi Mode" |
| 6 | description: "Tests for vi-style command line editing" |
| 7 | phase: 3 |
| 8 | |
| 9 | tests: |
| 10 | # ============================================================= |
| 11 | # MODE SWITCHING |
| 12 | # ============================================================= |
| 13 | - name: "Enable vi mode with set -o vi" |
| 14 | steps: |
| 15 | - send_line: "set -o vi" |
| 16 | - send_line: "echo vi_enabled" |
| 17 | expect_output: "vi_enabled" |
| 18 | match_type: "contains" |
| 19 | |
| 20 | - name: "Escape enters command mode" |
| 21 | steps: |
| 22 | - send_line: "set -o vi" |
| 23 | - send: "echo hello" |
| 24 | - send_key: "Escape" |
| 25 | - wait: 0.7 |
| 26 | - send: "0" |
| 27 | - wait: 0.2 |
| 28 | - send: "d" |
| 29 | - wait: 0.2 |
| 30 | - send: "w" |
| 31 | - wait: 0.2 |
| 32 | - send: "i" |
| 33 | - wait: 0.2 |
| 34 | - send: "echo goodbye" |
| 35 | - send_key: "Enter" |
| 36 | expect_output: "goodbye" |
| 37 | match_type: "contains" |
| 38 | |
| 39 | # ============================================================= |
| 40 | # MOVEMENT COMMANDS (in command mode) |
| 41 | # ============================================================= |
| 42 | - name: "h moves cursor left" |
| 43 | steps: |
| 44 | - send_line: "set -o vi" |
| 45 | - send: "echo ABCD" |
| 46 | - send_key: "Escape" |
| 47 | - wait: 0.7 |
| 48 | - send: "h" |
| 49 | - wait: 0.2 |
| 50 | - send: "i" |
| 51 | - wait: 0.2 |
| 52 | - send: "X" |
| 53 | - send_key: "Escape" |
| 54 | - wait: 0.2 |
| 55 | - send: "0" |
| 56 | - wait: 0.2 |
| 57 | - send: "i" |
| 58 | - wait: 0.2 |
| 59 | - send_key: "Enter" |
| 60 | expect_output: "ABXCD" |
| 61 | match_type: "contains" |
| 62 | |
| 63 | - name: "l moves cursor right" |
| 64 | steps: |
| 65 | - send_line: "set -o vi" |
| 66 | - send: "echo ABCD" |
| 67 | - send_key: "Escape" |
| 68 | - wait: 0.7 |
| 69 | - send: "0" |
| 70 | - wait: 0.2 |
| 71 | - send: "w" |
| 72 | - wait: 0.2 |
| 73 | - send: "l" |
| 74 | - wait: 0.2 |
| 75 | - send: "i" |
| 76 | - wait: 0.2 |
| 77 | - send: "X" |
| 78 | - send_key: "Escape" |
| 79 | - wait: 0.2 |
| 80 | - send: "0" |
| 81 | - wait: 0.2 |
| 82 | - send: "i" |
| 83 | - wait: 0.2 |
| 84 | - send_key: "Enter" |
| 85 | expect_output: "AXBCD" |
| 86 | match_type: "contains" |
| 87 | |
| 88 | - name: "0 moves to beginning of line" |
| 89 | steps: |
| 90 | - send_line: "set -o vi" |
| 91 | - send: "echo test" |
| 92 | - send_key: "Escape" |
| 93 | - wait: 0.7 |
| 94 | - send: "0" |
| 95 | - wait: 0.2 |
| 96 | - send: "d" |
| 97 | - wait: 0.2 |
| 98 | - send: "w" |
| 99 | - wait: 0.2 |
| 100 | - send: "i" |
| 101 | - wait: 0.2 |
| 102 | - send: "printf '" |
| 103 | - send_key: "Escape" |
| 104 | - wait: 0.2 |
| 105 | - send: "A" |
| 106 | - wait: 0.2 |
| 107 | - send: "'" |
| 108 | - send_key: "Enter" |
| 109 | expect_output: "test" |
| 110 | match_type: "contains" |
| 111 | |
| 112 | - name: "$ moves to end of line" |
| 113 | steps: |
| 114 | - send_line: "set -o vi" |
| 115 | - send: "echo test" |
| 116 | - send_key: "Escape" |
| 117 | - wait: 0.7 |
| 118 | - send: "0" |
| 119 | - wait: 0.2 |
| 120 | - send: "$" |
| 121 | - wait: 0.2 |
| 122 | - send: "a" |
| 123 | - wait: 0.2 |
| 124 | - send: "X" |
| 125 | - send_key: "Enter" |
| 126 | expect_output: "echo testX" |
| 127 | match_type: "contains" |
| 128 | |
| 129 | - name: "w moves forward one word" |
| 130 | steps: |
| 131 | - send_line: "set -o vi" |
| 132 | - send: "echo ABC DEF" |
| 133 | - send_key: "Escape" |
| 134 | - wait: 0.7 |
| 135 | - send: "0" |
| 136 | - wait: 0.2 |
| 137 | - send: "w" |
| 138 | - wait: 0.2 |
| 139 | - send: "w" |
| 140 | - wait: 0.2 |
| 141 | - send: "i" |
| 142 | - wait: 0.2 |
| 143 | - send: "X" |
| 144 | - send_key: "Escape" |
| 145 | - wait: 0.2 |
| 146 | - send: "0" |
| 147 | - wait: 0.2 |
| 148 | - send: "i" |
| 149 | - wait: 0.2 |
| 150 | - send_key: "Enter" |
| 151 | expect_output: "ABC XDEF" |
| 152 | match_type: "contains" |
| 153 | |
| 154 | - name: "b moves backward one word" |
| 155 | steps: |
| 156 | - send_line: "set -o vi" |
| 157 | - send: "echo ABC DEF" |
| 158 | - send_key: "Escape" |
| 159 | - wait: 0.7 |
| 160 | - send: "b" |
| 161 | - wait: 0.2 |
| 162 | - send: "i" |
| 163 | - wait: 0.2 |
| 164 | - send: "X" |
| 165 | - send_key: "Escape" |
| 166 | - wait: 0.2 |
| 167 | - send: "0" |
| 168 | - wait: 0.2 |
| 169 | - send: "i" |
| 170 | - wait: 0.2 |
| 171 | - send_key: "Enter" |
| 172 | expect_output: "ABC XDEF" |
| 173 | match_type: "contains" |
| 174 | |
| 175 | - name: "e moves to end of word" |
| 176 | steps: |
| 177 | - send_line: "set -o vi" |
| 178 | - send: "echo ABC DEF" |
| 179 | - send_key: "Escape" |
| 180 | - wait: 0.7 |
| 181 | - send: "0" |
| 182 | - wait: 0.2 |
| 183 | - send: "w" |
| 184 | - wait: 0.2 |
| 185 | - send: "e" |
| 186 | - wait: 0.2 |
| 187 | - send: "a" |
| 188 | - wait: 0.2 |
| 189 | - send: "X" |
| 190 | - send_key: "Escape" |
| 191 | - wait: 0.2 |
| 192 | - send: "0" |
| 193 | - wait: 0.2 |
| 194 | - send: "i" |
| 195 | - wait: 0.2 |
| 196 | - send_key: "Enter" |
| 197 | expect_output: "ABCX DEF" |
| 198 | match_type: "contains" |
| 199 | |
| 200 | # ============================================================= |
| 201 | # INSERT MODE COMMANDS |
| 202 | # ============================================================= |
| 203 | - name: "i enters insert mode before cursor" |
| 204 | steps: |
| 205 | - send_line: "set -o vi" |
| 206 | - send: "echo ABCD" |
| 207 | - send_key: "Escape" |
| 208 | - wait: 0.7 |
| 209 | - send: "0" |
| 210 | - wait: 0.2 |
| 211 | - send: "w" |
| 212 | - wait: 0.2 |
| 213 | - send: "i" |
| 214 | - wait: 0.2 |
| 215 | - send: "X" |
| 216 | - send_key: "Escape" |
| 217 | - wait: 0.2 |
| 218 | - send: "0" |
| 219 | - wait: 0.2 |
| 220 | - send: "i" |
| 221 | - wait: 0.2 |
| 222 | - send_key: "Enter" |
| 223 | expect_output: "XABCD" |
| 224 | match_type: "contains" |
| 225 | |
| 226 | - name: "a enters insert mode after cursor" |
| 227 | steps: |
| 228 | - send_line: "set -o vi" |
| 229 | - send: "echo ABCD" |
| 230 | - send_key: "Escape" |
| 231 | - wait: 0.7 |
| 232 | - send: "0" |
| 233 | - wait: 0.2 |
| 234 | - send: "w" |
| 235 | - wait: 0.2 |
| 236 | - send: "a" |
| 237 | - wait: 0.2 |
| 238 | - send: "X" |
| 239 | - send_key: "Escape" |
| 240 | - wait: 0.2 |
| 241 | - send: "0" |
| 242 | - wait: 0.2 |
| 243 | - send: "i" |
| 244 | - wait: 0.2 |
| 245 | - send_key: "Enter" |
| 246 | expect_output: "AXBCD" |
| 247 | match_type: "contains" |
| 248 | |
| 249 | - name: "I enters insert mode at beginning" |
| 250 | steps: |
| 251 | - send_line: "set -o vi" |
| 252 | - send: "cho test" |
| 253 | - send_key: "Escape" |
| 254 | - wait: 0.7 |
| 255 | - send: "I" |
| 256 | - wait: 0.2 |
| 257 | - send: "e" |
| 258 | - send_key: "Enter" |
| 259 | expect_output: "test" |
| 260 | match_type: "contains" |
| 261 | |
| 262 | - name: "A enters insert mode at end" |
| 263 | steps: |
| 264 | - send_line: "set -o vi" |
| 265 | - send: "echo test" |
| 266 | - send_key: "Escape" |
| 267 | - wait: 0.5 |
| 268 | - send: "A" |
| 269 | - wait: 0.1 |
| 270 | - send: "X" |
| 271 | - send_key: "Enter" |
| 272 | expect_output: "echo testX" |
| 273 | match_type: "contains" |
| 274 | |
| 275 | # ============================================================= |
| 276 | # DELETION COMMANDS |
| 277 | # ============================================================= |
| 278 | - name: "x deletes character under cursor" |
| 279 | steps: |
| 280 | - send_line: "set -o vi" |
| 281 | - send: "echo test" |
| 282 | - send_key: "Escape" |
| 283 | - wait: 0.7 |
| 284 | - send: "0" |
| 285 | - wait: 0.2 |
| 286 | - send: "x" |
| 287 | - wait: 0.2 |
| 288 | - send: "i" |
| 289 | - send_key: "Enter" |
| 290 | expect_output: "cho test" |
| 291 | match_type: "contains" |
| 292 | |
| 293 | - name: "X deletes character before cursor" |
| 294 | steps: |
| 295 | - send_line: "set -o vi" |
| 296 | - send: "echo test" |
| 297 | - send_key: "Escape" |
| 298 | - wait: 0.5 |
| 299 | - send: "X" |
| 300 | - wait: 0.1 |
| 301 | - send: "a" |
| 302 | - send_key: "Enter" |
| 303 | expect_output: "echo tes" |
| 304 | match_type: "contains" |
| 305 | |
| 306 | - name: "dw deletes word" |
| 307 | steps: |
| 308 | - send_line: "set -o vi" |
| 309 | - send: "echo hello world" |
| 310 | - send_key: "Escape" |
| 311 | - wait: 0.7 |
| 312 | - send: "0" |
| 313 | - wait: 0.2 |
| 314 | - send: "d" |
| 315 | - wait: 0.2 |
| 316 | - send: "w" |
| 317 | - wait: 0.2 |
| 318 | - send: "i" |
| 319 | - send_key: "Enter" |
| 320 | expect_output: "hello world" |
| 321 | match_type: "contains" |
| 322 | |
| 323 | - name: "dd clears entire line" |
| 324 | steps: |
| 325 | - send_line: "set -o vi" |
| 326 | - send: "echo test" |
| 327 | - send_key: "Escape" |
| 328 | - wait: 0.7 |
| 329 | - send: "d" |
| 330 | - wait: 0.2 |
| 331 | - send: "d" |
| 332 | - wait: 0.2 |
| 333 | - send: "i" |
| 334 | - wait: 0.2 |
| 335 | - send: "echo cleared" |
| 336 | - send_key: "Enter" |
| 337 | expect_output: "cleared" |
| 338 | match_type: "contains" |
| 339 | |
| 340 | - name: "D deletes to end of line" |
| 341 | steps: |
| 342 | - send_line: "set -o vi" |
| 343 | - send: "echo hello world" |
| 344 | - send_key: "Escape" |
| 345 | - wait: 0.7 |
| 346 | - send: "0" |
| 347 | - wait: 0.2 |
| 348 | - send: "w" |
| 349 | - wait: 0.2 |
| 350 | - send: "D" |
| 351 | - wait: 0.2 |
| 352 | - send: "a" |
| 353 | - send_key: "Enter" |
| 354 | expect_output: "echo" |
| 355 | match_type: "contains" |
| 356 | |
| 357 | # ============================================================= |
| 358 | # CHANGE COMMANDS |
| 359 | # ============================================================= |
| 360 | - name: "cw changes word" |
| 361 | steps: |
| 362 | - send_line: "set -o vi" |
| 363 | - send: "echo hello world" |
| 364 | - send_key: "Escape" |
| 365 | - wait: 0.7 |
| 366 | - send: "0" |
| 367 | - wait: 0.2 |
| 368 | - send: "w" |
| 369 | - wait: 0.2 |
| 370 | - send: "c" |
| 371 | - wait: 0.2 |
| 372 | - send: "w" |
| 373 | - wait: 0.2 |
| 374 | - send: "goodbye" |
| 375 | - send_key: "Enter" |
| 376 | expect_output: "goodbye world" |
| 377 | match_type: "contains" |
| 378 | |
| 379 | - name: "cc changes entire line" |
| 380 | steps: |
| 381 | - send_line: "set -o vi" |
| 382 | - send: "old command" |
| 383 | - send_key: "Escape" |
| 384 | - wait: 0.7 |
| 385 | - send: "c" |
| 386 | - wait: 0.2 |
| 387 | - send: "c" |
| 388 | - wait: 0.2 |
| 389 | - send: "echo new" |
| 390 | - send_key: "Enter" |
| 391 | expect_output: "new" |
| 392 | match_type: "contains" |
| 393 | |
| 394 | - name: "C changes to end of line" |
| 395 | steps: |
| 396 | - send_line: "set -o vi" |
| 397 | - send: "echo hello world" |
| 398 | - send_key: "Escape" |
| 399 | - wait: 0.7 |
| 400 | - send: "0" |
| 401 | - wait: 0.2 |
| 402 | - send: "w" |
| 403 | - wait: 0.2 |
| 404 | - send: "C" |
| 405 | - wait: 0.2 |
| 406 | - send: "changed" |
| 407 | - send_key: "Enter" |
| 408 | expect_output: "changed" |
| 409 | match_type: "contains" |
| 410 | |
| 411 | # ============================================================= |
| 412 | # HISTORY NAVIGATION (in command mode) |
| 413 | # ============================================================= |
| 414 | - name: "k moves to previous history" |
| 415 | steps: |
| 416 | - send_line: "set -o vi" |
| 417 | - send_line: "echo first" |
| 418 | - send_line: "echo second" |
| 419 | - send_key: "Escape" |
| 420 | - wait: 0.5 |
| 421 | - send: "k" |
| 422 | - send_key: "Enter" |
| 423 | expect_output: "second" |
| 424 | match_type: "contains" |
| 425 | |
| 426 | - name: "j moves to next history" |
| 427 | steps: |
| 428 | - send_line: "set -o vi" |
| 429 | - send_line: "echo first" |
| 430 | - send_line: "echo second" |
| 431 | - send_key: "Escape" |
| 432 | - wait: 0.7 |
| 433 | - send: "k" |
| 434 | - wait: 0.2 |
| 435 | - send: "k" |
| 436 | - wait: 0.2 |
| 437 | - send: "j" |
| 438 | - send_key: "Enter" |
| 439 | expect_output: "second" |
| 440 | match_type: "contains" |
| 441 | |
| 442 | # ============================================================= |
| 443 | # UNDO |
| 444 | # ============================================================= |
| 445 | - name: "u undoes last change" |
| 446 | steps: |
| 447 | - send_line: "set -o vi" |
| 448 | - send: "echo test" |
| 449 | - send_key: "Escape" |
| 450 | - wait: 0.7 |
| 451 | - send: "0" |
| 452 | - wait: 0.2 |
| 453 | - send: "d" |
| 454 | - wait: 0.2 |
| 455 | - send: "w" |
| 456 | - wait: 0.2 |
| 457 | - send: "u" |
| 458 | - wait: 0.2 |
| 459 | - send: "i" |
| 460 | - send_key: "Enter" |
| 461 | expect_output: "test" |
| 462 | match_type: "contains" |
| 463 | |
| 464 | # ============================================================= |
| 465 | # REPEAT AND COUNT |
| 466 | # ============================================================= |
| 467 | - name: "2x deletes two characters" |
| 468 | steps: |
| 469 | - send_line: "set -o vi" |
| 470 | - send: "echo abcd" |
| 471 | - send_key: "Escape" |
| 472 | - wait: 0.7 |
| 473 | - send: "0" |
| 474 | - wait: 0.2 |
| 475 | - send: "2" |
| 476 | - wait: 0.2 |
| 477 | - send: "x" |
| 478 | - wait: 0.2 |
| 479 | - send: "i" |
| 480 | - send_key: "Enter" |
| 481 | expect_output: "ho abcd" |
| 482 | match_type: "contains" |
| 483 | |
| 484 | - name: "3l moves 3 characters right" |
| 485 | steps: |
| 486 | - send_line: "set -o vi" |
| 487 | - send: "echo ABCDEF" |
| 488 | - send_key: "Escape" |
| 489 | - wait: 0.7 |
| 490 | - send: "0" |
| 491 | - wait: 0.2 |
| 492 | - send: "w" |
| 493 | - wait: 0.2 |
| 494 | - send: "3" |
| 495 | - wait: 0.2 |
| 496 | - send: "l" |
| 497 | - wait: 0.2 |
| 498 | - send: "i" |
| 499 | - wait: 0.2 |
| 500 | - send: "X" |
| 501 | - send_key: "Escape" |
| 502 | - wait: 0.2 |
| 503 | - send: "0" |
| 504 | - wait: 0.2 |
| 505 | - send: "i" |
| 506 | - wait: 0.2 |
| 507 | - send_key: "Enter" |
| 508 | expect_output: "ABCXDEF" |
| 509 | match_type: "contains" |
| 510 | |
| 511 | # ============================================================= |
| 512 | # RETURN TO EMACS MODE |
| 513 | # ============================================================= |
| 514 | - name: "set -o emacs returns to emacs mode" |
| 515 | steps: |
| 516 | - send_line: "set -o vi" |
| 517 | - send_line: "set -o emacs" |
| 518 | - send: "cho hello" |
| 519 | - send_key: "C-a" |
| 520 | - send: "e" |
| 521 | - send_key: "Enter" |
| 522 | expect_output: "hello" |
| 523 | match_type: "contains" |
| 524 |