~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/fakevim/fakevim_test.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-11-15 12:25:23 UTC
  • mfrom: (1.1.28)
  • Revision ID: timo.jyrinki@canonical.com-20131115122523-i2kyamsu4gs2mu1m
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
274
274
{
275
275
    setupTest(&data->title, &data->handler, &data->edit);
276
276
    data->reset();
277
 
    data->doCommand("set nopasskeys | set nopasscontrolkey");
 
277
    data->doCommand("| set nopasskeys"
 
278
                    "| set nopasscontrolkey"
 
279
                    "| set smartindent"
 
280
                    "| set autoindent");
278
281
}
279
282
 
280
283
 
281
284
void FakeVimPlugin::cleanup()
282
285
{
283
 
    Core::EditorManager::instance()->closeAllEditors(false);
 
286
    Core::EditorManager::closeAllEditors(false);
284
287
}
285
288
 
286
289
 
397
400
    KEYS("2B", X "123 "   "456.789 "   "abc "   "def");
398
401
    KEYS("4W",   "123 "   "456.789 "   "abc "   "de" X "f");
399
402
 
 
403
    data.setText("assert(abc);");
 
404
    KEYS("w",    "assert" X "(abc);");
 
405
    KEYS("w",    "assert(" X "abc);");
 
406
    KEYS("w",    "assert(abc" X ");");
 
407
    KEYS("w",    "assert(abc)" X ";");
 
408
 
400
409
    data.setText("123" N   "45."   "6" N   "" N " " N   "789");
401
410
    KEYS("3w",   "123" N   "45." X "6" N   "" N " " N   "789");
402
411
    // From Vim help (motion.txt): An empty line is also considered to be a word.
454
463
    data.setText("abc def");
455
464
    KEYS("}", "abc de" X "f");
456
465
    KEYS("{", X "abc def");
 
466
 
 
467
    // bracket movement commands
 
468
    data.setText(
 
469
         "void a()" N
 
470
         "{" N
 
471
         "}" N "" N "int b()" N
 
472
         "{ return 0; }" N "" N "int c()" N
 
473
         "{ return 0;" N
 
474
         "}" N
 
475
         "");
 
476
 
 
477
    KEYS("]]",
 
478
         "void a()" N
 
479
         X "{" N
 
480
         "}" N "" N "int b()" N
 
481
         "{ return 0; }" N "" N "int c()" N
 
482
         "{ return 0;" N
 
483
         "}" N
 
484
         "");
 
485
 
 
486
    KEYS("]]",
 
487
         "void a()" N
 
488
         "{" N
 
489
         "}" N "" N "int b()" N
 
490
         X "{ return 0; }" N "" N "int c()" N
 
491
         "{ return 0;" N
 
492
         "}" N
 
493
         "");
 
494
 
 
495
    KEYS("2[[",
 
496
         X "void a()" N
 
497
         "{" N
 
498
         "}" N "" N "int b()" N
 
499
         "{ return 0; }" N "" N "int c()" N
 
500
         "{ return 0;" N
 
501
         "}" N
 
502
         "");
 
503
 
 
504
    KEYS("4]]",
 
505
         "void a()" N
 
506
         "{" N
 
507
         "}" N "" N "int b()" N
 
508
         "{ return 0; }" N "" N "int c()" N
 
509
         "{ return 0;" N
 
510
         "}" N
 
511
         X "");
 
512
 
 
513
    KEYS("2[]",
 
514
         "void a()" N
 
515
         "{" N
 
516
         X "}" N "" N "int b()" N
 
517
         "{ return 0; }" N "" N "int c()" N
 
518
         "{ return 0;" N
 
519
         "}" N
 
520
         "");
 
521
 
 
522
    KEYS("][",
 
523
         "void a()" N
 
524
         "{" N
 
525
         "}" N "" N "int b()" N
 
526
         "{ return 0; }" N "" N "int c()" N
 
527
         "{ return 0;" N
 
528
         X "}" N
 
529
         "");
 
