summaryrefslogtreecommitdiff
path: root/tests/test_idris.py
blob: 42dcb3cbe7d83fc3746c8641d265beb7d2483ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
"""
    Basic IdrisLexer Test
    ~~~~~~~~~~~~~~~~~~~~

    :copyright: Copyright 2020 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import pytest

from pygments.token import Keyword, Text, Name, Operator, Literal
from pygments.lexers import IdrisLexer


@pytest.fixture(scope='module')
def lexer():
    yield IdrisLexer()

def test_reserved_word(lexer):
    fragment = 'namespace Foobar\n  links : String\n  links = "abc"'
    tokens = [
        (Keyword.Reserved, 'namespace'),
        (Text, ' '),
        (Keyword.Type, 'Foobar'),
        (Text, '\n'),
        (Text, '  '),
        (Name.Function, 'links'),
        (Text, ' '),
        (Operator.Word, ':'),
        (Text, ' '),
        (Keyword.Type, 'String'),
        (Text, '\n'),
        (Text, ' '),
        (Text, ' '),
        (Text, 'links'),
        (Text, ' '),
        (Operator.Word, '='),
        (Text, ' '),
        (Literal.String, '"'),
        (Literal.String, 'abc'),
        (Literal.String, '"'),
        (Text, '\n')
    ]
    assert list(lexer.get_tokens(fragment)) == tokens

def test_compiler_directive(lexer):
    fragment = '%link C "object.o"\n%name Vect xs'
    tokens = [
        (Keyword.Reserved, '%link'),
        (Text, ' '),
        (Keyword.Type, 'C'),
        (Text, ' '),
        (Literal.String, '"'),
        (Literal.String, 'object.o'),
        (Literal.String, '"'),
        (Text, '\n'),
        (Keyword.Reserved, '%name'),
        (Text, ' '),
        (Keyword.Type, 'Vect'),
        (Text, ' '),
        (Text, 'xs'),
        (Text, '\n')
    ]
    assert list(lexer.get_tokens(fragment)) == tokens