コード例 #1
0
        public void AddSymbol_ShouldAddSymbolIfCorrectDataIsGiven()
        {
            var typeEnv = new TypeEnvironment();

            var symbolToAdd = (Name : "HelloWorld", Type : new BooleanValueType());

            typeEnv.AddSymbol(symbolToAdd.Name, symbolToAdd.Type);

            Assert.Equal(symbolToAdd.Type, typeEnv.GetTypeOf(symbolToAdd.Name));
        }
コード例 #2
0
        public void AddSymbol_ShouldThrowExceptionIfNullSymbolTypeIsGiven()
        {
            var typeEnv = new TypeEnvironment();

            Assert.Throws <ArgumentNullException>(() => typeEnv.AddSymbol("HelloWorld", null));
        }
コード例 #3
0
        public void AddSymbol_ShouldThrowExceptionIfInvalidNameIsGiven(string symbolName)
        {
            var typeEnv = new TypeEnvironment();

            Assert.Throws <ArgumentNullException>(() => typeEnv.AddSymbol(symbolName, new BooleanValueType()));
        }