Esempio n. 1
0
 internal JScriptException(JSError errorNumber, Context context)
 {
     this.errorNumber      = errorNumber;
     this.wrappedException = null;
     this.context          = context;
     this.message          = null;
 }
Esempio n. 2
0
 internal JScriptException(JSError errorNumber, IndexSpan span, LocationResolver resolver) {
     m_valueObject = null;
     _span = span;
     _resolver = resolver;
     m_errorCode = errorNumber;
     SetHResult();
 }
Esempio n. 3
0
        internal void HandleError(JSError errorId, bool forceToError = false)
        {
            if ((errorId != JSError.UndeclaredVariable && errorId != JSError.UndeclaredFunction) || !Document.HasAlreadySeenErrorFor(Code))
            {
                var severity     = GetSeverity(errorId);
                var errorMessage = GetErrorString(errorId);
                var context      = this.ErrorSegment;
                if (!context.IsNullOrWhiteSpace())
                {
                    errorMessage += CommonStrings.ContextSeparator + context;
                }

                var error = new UglifyError()
                {
                    IsError     = forceToError || severity < 2,
                    File        = Document.FileContext,
                    Severity    = severity,
                    Subcategory = UglifyError.GetSubcategory(severity),
                    ErrorNumber = (int)errorId,
                    ErrorCode   = "JS{0}".FormatInvariant((int)errorId),
                    StartLine   = this.StartLineNumber,
                    StartColumn = this.StartColumn + 1,
                    EndLine     = this.EndLineNumber,
                    EndColumn   = this.EndColumn + 1,
                    Message     = errorMessage,
                };

                Document.HandleError(error);
            }
        }
Esempio n. 4
0
 internal JScriptException(JSError errorNumber, Context context)
 {
     m_valueObject = Missing.Value;
     m_context = (context == null ? null : context.Clone());
     m_fileContext = (context == null ? null : context.Document.FileContext);
     m_code = HResult = unchecked((int)(0x800A0000 + (int)errorNumber));
 }
	internal JScriptException(JSError errorNumber, Context context)
			{
				this.errorNumber = errorNumber;
				this.wrappedException = null;
				this.context = context;
				this.message = null;
			}
Esempio n. 6
0
 internal JScriptException(JSError errorNumber, Context context)
 {
     m_valueObject = Missing.Value;
     m_context     = (context == null ? null : context.Clone());
     m_fileContext = (context == null ? null : context.FileContext);
     m_code        = HResult = unchecked ((int)(0x800A0000 + (int)errorNumber));
 }
Esempio n. 7
0
 internal JScriptException(JSError errorNumber, Context context)
 {
     m_valueObject = null;
     m_context     = (context == null ? null : context.Clone());
     m_fileContext = (context == null ? null : context.Document.FileContext);
     m_errorCode   = errorNumber;
     SetHResult();
 }
Esempio n. 8
0
 public JScriptException(string message, Exception innerException)
     : base(message, innerException)
 {
     m_valueObject = message;
     m_context     = null;
     m_fileContext = null;
     m_errorCode   = JSError.UncaughtException;
     SetHResult();
 }
 protected ScannerException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     m_errorId = (JSError)Enum.Parse(typeof(JSError), info.GetString("errorid"));
 }
Esempio n. 10
0
 protected ScannerException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     m_errorId = (JSError)Enum.Parse(typeof(JSError), info.GetString("errorid"));
 }
Esempio n. 11
0
        protected JScriptException(SerializationInfo info, StreamingContext context)
            : base(info, context) {
            if (info == null) {
                throw new ArgumentException(JScript.InternalCompilerError);
            }

            m_valueObject = info.GetString("Value");
            m_isError = info.GetBoolean("IsError");
            m_errorCode = (JSError)info.GetInt32("JSError");
            m_canRecover = info.GetBoolean("CanRecover");
        }
Esempio n. 12
0
        internal void HandleError(JSError errorId, IndexSpan span, LocationResolver resolver, bool forceToError = false) {
            var error = new JScriptException(errorId, span, resolver);

            if (forceToError) {
                error.IsError = true;
            } else {
                error.IsError = error.Severity < 2;
            }

            if (!OnCompilerError(error)) {

            }
        }
