/Misc/Vim/syntax_test.py

http://unladen-swallow.googlecode.com/ · Python · 62 lines · 39 code · 1 blank · 22 comment · 1 complexity · c44314f8e9c9f8c3f30dc2be7720fe2f MD5 · raw file

  1. """Test file for syntax highlighting of editors.
  2. Meant to cover a wide range of different types of statements and expressions.
  3. Not necessarily sensical or comprehensive (assume that if one exception is
  4. highlighted that all are, for instance).
  5. Extraneous trailing whitespace can't be tested because of svn pre-commit hook
  6. checks for such things.
  7. """
  8. # Comment
  9. # OPTIONAL: XXX catch your attention
  10. # Statements
  11. from __future__ import with_statement # Import
  12. from sys import path as thing
  13. assert True # keyword
  14. def foo(): # function definition
  15. return []
  16. class Bar(object): # Class definition
  17. def __enter__(self):
  18. pass
  19. def __exit__(self, *args):
  20. pass
  21. foo() # UNCOLOURED: function call
  22. while False: # 'while'
  23. continue
  24. for x in foo(): # 'for'
  25. break
  26. with Bar() as stuff:
  27. pass
  28. if False: pass # 'if'
  29. elif False: pass
  30. else: pass
  31. # Constants
  32. 'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted
  33. "double-quote"
  34. """triple double-quote"""
  35. '''triple single-quote'''
  36. r'raw'
  37. ur'unicode raw'
  38. 'escape\n'
  39. '\04' # octal
  40. '\xFF' # hex
  41. '\u1111' # unicode character
  42. 1 # Integral
  43. 1L
  44. 1.0 # Float
  45. .1
  46. 1+2j # Complex
  47. # Expressions
  48. 1 and 2 or 3 # Boolean operators
  49. 2 < 3 # UNCOLOURED: comparison operators
  50. spam = 42 # UNCOLOURED: assignment
  51. 2 + 3 # UNCOLOURED: number operators
  52. [] # UNCOLOURED: list
  53. {} # UNCOLOURED: dict
  54. (1,) # UNCOLOURED: tuple
  55. all # Built-in functions
  56. GeneratorExit # Exceptions