Exemplo n.º 1
0
        public void RaiseIfVarPrimitiveReceivesUndefinedSymbol()
        {
            VarPrimitive varprim = new VarPrimitive();
            Machine machine = new Machine();

            varprim.Apply(machine, machine.Environment, new object[] { Symbol.Create("x") });
        }
Exemplo n.º 2
0
        public void GetVariableWithCurrentNamespace()
        {
            VarPrimitive varprim = new VarPrimitive();
            Machine machine = new Machine();
            machine.SetVariableValue(Variable.Intern(machine, (string)machine.Environment.GetValue(Machine.CurrentNamespaceKey), "x"), "bar");

            object result = varprim.Apply(machine, machine.Environment, new object[] { Symbol.Create("x") });

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Variable));

            Variable variable = (Variable)result;

            Assert.AreEqual(machine.Environment.GetValue(Machine.CurrentNamespaceKey), variable.Namespace);
            Assert.AreEqual("x", variable.Name);
        }
Exemplo n.º 3
0
        public void RaiseIfVarPrimitiveDoesNotReceiveASymbol()
        {
            VarPrimitive varprim = new VarPrimitive();
            Machine machine = new Machine();

            varprim.Apply(machine, machine.Environment, new object[] { "foo" });
        }
Exemplo n.º 4
0
        public void GetVariableFromQualifiedSymbol()
        {
            VarPrimitive varprim = new VarPrimitive();
            Machine machine = new Machine();
            machine.CreateNamespace("foo");

            machine.SetVariableValue(Variable.Intern(machine, "foo", "x"), "bar");

            object result = varprim.Apply(machine, machine.Environment, new object[] { Symbol.Create("foo/x") });

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Variable));

            Variable variable = (Variable)result;

            Assert.AreEqual("foo", variable.Namespace);
            Assert.AreEqual("x", variable.Name);
        }