Esempio n. 13
0
        /// <summary>
        /// Return the default severity for a given JSError value
        /// guide: 0 == there will be a run-time error if this code executes
        ///        1 == the programmer probably did not intend to do this
        ///        2 == this can lead to cross-browser or future problems.
        ///        3 == this can lead to performance problems
        ///        4 == this is just not right
        /// </summary>
        /// <param name="errorCode">error code</param>
        /// <returns>severity</returns>
        private static int GetSeverity(JSError errorCode)
        {
            switch (errorCode)
            {
            case JSError.AmbiguousCatchVar:
            case JSError.AmbiguousNamedFunctionExpression:
            case JSError.ExportNotAtModuleLevel:
            case JSError.NumericOverflow:
            case JSError.StrictComparisonIsAlwaysTrueOrFalse:
                return(1);

            case JSError.ArrayLiteralTrailingComma:
            case JSError.DuplicateCatch:
            case JSError.DuplicateConstantDeclaration:
            case JSError.DuplicateLexicalDeclaration:
            case JSError.HighSurrogate:
            case JSError.KeywordUsedAsIdentifier:
            case JSError.LowSurrogate:
            case JSError.MisplacedFunctionDeclaration:
            case JSError.ObjectLiteralKeyword:
                return(2);

            case JSError.ArgumentNotReferenced:
            case JSError.DuplicateName:
            case JSError.FunctionNotReferenced:
            case JSError.UndeclaredFunction:
            case JSError.UndeclaredVariable:
            case JSError.VariableDefinedNotReferenced:
                return(3);

            case JSError.FunctionNameMustBeIdentifier:
            case JSError.ObjectConstructorTakesNoArguments:
            case JSError.OctalLiteralsDeprecated:
            case JSError.NewLineNotAllowed:
            case JSError.NoModuleExport:
            case JSError.NumericMaximum:
            case JSError.NumericMinimum:
            case JSError.SemicolonInsertion:
            case JSError.StatementBlockExpected:
            case JSError.SuspectAssignment:
            case JSError.SuspectEquality:
            case JSError.SuspectSemicolon:
            case JSError.UnusedLabel:
            case JSError.WithNotRecommended:
                return(4);

            default:
                // all others
                return(0);
            }
        }
Esempio n. 14
0
 // constructor
 public ContextError(bool isError, int severity, string subcategory, JSError errorCode, string helpKeyword, int startLine, int startColumn, int endLine, int endColumn, string message)
 {
     // transfer the values as-is
     IsError     = isError;
     Severity    = severity;
     Subcategory = subcategory;
     ErrorCode   = errorCode;
     HelpKeyword = helpKeyword;
     StartLine   = startLine;
     StartColumn = startColumn;
     EndLine     = endLine;
     EndColumn   = endColumn;
     Message     = message;
 }
Esempio n. 15
0
 // constructor
 public ContextError(bool isError, int severity, string subcategory, JSError errorCode, string helpKeyword, int startLine, int startColumn, int endLine, int endColumn, string message)
 {
     // transfer the values as-is
     IsError = isError;
     Severity = severity;
     Subcategory = subcategory;
     ErrorCode = errorCode;
     HelpKeyword = helpKeyword;
     StartLine = startLine;
     StartColumn = startColumn;
     EndLine = endLine;
     EndColumn = endColumn;
     Message = message;
 }
Esempio n. 16
0
        internal void HandleError(JSError errorId, IndexSpan span, LocationResolver resolver, bool forceToError = false)
        {
            var error = new JScriptException(errorId, span, resolver);

            if (forceToError)
            {
                error.IsError = true;
            }
            else
            {
                error.IsError = error.Severity < 2;
            }

            if (!OnCompilerError(error))
            {
            }
        }
