Example #1
0
        public void GetGlobalContext()
        {
            BindingEnvironment global   = new BindingEnvironment();
            BindingEnvironment local    = new BindingEnvironment(global);
            ContextFunction    function = new ContextFunction("globals", true);

            var result = function.Apply(local, null, null);

            Assert.IsNotNull(result);
            Assert.AreEqual(global, result);
            Assert.IsTrue(function.IsGlobal);
            Assert.AreEqual("globals", function.Name);
        }
Example #2
0
        public void RaiseWhenTwoParameters()
        {
            ContextFunction function = new ContextFunction("locals", false);

            try
            {
                function.Apply(null, new object[] { 1, 2 }, null);
                Assert.Fail("Exception expected");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(TypeError));
                Assert.AreEqual("locals() takes no arguments (2 given)", ex.Message);
            }
        }