robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.6 KiB64 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3
4local describe, it, before_each, pending = t.describe, t.it, t.before_each, t.pending
5local clear, insert, eq = n.clear, n.insert, t.eq
6local command, expect = n.command, n.expect
7local feed, eval = n.feed, n.eval
8
9describe('gu and gU', function()
10  before_each(clear)
11
12  it('works in any locale with default casemap', function()
13    eq('internal,keepascii', eval('&casemap'))
14    insert('iI')
15    feed('VgU')
16    expect('II')
17    feed('Vgu')
18    expect('ii')
19  end)
20
21  describe('works in Turkish locale', function()
22    clear()
23
24    if not pcall(n.command, 'lang ctype tr_TR.UTF-8') then
25      pending('Locale tr_TR.UTF-8 not supported', function() end)
26      return
27    end
28
29    before_each(function()
30      command('lang ctype tr_TR.UTF-8')
31    end)
32
33    it('with default casemap', function()
34      eq('internal,keepascii', eval('&casemap'))
35      -- expect ASCII behavior
36      insert('iI')
37      feed('VgU')
38      expect('II')
39      feed('Vgu')
40      expect('ii')
41    end)
42
43    it('with casemap=""', function()
44      command('set casemap=')
45      -- expect either Turkish locale behavior or ASCII behavior
46      local iupper = eval("toupper('i')")
47      if iupper == 'İ' then
48        insert('iI')
49        feed('VgU')
50        expect('İI')
51        feed('Vgu')
52        expect('iı')
53      elseif iupper == 'I' then
54        insert('iI')
55        feed('VgU')
56        expect('II')
57        feed('Vgu')
58        expect('ii')
59      else
60        error("expected toupper('i') to be either 'I' or 'İ'")
61      end
62    end)
63  end)
64end)