530
 
 
531
    KEYS("][",
 
532
         "void a()" N
 
533
         "{" N
 
534
         "}" N "" N "int b()" N
 
535
         "{ return 0; }" N "" N "int c()" N
 
536
         "{ return 0;" N
 
537
         "}" N
 
538
         X "");
457
539
}
458
540
 
459
541
void FakeVimPlugin::test_vim_insert()
620
702
    KEYS("2F(", "123()456" N "a(b" X "(c)d)e");
621
703
    KEYS("l2F(", "123()456" N "a" X "(b(c)d)e");
622
704
    KEYS("F(", "123()456" N "a" X "(b(c)d)e");
 
705
 
 
706
    data.setText("abc def" N "ghi " X "jkl");
 
707
    KEYS("vFgx", "abc def" N X "kl");
 
708
    KEYS("u", "abc def" N X "ghi jkl");
 
709
    KEYS("tk", "abc def" N "ghi " X "jkl");
 
710
    KEYS("dTg", "abc def" N "g" X "jkl");
 
711
    INTEGRITY(false);
 
712
    KEYS("u", "abc def" N "g" X "hi jkl");
 
713
    KEYS("f .", "abc def" N "g" X " jkl");
 
714
    KEYS("u", "abc def" N "g" X "hi jkl");
 
715
    KEYS("rg$;", "abc def" N "gg" X "i jkl");
623
716
}
624
717
 
625
718
void FakeVimPlugin::test_vim_transform_numbers()
809
902
    data.setText("abc" N "def");
810
903
    KEYS("2lvox", "a" X "b" N "def");
811
904
    KEYS("vlox", "a" X "def");
 
905
 
 
906
    // bracket movement command
 
907
    data.setText(
 
908
         "void a()" N
 
909
         "{" N
 
910
         "}" N "" N "int b()" N
 
911
         "{ return 0; }" N "" N "int c()" N
 
912
         "{ return 0;" N
 
913
         "}" N
 
914
         "");
 
915
 
 
916
    KEYS("d]]",
 
917
         X "{" N
 
918
         "}" N "" N "int b()" N
 
919
         "{ return 0; }" N "" N "int c()" N
 
920
         "{ return 0;" N
 
921
         "}" N
 
922
         "");
 
923
 
 
924
    KEYS("u",
 
925
         X "void a()" N
 
926
         "{" N
 
927
         "}" N "" N "int b()" N
 
928
         "{ return 0; }" N "" N "int c()" N
 
929
         "{ return 0;" N
 
930
         "}" N
 
931
         "");
 
932
 
 
933
    // When ]] is used after an operator, then also stops below a '}' in the first column.
 
934
    KEYS("jd]]",
 
935
         "void a()" N
 
936
         X "" N "int b()" N
 
937
         "{ return 0; }" N "" N "int c()" N
 
938
         "{ return 0;" N
 
939
         "}" N
 
940
         "");
 
941
 
 
942
    KEYS("u",
 
943
         "void a()" N
 
944
         X "{" N
 
945
         "}" N "" N "int b()" N
 
946
         "{ return 0; }" N "" N "int c()" N
 
947
         "{ return 0;" N
 
948
         "}" N
 
949
         "");
 
950
 
 
951
    // do nothing on failed movement
 
952
    KEYS("Gd5[[",
 
953
         "void a()" N
 
954
         "{" N
 
955
         "}" N "" N "int b()" N
 
956
         "{ return 0; }" N "" N "int c()" N
 
957
         "{ return 0;" N
 
958
         "}" N
 
959
         X "");
812
960
}
813
961
 
814
962
void FakeVimPlugin::test_vim_delete_inner_word()
1324
1472
    KEYS("N", "abc" N X "def" N "ghi");
1325
1473
    KEYS("N", X "abc" N "def" N "ghi");
1326
1474
    KEYS("2n2N", X "abc" N "def" N "ghi");
 
1475
 
 
1476
    // delete to match
 
1477
    data.setText("abc" N "def" N "abc" N "ghi abc jkl" N "xyz");
 
1478
    KEYS("2l" "d/ghi<CR>", "ab" X "ghi abc jkl" N "xyz");
 
