~jbaker/storm/nose_plugin

« back to all changes in this revision

Viewing changes to storm/expr.py

  • Committer: Jamu Kakar
  • Author(s): Michael Hudson
  • Date: 2009-07-22 20:46:54 UTC
  • mfrom: (312.1.2 unary-minus)
  • Revision ID: jkakar@kakar.ca-20090722204654-3dwdo0v5vp2pg9u0
Merged unary-minus [r=jamesh,niemeyer] [f=397654]

A new Neg expression provides support for unary minus.  A minus is
automatically prepended to the expression passed to Neg.  A couple
of failures in the Zope doctest related to differences in repr
formatting between python2.5 and python2.6 have also been fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
473
473
            other = getattr(self, "variable_factory", Variable)(value=other)
474
474
        return Mod(self, other)
475
475
 
 
476
    def __neg__(self):
 
477
        return Neg(self)
 
478
 
476
479
    def is_in(self, others):
477
480
        if not isinstance(others, Expr):
478
481
            others = list(others)
1270
1273
    __slots__ = ()
1271
1274
    prefix = "EXISTS"
1272
1275
 
 
1276
class Neg(PrefixExpr):
 
1277
    __slots__ = ()
 
1278
    prefix = "-"
 
1279
 
 
1280
@compile_python.when(Neg)
 
1281
def compile_neg_expr(compile, expr, state):
 
1282
    return "-%s" % compile(expr.expr, state, raw=True)
 
1283
 
1273
1284
class Asc(SuffixExpr):
1274
1285
    __slots__ = ()
1275
1286
    suffix = "ASC"