summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthäus G. Chajdas <dev@anteru.net>2019-11-24 15:40:46 +0100
committerMatthäus G. Chajdas <dev@anteru.net>2019-11-24 15:40:46 +0100
commit8294dc861b0115ccb5b779166c3ce5f1b0b0e9ed (patch)
treee86fbb3f48758c7f9d6bfe1848d22f6504ce1f6c /tests
parent4aded7d864d51f5c14ba9db873c0364a8534f230 (diff)
downloadpygments-git-8294dc861b0115ccb5b779166c3ce5f1b0b0e9ed.tar.gz
Fix #1256.
Reduce TeraTerm.analyze_text score to 0.01. This resolves the conflict with Turtle, but doesn't take over nearly all other languages. Added a test as provided in the bug report to ensure this won't regress again.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cpp.py22
-rw-r--r--tests/test_guessing.py0
2 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_cpp.py b/tests/test_cpp.py
index b87b2dd3..a3ef33a3 100644
--- a/tests/test_cpp.py
+++ b/tests/test_cpp.py
@@ -9,9 +9,11 @@
import pytest
-from pygments.lexers import CppLexer
+from pygments.lexers import CppLexer, CLexer
from pygments.token import Token
+from pygments.lexers import guess_lexer
+
@pytest.fixture(scope='module')
def lexer():
@@ -33,3 +35,21 @@ def test_open_comment(lexer):
(Token.Comment.Multiline, u'/* foo\n'),
]
assert list(lexer.get_tokens(fragment)) == tokens
+
+def test_guess_c_lexer():
+ code = '''
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ int main(void);
+
+ int main(void) {
+ uint8_t x = 42;
+ uint8_t y = x + 1;
+
+ /* exit 1 for success! */
+ return 1;
+ }
+ '''
+ lexer = guess_lexer(code)
+ assert isinstance(lexer, CLexer) \ No newline at end of file
diff --git a/tests/test_guessing.py b/tests/test_guessing.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/test_guessing.py