Esempio n. 17
0
 internal JScriptException(Object value)
 {
     this.wrappedException = value;
     if (value is StackOverflowException)
     {
         this.errorNumber = JSError.OutOfStack;
     }
     else if (value is OutOfMemoryException)
     {
         this.errorNumber = JSError.OutOfMemory;
     }
     else
     {
         this.errorNumber = JSError.UncaughtException;
     }
     this.context = null;
     this.message = null;
 }
Esempio n. 18
0
    // Parse an invalid number.
    private void TestInvalidNum(String value, JSError expected)
    {
        JSScanner scanner;
        Context   token;

        scanner = JSScannerTest.TestCreateScanner(value);
        token   = JSScannerTest.TestGetTokenContext(scanner);
        try
        {
            scanner.GetNextToken();
            Fail("TestInvalidNum[" + value + "] (1)");
        }
        catch (Exception e)
        {
            AssertEquals("TestNum[" + value + "] (2)", expected,
                         JSScannerTest.TestExtractError(e));
        }
    }
	internal JScriptException(Object value)
			{
				this.wrappedException = value;
				if(value is StackOverflowException)
				{
					this.errorNumber = JSError.OutOfStack;
				}
				else if(value is OutOfMemoryException)
				{
					this.errorNumber = JSError.OutOfMemory;
				}
				else
				{
					this.errorNumber = JSError.UncaughtException;
				}
				this.context = null;
				this.message = null;
			}
