Beispiel #1
0
        public void Execute_OfDim_SetsHeight()
        {
            var indexes = new[] { new Constant(100), new Constant(200) };
            var array   = new ArrayVariable("A", indexes);
            var dim     = new Dim(array);
            var rte     = MakeRunTimeEnvironment();

            dim.Execute(rte);

            var actual = (object[, ])rte.Variables["A"];

            Assert.AreEqual(199, actual.GetUpperBound(1));
        }
Beispiel #2
0
        public void Execute_OfDim_CreatesArray()
        {
            var indexes = new[] { new Constant(100), new Constant(200) };
            var array   = new ArrayVariable("A", indexes);
            var dim     = new Dim(array);
            var rte     = MakeRunTimeEnvironment();

            dim.Execute(rte);

            var actual = rte.Variables["A"];

            Assert.IsInstanceOfType(actual, typeof(object[, ]));
        }
Beispiel #3
0
 public void TestDimWithEmptyIndexesSkipsCreate()
 {
     _runEnvironment = new RunEnvironment
     {
         CurrentLine = new ProgramLine(0, new List <IToken> {
         })
     };
     _mockExpressionEvaluator = new Mock <IExpressionEvaluator>();
     _mockVariableRepository  = new Mock <IVariableRepository>();
     _mockExpressionEvaluator.Setup(mee => mee.GetIndexes()).Returns(new short[] { });
     _mockExpressionEvaluator.Setup(mee => mee.GetVariableName()).Returns("A");
     _sut = new Dim(_runEnvironment, _mockExpressionEvaluator.Object, _mockVariableRepository.Object);
     _sut.Execute();
     _mockVariableRepository.Verify(mvr => mvr.DimensionArray(It.IsAny <string>(), It.IsAny <short[]>()), Times.Never);
 }
Beispiel #4
0
 public void TestDim()
 {
     _runEnvironment = new RunEnvironment
     {
         CurrentLine = new ProgramLine(0, new List <IToken> {
         })
     };
     _mockExpressionEvaluator = new Mock <IExpressionEvaluator>();
     _mockVariableRepository  = new Mock <IVariableRepository>();
     _mockExpressionEvaluator.Setup(mee => mee.GetIndexes()).Returns(new short[] { 3, 2 });
     _mockExpressionEvaluator.Setup(mee => mee.GetVariableName()).Returns("A");
     _sut = new Dim(_runEnvironment, _mockExpressionEvaluator.Object, _mockVariableRepository.Object);
     _sut.Execute();
     _mockVariableRepository.Verify(mvr => mvr.DimensionArray("A", new short[] { 3, 2 }), Times.Once);
 }
Beispiel #5
0
 public void TestDimMultipleArrays()
 {
     _runEnvironment = new RunEnvironment
     {
         CurrentLine = new ProgramLine(0, new List <IToken> {
             new Token(",", TokenClass.Seperator, TokenType.Comma)
         })
     };
     _mockExpressionEvaluator = new Mock <IExpressionEvaluator>();
     _mockVariableRepository  = new Mock <IVariableRepository>();
     _mockExpressionEvaluator.SetupSequence(mee => mee.GetIndexes())
     .Returns(new short[] { 3, 2 })
     .Returns(new short[] { 11, 12 });
     _mockExpressionEvaluator.SetupSequence(mee => mee.GetVariableName())
     .Returns("A")
     .Returns("B$");
     _sut = new Dim(_runEnvironment, _mockExpressionEvaluator.Object, _mockVariableRepository.Object);
     _sut.Execute();
     _mockVariableRepository.Verify(mvr => mvr.DimensionArray("A", new short[] { 3, 2 }), Times.Once);
     _mockVariableRepository.Verify(mvr => mvr.DimensionArray("B$", new short[] { 11, 12 }), Times.Once);
 }