pygments.rb 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +3 -0
  4. data/lexers +0 -0
  5. data/lib/pygments/popen.rb +3 -2
  6. data/lib/pygments/version.rb +1 -1
  7. data/pygments.rb.gemspec +2 -1
  8. data/vendor/pygments-main/AUTHORS +20 -1
  9. data/vendor/pygments-main/CHANGES +55 -3
  10. data/vendor/pygments-main/LICENSE +1 -1
  11. data/vendor/pygments-main/MANIFEST.in +1 -1
  12. data/vendor/pygments-main/Makefile +5 -8
  13. data/vendor/pygments-main/REVISION +1 -1
  14. data/vendor/pygments-main/doc/Makefile +153 -0
  15. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  16. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  17. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  18. data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
  19. data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
  20. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
  21. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  22. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  23. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  24. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  25. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  26. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
  27. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
  28. data/vendor/pygments-main/doc/conf.py +249 -0
  29. data/vendor/pygments-main/doc/docs/api.rst +316 -0
  30. data/vendor/pygments-main/doc/docs/authors.rst +4 -0
  31. data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
  32. data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
  33. data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
  34. data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
  35. data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
  36. data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
  37. data/vendor/pygments-main/doc/docs/index.rst +66 -0
  38. data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
  39. data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
  40. data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
  41. data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
  42. data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
  43. data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
  44. data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
  45. data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
  46. data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
  47. data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
  48. data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
  49. data/vendor/pygments-main/doc/download.rst +41 -0
  50. data/vendor/pygments-main/doc/faq.rst +143 -0
  51. data/vendor/pygments-main/doc/index.rst +53 -0
  52. data/vendor/pygments-main/doc/languages.rst +151 -0
  53. data/vendor/pygments-main/doc/make.bat +190 -0
  54. data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
  55. data/vendor/pygments-main/external/autopygmentize +65 -48
  56. data/vendor/pygments-main/external/markdown-processor.py +15 -15
  57. data/vendor/pygments-main/external/moin-parser.py +1 -1
  58. data/vendor/pygments-main/external/rst-directive.py +2 -3
  59. data/vendor/pygments-main/ez_setup.py +340 -234
  60. data/vendor/pygments-main/pygments/__init__.py +4 -4
  61. data/vendor/pygments-main/pygments/cmdline.py +81 -68
  62. data/vendor/pygments-main/pygments/console.py +1 -1
  63. data/vendor/pygments-main/pygments/filter.py +1 -1
  64. data/vendor/pygments-main/pygments/filters/__init__.py +11 -9
  65. data/vendor/pygments-main/pygments/formatter.py +3 -3
  66. data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
  67. data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
  68. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  69. data/vendor/pygments-main/pygments/formatters/html.py +44 -26
  70. data/vendor/pygments-main/pygments/formatters/img.py +21 -14
  71. data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
  72. data/vendor/pygments-main/pygments/formatters/other.py +53 -6
  73. data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
  74. data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
  75. data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
  76. data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
  77. data/vendor/pygments-main/pygments/lexer.py +59 -39
  78. data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
  79. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
  81. data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
  82. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
  83. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
  84. data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
  85. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
  86. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
  87. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
  88. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
  89. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
  90. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
  91. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
  92. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
  93. data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
  94. data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
  95. data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
  96. data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
  97. data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
  98. data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
  99. data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
  100. data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
  101. data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
  102. data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
  103. data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
  104. data/vendor/pygments-main/pygments/lexers/math.py +438 -70
  105. data/vendor/pygments-main/pygments/lexers/other.py +885 -171
  106. data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
  107. data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
  108. data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
  109. data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
  110. data/vendor/pygments-main/pygments/lexers/special.py +7 -8
  111. data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
  112. data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
  113. data/vendor/pygments-main/pygments/lexers/text.py +208 -46
  114. data/vendor/pygments-main/pygments/lexers/web.py +729 -264
  115. data/vendor/pygments-main/pygments/modeline.py +1 -1
  116. data/vendor/pygments-main/pygments/plugin.py +1 -1
  117. data/vendor/pygments-main/pygments/scanner.py +1 -1
  118. data/vendor/pygments-main/pygments/sphinxext.py +153 -0
  119. data/vendor/pygments-main/pygments/style.py +3 -2
  120. data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
  121. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  122. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  123. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  124. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  125. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  126. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  127. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  128. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  129. data/vendor/pygments-main/pygments/styles/igor.py +29 -0
  130. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  131. data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
  132. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  133. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  134. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +125 -0
  135. data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
  136. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  137. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  138. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  139. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  140. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  141. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  142. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  143. data/vendor/pygments-main/pygments/styles/xcode.py +51 -0
  144. data/vendor/pygments-main/pygments/token.py +4 -1
  145. data/vendor/pygments-main/pygments/unistring.py +6 -5
  146. data/vendor/pygments-main/pygments/util.py +35 -21
  147. data/vendor/pygments-main/scripts/check_sources.py +28 -44
  148. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
  149. data/vendor/pygments-main/scripts/find_codetags.py +27 -19
  150. data/vendor/pygments-main/scripts/find_error.py +16 -13
  151. data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
  152. data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
  153. data/vendor/pygments-main/setup.py +19 -19
  154. data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
  155. data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
  156. data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
  157. data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
  158. data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
  159. data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
  160. data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
  161. data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
  162. data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
  163. data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
  164. data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
  165. data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
  166. data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
  167. data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
  168. data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
  169. data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
  170. data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
  171. data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
  172. data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
  173. data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
  174. data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
  175. data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
  176. data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
  177. data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
  178. data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
  179. data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
  180. data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
  181. data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
  182. data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
  183. data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
  184. data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
  185. data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
  186. data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
  187. data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
  188. data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
  189. data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
  190. data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
  191. data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
  192. data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
  193. data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
  194. data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
  195. data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
  196. data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
  197. data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
  198. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
  199. data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
  200. data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
  201. data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
  202. data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
  203. data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
  204. data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
  205. data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
  206. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
  207. data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
  208. data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
  209. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
  210. data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
  211. data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
  212. data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
  213. data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
  214. data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
  215. data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
  216. data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
  217. data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
  218. data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
  219. data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
  220. data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
  221. data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
  222. data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
  223. data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
  224. data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
  225. data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
  226. data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
  227. data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
  228. data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
  229. data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
  230. data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
  231. data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
  232. data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
  233. data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
  234. data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
  235. data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
  236. data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
  237. data/vendor/pygments-main/tests/run.py +14 -19
  238. data/vendor/pygments-main/tests/string_asserts.py +22 -0
  239. data/vendor/pygments-main/tests/test_basic_api.py +28 -14
  240. data/vendor/pygments-main/tests/test_cfm.py +46 -0
  241. data/vendor/pygments-main/tests/test_clexer.py +208 -3
  242. data/vendor/pygments-main/tests/test_cmdline.py +6 -5
  243. data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
  244. data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
  245. data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
  246. data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
  247. data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
  248. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  249. data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
  250. data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
  251. data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
  252. data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
  253. data/vendor/pygments-main/tests/test_token.py +3 -3
  254. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  255. data/vendor/pygments-main/tests/test_util.py +1 -1
  256. metadata +138 -51
  257. data/vendor/pygments-main/docs/generate.py +0 -472
  258. data/vendor/pygments-main/docs/src/api.txt +0 -270
  259. data/vendor/pygments-main/docs/src/authors.txt +0 -5
  260. data/vendor/pygments-main/docs/src/changelog.txt +0 -5
  261. data/vendor/pygments-main/docs/src/index.txt +0 -69
  262. data/vendor/pygments-main/docs/src/installation.txt +0 -71
  263. data/vendor/pygments-main/external/rst-directive-old.py +0 -77
  264. data/vendor/pygments-main/scripts/reindent.py +0 -291
  265. data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
  266. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
  267. data/vendor/pygments-main/tests/old_run.py +0 -138
