summaryrefslogtreecommitdiff
path: root/tests/test_julia.py
blob: 14bcdee0da4ac57ef2dada12de891110aa47642f (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
# -*- coding: utf-8 -*-
"""
    Julia Tests
    ~~~~~~~~~~~

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

import pytest

from pygments.token import Token
from pygments.lexers import JuliaLexer


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


def test_unicode(lexer):
    """
    Test that unicode character, √, in an expression is recognized
    """
    fragment = 's = \u221a((1/n) * sum(count .^ 2) - mu .^2)\n'
    tokens = [
        (Token.Name, 's'),
        (Token.Text, ' '),
        (Token.Operator, '='),
        (Token.Text, ' '),
        (Token.Operator, '\u221a'),
        (Token.Punctuation, '('),
        (Token.Punctuation, '('),
        (Token.Literal.Number.Integer, '1'),
        (Token.Operator, '/'),
        (Token.Name, 'n'),
        (Token.Punctuation, ')'),
        (Token.Text, ' '),
        (Token.Operator, '*'),
        (Token.Text, ' '),
        (Token.Name, 'sum'),
        (Token.Punctuation, '('),
        (Token.Name, 'count'),
        (Token.Text, ' '),
        (Token.Operator, '.^'),
        (Token.Text, ' '),
        (Token.Literal.Number.Integer, '2'),
        (Token.Punctuation, ')'),
        (Token.Text, ' '),
        (Token.Operator, '-'),
        (Token.Text, ' '),
        (Token.Name, 'mu'),
        (Token.Text, ' '),
        (Token.Operator, '.^'),
        (Token.Literal.Number.Integer, '2'),
        (Token.Punctuation, ')'),
        (Token.Text, '\n'),
    ]
    assert list(lexer.get_tokens(fragment)) == tokens