Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_opcodes.py @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | 226ba34bd998 |
| children | 7d0bdd6e1c46 49c6eb688906 |
| rev | line source |
|---|---|
| 653 | 1 # Python test set -- part 2, opcodes |
| 2 | |
|
24442
226ba34bd998
Complete the absolute import patch for the test suite. All relative
Barry Warsaw <barry@python.org>
parents:
24364
diff
changeset
|
3 from test.test_support import TestFailed |
| 653 | 4 |
| 5 | |
| 6 print '2. Opcodes' | |
| 7 print 'XXX Not yet fully implemented' | |
| 8 | |
| 9 print '2.1 try inside for loop' | |
| 10 n = 0 | |
| 11 for i in range(10): | |
|
15305
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
12 n = n+i |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
13 try: 1/0 |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
14 except NameError: pass |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
15 except ZeroDivisionError: pass |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
16 except TypeError: pass |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
17 try: pass |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
18 except: pass |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
19 try: pass |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
20 finally: pass |
|
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
21 n = n+i |
|
15540
9d43129c8c55
Update the code to better reflect recommended style:
Fred Drake <fdrake@acm.org>
parents:
15305
diff
changeset
|
22 if n != 90: |
|
15305
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
7747
diff
changeset
|
23 raise TestFailed, 'try inside for' |
| 2302 | 24 |
| 25 | |
| 26 print '2.2 raise class exceptions' | |
| 27 | |
| 28 class AClass: pass | |
| 29 class BClass(AClass): pass | |
| 30 class CClass: pass | |
|
6150
9a78ce1db8f6
Added a few more tests of exception class raising
Barry Warsaw <barry@python.org>
parents:
5946
diff
changeset
|
31 class DClass(AClass): |
|
9a78ce1db8f6
Added a few more tests of exception class raising
Barry Warsaw <barry@python.org>
parents:
5946
diff
changeset
|
32 def __init__(self, ignore): |
|
7747
aedd2d0dcb31
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6369
diff
changeset
|
33 pass |
| 2302 | 34 |
| 35 try: raise AClass() | |
| 36 except: pass | |
| 37 | |
| 38 try: raise AClass() | |
| 39 except AClass: pass | |
| 40 | |
| 41 try: raise BClass() | |
| 42 except AClass: pass | |
| 43 | |
| 44 try: raise BClass() | |
| 45 except CClass: raise TestFailed | |
| 46 except: pass | |
| 47 | |
| 48 a = AClass() | |
| 49 b = BClass() | |
| 50 | |
| 51 try: raise AClass, b | |
|
6369
f8224046ccf8
There was actually a test that ensured that raising an exception A
Guido van Rossum <guido@python.org>
parents:
6150
diff
changeset
|
52 except BClass, v: |
|
16328
abd383f1905c
The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15540
diff
changeset
|
53 if v != b: raise TestFailed, "v!=b" |
|
abd383f1905c
The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15540
diff
changeset
|
54 else: raise TestFailed, "no exception" |
| 2302 | 55 |
| 56 try: raise b | |
| 57 except AClass, v: | |
|
16328
abd383f1905c
The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15540
diff
changeset
|
58 if v != b: raise TestFailed, "v!=b AClass" |
| 2302 | 59 |
|
6150
9a78ce1db8f6
Added a few more tests of exception class raising
Barry Warsaw <barry@python.org>
parents:
5946
diff
changeset
|
60 # not enough arguments |
| 2302 | 61 try: raise BClass, a |
| 62 except TypeError: pass | |
|
5946
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
63 |
|
6150
9a78ce1db8f6
Added a few more tests of exception class raising
Barry Warsaw <barry@python.org>
parents:
5946
diff
changeset
|
64 try: raise DClass, a |
|
9a78ce1db8f6
Added a few more tests of exception class raising
Barry Warsaw <barry@python.org>
parents:
5946
diff
changeset
|
65 except DClass, v: |
|
9a78ce1db8f6
Added a few more tests of exception class raising
Barry Warsaw <barry@python.org>
parents:
5946
diff
changeset
|
66 if not isinstance(v, DClass): |
|
16328
abd383f1905c
The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15540
diff
changeset
|
67 raise TestFailed, "v not DClass" |
|
5946
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
68 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
69 print '2.3 comparing function objects' |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
70 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
71 f = eval('lambda: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
72 g = eval('lambda: None') |
|
16328
abd383f1905c
The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15540
diff
changeset
|
73 if f == g: raise TestFailed, "functions should not be same" |
|
5946
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
74 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
75 f = eval('lambda a: a') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
76 g = eval('lambda a: a') |
|
16328
abd383f1905c
The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15540
diff
changeset
|
77 if f == g: raise TestFailed, "functions should not be same" |
|
5946
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
78 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
79 f = eval('lambda a=1: a') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
80 g = eval('lambda a=1: a') |
|
16328
abd383f1905c
The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15540
diff
changeset
|
81 if f == g: raise TestFailed, "functions should not be same" |
|
5946
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
82 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
83 f = eval('lambda: 0') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
84 g = eval('lambda: 1') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
85 if f == g: raise TestFailed |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
86 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
87 f = eval('lambda: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
88 g = eval('lambda a: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
89 if f == g: raise TestFailed |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
90 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
91 f = eval('lambda a: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
92 g = eval('lambda b: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
93 if f == g: raise TestFailed |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
94 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
95 f = eval('lambda a: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
96 g = eval('lambda a=None: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
97 if f == g: raise TestFailed |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
98 |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
99 f = eval('lambda a=0: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
100 g = eval('lambda a=1: None') |
|
9a56452c7e8e
Add test for function comparisons
Guido van Rossum <guido@python.org>
parents:
2302
diff
changeset
|
101 if f == g: raise TestFailed |
