Skip to content

Commit 97c0fbe

Browse files
committed
Fix hard-coded continuation prompt in tests
Since many of these work in screen reader mode, just without the prompt (as if it were an empty string).
1 parent 28ad9e6 commit 97c0fbe

9 files changed

+147
-195
lines changed

test/BasicEditingTest.VI.cs

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -494,16 +494,14 @@ public void ViDeletePreviousLines()
494494
{
495495
TestSetup(KeyMode.Vi);
496496

497-
int continuationPrefixLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
498-
499497
Test("\"\n\"", Keys(
500498
 _.DQuote, _.Enter,
501499
"one", _.Enter,
502500
"two", _.Enter,
503501
"three", _.Enter,
504502
_.DQuote, _.Escape,
505503
"kl", // go to the 'hree' portion of "three"
506-
"2dk", CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 0))
504+
"2dk", CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0))
507505
));
508506
}
509507

@@ -512,16 +510,14 @@ public void ViDeletePreviousLines_LastLine()
512510
{
513511
TestSetup(KeyMode.Vi);
514512

515-
int continuationPrefixLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
516-
517513
Test("\"\none\ntwo\n\"", Keys(
518514
 _.DQuote, _.Enter,
519515
"one", _.Enter,
520516
"two", _.Enter,
521517
"three", _.Enter,
522518
_.DQuote, _.Escape,
523519
"dk",
524-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 0)),
520+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0)),
525521
CheckThat(() => AssertCursorTopIs(2)),
526522
CheckThat(() => AssertLineIs("\"\none\ntwo")),
527523
// finish the buffer to close the multiline string
@@ -571,8 +567,6 @@ public void ViDeleteToEnd()
571567
{
572568
TestSetup(KeyMode.Vi);
573569

574-
int continuationPrefixLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
575-
576570
Test("\"\no\nthree\n\"", Keys(
577571
_.DQuote, _.Enter,
578572
"one", _.Enter,
@@ -582,7 +576,7 @@ public void ViDeleteToEnd()
582576
"kkkl", // go to the 'ne' portion of "one"
583577
// delete to the end of the next line
584578
"2d$",
585-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 0))
579+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0))
586580
));
587581
}
588582

@@ -591,18 +585,16 @@ public void ViBackwardDeleteLine()
591585
{
592586
TestSetup(KeyMode.Vi);
593587

594-
int continuationPrefixLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
595-
596588
Test("\"\nsome words\n\"", Keys(
597589

598590
_.DQuote, _.Enter,
599591
" this is a line with some words", _.Enter,
600592
_.DQuote, _.Escape,
601593
"k6W",
602-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 23)),
594+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 23)),
603595
// delete from first non blank of line
604596
"d0",
605-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength))
597+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength))
606598
));
607599
}
608600

@@ -611,17 +603,15 @@ public void ViDeleteLineToFirstChar()
611603
{
612604
TestSetup(KeyMode.Vi);
613605

614-
int continuationPrefixLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
615-
616606
Test("\"\n some spaces\n\"", Keys(
617607
_.DQuote, _.Enter,
618608
" this is a line with some spaces", _.Enter,
619609
_.DQuote, _.Escape,
620610
"k6W",
621-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 23)),
611+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 23)),
622612
// delete from first non blank of line
623613
"d^",
624-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 3))
614+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 3))
625615
));
626616
}
627617

@@ -630,16 +620,14 @@ public void ViDeleteNextLines()
630620
{
631621
TestSetup(KeyMode.Vi);
632622

633-
int continuationPrefixLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
634-
635623
Test("\"\n\"", Keys(
636624
 _.DQuote, _.Enter,
637625
"one", _.Enter,
638626
"two", _.Enter,
639627
"three", _.Enter,
640628
_.DQuote, _.Escape,
641629
"kkkl", // go to the 'ne' portion of "one"
642-
"2dj", CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 0))
630+
"2dj", CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0))
643631
));
644632
}
645633

