Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80530ce

Browse files
committed
* Add some more tests for numbers
* mainloop.py: don't use select unless absolutely necessary (for Mac)
1 parent 9672e44 commit 80530ce

4 files changed

Lines changed: 44 additions & 10 deletions

File tree

Lib/lib-stdwin/mainloop.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# - have a 'dispatch' function as a window member
55

66

7-
# XXX This is UNIX specific! For the Mac we need to use a simpler version!
8-
9-
107
import stdwin, stdwinq
118
from stdwinevents import *
129

@@ -132,9 +129,17 @@ def mainloop():
132129
recursion_level = recursion_level + 1
133130
try:
134131
stdwin_select_handler() # Process events already in queue
135-
fd = stdwin.fileno()
136132
while 1:
137-
if windows:
133+
if windows and not fdlist:
134+
while windows and not fdlist:
135+
try:
136+
event = stdwinq.getevent()
137+
except KeyboardInterrupt:
138+
event = (WE_COMMAND, \
139+
None, WC_CANCEL)
140+
dispatch(event)
141+
elif windows and fdlist:
142+
fd = stdwin.fileno()
138143
if recursion_level == 1:
139144
registerfd(fd, 'r', stdwin_select_handler)
140145
try:

Lib/stdwin/mainloop.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# - have a 'dispatch' function as a window member
55

66

7-
# XXX This is UNIX specific! For the Mac we need to use a simpler version!
8-
9-
107
import stdwin, stdwinq
118
from stdwinevents import *
129

@@ -132,9 +129,17 @@ def mainloop():
132129
recursion_level = recursion_level + 1
133130
try:
134131
stdwin_select_handler() # Process events already in queue
135-
fd = stdwin.fileno()
136132
while 1:
137-
if windows:
133+
if windows and not fdlist:
134+
while windows and not fdlist:
135+
try:
136+
event = stdwinq.getevent()
137+
except KeyboardInterrupt:
138+
event = (WE_COMMAND, \
139+
None, WC_CANCEL)
140+
dispatch(event)
141+
elif windows and fdlist:
142+
fd = stdwin.fileno()
138143
if recursion_level == 1:
139144
registerfd(fd, 'r', stdwin_select_handler)
140145
try:

Lib/test/test_types.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ class C(): pass
6060
else: raise TestFailed, 'long() does not round properly'
6161
if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass
6262
else: raise TestFailed, 'float() does not work properly'
63+
print '6.4.1 32-bit integers'
64+
if 12 + 24 <> 36: raise TestFailed, 'int op'
65+
if 12 + (-24) <> -12: raise TestFailed, 'int op'
66+
if (-12) + 24 <> 12: raise TestFailed, 'int op'
67+
if (-12) + (-24) <> -36: raise TestFailed, 'int op'
68+
if not 12 < 24: raise TestFailed, 'int op'
69+
if not -24 < -12: raise TestFailed, 'int op'
70+
print '6.4.2 Long integers'
71+
if 12L + 24L <> 36L: raise TestFailed, 'long op'
72+
if 12L + (-24L) <> -12L: raise TestFailed, 'long op'
73+
if (-12L) + 24L <> 12L: raise TestFailed, 'long op'
74+
if (-12L) + (-24L) <> -36L: raise TestFailed, 'long op'
75+
if not 12L < 24L: raise TestFailed, 'long op'
76+
if not -24L < -12L: raise TestFailed, 'long op'
77+
print '6.4.3 Floating point numbers'
78+
if 12.0 + 24.0 <> 36.0: raise TestFailed, 'float op'
79+
if 12.0 + (-24.0) <> -12.0: raise TestFailed, 'float op'
80+
if (-12.0) + 24.0 <> 12.0: raise TestFailed, 'float op'
81+
if (-12.0) + (-24.0) <> -36.0: raise TestFailed, 'float op'
82+
if not 12.0 < 24.0: raise TestFailed, 'float op'
83+
if not -24.0 < -12.0: raise TestFailed, 'float op'
6384

6485
print '6.5 Sequence types'
6586

Lib/test/testall.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ test_types
124124
6.2 Boolean operations
125125
6.3 Comparisons
126126
6.4 Numeric types (mostly conversions)
127+
6.4.1 32-bit integers
128+
6.4.2 Long integers
129+
6.4.3 Floating point numbers
127130
6.5 Sequence types
128131
6.5.1 Strings
129132
6.5.2 Tuples

0 commit comments

Comments
 (0)