1479
 
 
1480
    data.setText("abc" N "def" N "abc" N "ghi abc jkl" N "xyz");
 
1481
    KEYS("l" "d2/abc<CR>", "a" X "abc jkl" N "xyz");
 
1482
 
 
1483
    data.setText("abc" N "def" N "abc" N "ghi abc jkl" N "xyz");
 
1484
    KEYS("d/abc<CR>", X "abc" N "ghi abc jkl" N "xyz");
 
1485
    KEYS(".", "abc jkl" N "xyz");
 
1486
 
 
1487
    data.setText("abc" N "def" N "abc" N "ghi abc jkl" N "xyz");
 
1488
    KEYS("/abc<CR>" "l" "dn", "abc" N "def" N "a" X "abc jkl" N "xyz");
 
1489
 
 
1490
    data.setText("abc" N "def" N "abc" N "ghi abc jkl" N "xyz");
 
1491
    KEYS("2/abc<CR>" "h" "dN", "abc" N "def" N X " abc jkl" N "xyz");
 
1492
    KEYS("c/xxx<CR><ESC>" "h" "dN", "abc" N "def" N X " abc jkl" N "xyz");
 
1493
 
 
1494
    data.setText("abc" N "def" N "abc" N "ghi abc jkl" N "xyz");
 
1495
    KEYS("l" "v2/abc<CR>" "x", "abc jkl" N "xyz");
 
1496
 
 
1497
    // don't leave visual mode after search failed or is cancelled
 
1498
    data.setText("abc" N "def" N "abc" N "ghi abc jkl" N "xyz");
 
1499
    KEYS("vj" "/abc<ESC>" "x", X "ef" N "abc" N "ghi abc jkl" N "xyz");
 
1500
    KEYS("vj" "/xxx<CR>" "x", X "bc" N "ghi abc jkl" N "xyz");
1327
1501
}
1328
1502
 
1329
1503
void FakeVimPlugin::test_vim_indent()
2375
2549
    KEYS("f<space>", "abc" N "x " X " z" N "def");
2376
2550
    KEYS("t<space>", "abc" N "x " X " z" N "def");
2377
2551
    data.doCommand("unmap <SPACE>");
 
2552
 
 
2553
    // operator-pending mappings
 
2554
    data.setText("abc def" N "ghi jkl");
 
2555
    data.doCommand("omap <SPACE> aw");
 
2556
    KEYS("c<space>X<esc>", X "Xdef" N "ghi jkl");
 
2557
    data.doCommand("onoremap <SPACE> iwX");
 
2558
    KEYS("c<space>Y<esc>", "X" X "Y" N "ghi jkl");
 
2559
    data.doCommand("ono <SPACE> l");
 
2560
    KEYS("d<space>", X "X" N "ghi jkl");
 
2561
    data.doCommand("unmap <SPACE>");
 
2562
 
 
2563
    data.setText("abc def" N "ghi jkl");
 
2564
    data.doCommand("onoremap iwwX 3iwX Y");
 
2565
    KEYS("ciwwX Z<esc>", "X Y " X "Z" N "ghi jkl");
 
2566
    data.doCommand("unmap <SPACE>X");
2378
2567
}
2379
2568
 
2380
2569
void FakeVimPlugin::test_vim_command_cc()
3020
3209
    KEYS("@x", "def" N X "abc");
3021
3210
    KEYS("gg@x", "abc" N X "def");
3022
3211
    data.doCommand("unmap <S-down>");
 
3212
 
 
3213
    data.setText("   abc xyz>." N "   def xyz>." N "   ghi xyz>." N "   jkl xyz>.");
 
3214
    KEYS("qq" "^wdf>j" "q", "   abc ." N "   def " X "xyz>." N "   ghi xyz>." N "   jkl xyz>.");
 
3215
    KEYS("2@q", "   abc ." N "   def ." N "   ghi ." N "   jkl " X "xyz>.");
3023
3216
}
3024
3217
 
3025
3218
void FakeVimPlugin::test_vim_qtcreator()
3292
3485
         "");
3293
3486
 
