[pypy-svn] r31349 - in pypy/dist/pypy/objspace: cclp test
auc at codespeak.net
auc at codespeak.net
Wed Aug 16 15:11:17 CEST 2006
Author: auc
Date: Wed Aug 16 15:11:15 2006
New Revision: 31349
Modified:
pypy/dist/pypy/objspace/cclp/thunk.py
pypy/dist/pypy/objspace/test/test_logicobjspace.py
Log:
also test no solution case
Modified: pypy/dist/pypy/objspace/cclp/thunk.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/thunk.py (original)
+++ pypy/dist/pypy/objspace/cclp/thunk.py Wed Aug 16 15:11:15 2006
@@ -154,8 +154,6 @@
except ConsistencyError, e:
w("-- DISTRIBUTOR thunk exited because", str(e))
interp_bind(cspace._choice, self.space.newint(0))
- import traceback
- traceback.print_exc()
except:
import traceback
traceback.print_exc()
Modified: pypy/dist/pypy/objspace/test/test_logicobjspace.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_logicobjspace.py (original)
+++ pypy/dist/pypy/objspace/test/test_logicobjspace.py Wed Aug 16 15:11:15 2006
@@ -395,7 +395,7 @@
# outside this thread ... But this can't
# happen right now because we keep
# references also of this thread in the
- # scheduler.
+ # scheduler.
wait_needed(L)
Tail = newvar()
bind(L, (n, Tail))
@@ -766,14 +766,14 @@
#assert len(sched_all()['threads']) == 1
- def test_tell_ask_choose_commit(self):
+ def test_tell_ask_choose_commit_success(self):
from problem import conference_scheduling
- def solve(spc, Sol):
+ def solve(spc, commitment, Sol):
while 1:
status = spc.ask()
if status > 1:
- spc.commit(1)
+ spc.commit(commitment)
elif status in (0, 1):
break
if status:
@@ -781,15 +781,19 @@
else:
unify(Sol, False)
- s = newspace(conference_scheduling)
- Solution = newvar()
- stacklet(solve, s, Solution)
-
- assert Solution == [('room B', 'day 1 PM'), ('room A', 'day 1 PM'),
- ('room B', 'day 2 AM'), ('room B', 'day 1 AM'),
- ('room A', 'day 2 PM'), ('room C', 'day 2 AM'),
- ('room C', 'day 2 PM'), ('room C', 'day 1 PM'),
- ('room C', 'day 1 AM'), ('room B', 'day 2 PM')]
+ for commit_to in (1, 2):
+ s = newspace(conference_scheduling)
+ Solution = newvar()
+ stacklet(solve, s, commit_to, Solution)
+ if commit_to == 1:
+ assert Solution == [('room B', 'day 1 PM'), ('room A', 'day 1 PM'),
+ ('room B', 'day 2 AM'), ('room B', 'day 1 AM'),
+ ('room A', 'day 2 PM'), ('room C', 'day 2 AM'),
+ ('room C', 'day 2 PM'), ('room C', 'day 1 PM'),
+ ('room C', 'day 1 AM'), ('room B', 'day 2 PM')]
+ else:
+ assert Solution == False
- #XXX
+ #XXX who's still stuck there ?
#assert len(sched_all()['threads']) == 1
+
More information about the Pypy-commit
mailing list