File: bugs101.py

package info (click to toggle)
jython 2.1.0-20
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,388 kB
  • ctags: 12,215
  • sloc: java: 48,499; python: 16,220; xml: 403; makefile: 189; perl: 103; ansic: 24; sh: 14
file content (57 lines) | stat: -rw-r--r-- 1,035 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
import os
dir = os.path.dirname(sys.argv[0])
scriptsdir = os.path.normpath(os.path.join(dir, os.pardir, 'scripts'))
sys.path.append(scriptsdir)
from test_support import *

def test931():
    '''exec and eval are not thread safe'''

    from java.lang import Thread

    class TestThread(Thread):
	def run(self):
	    for i in range(30):
		exec("x=2+2")

    testers = []
    for i in range(10):
	testers.append(TestThread())

    for tester in testers:
	tester.start()


    for tester in testers:
	tester.join()

code32 = """\
def foo():
    try:
	2+2
    finally:
	return 4
"""

def test32():
    'return in finally clause causes java.lang.VerifyError at compile time'
    exec code32

print_test('Bug Fixes', 0)
print_test('From 1.0.1 to 1.0.2', 1)

items = locals().items()
items.sort()

errors = 0
for name, value in items:
    if name[:4] == 'test':
	print_test(value.__doc__+' #'+name[4:], 2)
	try:
	    value()
	except:
	    print 'Error!', sys.exc_type, sys.exc_value
	    errors = errors+1

print errors, 'errors'