diff options
author | Mathias Ertl <mati@er.tl> | 2020-12-26 16:17:25 +0100 |
---|---|---|
committer | Mathias Ertl <mati@er.tl> | 2020-12-26 16:19:11 +0100 |
commit | 456ac59d8481c09c29ea9f771550a933ba70edb8 (patch) | |
tree | 96f2fa58f4e3439a3ac5c0cb3f68916331735a97 | |
parent | 270ab316ed61b17e5cefebdd2081e469f06317e8 (diff) | |
download | pygments-git-456ac59d8481c09c29ea9f771550a933ba70edb8.tar.gz |
add tests to illustrate problem discussed in PR #1645
-rw-r--r-- | tests/test_shell.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_shell.py b/tests/test_shell.py index b43768d4..3cf7e204 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -154,6 +154,31 @@ def test_newline_in_echo(lexer_session): assert list(lexer_session.get_tokens(fragment)) == tokens +def test_newline_in_ls(lexer_session): + fragment = '$ ls \\\nhi\nhi\n' + tokens = [ + (Token.Text, ''), + (Token.Generic.Prompt, '$ '), + (Token.Text, 'ls'), + (Token.Text, ' '), + (Token.Literal.String.Escape, '\\\n'), + (Token.Text, 'hi'), + (Token.Text, '\n'), + (Token.Generic.Output, 'hi\n'), + ] + assert list(lexer_session.get_tokens(fragment)) == tokens + + +def test_comment_after_prompt(lexer_session): + fragment = '$# comment' + tokens = [ + (Token.Comment.Single, ''), + (Token.Generic.Prompt, '$'), + (Token.Comment.Single, '# comment\n'), + ] + assert list(lexer_session.get_tokens(fragment)) == tokens + + def test_msdos_gt_only(lexer_msdos): fragment = '> py\nhi\n' tokens = [ |