@@ -0,0 +1,33 @@
1
+ namespace Test;
2
+
3
+ use Test\Foo;
4
+
5
+ class Bar
6
+ {
7
+ protected a;
8
+ private b;
9
+ public c {set, get};
10
+
11
+ public function __construct(string str, boolean bool)
12
+ {
13
+ let this->c = str;
14
+ this->setC(bool);
15
+ let this->b = [];
16
+ }
17
+
18
+ public function sayHello(string name)
19
+ {
20
+ echo "Hello " . name;
21
+ }
22
+
23
+ protected function loops()
24
+ {
25
+ for a in b {
26
+ echo a;
27
+ }
28
+ loop {
29
+ return "boo!";
30
+ }
31
+ }
32
+
33
+ }
@@ -0,0 +1,10 @@
1
+ package main
2
+
3
+ import "fmt"
4
+
5
+ func main() {
6
+ 世界 := "Hello, world!"
7
+ さようなら := "Goodbye, world!"
8
+ fmt.Println(世界)
9
+ fmt.Println(さようなら)
10
+ }
@@ -0,0 +1,4 @@
1
+ M LICENSE
2
+ M setup.py
3
+ ! setup.cfg
4
+ ? vctreestatus_hg
@@ -0,0 +1,21 @@
1
+ " A comment
2
+
3
+ :py print "py"
4
+ ::pyt print 'pyt'
5
+ pyth print '''pyth'''
6
+ : pytho print "pytho"
7
+ python print """python"""
8
+
9
+ : : python<<E OF
10
+ print """my script"""
11
+
12
+ def MyFunc(str):
13
+ """ My Function """
14
+ print str
15
+ E OF
16
+
17
+ let py = 42
18
+ echo py
19
+
20
+ let foo = 42
21
+ echo foo
@@ -8,42 +8,37 @@
8
8
  python run.py [testfile ...]
