Example #1
0
 /**
  * Creates test data for this test.
  *
  * @return test data for this test
  */
 @Parameters
 public static Collection<Object[]> data() {
   return Arrays.asList(
       new Object[][] {
         // null
         {false, new StringValue("string"), null},
         // NullValue
         {false, new StringValue("string"), NullValue.INSTANCE},
         // IdentifierValue
         {false, new StringValue("string"), new IdentifierValue("identifier")},
         // BooleanValue
         {false, new StringValue("string"), BooleanValue.TRUE},
         {false, new StringValue("string"), BooleanValue.FALSE},
         // IntegerValue
         {false, new StringValue("string"), new IntegerValue(1)},
         // FloatValue
         {false, new StringValue("string"), new FloatValue(1)},
         // StringValue
         {true, new StringValue("string"), new StringValue("string")},
         {false, new StringValue("string"), new StringValue("String")},
         {false, new StringValue("string"), new StringValue("STRING")},
         {false, new StringValue("string 1"), new StringValue("string 2")},
         // PointValue
         {false, new StringValue("string"), new PointValue(1, 1)},
         // PairValue
         {false, new StringValue("string"), new PairValue("ident1", "ident2")},
         // DirectedPairValue
         {false, new StringValue("string"), new DirectedPairValue("ident1", "ident2")},
         // DurationValue
         {false, new StringValue("string"), new DurationValue(1)},
         // FileValue
         {false, new StringValue("string"), ValueTestUtils.createTestFileValue("file")},
         // UriValue
         {false, new StringValue("string"), new UriValue("uri")},
         // MultipleValue
         {false, new StringValue("string"), MultipleValue.emptyValue()},
         {
           false,
           new StringValue("string"),
           MultipleValue.createMultipleValue(new StringValue("string"))
         },
         // OrderedValue
         {false, new StringValue("string"), OrderedValue.emptyValue()},
         {
           false,
           new StringValue("string"),
           OrderedValue.createOrderedValue(new StringValue("string"))
         },
         // RecordValue
         {false, new StringValue("string"), RecordValue.emptyRecord()},
         {
           false,
           new StringValue("string"),
           RecordValue.createRecordValue("identifier", new StringValue("string"))
         },
       });
 }
Example #2
0
 /* Fully normalize this (composite) value. */
 public final void deepNormalize() {
   switch (this.getKind()) {
     case RECORDVALUE:
       {
         RecordValue rcd = (RecordValue) this;
         for (int i = 0; i < rcd.values.length; i++) {
           rcd.values[i].deepNormalize();
         }
         rcd.normalize();
         break;
       }
     case FCNRCDVALUE:
       {
         FcnRcdValue fcn = (FcnRcdValue) this;
         for (int i = 0; i < fcn.values.length; i++) {
           fcn.values[i].deepNormalize();
         }
         fcn.normalize();
         break;
       }
     case SETENUMVALUE:
       {
         SetEnumValue set = (SetEnumValue) this;
         for (int i = 0; i < set.elems.size(); i++) {
           set.elems.elementAt(i).deepNormalize();
         }
         set.normalize();
         break;
       }
     case TUPLEVALUE:
       {
         TupleValue tv = (TupleValue) this;
         for (int i = 0; i < tv.elems.length; i++) {
           tv.elems[i].deepNormalize();
         }
         break;
       }
     case SETCAPVALUE:
       {
         SetCapValue cap = (SetCapValue) this;
         cap.set1.deepNormalize();
         cap.set2.deepNormalize();
         if (cap.capSet == null) {
           cap.capSet = DummyEnum;
         } else if (cap.capSet != DummyEnum) {
           cap.capSet.deepNormalize();
         }
         break;
       }
     case SETCUPVALUE:
       {
         SetCupValue cup = (SetCupValue) this;
         cup.set1.deepNormalize();
         cup.set2.deepNormalize();
         if (cup.cupSet == null) {
           cup.cupSet = DummyEnum;
         } else if (cup.cupSet != DummyEnum) {
           cup.cupSet.deepNormalize();
         }
         break;
       }
     case SETDIFFVALUE:
       {
         SetDiffValue diff = (SetDiffValue) this;
         diff.set1.deepNormalize();
         diff.set2.deepNormalize();
         if (diff.diffSet == null) {
           diff.diffSet = DummyEnum;
         } else if (diff.diffSet != DummyEnum) {
           diff.diffSet.deepNormalize();
         }
         break;
       }
     case SETOFFCNSVALUE:
       {
         SetOfFcnsValue fcns = (SetOfFcnsValue) this;
         fcns.domain.deepNormalize();
         fcns.range.deepNormalize();
         if (fcns.fcnSet == null) {
           fcns.fcnSet = DummyEnum;
         } else if (fcns.fcnSet != DummyEnum) {
           fcns.fcnSet.deepNormalize();
         }
         break;
       }
     case SETOFRCDSVALUE:
       {
         SetOfRcdsValue srv = (SetOfRcdsValue) this;
         for (int i = 0; i < srv.values.length; i++) {
           srv.values[i].deepNormalize();
         }
         if (srv.rcdSet == null) {
           srv.rcdSet = DummyEnum;
         } else if (srv.rcdSet != DummyEnum) {
           srv.rcdSet.deepNormalize();
         }
         break;
       }
     case SETOFTUPLESVALUE:
       {
         SetOfTuplesValue stv = (SetOfTuplesValue) this;
         for (int i = 0; i < stv.sets.length; i++) {
           stv.sets[i].deepNormalize();
         }
         if (stv.tupleSet == null) {
           stv.tupleSet = DummyEnum;
         } else if (stv.tupleSet != DummyEnum) {
           stv.tupleSet.deepNormalize();
         }
         break;
       }
     case SUBSETVALUE:
       {
         SubsetValue pset = (SubsetValue) this;
         pset.set.deepNormalize();
         if (pset.pset == null) {
           pset.pset = DummyEnum;
         } else if (pset.pset != DummyEnum) {
           pset.pset.deepNormalize();
         }
         break;
       }
     case UNIONVALUE:
       {
         UnionValue uv = (UnionValue) this;
         if (uv.realSet == null) {
           uv.realSet = DummyEnum;
         } else if (uv.realSet != DummyEnum) {
           uv.realSet.deepNormalize();
         }
         break;
       }
     case SETPREDVALUE:
       {
         SetPredValue spv = (SetPredValue) this;
         spv.inVal.deepNormalize();
         break;
       }
     case FCNLAMBDAVALUE:
       {
         FcnLambdaValue flv = (FcnLambdaValue) this;
         if (flv.fcnRcd == null) {
           if (flv.excepts != null) {
             for (int i = 0; i < flv.excepts.length; i++) {
               flv.excepts[i].value.deepNormalize();
               for (int j = 0; j < flv.excepts[i].path.length; j++) {
                 flv.excepts[i].path[j].deepNormalize();
               }
             }
           }
           Value[] paramDoms = flv.params.domains;
           for (int i = 0; i < paramDoms.length; i++) {
             paramDoms[i].deepNormalize();
           }
         } else {
           flv.fcnRcd.deepNormalize();
         }
       }
     default:
       break;
   }
 }