public static int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();
            try
            {
                Console.WriteLine("In try1");
                throw new Exception();
            }
            catch (Exception)
            {
                Console.WriteLine("In catch1");
                try
                {
                    Console.WriteLine("In try2");
                    try
                    {
                        Console.WriteLine("In try3");
                        throw new Exception();
                    }
                    catch
                    {
                        Console.WriteLine("In catch3");
                        goto L;
                    }
                }
                finally
                {
                    Console.WriteLine("In finally2");
                }
            }
            finally
            {
                Console.WriteLine("In finally1");
            }

            Console.WriteLine("Never executed");
L:
            Console.WriteLine("Done");
            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #2
0
        static public int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                Console.WriteLine("try");
                try
                {
                    Console.WriteLine("\ttry - throwing outer exception");
                    throw new Exception("Outer Exception");
                }
                catch (System.Exception eo)
                {
                    Console.WriteLine("\tcatch - " + eo.Message);
                    try
                    {
                        Console.WriteLine("\t\ttry - throwing inner exception");
                        throw new Exception("Inner Exception");
                    }
                    catch (System.Exception ei)
                    {
                        Console.WriteLine("\t\tcatch - " + ei.Message);
                    }
                    finally
                    {
                        Console.WriteLine("\t\tfinally - Rethrowing Outer Exception");
                        // excplicitly added 'eo' so that the CS compiler wouldn't complain.
                        throw eo;
                    }
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine("catch - " + e.Message);
            }

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
        public static int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                MiddleMethod();
            }
            catch
            {
                Console.WriteLine("Pass");
            }

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
        static public int Main(string[] args)
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                inTry();
            }
            catch (Exception)
            {
                inCatch();
            }

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #5
0
        static public int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                inTry();
            }
            catch (Exception)
            {
                inCatch();
            }

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
        static public int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                f1();
            }
            catch (Exception e)
            {
                Console.WriteLine("In main's catch " + e.Message);
            }

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
        public static int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                Console.WriteLine("In main try...");
            }
            finally
            {
                Console.WriteLine("In main finally...");

                try
                {
                    Console.WriteLine("In inner try 1...");

                    try
                    {
                        Console.WriteLine("In inner try 2...");

                        goto LABEL;
                    }
                    catch
                    {
                        Console.WriteLine("Will never see this catch...");
                    }

                    Console.WriteLine("Will never see this code, jumping over it!");

LABEL:
                    Console.WriteLine("Back in inner try 1...");
                }
                finally
                {
                    Console.WriteLine("Now in inner finally...");
                }
            }
            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
        static public int Main()
        {
            //Start recording
            testLog.StartRecording();

            int i = 1234;

            Console.WriteLine(i);
            String s = "test";

            try
            {
                throw new Exception();
            }
            catch
            {
                try
                {
                    if (i != 0)
                    {
                        goto incatch;
                    }
                }
                catch
                {
                    if (i != 0)
                    {
                        goto incatch;
                    }
                    Console.WriteLine("end inner catch");
                }
                Console.WriteLine("unreached");

incatch:
                Console.WriteLine("end outer catch " + s);
            }
            Console.WriteLine(i);
            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #9
0
        static public int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();
            try
            {
                Console.WriteLine("In main's try");
                Middle(0);
            }
            catch
            {
                Console.WriteLine("caught in main");
            }
            Console.WriteLine("Passed");

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #10
0
        static public int Main()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                inTry();
            }
            catch (Exception e)
            {
                inCatch();
                Console.WriteLine(e);
            }

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
        static public int Main(string[] args)
        {
            //Start recording
            testLog.StartRecording();
            try
            {
                Console.WriteLine("In main's try");
                Middle(args.Length);
            }
            catch
            {
                Console.WriteLine("caught in main");
            }
            Console.WriteLine("Passed");

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #12
0
        static public int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                inTry();
            }
            finally
            {
                inFinally();
            }
            Console.WriteLine("done");

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #13
0
        public static int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                Console.WriteLine("Main: In Try");
                MiddleMethod();
            }
            catch
            {
                Console.WriteLine("Main: Caught the exception");
            }

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #14
0
        public static int TestEntryPoint()
        {
            int x = 7, y = 0, z;

            //Start recording
            testLog.StartRecording();

            try
            {
                Console.WriteLine(" try 1");
                try
                {
                    Console.WriteLine("\t try 1.1");
                }
                finally
                {
                    Console.WriteLine("\t finally 1.1");
                    try
                    {
                        Console.WriteLine("\t\t try 1.1.1");
                        Console.WriteLine("\t\t Throwing an exception here!");
                        z = x / y;
                    }
                    finally
                    {
                        Console.WriteLine("\t\t finally 1.1.1");
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine(" catch 1");
            }
            finally
            {
                Console.WriteLine(" finally 1");
            }
            // stop recoding
            testLog.StopRecording();
            return(testLog.VerifyOutput());
        }
Beispiel #15
0
        public static int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            int i = 3;

beginloop:
            try
            {
                try
                {
                    if (i == 3)
                    {
                        throw new IndexOutOfRangeException();
                    }
                    else if (i == 4)
                    {
                        Console.WriteLine("bye");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Caught an exception");
                    i++;
                    goto beginloop;
                }
            }
            finally
            {
                Console.WriteLine("In outer finally");
            }

continueloop:

finish:
            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        } //  main
Beispiel #16
0
        static public int Main(string[] args)
        {
            //Start recording
            testLog.StartRecording();
            int i = 0;

            try
            {
begintry1:
                Console.WriteLine("in try1");
                if (i > 0)
                {
                    goto done;
                }
                try
                {
                    if (args.Length == 0)
                    {
                        i++;
                        goto begintry1;
                    }
                }
                finally
                {
                    Console.WriteLine("in finally 2");
                }
            }
            finally
            {
                Console.WriteLine("in finally 1");
            }
            Console.WriteLine("after finally");
            Console.WriteLine("unreached");
done:
            Console.WriteLine("done");
            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #17
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static int Main()
        {
            int[] ar = new int[] { 1, 2, 3, 4, 5 };

            //Start recording
            testLog.StartRecording();

            try
            {
                Console.WriteLine("In try");
                GC.Collect();
                GC.WaitForPendingFinalizers();
                for (int i = 0; i < ar.Length; i++)
                {
                    Console.WriteLine("ar[" + i + "]=" + ar[i]);
                }
                throw new Exception();
            }
            catch
            {
                Console.WriteLine("In catch");
                int x = new int();

                Console.WriteLine("x = {0}", x);

                GC.Collect();
                GC.WaitForPendingFinalizers();
                for (int i = 0; i < ar.Length; i++)
                {
                    Console.WriteLine("ar[" + i + "]=" + ar[i]);
                }
                ar = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #18
0
        static int Main(string[] args)
        {
            int[] array = { 1, 2, 3, 4, 5, 6 };

            //Start recording
            testLog.StartRecording();
            try
            {
                Console.WriteLine("try 1");
                try
                {
                    Console.WriteLine("\ttry 1.1");
                }
                finally
                {
                    Console.WriteLine("\tfinally 1.1");
                    Console.WriteLine("\t\tThrowing an exception here");
                    Console.WriteLine(array[array.Length]);
                    try
                    {
                    }
                    finally
                    {
                    }
                }
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("catch 1");
            }
            finally
            {
                Console.WriteLine("finally 1");
            }
            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #19
0
        static public int TestEntryPoint()
        {
            // start recording
            testLog.StartRecording();

            int i = Environment.TickCount != 0 ? 0 : 1;

            try
            {
                Console.WriteLine("in main try");
                Middle1(i);
            }
            catch
            {
                Console.WriteLine("in main catch");
            }

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #20
0
        static public int TestEntryPoint()
        {
            int[] a;
            //Start recording
            testLog.StartRecording();
            a = new int[2];
            try
            {
            }
            finally
            {
                a[0] = 1234;
                Console.WriteLine("In finally");
            }
            Console.WriteLine("Done");
            Console.WriteLine(a[0]);

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #21
0
        public static int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                byte[] arr = new byte[] { 1, 2, 3, 4, 5 };
                WriteLocations(arr);
            }
            catch
            {
                Console.WriteLine("In catch, Unreached\n");
                goto done;
            }
            Console.WriteLine("After try");
done:
            Console.WriteLine("Done");
            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #22
0
        static public int Main(string[] args)
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                try
                {
                    Console.WriteLine("In try");
                    try
                    {
                        Console.WriteLine("In try 2, 1st throw");
                        throw new Exception();
                    }
                    catch
                    {
                        Console.WriteLine("In 1st catch, 2nd throw");
                        throw new Exception();
                    }
                }
                catch
                {
                    Console.WriteLine("In 2nd catch");
                }
            }
            catch
            {
                Console.WriteLine("Unreached");
            }
            Console.WriteLine("Done");

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #23
0
        static public int TestEntryPoint()
        {
            //Start recording
            testLog.StartRecording();

            try
            {
                goto done;
                Console.WriteLine("in try");
            }
            finally
            {
                Console.WriteLine("in finally");
            }
            Console.WriteLine("after finally");
            Console.WriteLine("unreached");
done:
            Console.WriteLine("done");

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        }
Beispiel #24
0
        static public int Main(string[] args)
        {
            //Start recording
            testLog.StartRecording();

            i = 0;
L1:
            if (i > 0)
            {
                goto L3;
            }
            try
            {
                inTry();
                try
                {
                    inTry();
L2:
                    try
                    { // catch Exception
                        inTry();
                        throw new Exception();
                    }
                    catch (Exception e)
                    {
L5:
                        Console.WriteLine("L5");
                        inCatch();
                        if (i == 5)
                        {
                            goto L1;
                        }
                        try
                        { // catch System
                            inTry();
                        }
                        catch (Exception e1)
                        {
                            inCatch();
                            if (i == 0)
                            {
                                goto L1;
                            }
                            if (i == 1)
                            {
                                goto L2;
                            }
L4:
                            Console.WriteLine("L4");
                            if (i == 5)
                            {
                                goto L5;
                            }
                            try
                            {
                                inTry();
                            }
                            catch (Exception e2)
                            {
                                inCatch();
                                if (i == 0)
                                {
                                    goto L3;
                                }
                                if (i == 1)
                                {
                                    goto L2;
                                }
                                if (i > 1)
                                {
                                    goto L4;
                                }
                                Console.WriteLine("Unreached\n");
                                try
                                {
                                    for (int ii = 0; ii < 10; ii++)
                                    {
                                        try
                                        {
                                            Console.WriteLine(args[ii]);
                                        }
                                        finally
                                        {
                                            Console.WriteLine("Unreached finally\n");
                                        }
                                    }
                                }
                                catch
                                {
                                    Console.WriteLine("Unreached catch\n");
                                    switch (i)
                                    {
                                    case 0: goto L1;

                                    case 3: goto L2;

                                    case 4: goto L4;

                                    default: break;
                                    }
                                    goto L5;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    inFinally();
                }
            }
            finally
            {
                inFinally();
            }
L3:

            // stop recoding
            testLog.StopRecording();

            return(testLog.VerifyOutput());
        } // Main
Beispiel #25
0
        private static int Main(string[] args)
        {
            string[] s = { "one", "two", "three", "four", "five", "six" };
            s_testLog.StartRecording();
            for (int i = 0; i < s.Length; i++)
            {
beginloop:
                try
                {
                    try
                    {
                        try
                        {
                            switch (s[i])
                            {
                            case "one":
                                try
                                {
                                    Console.WriteLine("s == one");
                                }
                                catch
                                {
                                    Console.WriteLine("Exception at one");
                                }
                                break;

                            case "two":
                                try
                                {
                                    Console.WriteLine("s == two");
                                }
                                finally
                                {
                                    Console.WriteLine("After two");
                                }
                                break;

                            case "three":
                                try
                                {
                                    try
                                    {
                                        Console.WriteLine("s == three");
                                    }
                                    catch (System.Exception e)
                                    {
                                        Console.WriteLine(e);
                                        goto continueloop;
                                    }
                                }
                                finally
                                {
                                    Console.WriteLine("After three");
                                    try
                                    {
                                        switch (s[s.Length - 1])
                                        {
                                        case "six":
                                            Console.WriteLine("Ok");
                                            Console.WriteLine(s[s.Length]);
                                            goto label2;

                                        default:
                                            try
                                            {
                                                Console.WriteLine("Ack");
                                                goto label;
                                            }
                                            catch
                                            {
                                                Console.WriteLine("I don't think so ...");
                                            }
                                            break;
                                        }
label:
                                        Console.WriteLine("Unreached");
                                        throw new Exception();
                                    }
                                    finally
                                    {
                                        Console.WriteLine("After after three");
                                    }
label2:
                                    Console.WriteLine("Unreached");
                                }
                                goto continueloop;

                            case "four":
                                try
                                {
                                    try
                                    {
                                        Console.WriteLine("s == " + s[s.Length]);
                                        try
                                        {
                                        }
                                        finally
                                        {
                                            Console.WriteLine("Unreached");
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        goto test;
rethrowex:
                                        throw;
test:
                                        if (e is System.ArithmeticException)
                                        {
                                            try
                                            {
                                                Console.WriteLine("unreached ");
                                                goto finishfour;
                                            }
                                            finally
                                            {
                                                Console.WriteLine("also unreached");
                                            }
                                        }
                                        else
                                        {
                                            goto rethrowex;
                                        }
                                    }
                                }
                                finally
                                {
                                    Console.WriteLine("In four's finally");
                                }
finishfour:
                                break;

                            case "five":
                                try
                                {
                                    try
                                    {
                                        try
                                        {
                                            Console.WriteLine("s == five");
                                        }
                                        finally
                                        {
                                            Console.WriteLine("Five's finally 0");
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        Console.WriteLine("Unreached");
                                    }
                                    finally
                                    {
                                        Console.WriteLine("Five's finally 1");
                                    }
                                    break;
                                }
                                finally
                                {
                                    Console.WriteLine("Five's finally 2");
                                }

                            default:
                                try
                                {
                                    Console.WriteLine("Greater than five");
                                    goto finish;
                                }
                                finally
                                {
                                    Console.WriteLine("in six's finally");
                                }
                            }
                            ;
                            continue;
                        }
                        finally
                        {
                            Console.WriteLine("In inner finally");
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Caught an exception\n");

                        switch (s[i])
                        {
                        case "three":
                            if (e is System.IndexOutOfRangeException)
                            {
                                Console.WriteLine("Ok\n");
                                i++;
                                goto beginloop;
                            }
                            Console.WriteLine("Unreached\n");
                            break;

                        case "four":
                            if (e is System.IndexOutOfRangeException)
                            {
                                Console.WriteLine("Ok\n");
                                i++;
                                goto beginloop;
                            }
                            Console.WriteLine("Unreached\n");
                            break;

                        default:
                            Console.WriteLine("****** Unreached");
                            goto continueloop;
                        }
                    }

                    Console.WriteLine("Unreached");
                }
                finally
                {
                    Console.WriteLine("In outer finally\n");
                }

continueloop:
                Console.WriteLine("Continuing");
            }
finish:
            s_testLog.StopRecording();

            return(s_testLog.VerifyOutput());
        }