9
9
 
10
10
 
11
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
11
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
12
12
  :license: BSD, see LICENSE for details.
13
13
  """
14
14
 
15
+ from __future__ import print_function
16
+
15
17
  import sys, os
16
18
 
17
- if sys.version_info >= (3,):
18
- # copy test suite over to "build/lib" and convert it
19
- print ('Copying and converting sources to build/lib/test...')
20
- from distutils.util import copydir_run_2to3
21
- testroot = os.path.dirname(__file__)
22
- newroot = os.path.join(testroot, '..', 'build/lib/test')
23
- copydir_run_2to3(testroot, newroot)
24
- # make nose believe that we run from the converted dir
25
- os.chdir(newroot)
26
- else:
27
- # only find tests in this directory
28
- if os.path.dirname(__file__):
29
- os.chdir(os.path.dirname(__file__))
19
+ # only find tests in this directory
20
+ if os.path.dirname(__file__):
21
+ os.chdir(os.path.dirname(__file__))
30
22
 
31
23
 
32
24
  try:
33
25
  import nose
34
26
  except ImportError:
35
- print ('nose is required to run the Pygments test suite')
27
+ print('nose is required to run the Pygments test suite')
36
28
  sys.exit(1)
37
29
 
38
30
  try:
39
31
  # make sure the current source is first on sys.path
40
32
  sys.path.insert(0, '..')
41
33
  import pygments
42
- except ImportError:
43
- print ('Cannot find Pygments to test: %s' % sys.exc_info()[1])
34
+ except SyntaxError as err:
35
+ print('Syntax error: %s' % err)
36
+ sys.exit(1)
37
+ except ImportError as err:
38
+ print('Cannot find Pygments to test: %s' % err)
44
39
  sys.exit(1)
45
40
  else:
46
- print ('Pygments %s test suite running (Python %s)...' %
47
- (pygments.__version__, sys.version.split()[0]))
41
+ print('Pygments %s test suite running (Python %s)...' %
42
+ (pygments.__version__, sys.version.split()[0]))
48
43
 
49
44
  nose.main()
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Pygments string assert utility
4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
7
+ :license: BSD, see LICENSE for details.
8
+ """
9
+
10
+ class StringTests(object):
11
+
12
+ def assertStartsWith(self, haystack, needle, msg=None):
13
+ if msg is None:
14
+ msg = "'{}' does not start with '{}'".format(haystack, needle)
15
+ if not haystack.startswith(needle):
16
+ raise(AssertionError(msg))
17
+
18
+ def assertEndsWith(self, haystack, needle, msg=None):
19
+ if msg is None:
20
+ msg = "'{}' does not end with '{}'".format(haystack, needle)
21
+ if not haystack.endswith(needle):
22
+ raise(AssertionError(msg))
@@ -3,11 +3,12 @@
3
3
  Pygments basic API tests
4
4
  ~~~~~~~~~~~~~~~~~~~~~~~~
5
5
 
6
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
6
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
7
7
  :license: BSD, see LICENSE for details.
