Clover coverage report - DynamicJava Test Coverage (dynamicjava-20130622-r5436)
Coverage timestamp: Sat Jun 22 2013 03:01:29 CDT
file stats: LOC: 89   Methods: 13
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BoundedSymbol.java 50% 87.1% 92.3% 84%
coverage coverage
 1    package edu.rice.cs.dynamicjava.symbol;
 2   
 3    import edu.rice.cs.dynamicjava.symbol.type.Type;
 4    import edu.rice.cs.plt.lambda.DelayedThunk;
 5   
 6    /**
 7    * <p>Represents a type variable or wildcard. For simplicity, two kinds of symbols may be
 8    * represented. Declared symbols have a name; generated symbols (including
 9    * wildcards) are unnamed. In both cases, equality is defined in terms of an id object, rather
 10    * than by equating names or other parameters. Clients are responsible for ensuring, where
 11    * two symbols have the same {@code id} (according to {@code equals()}), that the other
 12    * properties of the symbol are the same.</p>
 13    *
 14    * <p>Each symbol has an upper and a lower bound. These may be initialized after object creation,
 15    * but must be initialized exactly once before use, or an exception will occur.</p>
 16    */
 17    public class BoundedSymbol {
 18   
 19    private final Object _id;
 20    private final boolean _generated;
 21    private final String _name;
 22    private final DelayedThunk<Type> _upperBound;
 23    private final DelayedThunk<Type> _lowerBound;
 24   
 25  842 public BoundedSymbol(Object id) {
 26  842 _id = id;
 27  842 _generated = true;
 28  842 _name = null;
 29  842 _upperBound = new DelayedThunk<Type>();
 30  842 _lowerBound = new DelayedThunk<Type>();
 31    }
 32   
 33  12607 public BoundedSymbol(Object id, String name) {
 34  12607 _id = id;
 35  12607 _generated = false;
 36  12607 _name = name;
 37  12607 _upperBound = new DelayedThunk<Type>();
 38  12607 _lowerBound = new DelayedThunk<Type>();
 39    }
 40   
 41  143 public BoundedSymbol(Object id, Type upperBound, Type lowerBound) {
 42  143 this(id);
 43  143 _upperBound.set(upperBound);
 44  143 _lowerBound.set(lowerBound);
 45    }
 46   
 47  69 public BoundedSymbol(Object id, String name, Type upperBound, Type lowerBound) {
 48  69 this(id, name);
 49  69 _upperBound.set(upperBound);
 50  69 _lowerBound.set(lowerBound);
 51    }
 52   
 53    /* This code is a bad idea.
 54    public TypeVariable changeBounds(Type upperBound, Type lowerBound) {
 55    // TODO: This allows two variables to be equal (same id), even though their
 56    // bounds are different. How do we handle that?
 57    if (_generated) { return new TypeVariable(_id, upperBound, lowerBound); }
 58    else { return new TypeVariable(_id, _name, upperBound, lowerBound); }
 59    }
 60    */
 61   
 62  13 public boolean generated() { return _generated; }
 63   
 64  773 public String name() {
 65  0 if (_generated) { throw new IllegalArgumentException("Symbol is unnamed"); }
 66  773 else { return _name; }
 67    }
 68   
 69  13222 public void initializeUpperBound(Type t) { _upperBound.set(t); }
 70   
 71  13222 public void initializeLowerBound(Type t) { _lowerBound.set(t); }
 72   
 73  3078 public Type upperBound() { return _upperBound.value(); }
 74   
 75  2682 public Type lowerBound() { return _lowerBound.value(); }
 76   
 77  0 public String toString() { return "symbol " + _id; }
 78   
 79  2730 public boolean equals(Object o) {
 80  0 if (this == o) { return true; }
 81  0 else if (!(o instanceof BoundedSymbol)) { return false; }
 82  2730 else { return ((BoundedSymbol) o)._id.equals(_id); }
 83    }
 84   
 85  5172 public int hashCode() {
 86  5172 return getClass().hashCode() ^ _id.hashCode();
 87    }
 88   
 89    }