diff options
author | Gaurav Jain <gaurav@gauravjain.org> | 2014-04-24 12:48:20 -0400 |
---|---|---|
committer | Gaurav Jain <gaurav@gauravjain.org> | 2014-04-24 12:48:20 -0400 |
commit | a5368fe16c36cb6d60eaa7985d6c1151451f8ed1 (patch) | |
tree | 538ae6e5dd126e7e2582a66148f91ef8ad051c29 /tests/test_objectiveclexer.py | |
parent | 581a2348f900f8a22b7b1360ef6b2f576c42d2b4 (diff) | |
download | pygments-a5368fe16c36cb6d60eaa7985d6c1151451f8ed1.tar.gz |
Add Objective-C unit tests
Diffstat (limited to 'tests/test_objectiveclexer.py')
-rw-r--r-- | tests/test_objectiveclexer.py | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/test_objectiveclexer.py b/tests/test_objectiveclexer.py new file mode 100644 index 00000000..46fdb6d2 --- /dev/null +++ b/tests/test_objectiveclexer.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +""" + Basic CLexer Test + ~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import unittest +import os + +from pygments.token import Token +from pygments.lexers import ObjectiveCLexer + + +class ObjectiveCLexerTest(unittest.TestCase): + + def setUp(self): + self.lexer = ObjectiveCLexer() + + def testLiteralNumberInt(self): + fragment = u'@(1);\n' + expected = [ + (Token.Text, u''), + (Token.Literal, u'@('), + (Token.Literal.Number.Integer, u'1'), + (Token.Literal, u')'), + (Token.Punctuation, u';'), + (Token.Text, u'\n'), + (Token.Text, u''), + ] + self.assertEqual(expected, list(self.lexer.get_tokens(fragment))) + + def testLiteralNumberExpression(self): + fragment = u'@(1+2);\n' + expected = [ + (Token.Text, u''), + (Token.Literal, u'@('), + (Token.Literal.Number.Integer, u'1'), + (Token.Operator, u'+'), + (Token.Literal.Number.Integer, u'2'), + (Token.Literal, u')'), + (Token.Punctuation, u';'), + (Token.Text, u'\n'), + (Token.Text, u''), + ] + self.assertEqual(expected, list(self.lexer.get_tokens(fragment))) + + def testLiteralNumberNestedExpression(self): + fragment = u'@(1+(2+3));\n' + expected = [ + (Token.Text, u''), + (Token.Literal, u'@('), + (Token.Literal.Number.Integer, u'1'), + (Token.Operator, u'+'), + (Token.Punctuation, u'('), + (Token.Literal.Number.Integer, u'2'), + (Token.Operator, u'+'), + (Token.Literal.Number.Integer, u'3'), + (Token.Punctuation, u')'), + (Token.Literal, u')'), + (Token.Punctuation, u';'), + (Token.Text, u'\n'), + (Token.Text, u''), + ] + self.assertEqual(expected, list(self.lexer.get_tokens(fragment))) + + def testLiteralNumberBool(self): + fragment = u'@NO;\n' + expected = [ + (Token.Text, u''), + (Token.Literal.Number, u'@NO'), + (Token.Punctuation, u';'), + (Token.Text, u'\n'), + (Token.Text, u''), + ] + self.assertEqual(expected, list(self.lexer.get_tokens(fragment))) + + def testLieralNumberBoolExpression(self): + fragment = u'@(YES);\n' + expected = [ + (Token.Text, u''), + (Token.Literal, u'@('), + (Token.Name.Builtin, u'YES'), + (Token.Literal, u')'), + (Token.Punctuation, u';'), + (Token.Text, u'\n'), + (Token.Text, u''), + ] + self.assertEqual(expected, list(self.lexer.get_tokens(fragment))) |