Wiki

Changeset 1818

Show
Ignore:
Timestamp:
12/08/08 07:29:18 (3 years ago)
Author:
Chuck.Esterbrook
Message:

Support bitwise-and for testing enums.
reported-by:gauthier

Location:
cobra/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/BinaryOpExpr.cobra

    r1768 r1818  
    342342        else if _left.isKindOf(tpassthrough) or _right.isKindOf(tpassthrough) 
    343343            _type = tpassthrough 
     344        else if leftType == rightType and leftType inherits EnumDecl 
     345            _type = leftType 
    344346        else if cannotMix 
    345347            .throwError('Cannot mix types [_left.type.name] and [_right.type.name] for arithmetic.') 
  • cobra/trunk/Tests/100-basics/310-enums-combine.cobra

    r1428 r1818  
    1212        .takeColor(Color(Red, Green)) 
    1313        # TODO: Should have a qualified example. System.SomeEnum(MemberA, MemberB) and System.Something.SomeEnum(MemberA, MemberB) 
     14         
     15        # testing enum membership with bitwise-and 
     16        assert c & Color.Red == Color.Red 
     17        assert c & Color.Green == Color.Green 
     18        assert c & Color.Blue <> Color.Blue 
    1419 
    1520    def takeColor(c as Color) is shared