Ejemplo n.º 1
0
        public void DefineASimpleSymbol()
        {
            DefPrimitive defprim = new DefPrimitive();
            Machine machine = new Machine();

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

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(int));
            Assert.AreEqual(1, result);

            object value = machine.GetVariableValue((string)machine.Environment.GetValue(Machine.CurrentNamespaceKey), "x");

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(int));
            Assert.AreEqual(1, value);
        }
Ejemplo n.º 2
0
        public void RaiseIfQualifiedSymbol()
        {
            DefPrimitive defprim = new DefPrimitive();
            Machine machine = new Machine();

            defprim.Apply(machine, machine.Environment, new object[] { Symbol.Create("foo/x"), 1 });
        }
Ejemplo n.º 3
0
        public void DefineAnSpecialForm()
        {
            DefPrimitive defprim = new DefPrimitive();
            Machine machine = new Machine();
            DefinedSpecialForm sf = new DefinedSpecialForm("x", null, null);

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

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DefinedSpecialForm));
            Assert.IsTrue(sf == result);

            object value = machine.GetVariableValue((string)machine.Environment.GetValue(Machine.CurrentNamespaceKey), "x");

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(DefinedSpecialForm));
            Assert.IsTrue(sf == value);

            object defsf = machine.Environment.GetValue("x");

            Assert.IsNotNull(defsf);
            Assert.IsInstanceOfType(defsf, typeof(DefinedSpecialForm));
            Assert.IsTrue(defsf == value);
        }