3294
3487
    // Record long insert mode.
3295
 
    KEYS("qb" "4s" "bool" "<down>" "Q_<insert>ASSERT" "<down><down>" "<insert><bs>2"
3296
 
         "<c-o>2w<delete>1" "<c-o>:s/true/false<cr><esc>" "q",
 
3488
    KEYS("qb"
 
3489
         "4s" "bool" // 1
 
3490
         "<down>"
 
3491
         "Q_<insert>ASSERT" // 2
 
3492
         "<down><down>"
 
3493
         "<insert><bs>2" // 3
 
3494
         "<c-o>2w"
 
3495
         "<delete>1" // 4
 
3496
         "<c-o>:s/true/false<cr><esc>" // 5
 
3497
         "q",
3297
3498
         "bool f(int arg1, int arg2 = 0) {" N
3298
3499
         "    Q_ASSERT(arg1 >= 0);" N
3299
3500
         "    if (arg1 > 0) return true;" N
3301
3502
         "}" N
3302
3503
         "");
3303
3504
 
3304
 
    KEYS("u",
 
3505
    KEYS("u", // 5
3305
3506
         "bool f(int arg1, int arg2 = 0) {" N
3306
3507
         "    Q_ASSERT(arg1 >= 0);" N
3307
3508
         "    if (arg1 > 0) return true;" N
3308
3509
         X "    if (arg2 > 1) return true;" N
3309
3510
         "}" N
3310
3511
         "");
3311
 
    KEYS("u",
 
3512
    KEYS("u", // 4
3312
3513
         "bool f(int arg1, int arg2 = 0) {" N
3313
3514
         "    Q_ASSERT(arg1 >= 0);" N
3314
3515
         "    if (arg1 > 0) return true;" N
3315
3516
         "    if (arg2 > " X "0) return true;" N
3316
3517
         "}" N
3317
3518
         "");
3318
 
    KEYS("u",
 
3519
    KEYS("u", // 3
3319
3520
         "bool f(int arg1, int arg2 = 0) {" N
3320
3521
         "    Q_ASSERT(arg1 >= 0);" N
3321
3522
         "    if (arg1 > 0) return true;" N
3322
3523
         "    if (arg1" X " > 0) return true;" N
3323
3524
         "}" N
3324
3525
         "");
3325
 
    KEYS("u",
 
3526
    KEYS("u", // 2
3326
3527
         "bool f(int arg1, int arg2 = 0) {" N
3327
3528
         "    " X "assert(arg1 >= 0);" N
3328
3529
         "    if (arg1 > 0) return true;" N
3329
3530
         "    if (arg1 > 0) return true;" N
3330
3531
         "}" N
3331
3532
         "");
3332
 
    KEYS("u",
 
3533
    KEYS("u", // 1
3333
3534
         X "void f(int arg1, int arg2 = 0) {" N
3334
3535
         "    assert(arg1 >= 0);" N
3335
3536
         "    if (arg1 > 0) return true;" N
3374
3575
         "    if (arg2 > 1) return false;" N
3375
3576
         "}" N
3376
3577
         "");
 
3578
 
 
3579
    // Macros
 
3580
    data.setText(
 
3581
         "void f(int arg1) {" N
 
3582
         "}" N
 
3583
         "");
 
3584
    KEYS("2o" "#ifdef HAS_FEATURE<cr>doSomething();<cr>"
 
3585
         "#else<cr>"
 
3586
         "doSomethingElse<bs><bs><bs><bs>2();<cr>"
 
3587
         "#endif"
 
3588
         "<esc>",
 
3589
         "void f(int arg1) {" N
 
3590
         "#ifdef HAS_FEATURE" N
 
3591
         "    doSomething();" N
 
3592
         "#else" N
 
3593
         "    doSomething2();" N
 
3594
         "#endif" N
 
3595
         "#ifdef HAS_FEATURE" N
 
3596
         "    doSomething();" N
 
3597
         "#else" N
 
3598
         "    doSomething2();" N
 
3599
         "#endi" X "f" N
 
3600
         "}" N
 
3601
         "");
3377
3602
}