8
8
  """
9
9
 
10
- import os
10
+ from __future__ import print_function
11
+
11
12
  import random
12
13
  import unittest
13
14
 
@@ -15,7 +16,7 @@ from pygments import lexers, formatters, filters, format
15
16
  from pygments.token import _TokenType, Text
16
17
  from pygments.lexer import RegexLexer
17
18
  from pygments.formatters.img import FontNotFound
18
- from pygments.util import BytesIO, StringIO, bytes, b
19
+ from pygments.util import text_type, StringIO, xrange, ClassNotFound
19
20
 
20
21
  import support
21
22
 
@@ -28,7 +29,7 @@ test_content = ''.join(test_content) + '\n'
28
29
 
29
30
  def test_lexer_import_all():
30
31
  # instantiate every lexer, to see if the token type defs are correct
31
- for x in lexers.LEXERS.keys():
32
+ for x in lexers.LEXERS:
32
33
  c = getattr(lexers, x)()
33
34
 
34
35
 
@@ -45,6 +46,8 @@ def test_lexer_classes():
45
46
  result = cls.analyse_text(".abc")
46
47
  assert isinstance(result, float) and 0.0 <= result <= 1.0
47
48
 
49
+ assert all(al.lower() == al for al in cls.aliases)
50
+
48
51
  inst = cls(opt1="val1", opt2="val2")
49
52
  if issubclass(cls, RegexLexer):
50
53
  if not hasattr(cls, '_tokens'):
@@ -60,14 +63,17 @@ def test_lexer_classes():
60
63
  if cls.name in ['XQuery', 'Opa']: # XXX temporary
61
64
  return
62
65
 
63
- tokens = list(inst.get_tokens(test_content))
66
+ try:
67
+ tokens = list(inst.get_tokens(test_content))
68
+ except KeyboardInterrupt:
69
+ raise KeyboardInterrupt('interrupted %s.get_tokens(): test_content=%r' % (cls.__name__, test_content))
64
70
  txt = ""
65
71
  for token in tokens:
66
72
  assert isinstance(token, tuple)
67
73
  assert isinstance(token[0], _TokenType)
68
74
  if isinstance(token[1], str):
69
- print repr(token[1])
70
- assert isinstance(token[1], unicode)
75
+ print(repr(token[1]))
76
+ assert isinstance(token[1], text_type)
71
77
  txt += token[1]
72
78
  assert txt == test_content, "%s lexer roundtrip failed: %r != %r" % \
73
79
  (cls.name, test_content, txt)
@@ -94,7 +100,8 @@ def test_lexer_options():
94
100
  'SqliteConsoleLexer', 'MatlabSessionLexer', 'ErlangShellLexer',
95
101
  'BashSessionLexer', 'LiterateHaskellLexer', 'LiterateAgdaLexer',
96
102
  'PostgresConsoleLexer', 'ElixirConsoleLexer', 'JuliaConsoleLexer',
97
- 'RobotFrameworkLexer', 'DylanConsoleLexer', 'ShellSessionLexer'):
103
+ 'RobotFrameworkLexer', 'DylanConsoleLexer', 'ShellSessionLexer',
104
+ 'LiterateIdrisLexer', 'LiterateCryptolLexer'):
98
105
  inst = cls(ensurenl=False)
99
106
  ensure(inst.get_tokens('a\nb'), 'a\nb')
100
107
  inst = cls(ensurenl=False, stripall=True)
@@ -122,7 +129,7 @@ def test_get_lexers():
122
129
  ]:
123
130
  yield verify, func, args
124
131
 
125
- for cls, (_, lname, aliases, _, mimetypes) in lexers.LEXERS.iteritems():
132
+ for cls, (_, lname, aliases, _, mimetypes) in lexers.LEXERS.items():
126
133
  assert cls == lexers.find_lexer_class(lname).__name__
127
134
 
128
135
  for alias in aliases:
@@ -131,6 +138,13 @@ def test_get_lexers():
131
138
  for mimetype in mimetypes:
132
139
  assert cls == lexers.get_lexer_for_mimetype(mimetype).__class__.__name__
133
140
 
141
+ try:
142
+ lexers.get_lexer_by_name(None)
143
+ except ClassNotFound:
144
+ pass
145
+ else:
146
+ raise Exception
147
+
134
148
 
135
149
  def test_formatter_public_api():
136
150
  ts = list(lexers.PythonLexer().get_tokens("def f(): pass"))
@@ -157,7 +171,7 @@ def test_formatter_public_api():
157
171
  pass
158
172
  inst.format(ts, out)
159
173
 
160
- for formatter, info in formatters.FORMATTERS.iteritems():
174
+ for formatter, info in formatters.FORMATTERS.items():
161
175
  yield verify, formatter, info
162
176
 
163
177
  def test_formatter_encodings():
@@ -167,7 +181,7 @@ def test_formatter_encodings():
167
181
  fmt = HtmlFormatter()
168
182
  tokens = [(Text, u"ä")]
169
183
  out = format(tokens, fmt)
170
- assert type(out) is unicode
184
+ assert type(out) is text_type
171
185
  assert u"ä" in out
172
186
 
173
187
  # encoding option
@@ -196,7 +210,7 @@ def test_formatter_unicode_handling():
196
210
  if formatter.name != 'Raw tokens':
197
211
  out = format(tokens, inst)
198
212
  if formatter.unicodeoutput:
199
- assert type(out) is unicode
213
+ assert type(out) is text_type
200
214
 
201
215
  inst = formatter(encoding='utf-8')
202
216
  out = format(tokens, inst)
@@ -208,7 +222,7 @@ def test_formatter_unicode_handling():
208
222
  out = format(tokens, inst)
209
223
  assert type(out) is bytes, '%s: %r' % (formatter, out)
210
224
 
211
- for formatter, info in formatters.FORMATTERS.iteritems():
225
+ for formatter, info in formatters.FORMATTERS.items():
212
226
  yield verify, formatter
213
227
 
214
228
 
@@ -236,7 +250,7 @@ class FiltersTest(unittest.TestCase):
236
250
  'whitespace': {'spaces': True, 'tabs': True, 'newlines': True},
237
251
  'highlight': {'names': ['isinstance', 'lexers', 'x']},
238
252
  }
239
- for x in filters.FILTERS.keys():
253
+ for x in filters.FILTERS:
240
254
  lx = lexers.PythonLexer()
241
255
  lx.add_filter(x, **filter_args.get(x, {}))
242
256
  fp = open(TESTFILE, 'rb')
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Basic ColdfusionHtmlLexer Test
4
+ ~~~~~~~~~~~~~~~~~
5
+
6
+ :copyright: Copyright 2014 by the Pygments team, see AUTHORS.
7
+ :license: BSD, see LICENSE for details.
8
+ """
9
+
10
+ import unittest
11
+ import os
12
+
13
+ from pygments.token import Token
14
+ from pygments.lexers import ColdfusionHtmlLexer
15
+
16
+
17
+ class ColdfusionHtmlLexerTest(unittest.TestCase):
18
+
19
+ def setUp(self):
20
+ self.lexer = ColdfusionHtmlLexer()
21
+
22
+ def testBasicComment(self):
23
+ fragment = u'<!--- cfcomment --->'
24
+ expected = [
25
+ (Token.Text, u''),
26
+ (Token.Comment.Multiline, u'<!---'),
27
+ (Token.Comment.Multiline, u' cfcomment '),
28
+ (Token.Comment.Multiline, u'--->'),
29
+ (Token.Text, u'\n'),
30
+ ]
31
+ self.assertEqual(expected, list(self.lexer.get_tokens(fragment)))
32
+
33
+ def testNestedComment(self):
34
+ fragment = u'<!--- nested <!--- cfcomment ---> --->'
35
+ expected = [
36
+ (Token.Text, u''),
37
+ (Token.Comment.Multiline, u'<!---'),
38
+ (Token.Comment.Multiline, u' nested '),
39
+ (Token.Comment.Multiline, u'<!---'),
40
+ (Token.Comment.Multiline, u' cfcomment '),
41
+ (Token.Comment.Multiline, u'--->'),
42
+ (Token.Comment.Multiline, u' '),
43
+ (Token.Comment.Multiline, u'--->'),
44
+ (Token.Text, u'\n'),
45
+ ]
46
+ self.assertEqual(expected, list(self.lexer.get_tokens(fragment)))
@@ -3,14 +3,15 @@
3
3
  Basic CLexer Test
