Пример #1
0
        public void FunctionDefTests()
        {
            mysharp.mysREPL REPL = new mysREPL();
            mysToken result;

            REPL.Evaluate( "(def 'f (=> [x :int] [+ 3 x]))" );
            result = REPL.Evaluate( "(f 2)" );

            Debug.Assert(
                result.Type == typeof(int),
                "f not returning :int."
            );

            Debug.Assert(
                (int)result.Value == 5,
                "f not returning correct value."
            );

            REPL.Evaluate( "(def 'g (=> [x :int] [+ 2 (f x)]))" );
            result = REPL.Evaluate( "(g 2)" );

            Debug.Assert(
                result.Type == typeof(int),
                "g not returning :int."
            );

            Debug.Assert(
                (int)result.Value == 7,
                "g not returning correct value."
            );
        }
Пример #2
0
        void Test(
			mysREPL REPL,
			string expression,
			int expected
		)
        {
            mysToken result = REPL.Evaluate( expression );

            Debug.Assert(
                result.Type == typeof(int) &&
                (int)result.Value == expected,
                $"Failing at {expression}."
            );
        }