Пример #1
0
 public void Cons()
 {
     LispAssert.EvaluatesTo(Lisp.List(Lisp.Constant(1)),
                            Lisp.List(Lisp.Symbol("cons"), Lisp.Constant(1), Lisp.Nil));
     LispAssert.EvaluatesTo(Lisp.List(Lisp.Constant(1), Lisp.Constant(2)),
                            Lisp.List(Lisp.Symbol("cons"), Lisp.Constant(1), Lisp.Quote(Lisp.List(Lisp.Constant(2)))));
     LispAssert.EvaluatesTo(Lisp.Cons(Lisp.Constant(1), Lisp.Constant(2)),
                            Lisp.List(Lisp.Symbol("cons"), Lisp.Constant(1), Lisp.Constant(2)));
 }
Пример #2
0
        public void Cdr()
        {
            LispAssert.EvaluatesTo(Lisp.List(Lisp.Constant(2), Lisp.Constant(3)),
                                   Lisp.List(Lisp.Symbol("cdr"), Lisp.Quote(Lisp.List(Lisp.Constant(1), Lisp.Constant(2), Lisp.Constant(3)))));
            LispAssert.EvaluatesTo(Lisp.Nil,
                                   Lisp.List(Lisp.Symbol("cdr"), Lisp.Quote(Lisp.List(Lisp.Constant(1)))));
            LispAssert.EvaluatesTo(Lisp.Constant(2),
                                   Lisp.List(Lisp.Symbol("cdr"), Lisp.Quote(Lisp.Cons(Lisp.Constant(1), Lisp.Constant(2)))));

            LispAssert.ThrowsWhenEvaluated(Lisp.List(Lisp.Symbol("cdr"), Lisp.Nil));
            LispAssert.ThrowsWhenEvaluated <TypeMismatchException>(Lisp.List(Lisp.Symbol("cdr"), Lisp.Constant(3)));
            LispAssert.ThrowsWhenEvaluated <SignatureMismatchException>(Lisp.List(Lisp.Symbol("cdr")));
        }