예제 #1
0
        public void AddFunction_AlreadyDefinedSymbol_ThrowsException()
        {
            Environment environment = new Environment();

            DefinedSymbolException exception = Assert.Throws <DefinedSymbolException>(() => {
                environment.AddFunction("sin", null);
            });

            Assert.AreEqual("Symbol sin has already been defined", exception.Message);
        }
예제 #2
0
        public void AddValue_AlreadyDefinedSymbol_ThrowsException()
        {
            Environment environment = new Environment();

            environment.AddValue("x", 2);

            DefinedSymbolException exception = Assert.Throws <DefinedSymbolException>(() => {
                environment.AddSymbol("x");
            });

            Assert.AreEqual("Symbol x has already been defined", exception.Message);
        }