summaryrefslogtreecommitdiff
path: root/tests/test_objectiveclexer.py
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-05-17 09:19:35 -0700
committerTim Hatch <tim@timhatch.com>2014-05-17 09:19:35 -0700
commita62cdcfaa5a260274303cb93b92a3f2e2ce3be98 (patch)
treee7d2b4cd4e10a6e43fe4b2dc4e03ab2e827ebc20 /tests/test_objectiveclexer.py
parent70a10a2e423d9729b62c7b56faca28889c0d688a (diff)
parentff12540907fe9d98bf02c9508a171659457b14b2 (diff)
downloadpygments-a62cdcfaa5a260274303cb93b92a3f2e2ce3be98.tar.gz
Merged in timgilbert/pygments-main/clj-keyword-fix (pull request #326)
Tweaking clojure keyword lexing
Diffstat (limited to 'tests/test_objectiveclexer.py')
-rw-r--r--tests/test_objectiveclexer.py91
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)))