public void Optimize_DivisionInts() { var threeAddressCodeVisitor = new ThreeAddressCodeVisitor(); threeAddressCodeVisitor.TACodeContainer.PushNode( new TacAssignmentNode() { LeftPartIdentifier = "t1", FirstOperand = "4", Operation = "/", SecondOperand = "2" }); var isOptimized = new ConvConstOptimization().Optimize(threeAddressCodeVisitor.TACodeContainer); var optimizedTac = threeAddressCodeVisitor.TACodeContainer.TACodeLines.First.Value as TacAssignmentNode; var res = new TacAssignmentNode() { LeftPartIdentifier = "t1", FirstOperand = "2" }; Assert.IsTrue(isOptimized); Assert.AreEqual(optimizedTac.ToString(), res.ToString()); }
public void Optimize_IsNotOptimized() { var threeAddressCodeVisitor = new ThreeAddressCodeVisitor(); threeAddressCodeVisitor.TACodeContainer.PushNode( new TacAssignmentNode() { LeftPartIdentifier = "t1", FirstOperand = "4", Operation = "!=", SecondOperand = "a" }); var isOptimized = new ConvConstOptimization().Optimize(threeAddressCodeVisitor.TACodeContainer); Assert.IsFalse(isOptimized); }