Beispiel #1
0
        public void Option_ProcessEnvironment_IgnoresEmptyValues()
        {
            OptFunctScopes.Clear();

            MockScope mockScope = new MockScope();

            mockScope.LookupResult            = new ExprOp(OpKindEnum.FUNCTION);
            mockScope.LookupResult.AsFunction = OptFunct;

            IDictionary <string, string> envp = new Dictionary <string, string>();

            envp.Add("opt-1-1", "val1");
            envp.Add("opt-1-2", "val2");
            envp.Add("opt-2-1", "");
            envp.Add("opt-2-2", "val4");
            envp.Add("opt-3-1", "val5");
            envp.Add("opt-3-2", "val6");

            Option.ProcessEnvironment(envp, "opt-2", mockScope);

            Assert.AreEqual(1, OptFunctScopes.Count);
            CallScope callScope = OptFunctScopes.First() as CallScope;

            Assert.AreEqual(2, callScope.Size);
            Assert.AreEqual("$-2", callScope[0].ToString());
            Assert.AreEqual("val4", callScope[1].ToString());
        }
Beispiel #2
0
        public void Option_ProcessOption_PopulatesArgsAndCallsFunc()
        {
            OptFunctScopes.Clear();

            MockScope mockScope = new MockScope();
            string    whence    = "whence";
            ExprFunc  opt       = OptFunct;
            string    arg       = "arg";
            string    name      = "name";

            Option.ProcessOption(whence, opt, mockScope, arg, name);

            Assert.AreEqual(1, OptFunctScopes.Count);
            CallScope callScope = OptFunctScopes.First() as CallScope;

            Assert.IsNotNull(callScope);
            Assert.IsNotNull(callScope.Args);
            Assert.AreEqual(2, callScope.Size);
            Assert.AreEqual(whence, callScope[0].ToString());
            Assert.AreEqual(arg, callScope[1].ToString());
        }
Beispiel #3
0
        public void Option_ProcessEnvironment_ReplacesUndescoreToMinus()
        {
            OptFunctScopes.Clear();

            MockScope mockScope = new MockScope();

            mockScope.LookupResult            = new ExprOp(OpKindEnum.FUNCTION);
            mockScope.LookupResult.AsFunction = OptFunct;

            IDictionary <string, string> envp = new Dictionary <string, string>();

            envp.Add("opt-1_1", "val1");

            Option.ProcessEnvironment(envp, "opt-1", mockScope);

            Assert.AreEqual(1, OptFunctScopes.Count);
            CallScope callScope = OptFunctScopes.First() as CallScope;

            Assert.AreEqual(2, callScope.Size);
            Assert.AreEqual("$-1", callScope[0].ToString());
        }
Beispiel #4
0
        public void Option_ProcessOption_LooksForOpByName()
        {
            OptFunctScopes.Clear();

            MockScope mockScope = new MockScope();

            mockScope.LookupResult            = new ExprOp(OpKindEnum.FUNCTION);
            mockScope.LookupResult.AsFunction = OptFunct;

            string whence = "whence";
            string arg    = "arg";
            string name   = "name";

            Option.ProcessOption(whence, "dummy-name", mockScope, arg, name);

            Assert.AreEqual(1, OptFunctScopes.Count);
            CallScope callScope = OptFunctScopes.First() as CallScope;

            Assert.IsNotNull(callScope);
            Assert.IsNotNull(callScope.Args);
            Assert.AreEqual(2, callScope.Size);
            Assert.AreEqual(whence, callScope[0].ToString());
            Assert.AreEqual(arg, callScope[1].ToString());
        }
Beispiel #5
0
 private Value OptFunct(Scope scope)
 {
     OptFunctScopes.Add(scope);
     return(null);
 }