Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 1 | """Test file for syntax highlighting of editors. |
| 2 | |
| 3 | Meant to cover a wide range of different types of statements and expressions. |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 4 | Not necessarily sensical or comprehensive (assume that if one exception is |
| 5 | highlighted that all are, for instance). |
| 6 | |
| 7 | Highlighting extraneous whitespace at the end of the line is not represented |
| 8 | here as all trailing whitespace is automatically removed from .py files in the |
| 9 | repository. |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 10 | |
| 11 | """ |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 12 | # Comment |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 13 | # OPTIONAL: XXX catch your attention |
| 14 | |
| 15 | # Statements |
Brett Cannon | 20e192b | 2006-03-01 20:53:08 +0000 | [diff] [blame] | 16 | from __future__ import with_statement # Import |
| 17 | from sys import path as thing |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 18 | assert True # keyword |
| 19 | def foo(): # function definition |
| 20 | return [] |
| 21 | class Bar(object): # Class definition |
Brett Cannon | 20e192b | 2006-03-01 20:53:08 +0000 | [diff] [blame] | 22 | def __context__(self): |
| 23 | return self |
| 24 | def __enter__(self): |
| 25 | pass |
| 26 | def __exit__(self, *args): |
| 27 | pass |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 28 | foo() # UNCOLOURED: function call |
| 29 | while False: # 'while' |
| 30 | continue |
| 31 | for x in foo(): # 'for' |
| 32 | break |
Brett Cannon | 20e192b | 2006-03-01 20:53:08 +0000 | [diff] [blame] | 33 | with Bar() as stuff: |
| 34 | pass |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 35 | if False: pass # 'if' |
| 36 | elif False: pass |
Brett Cannon | 20e192b | 2006-03-01 20:53:08 +0000 | [diff] [blame] | 37 | else: pass |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 38 | |
| 39 | # Constants |
| 40 | 'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 41 | "double-quote" |
| 42 | """triple double-quote""" |
| 43 | '''triple single-quote''' |
| 44 | r'raw' |
| 45 | ur'unicode raw' |
| 46 | 'escape\n' |
| 47 | '\04' # octal |
| 48 | '\xFF' # hex |
| 49 | '\u1111' # unicode character |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 50 | 1 # Integral |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 51 | 1L |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 52 | 1.0 # Float |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 53 | .1 |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 54 | 1+2j # Complex |
| 55 | |
| 56 | # Expressions |
| 57 | 1 and 2 or 3 # Boolean operators |
| 58 | 2 < 3 # UNCOLOURED: comparison operators |
| 59 | spam = 42 # UNCOLOURED: assignment |
| 60 | 2 + 3 # UNCOLOURED: number operators |
| 61 | [] # UNCOLOURED: list |
| 62 | {} # UNCOLOURED: dict |
| 63 | (1,) # UNCOLOURED: tuple |
| 64 | all # Built-in functions |
| 65 | GeneratorExit # Exceptions |