4
4
  ~~~~~~~~~~~~~~~~~
5
5
 
6
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
6
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
7
7
  :license: BSD, see LICENSE for details.
8
8
  """
9
9
 
10
10
  import unittest
11
11
  import os
12
+ import textwrap
12
13
 
13
- from pygments.token import Text, Number
14
+ from pygments.token import Text, Number, Token
14
15
  from pygments.lexers import CLexer
15
16
 
16
17
 
@@ -27,5 +28,209 @@ class CLexerTest(unittest.TestCase):
27
28
  Number.Float, Number.Float], code.split()):
28
29
  wanted.append(item)
29
30
  wanted.append((Text, ' '))
30
- wanted = [(Text, '')] + wanted[:-1] + [(Text, '\n')]
31
+ wanted = wanted[:-1] + [(Text, '\n')]
31
32
  self.assertEqual(list(self.lexer.get_tokens(code)), wanted)
33
+
34
+ def testSwitch(self):
35
+ fragment = u'''\
36
+ int main()
37
+ {
38
+ switch (0)
39
+ {
40
+ case 0:
41
+ default:
42
+ ;
43
+ }
44
+ }
45
+ '''
46
+ tokens = [
47
+ (Token.Keyword.Type, u'int'),
48
+ (Token.Text, u' '),
49
+ (Token.Name.Function, u'main'),
50
+ (Token.Punctuation, u'('),
51
+ (Token.Punctuation, u')'),
52
+ (Token.Text, u'\n'),
53
+ (Token.Punctuation, u'{'),
54
+ (Token.Text, u'\n'),
55
+ (Token.Text, u' '),
56
+ (Token.Keyword, u'switch'),
57
+ (Token.Text, u' '),
58
+ (Token.Punctuation, u'('),
59
+ (Token.Literal.Number.Integer, u'0'),
60
+ (Token.Punctuation, u')'),
61
+ (Token.Text, u'\n'),
62
+ (Token.Text, u' '),
63
+ (Token.Punctuation, u'{'),
64
+ (Token.Text, u'\n'),
65
+ (Token.Text, u' '),
66
+ (Token.Keyword, u'case'),
67
+ (Token.Text, u' '),
68
+ (Token.Literal.Number.Integer, u'0'),
69
+ (Token.Operator, u':'),
70
+ (Token.Text, u'\n'),
71
+ (Token.Text, u' '),
72
+ (Token.Keyword, u'default'),
73
+ (Token.Operator, u':'),
74
+ (Token.Text, u'\n'),
75
+ (Token.Text, u' '),
76
+ (Token.Punctuation, u';'),
77
+ (Token.Text, u'\n'),
78
+ (Token.Text, u' '),
79
+ (Token.Punctuation, u'}'),
80
+ (Token.Text, u'\n'),
81
+ (Token.Punctuation, u'}'),
82
+ (Token.Text, u'\n'),
83
+ ]
84
+ self.assertEqual(tokens, list(self.lexer.get_tokens(textwrap.dedent(fragment))))
85
+
86
+ def testSwitchSpaceBeforeColon(self):
87
+ fragment = u'''\
88
+ int main()
89
+ {
90
+ switch (0)
91
+ {
92
+ case 0 :
93
+ default :
94
+ ;
95
+ }
96
+ }
97
+ '''
98
+ tokens = [
99
+ (Token.Keyword.Type, u'int'),
100
+ (Token.Text, u' '),
101
+ (Token.Name.Function, u'main'),
102
+ (Token.Punctuation, u'('),
103
+ (Token.Punctuation, u')'),
104
+ (Token.Text, u'\n'),
105
+ (Token.Punctuation, u'{'),
106
+ (Token.Text, u'\n'),
107
+ (Token.Text, u' '),
108
+ (Token.Keyword, u'switch'),
109
+ (Token.Text, u' '),
110
+ (Token.Punctuation, u'('),
111
+ (Token.Literal.Number.Integer, u'0'),
112
+ (Token.Punctuation, u')'),
113
+ (Token.Text, u'\n'),
114
+ (Token.Text, u' '),
115
+ (Token.Punctuation, u'{'),
116
+ (Token.Text, u'\n'),
117
+ (Token.Text, u' '),
118
+ (Token.Keyword, u'case'),
119
+ (Token.Text, u' '),
120
+ (Token.Literal.Number.Integer, u'0'),
121
+ (Token.Text, u' '),
122
+ (Token.Operator, u':'),
123
+ (Token.Text, u'\n'),
124
+ (Token.Text, u' '),
125
+ (Token.Keyword, u'default'),
126
+ (Token.Text, u' '),
127
+ (Token.Operator, u':'),
128
+ (Token.Text, u'\n'),
129
+ (Token.Text, u' '),
130
+ (Token.Punctuation, u';'),
131
+ (Token.Text, u'\n'),
132
+ (Token.Text, u' '),
133
+ (Token.Punctuation, u'}'),
134
+ (Token.Text, u'\n'),
135
+ (Token.Punctuation, u'}'),
136
+ (Token.Text, u'\n'),
137
+ ]
138
+ self.assertEqual(tokens, list(self.lexer.get_tokens(textwrap.dedent(fragment))))
139
+
140
+ def testLabel(self):
141
+ fragment = u'''\
142
+ int main()
143
+ {
144
+ foo:
145
+ goto foo;
146
+ }
147
+ '''
148
+ tokens = [
149
+ (Token.Keyword.Type, u'int'),
150
+ (Token.Text, u' '),
151
+ (Token.Name.Function, u'main'),
152
+ (Token.Punctuation, u'('),
153
+ (Token.Punctuation, u')'),
154
+ (Token.Text, u'\n'),
155
+ (Token.Punctuation, u'{'),
156
+ (Token.Text, u'\n'),
157
+ (Token.Name.Label, u'foo'),
158
+ (Token.Punctuation, u':'),
159
+ (Token.Text, u'\n'),
160
+ (Token.Text, u' '),
161
+ (Token.Keyword, u'goto'),
162
+ (Token.Text, u' '),
163
+ (Token.Name, u'foo'),
164
+ (Token.Punctuation, u';'),
165
+ (Token.Text, u'\n'),
166
+ (Token.Punctuation, u'}'),
167
+ (Token.Text, u'\n'),
168
+ ]
169
+ self.assertEqual(tokens, list(self.lexer.get_tokens(textwrap.dedent(fragment))))
170
+
171
+ def testLabelSpaceBeforeColon(self):
172
+ fragment = u'''\
173
+ int main()
174
+ {
175
+ foo :
176
+ goto foo;
177
+ }
178
+ '''
179
+ tokens = [
180
+ (Token.Keyword.Type, u'int'),
181
+ (Token.Text, u' '),
182
+ (Token.Name.Function, u'main'),
183
+ (Token.Punctuation, u'('),
184
+ (Token.Punctuation, u')'),
185
+ (Token.Text, u'\n'),
186
+ (Token.Punctuation, u'{'),
187
+ (Token.Text, u'\n'),
188
+ (Token.Name.Label, u'foo'),
189
+ (Token.Text, u' '),
190
+ (Token.Punctuation, u':'),
191
+ (Token.Text, u'\n'),
192
+ (Token.Text, u' '),
193
+ (Token.Keyword, u'goto'),
194
+ (Token.Text, u' '),
195
+ (Token.Name, u'foo'),
196
+ (Token.Punctuation, u';'),
197
+ (Token.Text, u'\n'),
198
+ (Token.Punctuation, u'}'),
199
+ (Token.Text, u'\n'),
200
+ ]
201
+ self.assertEqual(tokens, list(self.lexer.get_tokens(textwrap.dedent(fragment))))
202
+
203
+ def testLabelFollowedByStatement(self):
204
+ fragment = u'''\
205
+ int main()
206
+ {
207
+ foo:return 0;
208
+ goto foo;
209
+ }
210
+ '''
211
+ tokens = [
212
+ (Token.Keyword.Type, u'int'),
213
+ (Token.Text, u' '),
214
+ (Token.Name.Function, u'main'),
215
+ (Token.Punctuation, u'('),
216
+ (Token.Punctuation, u')'),
217
+ (Token.Text, u'\n'),
218
+ (Token.Punctuation, u'{'),
219
+ (Token.Text, u'\n'),
220
+ (Token.Name.Label, u'foo'),
221
+ (Token.Punctuation, u':'),
222
+ (Token.Keyword, u'return'),
223
+ (Token.Text, u' '),
224
+ (Token.Literal.Number.Integer, u'0'),
225
+ (Token.Punctuation, u';'),
226
+ (Token.Text, u'\n'),
227
+ (Token.Text, u' '),
228
+ (Token.Keyword, u'goto'),
229
+ (Token.Text, u' '),
230
+ (Token.Name, u'foo'),
231
+ (Token.Punctuation, u';'),
232
+ (Token.Text, u'\n'),
233
+ (Token.Punctuation, u'}'),
234
+ (Token.Text, u'\n'),
235
+ ]
236
+ self.assertEqual(tokens, list(self.lexer.get_tokens(textwrap.dedent(fragment))))