Esempio n. 20
0
        internal void HandleError(JSError errorId, bool forceToError)
        {
            if ((errorId != JSError.UndeclaredVariable && errorId != JSError.UndeclaredFunction) || !Document.HasAlreadySeenErrorFor(Code))
            {
                var error = new JScriptException(errorId, this);

                if (forceToError)
                {
                    error.IsError = true;
                }
                else
                {
                    error.IsError = error.Severity < 2;
                }

                Document.HandleError(error);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Return the default severity for a given JSError value
        /// guide: 0 == there will be a run-time error if this code executes
        ///        1 == the programmer probably did not intend to do this
        ///        2 == this can lead to cross-browser of future problems.
        ///        3 == this can lead to performance problems
        ///        4 == this is just not right
        /// </summary>
        /// <param name="errorCode">error code</param>
        /// <returns>severity</returns>
        public static int GetSeverity(JSError errorCode)
        {
            switch (errorCode)
            {
                case JSError.AmbiguousCatchVar:
                case JSError.AmbiguousNamedFunctionExpression:
                case JSError.NumericOverflow:
                case JSError.StrictComparisonIsAlwaysTrueOrFalse:
                    return 1;

                case JSError.DuplicateCatch:
                case JSError.DuplicateConstantDeclaration:
                case JSError.DuplicateLexicalDeclaration:
                case JSError.KeywordUsedAsIdentifier:
                case JSError.MisplacedFunctionDeclaration:
                case JSError.ObjectLiteralKeyword:
                    return 2;

                case JSError.ArgumentNotReferenced:
                case JSError.DuplicateName:
                case JSError.FunctionNotReferenced:
                case JSError.UndeclaredFunction:
                case JSError.UndeclaredVariable:
                case JSError.VariableDefinedNotReferenced:
                    return 3;

                case JSError.StatementBlockExpected:
                case JSError.SuspectAssignment:
                case JSError.SuspectSemicolon:
                case JSError.SuspectEquality:
                case JSError.WithNotRecommended:
                case JSError.ObjectConstructorTakesNoArguments:
                case JSError.NumericMaximum:
                case JSError.NumericMinimum:
                case JSError.OctalLiteralsDeprecated:
                case JSError.FunctionNameMustBeIdentifier:
                case JSError.SemicolonInsertion:
                    return 4;

                default:
                    // all others
                    return 0;
            }
        }
Esempio n. 22
0
 internal void HandleError(JSError errorId, string message, bool treatAsError)
 {
     if ((errorId != JSError.UndeclaredVariable) || !this.document.HasAlreadySeenErrorFor(this.GetCode()))
     {
         JScriptException error = new JScriptException(errorId, this);
         if (message != null)
         {
             error.value = message;
         }
         if (treatAsError)
         {
             error.isError = treatAsError;
         }
         int severity = error.Severity;
         if (severity < this.errorReported)
         {
             this.document.HandleError(error);
             this.errorReported = severity;
         }
     }
 }
Esempio n. 23
0
        internal void HandleError(JSError errorId, String message, bool treatAsError)
        {
            if ((errorId == JSError.UndeclaredVariable || errorId == JSError.UndeclaredFunction) && Document.HasAlreadySeenErrorFor(Code))
            {
                return;
            }
            JScriptException error = new JScriptException(errorId, this);

            if (message != null)
            {
                error.Value = message;
            }
            if (treatAsError)
            {
                error.IsError = treatAsError;
            }
            int sev = error.Severity;

            if (sev < m_errorReported)
            {
                Document.HandleError(error);
                m_errorReported = sev;
            }
        }
Esempio n. 24
0
 private int code; // This is same as base.HResult. We have this so that the debuugger can get the
                   // error code without doing a func-eval ( to evaluate the HResult property )
   
 public JScriptException(JSError errorNumber)
   :this(errorNumber, null){
 }
        protected JScriptException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            if (info == null)
            {
                throw new ArgumentException(JScript.InternalCompilerError);
            }

            m_valueObject = info.GetString("Value");
            m_isError = info.GetBoolean("IsError");
            m_errorCode = (JSError)info.GetInt32("JSError");
            m_canRecover = info.GetBoolean("CanRecover");
            m_fileContext = info.GetString("FileContext");
        }
 public JScriptException(string message, Exception innerException)
     : base(message, innerException)
 {
     m_valueObject = message;
     m_context = null;
     m_fileContext = null;
     m_errorCode = JSError.UncaughtException;
     SetHResult();
 }
Esempio n. 27
0
 internal ScannerException(JSError errorId) : base ("Syntax Error"){
   m_errorId = errorId;
 }
Esempio n. 28
0
 public ScannerException()
 {
     m_errorId = JSError.SyntaxError;
 }
Esempio n. 29
0
		internal JScriptException (string user_err)
		{
			error_number = JSError.NoError;
			user_error = user_err;
		}
Esempio n. 30
0
		public JScriptException (JSError errorNumber)
		{
			error_number = errorNumber;
		}
Esempio n. 31
0
 //---------------------------------------------------------------------------------------
 // ForceReportInfo
 //
 //  Generate a parser error (info), does not change the error state in the parse
 //---------------------------------------------------------------------------------------
 private static void ForceReportInfo(Context context, JSError errorId)
 {
     Debug.Assert(context != null);
     context.HandleError(errorId);
 }
Esempio n. 32
0
 internal void HandleError(JSError errorId)
 {
     HandleError(errorId, null, false);
 }
Esempio n. 33
0
 public JScriptException(JSError errorNumber)
 {
 }
Esempio n. 34
0
 public JScriptException(JSError errorNumber) : this(errorNumber, null)
 {
 }
Esempio n. 35
0
 //---------------------------------------------------------------------------------------
 // EOFError
 //
 //  Create a context for EOF error. The created context points to the end of the source
 //  code. Assume the the scanner actually reached the end of file
 //---------------------------------------------------------------------------------------
 private void EOFError(JSError errorId)
 {
     Context eofCtx = m_sourceContext.Clone();
     eofCtx.StartLineNumber = m_scanner.CurrentLine;
     eofCtx.EndLineNumber = eofCtx.StartLineNumber;
     eofCtx.StartLinePosition = m_scanner.StartLinePosition;
     eofCtx.EndLinePosition = eofCtx.StartLinePosition;
     eofCtx.StartPosition = m_sourceContext.EndPosition;
     eofCtx.EndPosition++;
     eofCtx.HandleError(errorId);
 }
	public JScriptException(JSError errorNumber) {}
Esempio n. 37
0
 //---------------------------------------------------------------------------------------
 // ForceReportInfo
 //
 //  Generate a parser error (info), does not change the error state in the parse
 //---------------------------------------------------------------------------------------
 private void ForceReportInfo(JSError errorId)
 {
     ForceReportInfo(m_currentToken.Clone(), errorId);
 }
Esempio n. 38
0
 private void HandleError(JSError error){
   if (!this.IsAuthoring)
     this.currentToken.HandleError(error);
 }
Esempio n. 39
0
 public static string GetErrorString(JSError errorCode)
 {
     return(JScript.ResourceManager.GetString(errorCode.ToString(), JScript.Culture));
 }
Esempio n. 40
0
		internal JScriptException (JSError errorNumber, string extraData)
		{
			error_number = errorNumber;
			extra_data = extraData;
		}
Esempio n. 41
0
        //---------------------------------------------------------------------------------------
        // ReportError
        //
        //  Generate a parser error.
        //  The function is told whether or not next call to GetToken() should return the same
        //  token or not
        //---------------------------------------------------------------------------------------
        private void ReportError(JSError errorId, Context context, bool skipToken)
        {
            Debug.Assert(context != null);
            int previousSeverity = m_severity;
            m_severity = (new JScriptException(errorId)).Severity;
            // EOF error is special and it's the last error we can possibly get
            if (JSToken.EndOfFile == context.Token)
                EOFError(errorId); // EOF context is special
            else
            {
                // report the error if not in error condition and the
                // error for this token is not worse than the one for the
                // previous token
                if (m_goodTokensProcessed > 0 || m_severity < previousSeverity)
                    context.HandleError(errorId);

                // reset proper info
                if (skipToken)
                    m_goodTokensProcessed = -1;
                else
                {
                    m_errorToken = m_currentToken;
                    m_goodTokensProcessed = 0;
                }
            }
        }
Esempio n. 42
0
 internal ScannerException(JSError errorId)
     : base(s_syntaxErrorMsg)
 {
     m_errorId = errorId;
 }
Esempio n. 43
0
 //---------------------------------------------------------------------------------------
 // ReportError
 //
 //  Generate a parser error.
 //  When no context is provided the token is missing so the context is the current position
 //  The function is told whether or not next call to GetToken() should return the same
 //  token or not
 //---------------------------------------------------------------------------------------
 private void ReportError(JSError errorId, bool skipToken)
 {
     // get the current position token
     Context context = m_currentToken.Clone();
     context.EndPosition = context.StartPosition + 1;
     ReportError(errorId, context, skipToken);
 }
Esempio n. 44
0
 public ScannerException(string message, Exception innerException)
     : base(message, innerException)
 {
     m_errorId = JSError.SyntaxError;
 }
Esempio n. 45
0
 //---------------------------------------------------------------------------------------
 // ReportError
 //
 //  Generate a parser error.
 //  When no context is provided the token is missing so the context is the current position
 //---------------------------------------------------------------------------------------
 private void ReportError(JSError errorId)
 {
     ReportError(errorId, false);
 }
Esempio n. 46
0
 public ErrorResult(string message, SourceSpan span, JSError errorCode)
 {
     _message   = message;
     _span      = span;
     _errorCode = errorCode;
 }
Esempio n. 47
0
 internal JScriptException(string user_err)
 {
     error_number = JSError.NoError;
     user_error   = user_err;
 }
 internal JScriptException(JSError errorNumber, Context context)
 {
     m_valueObject = null;
     m_context = (context == null ? null : context.Clone());
     m_fileContext = (context == null ? null : context.Document.FileContext);
     m_errorCode = errorNumber;
     SetHResult();
 }
Esempio n. 49
0
 internal JScriptException(JSError errorNumber, string extraData)
 {
     error_number = errorNumber;
     extra_data   = extraData;
 }
        /// <summary>
        /// Return the default severity for a given JSError value
        /// guide: 0 == there will be a run-time error if this code executes
        ///        1 == the programmer probably did not intend to do this
        ///        2 == this can lead to cross-browser of future problems.
        ///        3 == this can lead to performance problems
        ///        4 == this is just not right
        /// </summary>
        /// <param name="errorCode">error code</param>
        /// <returns>severity</returns>
        public static int GetSeverity(JSError errorCode)
        {
            switch (errorCode)
            {
                case JSError.AmbiguousCatchVar:
                case JSError.AmbiguousNamedFunctionExpression:
                case JSError.NumericOverflow:
                case JSError.StrictComparisonIsAlwaysTrueOrFalse:
                    return 1;

                case JSError.DuplicateCatch:
                case JSError.DuplicateConstantDeclaration:
                case JSError.DuplicateLexicalDeclaration:
                case JSError.KeywordUsedAsIdentifier:
                case JSError.MisplacedFunctionDeclaration:
                case JSError.ObjectLiteralKeyword:
                    return 2;

                case JSError.ArgumentNotReferenced:
                case JSError.DuplicateName:
                case JSError.FunctionNotReferenced:
                case JSError.UndeclaredFunction:
                case JSError.UndeclaredVariable:
                case JSError.VariableDefinedNotReferenced:
                    return 3;

                case JSError.StatementBlockExpected:
                case JSError.SuspectAssignment:
                case JSError.SuspectSemicolon:
                case JSError.SuspectEquality:
                case JSError.WithNotRecommended:
                case JSError.ObjectConstructorTakesNoArguments:
                case JSError.NumericMaximum:
                case JSError.NumericMinimum:
                case JSError.OctalLiteralsDeprecated:
                case JSError.FunctionNameMustBeIdentifier:
                case JSError.SemicolonInsertion:
                    return 4;

                default:
                    // all others
                    return 0;
            }
        }
Esempio n. 51
0
 public JScriptException(JSError errorNumber)
 {
     error_number = errorNumber;
 }
Esempio n. 52
0
 internal JScriptException(JSError errorNumber, Context context){
   this.value = Missing.Value;
   this.context = context;
   this.code = this.HResult = unchecked((int)(0x800A0000 + (int)errorNumber));
 }
Esempio n. 53
0
	// Parse an invalid number.
	private void TestInvalidNum(String value, JSError expected)
			{
				JSScanner scanner;
				Context token;
				scanner = JSScannerTest.TestCreateScanner(value);
				token = JSScannerTest.TestGetTokenContext(scanner);
				try
				{
					scanner.GetNextToken();
					Fail("TestInvalidNum[" + value + "] (1)");
				}
				catch(Exception e)
				{
					AssertEquals("TestNum[" + value + "] (2)", expected,
								 JSScannerTest.TestExtractError(e));
				}
			}
Esempio n. 54
0
 private void HandleError(JSError error)
 {
     m_currentToken.EndPosition = m_currentPos;
     m_currentToken.EndLinePosition = StartLinePosition;
     m_currentToken.EndLineNumber = CurrentLine;
     m_currentToken.HandleError(error);
 }
 internal ScannerException(JSError errorId)
     : base(s_syntaxErrorMsg)
 {
     m_errorId = errorId;
 }
Esempio n. 56
0
 internal void HandleError(JSError errorId, bool treatAsError)
 {
     HandleError(errorId, null, treatAsError);
 }
 public ScannerException()
 {
     m_errorId = JSError.SyntaxError;
 }
Esempio n. 58
0
        public void RunErrorTest(params JSError[] expectedErrorArray)
        {
            // open the stack trace for this call
            StackTrace stackTrace = new StackTrace();
            string     testClass  = null;
            string     testName   = null;

            // save the name of the current method (RunTest)
            string currentMethodName = MethodInfo.GetCurrentMethod().Name;

            // loop from the previous frame up until we get a method name that is not the
            // same as the current method name
            for (int ndx = 1; ndx < stackTrace.FrameCount; ++ndx)
            {
                // get the frame
                StackFrame stackFrame = stackTrace.GetFrame(ndx);

                // we have different entry points with the same name -- we're interested
                // in the first one that ISN'T the same name as our method
                MethodBase methodBase = stackFrame.GetMethod();
                if (methodBase.Name != currentMethodName)
                {
                    // the calling method's name is the test name - we use this as-is for the output file name
                    // and we use any portion before an underscore as the input file
                    testName = methodBase.Name;
                    // get the method's class - we use this as the subfolder under input/output/expected
                    testClass = methodBase.DeclaringType.Name;
                    break;
                }
            }
            // we definitely should be able to find a function on the stack frame that
            // has a different name than this function, but just in case...
            Debug.Assert(testName != null && testClass != null, "Couldn't locate calling stack frame");

            // the input file is the portion of the test name before the underscore (if any)
            string inputFile = testName.Split('_')[0];

            // get the input path
            string inputPath = GetJsPath(
                m_inputFolder,
                testClass,
                inputFile,
                false
                );

            Assert.IsTrue(File.Exists(inputPath), "Input File does not exist: {0}", inputPath);

            // read the input JS
            string jsSource;

            using (StreamReader reader = new StreamReader(inputPath, true))
            {
                jsSource = reader.ReadToEnd();
            }
            Trace.Write("INPUT FILE: ");
            Trace.WriteLine(inputPath);
            Trace.WriteLine(jsSource);

            /*int expectedErrorCode = (int)(0x800A0000 + (int)expectedError);
             * Trace.WriteLine(string.Empty);
             * Trace.WriteLine(string.Format("Expecting error 0x{0:X}", expectedErrorCode));*/

            bool           testPassed        = true;
            List <JSError> expectedErrorList = new List <JSError>(expectedErrorArray);
            ErrorTrap      errorTrap         = new ErrorTrap();
            string         crunchedCode      = errorTrap.RunTest(jsSource);

            JScriptException[] errors = errorTrap.Errors;

            Trace.WriteLine(string.Empty);
            Trace.WriteLine("---ERRORS---");
            Trace.Indent();
            foreach (JScriptException ex in errors)
            {
                // log the error
                Trace.WriteLine(string.Empty);
                Trace.WriteLine(string.Format("Error 0x{0:X} at Line {1}, Column {2}: {3}", ex.Error, ex.Line, ex.Column, ex.ErrorSegment));
                Trace.Indent();
                Trace.WriteLine(ex.Message);

                JSError errorCode = (JSError)(ex.Error & 0xffff);
                int     index     = expectedErrorList.IndexOf(errorCode);
                if (index >= 0)
                {
                    // expected error -- remove it from the list so we can tell what we're missing later
                    expectedErrorList.RemoveAt(index);
                }
                else
                {
                    // unexpected error
                    testPassed = false;
                    Trace.WriteLine("UNEXPECTED");
                }
                Trace.Unindent();
            }
            Trace.Unindent();
            // the list should be empty now -- if it isn't, then there was an expected error that didn't happen
            if (expectedErrorList.Count > 0)
            {
                testPassed = false;
                Trace.WriteLine(string.Empty);
                Trace.WriteLine("---MISSING ERRORS---");
                Trace.Indent();
                foreach (JSError jsError in expectedErrorList)
                {
                    Trace.WriteLine(jsError.ToString());
                }
                Trace.Unindent();
            }

            if (!testPassed)
            {
                Trace.WriteLine("UNEXPECTED ERROR RESULTS");
            }

            Trace.WriteLine(string.Empty);
            Trace.WriteLine("---Resulting Code---");
            Trace.WriteLine(crunchedCode);

            // compute the path to the expected file
            string expectedPath = GetJsPath(
                m_expectedFolder,
                testClass,
                testName,
                false
                );

            if (File.Exists(expectedPath))
            {
                string expectedCode;
                using (StreamReader reader = new StreamReader(expectedPath, true))
                {
                    expectedCode = reader.ReadToEnd();
                }
                Trace.WriteLine(string.Empty);
                Trace.WriteLine("---Expected Code---");
                Trace.WriteLine(expectedCode);
                if (string.CompareOrdinal(expectedCode, crunchedCode) != 0)
                {
                    Trace.WriteLine("EXPECTED OUTPUT IS DIFFERENT");
                    testPassed = false;
                }
            }
            Assert.IsTrue(testPassed, "Test failed");
        }
 public ScannerException(string message, Exception innerException)
     : base(message, innerException)
 {
     m_errorId = JSError.SyntaxError;
 }