Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 1 | " Tests for startup using utf-8. |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 2 | |
Bram Moolenaar | a45551a | 2020-06-09 15:57:37 +0200 | [diff] [blame] | 3 | source check.vim |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 4 | source shared.vim |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 5 | source screendump.vim |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 6 | |
| 7 | func Test_read_stdin_utf8() |
| 8 | let linesin = ['テスト', '€ÀÈÌÒÙ'] |
Bram Moolenaar | 5656496 | 2022-10-10 22:39:42 +0100 | [diff] [blame] | 9 | call writefile(linesin, 'Xtestin', 'D') |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 10 | let before = [ |
| 11 | \ 'set enc=utf-8', |
| 12 | \ 'set fencs=cp932,utf-8', |
| 13 | \ ] |
| 14 | let after = [ |
| 15 | \ 'write ++enc=utf-8 Xtestout', |
| 16 | \ 'quit!', |
| 17 | \ ] |
| 18 | if has('win32') |
| 19 | let pipecmd = 'type Xtestin | ' |
| 20 | else |
| 21 | let pipecmd = 'cat Xtestin | ' |
| 22 | endif |
| 23 | if RunVimPiped(before, after, '-', pipecmd) |
| 24 | let lines = readfile('Xtestout') |
| 25 | call assert_equal(linesin, lines) |
| 26 | else |
| 27 | call assert_equal('', 'RunVimPiped failed.') |
| 28 | endif |
Bram Moolenaar | 5656496 | 2022-10-10 22:39:42 +0100 | [diff] [blame] | 29 | |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 30 | call delete('Xtestout') |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 31 | endfunc |
| 32 | |
| 33 | func Test_read_fifo_utf8() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 34 | CheckUnix |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 35 | " Using bash/zsh's process substitution. |
| 36 | if executable('bash') |
| 37 | set shell=bash |
| 38 | elseif executable('zsh') |
| 39 | set shell=zsh |
| 40 | else |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 41 | throw 'Skipped: bash or zsh is required' |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 42 | endif |
| 43 | let linesin = ['テスト', '€ÀÈÌÒÙ'] |
Bram Moolenaar | 5656496 | 2022-10-10 22:39:42 +0100 | [diff] [blame] | 44 | call writefile(linesin, 'Xtestin', 'D') |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 45 | let before = [ |
| 46 | \ 'set enc=utf-8', |
| 47 | \ 'set fencs=cp932,utf-8', |
| 48 | \ ] |
| 49 | let after = [ |
| 50 | \ 'write ++enc=utf-8 Xtestout', |
| 51 | \ 'quit!', |
| 52 | \ ] |
| 53 | if RunVim(before, after, '<(cat Xtestin)') |
| 54 | let lines = readfile('Xtestout') |
| 55 | call assert_equal(linesin, lines) |
| 56 | else |
| 57 | call assert_equal('', 'RunVim failed.') |
| 58 | endif |
Bram Moolenaar | 5656496 | 2022-10-10 22:39:42 +0100 | [diff] [blame] | 59 | |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 60 | call delete('Xtestout') |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 61 | endfunc |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 62 | |
Christian Brabandt | f1c3134 | 2025-02-23 09:36:56 +0100 | [diff] [blame] | 63 | func Test_detect_fifo() |
| 64 | CheckUnix |
| 65 | " Using bash/zsh's process substitution. |
| 66 | if executable('bash') |
| 67 | set shell=bash |
| 68 | elseif executable('zsh') |
| 69 | set shell=zsh |
| 70 | else |
| 71 | throw 'Skipped: bash or zsh is required' |
| 72 | endif |
| 73 | let linesin = ['one', 'two'] |
| 74 | call writefile(linesin, 'Xtestin_fifo', 'D') |
| 75 | let after = [ |
| 76 | \ 'call writefile(split(execute(":mess"), "\\n"), "Xtestout")', |
| 77 | \ 'quit!', |
| 78 | \ ] |
| 79 | if RunVim([], after, '<(cat Xtestin_fifo)') |
| 80 | let lines = readfile('Xtestout') |
| 81 | call assert_match('\[fifo\]', lines[0]) |
| 82 | call assert_match('\[fifo\]', lines[1]) |
| 83 | else |
| 84 | call assert_equal('', 'RunVim failed.') |
| 85 | endif |
| 86 | |
| 87 | call delete('Xtestout') |
| 88 | endfunc |
| 89 | |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 90 | func Test_detect_ambiwidth() |
Bram Moolenaar | 494e906 | 2020-05-31 21:28:02 +0200 | [diff] [blame] | 91 | CheckRunVimInTerminal |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 92 | |
| 93 | " Use the title termcap entries to output the escape sequence. |
| 94 | call writefile([ |
| 95 | \ 'set enc=utf-8', |
| 96 | \ 'set ambiwidth=double', |
| 97 | \ 'call test_option_not_set("ambiwidth")', |
| 98 | \ 'redraw', |
Bram Moolenaar | 5656496 | 2022-10-10 22:39:42 +0100 | [diff] [blame] | 99 | \ ], 'Xscript', 'D') |
Bram Moolenaar | a45551a | 2020-06-09 15:57:37 +0200 | [diff] [blame] | 100 | let buf = RunVimInTerminal('-S Xscript', #{keep_t_u7: 1}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 101 | call TermWait(buf) |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 102 | call term_sendkeys(buf, "S\<C-R>=&ambiwidth\<CR>\<Esc>") |
| 103 | call WaitForAssert({-> assert_match('single', term_getline(buf, 1))}) |
| 104 | |
| 105 | call StopVimInTerminal(buf) |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 106 | endfunc |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 107 | |
| 108 | " vim: shiftwidth=2 sts=2 expandtab |