Ejemplo n.º 1
0
        // Returns true iff the script compiles but generates the given runtime error.
        public bool RunRuntimeFailTest(string script, RuntimeErrorType errorType, bool verbose = false)
        {
            if (verbose)
            {
                Log("-> " + script);
            }

            List <ParseErrorInst> errors = new List <ParseErrorInst>();
            IExpr expr = _Parse(_GetScriptNameFromScript(script), script, ref errors, verbose, false);

            if (null == expr)
            {
                if (!verbose)
                {
                    LogError("-> " + script);
                }
                LogError("Expected 'execution fail' script to compile: '" + script + "'");
                return(false);
            }

            ScriptResult result = _EvaluateExpression(expr, false);

            if (null == result.runtimeError)
            {
                if (!verbose)
                {
                    LogError("-> " + script);
                }
                LogError("Parse = " + expr);
                LogError("Expected 'execution fail' script to throw an error on execution, instead returned " + ((null != result) ? result.value.GetType().ToString() : "null"));
                return(false);
            }
            else if (result.runtimeError.type != errorType)
            {
                if (!verbose)
                {
                    LogError("-> " + script);
                }
                LogError("Parse = " + expr);
                LogError("Expected 'execution fail' script to throw a (" + errorType + ") error on execution, instead returned " + result.runtimeError.type);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
 public void SetRuntimeError(RuntimeErrorType errorType, string msg)
 {
     control.flags       |= ControlInfo.ERROR;
     control.runtimeError = new RuntimeErrorInst(errorType, msg);
 }
Ejemplo n.º 3
0
 public RuntimeErrorInst(RuntimeErrorType _type, string _msg)
 {
     type = _type;
     msg  = _msg;
 }