fortrangoingonforty/fortsh / a2c4666

Browse files

add PTY tests for Ctrl+X cut and Ctrl+V paste

Authored by espadonne
SHA
a2c46666aaaeaaa3bca024475c3d97e017c5b615
Parents
3feed7f
Tree
4e64df8

1 changed file

StatusFile+-
M tests/interactive/test_specs/selection.yaml 53 0
tests/interactive/test_specs/selection.yamlmodified
@@ -487,3 +487,56 @@ tests:
487
       - send_key: "Enter"
487
       - send_key: "Enter"
488
     expect_output: "abc"
488
     expect_output: "abc"
489
     match_type: "contains"
489
     match_type: "contains"
490
+
491
+  # =============================================================
492
+  # SPRINT 5 — CLIPBOARD BRIDGE + CTRL+X / CTRL+V
493
+  # These tests run outside test mode so clipboard tools are
494
+  # accessible (test mode doesn't affect clipboard, but we need
495
+  # FORTSH_TEST_MODE=0 for full redraw + echo output assertions).
496
+  # =============================================================
497
+
498
+  - name: "Sprint 5: Ctrl+X on selection cuts (dual-mode)"
499
+    # Select "bbb", Ctrl+X cuts it. Buffer becomes "aaa  ccc".
500
+    # (The trailing space after "aaa" was between "aaa" and "bbb".)
501
+    # Then type "Z" where cursor is → "aaa Z ccc".
502
+    steps:
503
+      - send: "aaa bbb ccc"
504
+      - send_key: "C-S-Left"
505
+      - send_key: "C-S-Left"
506
+      - send_key: "C-x"
507
+      - send: "Z"
508
+      - send_key: "C-a"
509
+      - send: "echo "
510
+      - send_key: "Enter"
511
+    # C-S-Left from 11 → word back to 8 (start of "ccc"), again to 4 (start of "bbb").
512
+    # Selection = [4..11) = "bbb ccc". After Ctrl+X delete: buffer "aaa ", cursor=4.
513
+    # Insert Z → "aaa Z", cursor=5. Echo → "aaa Z".
514
+    expect_output: "aaa Z"
515
+    match_type: "contains"
516
+
517
+  - name: "Sprint 5: Ctrl+X with no selection enters process kill mode"
518
+    # Regression guard: Ctrl+X without selection must NOT cut anything.
519
+    # It enters process-kill-mode (the existing behavior). Pressing
520
+    # Escape exits process-kill mode. Then normal editing resumes.
521
+    steps:
522
+      - send: "echo intact"
523
+      - send_key: "C-x"
524
+      - send_key: "Escape"
525
+      - send_key: "Enter"
526
+    expect_output: "intact"
527
+    match_type: "contains"
528
+
529
+  - name: "Sprint 5: Ctrl+V pastes from kill buffer when no clipboard"
530
+    # Populate kill buffer via Ctrl+U, then Ctrl+V to paste. Since the
531
+    # PTY test harness runs in test mode with a clean env, Ctrl+V reads
532
+    # the system clipboard (which may contain stale data from earlier
533
+    # tests). Instead we verify the kill-buffer fallback: Ctrl+U kills
534
+    # "hello", Ctrl+V pastes it back.
535
+    steps:
536
+      - send: "hello"
537
+      - send_key: "C-u"
538
+      - send: "echo "
539
+      - send_key: "C-v"
540
+      - send_key: "Enter"
541
+    expect_output: "hello"
542
+    match_type: "contains"