This repository has been archived by the owner on Oct 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_julia.py
58 lines (52 loc) · 1.75 KB
/
test_julia.py
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
# -*- coding: utf-8 -*-
"""
Julia Tests
~~~~~~~~~~~
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import unittest
from pygments.lexers import JuliaLexer
from pygments.token import Token
class JuliaTests(unittest.TestCase):
def setUp(self):
self.lexer = JuliaLexer()
def test_unicode(self):
"""
Test that unicode character, √, in an expression is recognized
"""
fragment = u's = \u221a((1/n) * sum(count .^ 2) - mu .^2)\n'
tokens = [
(Token.Name, u's'),
(Token.Text, u' '),
(Token.Operator, u'='),
(Token.Text, u' '),
(Token.Operator, u'\u221a'),
(Token.Punctuation, u'('),
(Token.Punctuation, u'('),
(Token.Literal.Number.Integer, u'1'),
(Token.Operator, u'/'),
(Token.Name, u'n'),
(Token.Punctuation, u')'),
(Token.Text, u' '),
(Token.Operator, u'*'),
(Token.Text, u' '),
(Token.Name, u'sum'),
(Token.Punctuation, u'('),
(Token.Name, u'count'),
(Token.Text, u' '),
(Token.Operator, u'.^'),
(Token.Text, u' '),
(Token.Literal.Number.Integer, u'2'),
(Token.Punctuation, u')'),
(Token.Text, u' '),
(Token.Operator, u'-'),
(Token.Text, u' '),
(Token.Name, u'mu'),
(Token.Text, u' '),
(Token.Operator, u'.^'),
(Token.Literal.Number.Integer, u'2'),
(Token.Punctuation, u')'),
(Token.Text, u'\n'),
]
self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))