diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/ui/cmdline_highlight_spec.lua | 87 | ||||
| -rw-r--r-- | test/unit/viml/expressions/parser_tests.lua | 88 | 
2 files changed, 171 insertions, 4 deletions
| diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 023673738d..54d27723f0 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -147,6 +147,10 @@ before_each(function()      PE={bold = true, foreground = Screen.colors.SeaGreen4},      NUM={foreground = Screen.colors.Blue2},      NPAR={foreground = Screen.colors.Yellow}, +    SQ={foreground = Screen.colors.Blue3}, +    SB={foreground = Screen.colors.Blue4}, +    E={foreground = Screen.colors.Red, background = Screen.colors.Blue}, +    M={bold = true},    })  end) @@ -898,8 +902,83 @@ describe('Expressions coloring support', function()        ={NUM:1}^                                      |      ]])    end) -  -- FIXME: Test expr coloring when using -u NORC and -u NONE. -  -- FIXME: Test different ways of triggering expression highlighting (:<C-r>=, -  --        i<C-r>=, :<C-\>e, "=). -  -- FIXME: Test with various invalid unicode and multibyte characters. +  it('works correctly with non-ASCII and control characters', function() +    meths.command('hi clear NVimStringBody') +    meths.command('hi clear NVimStringQuote') +    meths.command('hi clear NVimInvalid') +    meths.command('hi NVimStringQuote guifg=Blue3') +    meths.command('hi NVimStringBody guifg=Blue4') +    meths.command('hi NVimInvalid guifg=Red guibg=Blue') +    feed('i<C-r>="«»"«»') +    screen:expect([[ +                                              | +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      ={SQ:"}{SB:«»}{SQ:"}{E:«»}^                                 | +    ]]) +    feed('<C-c>') +    screen:expect([[ +      ^                                        | +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {M:-- INSERT --}                            | +    ]]) +    feed('<Esc>') +    screen:expect([[ +      ^                                        | +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +                                              | +    ]]) +    feed(':<C-\\>e"<C-v><C-x>"<C-v><C-x>') +    -- TODO(ZyX-I): Parser highlighting should not override special character +    --              highlighting. +    screen:expect([[ +                                              | +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      ={SQ:"}{SB:^X}{SQ:"}{ERR:^X}^                                 | +    ]]) +    feed('<C-c>') +    screen:expect([[ +                                              | +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      :^                                       | +    ]]) +    funcs.setreg('a', {'\192'}) +    feed('<C-r>="<C-r><C-r>a"<C-r><C-r>a"foo"') +    -- TODO(ZyX-I): Parser highlighting should not override special character +    --              highlighting. +    screen:expect([[ +                                              | +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      {EOB:~                                       }| +      ={SQ:"}{SB:<c0>}{SQ:"}{E:<c0>"}{SB:foo}{E:"}^                        | +    ]]) +  end)  end) diff --git a/test/unit/viml/expressions/parser_tests.lua b/test/unit/viml/expressions/parser_tests.lua index f0c2723a38..4700b6ee42 100644 --- a/test/unit/viml/expressions/parser_tests.lua +++ b/test/unit/viml/expressions/parser_tests.lua @@ -8182,4 +8182,92 @@ return function(itp, _check_parsing, hl, fmtn)        hl('List', ']'),      })    end) +  itp('works with non-ASCII characters', function() +    check_parsing('"«»"«»', { +      --           013568 +      ast = { +        { +          'OpMissing:0:6:', +          children = { +            'DoubleQuotedString(val="«»"):0:0:"«»"', +            { +              'ComplexIdentifier:0:8:', +              children = { +                'PlainIdentifier(scope=0,ident=«):0:6:«', +                'PlainIdentifier(scope=0,ident=»):0:8:»', +              }, +            }, +          }, +        }, +      }, +      err = { +        arg = '«»', +        msg = 'E15: Unidentified character: %.*s', +      }, +    }, { +      hl('DoubleQuote', '"'), +      hl('DoubleQuotedBody', '«»'), +      hl('DoubleQuote', '"'), +      hl('InvalidIdentifierName', '«'), +      hl('InvalidIdentifierName', '»'), +    }, { +      [1] = { +        ast = { +          ast = { +            'DoubleQuotedString(val="«»"):0:0:"«»"', +          }, +          len = 6, +        }, +        hl_fs = { +          [5] = REMOVE_THIS, +          [4] = REMOVE_THIS, +        }, +      }, +    }) +    check_parsing('"\192"\192"foo"', { +      --           01   23   45678 +      ast = { +        { +          'OpMissing:0:3:', +          children = { +            'DoubleQuotedString(val="\192"):0:0:"\192"', +            { +              'OpMissing:0:4:', +              children = { +                'PlainIdentifier(scope=0,ident=\192):0:3:\192', +                'DoubleQuotedString(val="foo"):0:4:"foo"', +              }, +            }, +          }, +        }, +      }, +      err = { +        arg = '\192"foo"', +        msg = 'E15: Unidentified character: %.*s', +      }, +    }, { +      hl('DoubleQuote', '"'), +      hl('DoubleQuotedBody', '\192'), +      hl('DoubleQuote', '"'), +      hl('InvalidIdentifierName', '\192'), +      hl('InvalidDoubleQuote', '"'), +      hl('InvalidDoubleQuotedBody', 'foo'), +      hl('InvalidDoubleQuote', '"'), +    }, { +      [1] = { +        ast = { +          ast = { +            'DoubleQuotedString(val="\192"):0:0:"\192"', +          }, +          len = 3, +        }, +        hl_fs = { +          [4] = REMOVE_THIS, +          [5] = REMOVE_THIS, +          [6] = REMOVE_THIS, +          [7] = REMOVE_THIS, +        }, +      }, +    }) +  end)  end | 
