blob: a530a25364f12f89f73dbaa9f6ab72e9a440af60 [file] [log] [blame]
Brett Cannona4fe1822006-02-25 14:52:53 +00001"""Test file for syntax highlighting of editors.
2
3Meant to cover a wide range of different types of statements and expressions.
Brett Cannon23b0dc52006-02-26 19:27:29 +00004Not necessarily sensical or comprehensive (assume that if one exception is
5highlighted that all are, for instance).
6
7Highlighting extraneous whitespace at the end of the line is not represented
8here as all trailing whitespace is automatically removed from .py files in the
9repository.
Brett Cannona4fe1822006-02-25 14:52:53 +000010
11"""
Brett Cannona4fe1822006-02-25 14:52:53 +000012# Comment
Brett Cannon23b0dc52006-02-26 19:27:29 +000013# OPTIONAL: XXX catch your attention
14
15# Statements
Brett Cannon20e192b2006-03-01 20:53:08 +000016from __future__ import with_statement # Import
17from sys import path as thing
Brett Cannon23b0dc52006-02-26 19:27:29 +000018assert True # keyword
19def foo(): # function definition
20 return []
21class Bar(object): # Class definition
Brett Cannon20e192b2006-03-01 20:53:08 +000022 def __context__(self):
23 return self
24 def __enter__(self):
25 pass
26 def __exit__(self, *args):
27 pass
Brett Cannon23b0dc52006-02-26 19:27:29 +000028foo() # UNCOLOURED: function call
29while False: # 'while'
30 continue
31for x in foo(): # 'for'
32 break
Brett Cannon20e192b2006-03-01 20:53:08 +000033with Bar() as stuff:
34 pass
Brett Cannon23b0dc52006-02-26 19:27:29 +000035if False: pass # 'if'
36elif False: pass
Brett Cannon20e192b2006-03-01 20:53:08 +000037else: pass
Brett Cannon23b0dc52006-02-26 19:27:29 +000038
39# Constants
40'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted
Brett Cannona4fe1822006-02-25 14:52:53 +000041"double-quote"
42"""triple double-quote"""
43'''triple single-quote'''
44r'raw'
45ur'unicode raw'
46'escape\n'
47'\04' # octal
48'\xFF' # hex
49'\u1111' # unicode character
Brett Cannon23b0dc52006-02-26 19:27:29 +0000501 # Integral
Brett Cannona4fe1822006-02-25 14:52:53 +0000511L
Brett Cannon23b0dc52006-02-26 19:27:29 +0000521.0 # Float
Brett Cannona4fe1822006-02-25 14:52:53 +000053.1
Brett Cannon23b0dc52006-02-26 19:27:29 +0000541+2j # Complex
55
56# Expressions
571 and 2 or 3 # Boolean operators
582 < 3 # UNCOLOURED: comparison operators
59spam = 42 # UNCOLOURED: assignment
602 + 3 # UNCOLOURED: number operators
61[] # UNCOLOURED: list
62{} # UNCOLOURED: dict
63(1,) # UNCOLOURED: tuple
64all # Built-in functions
65GeneratorExit # Exceptions