@@ -648,8 +636,6 @@ public void ViDeleteRelativeLines()
648636
{
649637
TestSetup(KeyMode.Vi);
650638

651-
var continuationPrefixLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
652-
653639
Test("\"\nthree\n\"", Keys(
654640
_.DQuote, _.Enter,
655641
"one", _.Enter,
@@ -659,7 +645,7 @@ public void ViDeleteRelativeLines()
659645
"kkl", // go to the 'wo' portion of "two"
660646
// delete from line 2 to the current line (3)
661647
"2dgg",
662-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 0))
648+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0))
663649
));
664650

665651
Test("\"\none\nthree\n\"", Keys(
@@ -671,7 +657,7 @@ public void ViDeleteRelativeLines()
671657
"kkl", // go to the 'wo' portion of "two"
672658
// delete the current line (3)
673659
"3dgg",
674-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 0))
660+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0))
675661
));
676662

677663
Test("\"\none\n\"", Keys(
@@ -683,7 +669,7 @@ public void ViDeleteRelativeLines()
683669
"kkl", // go to the 'wo' portion of "two"
684670
// delete from the current line (3) to line 4
685671
"4dgg",
686-
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 0))
672+
CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0))
687673
));
688674
}
689675

@@ -977,16 +963,15 @@ public void ViDefect651()
977963
[SkippableFact]
978964
public void ViInsertLine()
979965
{
980-
int adder = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
981966
TestSetup(KeyMode.Vi);
982967

983968
Test("line1\n", Keys(
984969
_.Escape, "Oline1", CheckThat(() => AssertCursorLeftIs(5))
985970
));
986971

987972
Test("\nline1", Keys(
988-
_.Escape, "oline1", CheckThat(() => AssertCursorLeftIs(5 + adder)), CheckThat(() => AssertLineIs("\nline1")),
989-
_.Escape, CheckThat(() => AssertCursorLeftIs(4 + adder))
973+
_.Escape, "oline1", CheckThat(() => AssertCursorLeftIs(5 + ContinuationPromptLength)), CheckThat(() => AssertLineIs("\nline1")),
974+
_.Escape, CheckThat(() => AssertCursorLeftIs(4 + ContinuationPromptLength))
990975
));
991976

992977
Test("", Keys(
@@ -1010,10 +995,10 @@ public void ViInsertLine()
1010995
));
1011996

1012997
Test("", Keys(
1013-
_.Escape, "oline4", CheckThat(() => AssertLineIs("\nline4")), CheckThat(() => AssertCursorLeftIs(5 + adder)),
1014-
_.Escape, "Oline2", CheckThat(() => AssertLineIs("\nline2\nline4")), CheckThat(() => AssertCursorLeftIs(5 + adder)),
998+
_.Escape, "oline4", CheckThat(() => AssertLineIs("\nline4")), CheckThat(() => AssertCursorLeftIs(5 + ContinuationPromptLength)),
999+
_.Escape, "Oline2", CheckThat(() => AssertLineIs("\nline2\nline4")), CheckThat(() => AssertCursorLeftIs(5 + ContinuationPromptLength)),
10151000
_.Escape, "oline3", CheckThat(() => AssertLineIs("\nline2\nline3\nline4")),
1016-
_.Escape, CheckThat(() => AssertLineIs("\nline2\nline3\nline4")), CheckThat(() => AssertCursorLeftIs(4 + adder)),
1001+
_.Escape, CheckThat(() => AssertLineIs("\nline2\nline3\nline4")), CheckThat(() => AssertCursorLeftIs(4 + ContinuationPromptLength)),
10171002
'u', CheckThat(() => AssertLineIs("\nline2\nline4")),
10181003
'u', CheckThat(() => AssertLineIs("\nline4")),
10191004
'u'

test/BasicEditingTest.cs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ public void InsertLineAbove()
340340
{
341341
TestSetup(KeyMode.Cmd);
342342

343-
var continutationPromptLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
344-
345343
// Test case - start with single line, cursor at end
346344
Test("56\n1234", Keys("1234", _.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(0, 0)), "56"));
347345

@@ -356,13 +354,13 @@ public void InsertLineAbove()
356354

357355
// Test case - start with multi-line, cursor at end of second line (end of input)
358356
Test("1234\n9ABC\n5678", Keys("1234", _.Shift_Enter, "5678",
359-
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
357+
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
360358
"9ABC"));
361359

362360
// Test case - start with multi-line, cursor at beginning of second line
363361
Test("1234\n9ABC\n5678", Keys("1234", _.Shift_Enter, "5678",
364-
_.LeftArrow, _.Home, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
365-
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
362+
_.LeftArrow, _.Home, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
363+
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
366364
"9ABC"));
367365

368366
// Test case - start with multi-line, cursor at end of first line
@@ -380,67 +378,65 @@ public void InsertLineAbove()
380378

381379
// Test case - insert multiple blank lines
382380
Test("1234\n9ABC\n\n5678", Keys("1234", _.Shift_Enter, "5678",
383-
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
384-
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
381+
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
382+
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
385383
"9ABC"));
386384

387385
// Test case - create leading blank line, cursor to stay on same line
388386
Test("\n\n1234", Keys("1234",
389387
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(0,0)),
390-
_.DownArrow, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
391-
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1))));
388+
_.DownArrow, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
389+
_.Ctrl_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1))));
392390
}
393391

