1# -*- coding: utf-8 -*-
2"""
3    Julia Tests
4    ~~~~~~~~~~~
5
6    :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
7    :license: BSD, see LICENSE for details.
8"""
9
10import pytest
11
12from pygments.token import Token
13from pygments.lexers import JuliaLexer
14
15
16@pytest.fixture(scope='module')
17def lexer():
18    yield JuliaLexer()
19
20
21def test_unicode(lexer):
22    """
23    Test that unicode character, √, in an expression is recognized
24    """
25    fragment = 's = \u221a((1/n) * sum(count .^ 2) - mu .^2)\n'
26    tokens = [
27        (Token.Name, 's'),
28        (Token.Text, ' '),
29        (Token.Operator, '='),
30        (Token.Text, ' '),
31        (Token.Operator, '\u221a'),
32        (Token.Punctuation, '('),
33        (Token.Punctuation, '('),
34        (Token.Literal.Number.Integer, '1'),
35        (Token.Operator, '/'),
36        (Token.Name, 'n'),
37        (Token.Punctuation, ')'),
38        (Token.Text, ' '),
39        (Token.Operator, '*'),
40        (Token.Text, ' '),
41        (Token.Name, 'sum'),
42        (Token.Punctuation, '('),
43        (Token.Name, 'count'),
44        (Token.Text, ' '),
45        (Token.Operator, '.^'),
46        (Token.Text, ' '),
47        (Token.Literal.Number.Integer, '2'),
48        (Token.Punctuation, ')'),
49        (Token.Text, ' '),
50        (Token.Operator, '-'),
51        (Token.Text, ' '),
52        (Token.Name, 'mu'),
53        (Token.Text, ' '),
54        (Token.Operator, '.^'),
55        (Token.Literal.Number.Integer, '2'),
56        (Token.Punctuation, ')'),
57        (Token.Text, '\n'),
58    ]
59    assert list(lexer.get_tokens(fragment)) == tokens
60