コード例 #1
0
        private static string ShrinkIEnumerable <T>(QAcidState state, object key, T value)
        {
            var theList = ((IEnumerable <int>)value).ToList();
            int index   = 0;

            while (index < theList.Count)
            {
                var ix            = index;
                var before        = theList[ix];
                var primitiveVals = new[] { -1, 0, 1 };
                var removed       = false;
                foreach (var primitiveVal in primitiveVals.Where(p => !p.Equals(before)))
                {
                    theList[ix] = primitiveVal;
                    var shrinkstate = state.ShrinkRun(key, theList);
                    if (shrinkstate)
                    {
                        theList.RemoveAt(index);
                        removed = true;
                        break;
                    }
                }
                if (!removed)
                {
                    theList[ix] = before;
                    index++;
                }
            }
            return(string.Format("[ {0} ]", string.Join(", ", theList.Select(v => v.ToString()))));
        }
コード例 #2
0
 private static string ShrinkPrimitive(QAcidState state, object key, object value, IEnumerable <object> primitiveVals)
 {
     return
         (primitiveVals
          .Select(primitiveVal => state.ShrinkRun(key, primitiveVal))
          .Any(shrinkstate => shrinkstate)
                                 ? "Irrelevant"
                                 : value.ToString());
 }