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 | |
Brett Cannon | 8fff20f | 2008-01-29 04:18:04 +0000 | [diff] [blame] | 7 | Extraneous trailing whitespace can't be tested because of svn pre-commit hook |
| 8 | checks for such things. |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 9 | |
| 10 | """ |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 11 | # Comment |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 12 | # OPTIONAL: XXX catch your attention |
| 13 | |
| 14 | # Statements |
Brett Cannon | 20e192b | 2006-03-01 20:53:08 +0000 | [diff] [blame] | 15 | from __future__ import with_statement # Import |
| 16 | from sys import path as thing |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 17 | assert True # keyword |
| 18 | def foo(): # function definition |
| 19 | return [] |
| 20 | class Bar(object): # Class definition |
Brett Cannon | 20e192b | 2006-03-01 20:53:08 +0000 | [diff] [blame] | 21 | def __enter__(self): |
| 22 | pass |
| 23 | def __exit__(self, *args): |
| 24 | pass |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 25 | foo() # UNCOLOURED: function call |
| 26 | while False: # 'while' |
| 27 | continue |
| 28 | for x in foo(): # 'for' |
| 29 | break |
Brett Cannon | 20e192b | 2006-03-01 20:53:08 +0000 | [diff] [blame] | 30 | with Bar() as stuff: |
| 31 | pass |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 32 | if False: pass # 'if' |
| 33 | elif False: pass |
Brett Cannon | 20e192b | 2006-03-01 20:53:08 +0000 | [diff] [blame] | 34 | else: pass |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 35 | |
| 36 | # Constants |
| 37 | 'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 38 | "double-quote" |
| 39 | """triple double-quote""" |
| 40 | '''triple single-quote''' |
| 41 | r'raw' |
| 42 | ur'unicode raw' |
| 43 | 'escape\n' |
| 44 | '\04' # octal |
| 45 | '\xFF' # hex |
| 46 | '\u1111' # unicode character |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 47 | 1 # Integral |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 48 | 1L |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 49 | 1.0 # Float |
Brett Cannon | a4fe182 | 2006-02-25 14:52:53 +0000 | [diff] [blame] | 50 | .1 |
Brett Cannon | 23b0dc5 | 2006-02-26 19:27:29 +0000 | [diff] [blame] | 51 | 1+2j # Complex |
| 52 | |
| 53 | # Expressions |
| 54 | 1 and 2 or 3 # Boolean operators |
| 55 | 2 < 3 # UNCOLOURED: comparison operators |
| 56 | spam = 42 # UNCOLOURED: assignment |
| 57 | 2 + 3 # UNCOLOURED: number operators |
| 58 | [] # UNCOLOURED: list |
| 59 | {} # UNCOLOURED: dict |
| 60 | (1,) # UNCOLOURED: tuple |
| 61 | all # Built-in functions |
| 62 | GeneratorExit # Exceptions |