public void ExceptionHandlingStatementRequiresCatchVariable()
        {
            var e = new ExceptionHandlingStatement
            {
                TryBlock = new CompoundStatement(),
                CatchBlock = new CompoundStatement()
            };

            Expect.Throw<InvalidOperationException>(() => e.ToString());
        }
Example #2
0
        public void ExceptionHandlingStatementRequiresCatchVariable()
        {
            var e = new ExceptionHandlingStatement
            {
                TryBlock   = new CompoundStatement(),
                CatchBlock = new CompoundStatement()
            };

            Expect.Throw <InvalidOperationException>(() => e.ToString());
        }
Example #3
0
        public void ExceptionHandlingStatementHelpersRequireStatement()
        {
            ExceptionHandlingStatement e = null;

            Expect.Throw <ArgumentNullException>(() => e.Catch(E));
            Expect.Throw <ArgumentNullException>(() => e.Catch(E, new List <Statement>()));
            Expect.Throw <ArgumentNullException>(() => e.Catch(E, new CompoundStatement()));
            Expect.Throw <ArgumentNullException>(() => e.Finally());
            Expect.Throw <ArgumentNullException>(() => e.Finally(new List <Statement>()));
            Expect.Throw <ArgumentNullException>(() => e.Finally(new CompoundStatement()));
        }
        public void ExceptionHandlingStatementProducesTryCatchFinally()
        {
            var t1 = JS
                .Try(JS.Return())
                .Catch(E, new List<Statement> { Alert.Call(E) })
                .Finally(new List<Statement> { JS.Null() });

            var t2 = new ExceptionHandlingStatement
            {
                TryBlock = new CompoundStatement(JS.Return()),
                CatchVariable = E,
                CatchBlock = new CompoundStatement(Alert.Call(E)),
                FinallyBlock = new CompoundStatement(JS.Null())
            };

            Assert.AreEqual("try{return;}catch(e){alert(e);}finally{null;}", t1.ToString());
            Assert.AreEqual("try{return;}catch(e){alert(e);}finally{null;}", t2.ToString());
        }
Example #5
0
        public void ExceptionHandlingStatementProducesTryCatchFinally()
        {
            var t1 = JS
                     .Try(JS.Return())
                     .Catch(E, new List <Statement> {
                Alert.Call(E)
            })
                     .Finally(new List <Statement> {
                JS.Null()
            });

            var t2 = new ExceptionHandlingStatement
            {
                TryBlock      = new CompoundStatement(JS.Return()),
                CatchVariable = E,
                CatchBlock    = new CompoundStatement(Alert.Call(E)),
                FinallyBlock  = new CompoundStatement(JS.Null())
            };

            Assert.AreEqual("try{return;}catch(e){alert(e);}finally{null;}", t1.ToString());
            Assert.AreEqual("try{return;}catch(e){alert(e);}finally{null;}", t2.ToString());
        }
        public void ExceptionHandlingStatementRequiresTryBlock()
        {
            var e = new ExceptionHandlingStatement();

            Expect.Throw<InvalidOperationException>(() => e.ToString());
        }
Example #7
0
        public void ExceptionHandlingStatementRequiresTryBlock()
        {
            var e = new ExceptionHandlingStatement();

            Expect.Throw <InvalidOperationException>(() => e.ToString());
        }