394392
[SkippableFact]
395393
public void InsertLineBelow()
396394
{
397395
TestSetup(KeyMode.Cmd);
398396

399-
var continutationPromptLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
400-
401397
// Test case - start with single line, cursor at end
402398
Test("1234\n56", Keys("1234",
403-
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
399+
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
404400
"56"));
405401

406402
// Test case - start with single line, cursor in home position
407403
Test("1234\n56", Keys("1234",
408-
_.Home, _.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
404+
_.Home, _.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
409405
"56"));
410406

411407
// Test case - start with single line, cursor in middle
412408
Test("1234\n56", Keys("1234",
413-
_.LeftArrow, _.LeftArrow, _.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
409+
_.LeftArrow, _.LeftArrow, _.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
414410
"56"));
415411

416412
// Test case - start with multi-line, cursor at end of second line (end of input)
417413
Test("1234\n5678\n9ABC", Keys("1234", _.Shift_Enter, "5678",
418-
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 2)),
414+
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 2)),
419415
"9ABC"));
420416

421417
// Test case - start with multi-line, cursor at beginning of second line
422418
Test("1234\n5678\n9ABC", Keys("1234", _.Shift_Enter, "5678",
423-
_.LeftArrow, _.Home, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
424-
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 2)),
419+
_.LeftArrow, _.Home, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
420+
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 2)),
425421
"9ABC"));
426422

427423
// Test case - start with multi-line, cursor at end of first line
428424
Test("1234\n9ABC\n5678", Keys("1234", _.Shift_Enter, "5678",
429425
_.UpArrow, _.LeftArrow, _.End, CheckThat(() => AssertCursorLeftTopIs(4, 0)),
430-
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
426+
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
431427
"9ABC"));
432428

433429
// Test case - start with multi-line, cursor at beginning of first line - temporarily having to press Home twice to
434430
// work around bug in home handler.
435431
Test("1234\n9ABC\n5678", Keys("1234", _.Shift_Enter, "5678",
436432
_.UpArrow, _.LeftArrow, _.Home, _.Home, CheckThat(() => AssertCursorLeftTopIs(0, 0)),
437-
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 1)),
433+
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
438434
"9ABC"));
439435

440436
// Test case - insert multiple blank lines
441437
Test("1234\n5678\n\n9ABC", Keys("1234", _.Shift_Enter, "5678",
442-
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 2)),
443-
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(continutationPromptLength, 3)),
438+
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 2)),
439+
_.Ctrl_Shift_Enter, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 3)),
444440
"9ABC"));
445441
}
446442

0 commit comments

Comments
 (0)