Mercurial > vim
comparison src/testdir/test_writefile.vim @ 21510:31cb78014fe4 v8.2.1305
patch 8.2.1305: some tests are still old style
Commit: https://github.com/vim/vim/commit/622b3568fa1baf07671d31390815fb0a55a99891
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jul 27 20:02:41 2020 +0200
patch 8.2.1305: some tests are still old style
Problem: Some tests are still old style.
Solution: Convert tests 52 and 70 to new style. (Yegappan Lakshmanan,
closes #6544) Fix error in FinishTesting().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 27 Jul 2020 20:15:07 +0200 |
parents | 6a4806e326dd |
children | dc1c26547a42 |
comparison
equal
deleted
inserted
replaced
21509:00a2e4d3fc38 | 21510:31cb78014fe4 |
---|---|
440 call setline(1, 'abc') | 440 call setline(1, 'abc') |
441 call assert_fails('write ++enc=axbyc Xfile', 'E213:') | 441 call assert_fails('write ++enc=axbyc Xfile', 'E213:') |
442 close! | 442 close! |
443 endfunc | 443 endfunc |
444 | 444 |
445 " Tests for reading and writing files with conversion for Win32. | |
446 func Test_write_file_encoding() | |
447 CheckMSWindows | |
448 let save_encoding = &encoding | |
449 let save_fileencodings = &fileencodings | |
450 set encoding& fileencodings& | |
451 let text =<< trim END | |
452 1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 | |
453 2 cp1251 text: Vim version 6.2. : 1970 Jan 01 | |
454 3 cp866 text: Vim version 6.2. : 1970 Jan 01 | |
455 END | |
456 call writefile(text, 'Xfile') | |
457 edit Xfile | |
458 | |
459 " write tests: | |
460 " combine three values for 'encoding' with three values for 'fileencoding' | |
461 " also write files for read tests | |
462 call cursor(1, 1) | |
463 set encoding=utf-8 | |
464 .w! ++enc=utf-8 Xtest | |
465 .w ++enc=cp1251 >> Xtest | |
466 .w ++enc=cp866 >> Xtest | |
467 .w! ++enc=utf-8 Xutf8 | |
468 let expected =<< trim END | |
469 1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 | |
470 1 utf-8 text: Vim version 6.2. : 1970 Jan 01 | |
471 1 utf-8 text: Vim version 6.2. : 1970 Jan 01 | |
472 END | |
473 call assert_equal(expected, readfile('Xtest')) | |
474 | |
475 call cursor(2, 1) | |
476 set encoding=cp1251 | |
477 .w! ++enc=utf-8 Xtest | |
478 .w ++enc=cp1251 >> Xtest | |
479 .w ++enc=cp866 >> Xtest | |
480 .w! ++enc=cp1251 Xcp1251 | |
481 let expected =<< trim END | |
482 2 cp1251 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 | |
483 2 cp1251 text: Vim version 6.2. : 1970 Jan 01 | |
484 2 cp1251 text: Vim version 6.2. : 1970 Jan 01 | |
485 END | |
486 call assert_equal(expected, readfile('Xtest')) | |
487 | |
488 call cursor(3, 1) | |
489 set encoding=cp866 | |
490 .w! ++enc=utf-8 Xtest | |
491 .w ++enc=cp1251 >> Xtest | |
492 .w ++enc=cp866 >> Xtest | |
493 .w! ++enc=cp866 Xcp866 | |
494 let expected =<< trim END | |
495 3 cp866 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 | |
496 3 cp866 text: Vim version 6.2. : 1970 Jan 01 | |
497 3 cp866 text: Vim version 6.2. : 1970 Jan 01 | |
498 END | |
499 call assert_equal(expected, readfile('Xtest')) | |
500 | |
501 " read three 'fileencoding's with utf-8 'encoding' | |
502 set encoding=utf-8 fencs=utf-8,cp1251 | |
503 e Xutf8 | |
504 .w! ++enc=utf-8 Xtest | |
505 e Xcp1251 | |
506 .w ++enc=utf-8 >> Xtest | |
507 set fencs=utf-8,cp866 | |
508 e Xcp866 | |
509 .w ++enc=utf-8 >> Xtest | |
510 let expected =<< trim END | |
511 1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 | |
512 2 cp1251 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 | |
513 3 cp866 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 | |
514 END | |
515 call assert_equal(expected, readfile('Xtest')) | |
516 | |
517 " read three 'fileencoding's with cp1251 'encoding' | |
518 set encoding=utf-8 fencs=utf-8,cp1251 | |
519 e Xutf8 | |
520 .w! ++enc=cp1251 Xtest | |
521 e Xcp1251 | |
522 .w ++enc=cp1251 >> Xtest | |
523 set fencs=utf-8,cp866 | |
524 e Xcp866 | |
525 .w ++enc=cp1251 >> Xtest | |
526 let expected =<< trim END | |
527 1 utf-8 text: Vim version 6.2. : 1970 Jan 01 | |
528 2 cp1251 text: Vim version 6.2. : 1970 Jan 01 | |
529 3 cp866 text: Vim version 6.2. : 1970 Jan 01 | |
530 END | |
531 call assert_equal(expected, readfile('Xtest')) | |
532 | |
533 " read three 'fileencoding's with cp866 'encoding' | |
534 set encoding=cp866 fencs=utf-8,cp1251 | |
535 e Xutf8 | |
536 .w! ++enc=cp866 Xtest | |
537 e Xcp1251 | |
538 .w ++enc=cp866 >> Xtest | |
539 set fencs=utf-8,cp866 | |
540 e Xcp866 | |
541 .w ++enc=cp866 >> Xtest | |
542 let expected =<< trim END | |
543 1 utf-8 text: Vim version 6.2. : 1970 Jan 01 | |
544 2 cp1251 text: Vim version 6.2. : 1970 Jan 01 | |
545 3 cp866 text: Vim version 6.2. : 1970 Jan 01 | |
546 END | |
547 call assert_equal(expected, readfile('Xtest')) | |
548 | |
549 call delete('Xfile') | |
550 call delete('Xtest') | |
551 call delete('Xutf8') | |
552 call delete('Xcp1251') | |
553 call delete('Xcp866') | |
554 let &encoding = save_encoding | |
555 let &fileencodings = save_fileencodings | |
556 %bw! | |
557 endfunc | |
558 | |
445 " vim: shiftwidth=2 sts=2 expandtab | 559 " vim: shiftwidth=2 sts=2 expandtab |