Ejemplo n.º 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()))));
        }
Ejemplo n.º 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());
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
 public Memory(QAcidState state)
 {
     this.state   = state;
     MemoryPerRun = new Dictionary <int, Dictionary <object, object> >();
 }