1# -*- coding: utf-8 -*-
2"""
3    Pygments basic API tests
4    ~~~~~~~~~~~~~~~~~~~~~~~~
5
6    :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
7    :license: BSD, see LICENSE for details.
8"""
9
10import random
11from io import StringIO, BytesIO
12from os import path
13
14import pytest
15
16from pygments import lexers, formatters, lex, format
17
18TESTDIR = path.dirname(path.abspath(__file__))
19
20def _guess_lexer_for_file(filename):
21    return lexers.guess_lexer(open(path.join(TESTDIR, 'examplefiles', filename), 'r', encoding='utf-8').read())
22
23@pytest.mark.skip(reason="This is identified as T-SQL")
24def test_guess_lexer_fsharp():
25    l = _guess_lexer_for_file('Deflate.rs')
26    assert l.__class__.__name__ == 'FSharpLexer'
27
28def test_guess_lexer_brainfuck():
29    l = lexers.guess_lexer(">>[-]<<[->>+<<]")
30    assert l.__class__.__name__ == 'BrainfuckLexer'
31
32def test_guess_lexer_singularity():
33    l = _guess_lexer_for_file('Singularity')
34    assert l.__class__.__name__ == 'SingularityLexer'
35
36@pytest.mark.skip(reason="This is identified as MIME")
37def test_guess_lexer_matlab():
38    l = lexers.guess_lexer(r'A \ B')
39    assert l.__class__.__name__ == 'OctaveLexer'
40
41@pytest.mark.skip(reason="This is identified as Python")
42def test_guess_lexer_hybris():
43    l = _guess_lexer_for_file('hybris_File.hy')
44    assert l.__class__.__name__ == 'HybrisLexer'
45
46def test_guess_lexer_forth():
47    l = _guess_lexer_for_file('demo.frt')
48    assert l.__class__.__name__ == 'ForthLexer'
49
50def test_guess_lexer_modula2():
51    l = _guess_lexer_for_file('modula2_test_cases.def')
52    assert l.__class__.__name__ == 'Modula2Lexer'
53
54def test_guess_lexer_unicon():
55    l = _guess_lexer_for_file('example.icn')
56    assert l.__class__.__name__ == 'UcodeLexer'
57
58def test_guess_lexer_ezhil():
59    l = _guess_lexer_for_file('ezhil_primefactors.n')
60    assert l.__class__.__name__ == 'EzhilLexer'