예제 #1
0
        public void ParseTest2()
        {
            var target = new TryComponent(SobaAcs.MakeWithTryComponent());

            Assert.Equal(Value.Empty, target.Eval("[try\n{}\ncatch\n{ if error }]"));
            Assert.Equal(Value.Empty, target.Eval("[try\n{}\n catch\n { \n} ]"));
        }
예제 #2
0
        public void CatchTest5()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithTryComponent(uvar);

            Assert.Empty(uvar.Variables);
            target.Eval(@"
                            #[try
                            { 
                                #[notrealcomponentToError]
     
                                #[( true ){
                                    $(test1 = '123')
                                }]
                            }
                            catch
                            {
                                #[( true ){
                                    $(test2 = '456')
                                }]
                            }] 
                        ");

            Assert.Single(uvar.Variables);
            Assert.Null(uvar.GetValue("test1", null));
            Assert.Equal("456", uvar.GetValue("test2", null));
        }
예제 #3
0
        public void ParseTest4()
        {
            var target = new TryComponent(SobaAcs.MakeWithTryComponent());

            Assert.Throws <NotSupportedOperationException>(() =>
                                                           target.Eval("[try{ #[notrealcomponentToError] }catch('err', 'msg'){ }]")
                                                           );
        }
예제 #4
0
        public void ParseTest3()
        {
            var target = new TryComponent(SobaAcs.MakeWithTryComponent());

            Assert.Throws <IncorrectSyntaxException>(() =>
                                                     target.Eval("[try{ }]")
                                                     );
        }
예제 #5
0
        public void CatchTest1()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithTryComponent(uvar);

            target.Eval("#[try{ $(test = '123') }catch{ $(test2 = '456') }]");

            Assert.Single(uvar.Variables);
            Assert.Equal("123", uvar.GetValue("test", null));
        }
예제 #6
0
        public void ParseTest1()
        {
            var uvar   = new UVars();
            var target = new TryComponent(SobaAcs.MakeWithTryComponent(uvar));

            Assert.Equal(Value.Empty, target.Eval("[try{}catch{ if error }]"));
            Assert.Equal(Value.Empty, target.Eval("[try{}catch(err, msg){ if error }]"));
            Assert.Equal(Value.Empty, target.Eval("[try{}catch(){ }]"));
            Assert.Empty(uvar.Variables);
        }
예제 #7
0
        public void CatchTest3()
        {
            var uvar   = new UVars();
            var target = SobaAcs.MakeWithTryComponent(uvar);

            Assert.Empty(uvar.Variables);
            target.Eval(@"
                            #[( false ){

                                #[try
                                { 
                                     #[notrealcomponentToError]
                                }
                                catch(err, msg)
                                {
                                    $(test1 = '123')
                                }]

                            }
                            else{

                                #[try
                                { 
                                     #[notrealcomponentToError]
                                }
                                catch(err, msg)
                                {
                                    $(test2 = '456')
                                    $(exErr = $(err))
                                    $(exMsg = $(msg))
                                }]

                            }] ");

            Assert.Equal(3, uvar.Variables.Count());
            Assert.Null(uvar.GetValue("test1", null));
            Assert.Equal("456", uvar.GetValue("test2", null));
            Assert.True(!string.IsNullOrWhiteSpace(uvar.GetValue("exErr", null)));
            Assert.True(!string.IsNullOrWhiteSpace(uvar.GetValue("exMsg", null)));
            Assert.Null(uvar.GetValue("err", null));
            Assert.Null(uvar.GetValue("msg", null));
        }