Beispiel #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()))));
        }
Beispiel #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());
 }
Beispiel #3
0
 public static void Verify(this QAcidRunner<Unit> runner, int loops,int actions)
 {
     for (int i = 0; i < loops; i++)
     {
         var state = new QAcidState(runner);
         state.Run(actions);
         if (state.Failed)
             break;
     }
 }
Beispiel #4
0
 public static void Verify(this QAcidRunner <Unit> runner, int loops, int actions)
 {
     for (int i = 0; i < loops; i++)
     {
         var state = new QAcidState(runner);
         state.Run(actions);
         if (state.Failed)
         {
             break;
         }
     }
 }
Beispiel #5
0
        private static void ShrinkInput <T>(QAcidState state, object key, T value)
        {
            var shrunk = "Busy";

            state.Shrunk.Set(key, shrunk);
            if (typeof(IEnumerable <int>).IsAssignableFrom(typeof(T)))
            {
                shrunk = ShrinkIEnumerable(state, key, value);
            }
            var primitiveKey = PrimitiveValues.Keys.FirstOrDefault(k => k.IsAssignableFrom(typeof(T)));

            if (primitiveKey != null)
            {
                shrunk = ShrinkPrimitive(state, key, value, PrimitiveValues[primitiveKey]);
            }
            state.Shrunk.Set(key, shrunk);
        }
Beispiel #6
0
 public Memory(QAcidState state)
 {
     this.state   = state;
     MemoryPerRun = new Dictionary <int, Dictionary <object, object> >();
 }