Example #1
0
        public void Sub_Basic_Works()
        {
            var board = new Board();
            var chip = new AssemblyChip();
            var input = new InputRW(new List<int>() { 1, 2, 4, 3 });
            var output = new OutputRW();

            chip.Operations = new List<IOperation>() {
                new Mov(new ConnectionRef("UP"), new ConnectionRef("ACC")),
                new Sub(new ConnectionRef("UP")),
                new Mov(new ConnectionRef("ACC"), new ConnectionRef("DOWN")),
            };

            board.Install(chip, new Point(0, 0));
            chip.Connections["UP"] = input;
            chip.Connections["DOWN"] = output;

            board.ExecuteUntilBlocked();

            Assert.AreEqual("-1, 1", output.ToString());
        }
Example #2
0
        private void AssertAddOutputMatches(List<int> inQueue, List<int> expectedOutQueue)
        {
            var board = new Board();
            var chip = new AssemblyChip();
            var input = new InputRW(inQueue);
            var output = new OutputRW();

            chip.Operations = new List<IOperation>
            {
                new Mov(UP, ACC),
                new Add(UP),
                new Mov(ACC, DOWN)
            };

            board.Install(chip, new Point(0, 0));
            chip.Connections[UP.RefName] = input;
            chip.Connections[DOWN.RefName] = output;

            board.ExecuteUntilBlocked();
            var expectedOutput = expectedOutQueue
                .Select(a => a.ToString())
                .Aggregate((a, b) => a + ", " + b);
            Assert.AreEqual(expectedOutput, output.ToString());
        }