コード例 #1
0
        public AphidRuntimeException CreateRuntimeException01(
            [PexAssumeUnderTest] AphidInterpreter target,
            AphidExpression expression,
            object obj
            )
        {
            AphidRuntimeException result = target.CreateRuntimeException(expression, obj);

            return(result);
            // TODO: add assertions to method AphidInterpreterTest.CreateRuntimeException01(AphidInterpreter, AphidExpression, Object)
        }
コード例 #2
0
        public AphidRuntimeException CreateRuntimeException(
            [PexAssumeUnderTest] AphidInterpreter target,
            string message,
            object[] args
            )
        {
            AphidRuntimeException result = target.CreateRuntimeException(message, args);

            return(result);
            // TODO: add assertions to method AphidInterpreterTest.CreateRuntimeException(AphidInterpreter, String, Object[])
        }
コード例 #3
0
        public static void StreamWrite(AphidInterpreter interpreter, Stream stream, object buffer)
        {
            byte[] bytes = buffer is List <AphidObject> objects
                ? objects.Select(x => (byte)(decimal)x.Value).ToArray()
                : buffer is string str
                    ? StandardLibrary.Encoding.GetBytes(str)
                    : throw interpreter.CreateRuntimeException(
                                     "Invalid object passed as buffer: {0}",
                                     buffer);

            stream.Write(bytes, 0, bytes.Length);
        }
コード例 #4
0
 public static void Kill(AphidInterpreter interpreter, AphidObject process)
 {
     if (process.Value is int)
     {
         Process.GetProcessById((int)process.Value).Kill();
     }
     else if (process.Value is string)
     {
         foreach (var p in Process.GetProcessesByName((string)process.Value))
         {
             p.Kill();
             p.WaitForExit();
         }
     }
     else
     {
         throw interpreter.CreateRuntimeException(
                   "Invalid process id: {0}",
                   process.Value);
     }
 }