Changeset 14908 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExecExpressionTests.cs
- Timestamp:
- 05/02/17 22:03:01 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExecExpressionTests.cs
r14875 r14908 20 20 get 21 21 { 22 return this.interpreter.ExecStack;22 return interpreter.ExecStack; 23 23 } 24 24 } 25 25 26 26 protected override void Test(Expression expression) { 27 this.interpreter.Run(expression, true);28 this.interpreter.Step();27 interpreter.Run(expression, true); 28 interpreter.Step(); 29 29 } 30 30 … … 34 34 [TestCategory("ExecExpressionTest")] 35 35 public void TestIfTrue() { 36 this.interpreter.BooleanStack.Push(true);37 this.interpreter.Run("( EXEC.IF WAHR FALSCH )");36 interpreter.BooleanStack.Push(true); 37 interpreter.Run("( EXEC.IF WAHR FALSCH )"); 38 38 39 Assert.AreEqual("WAHR", this.interpreter.NameStack.Top);40 this.TestStackCounts(nameStack: 1);39 Assert.AreEqual("WAHR", interpreter.NameStack.Top); 40 TestStackCounts(nameStack: 1); 41 41 } 42 42 … … 46 46 [TestCategory("ExecExpressionTest")] 47 47 public void TestIfFalse() { 48 this.interpreter.BooleanStack.Push(false);49 this.interpreter.Run("( EXEC.IF WAHR FALSCH )");48 interpreter.BooleanStack.Push(false); 49 interpreter.Run("( EXEC.IF WAHR FALSCH )"); 50 50 51 Assert.AreEqual("FALSCH", this.interpreter.NameStack.Top);52 this.TestStackCounts(nameStack: 1);51 Assert.AreEqual("FALSCH", interpreter.NameStack.Top); 52 TestStackCounts(nameStack: 1); 53 53 } 54 54 … … 80 80 var result = PushParser.Parse("( B C )"); 81 81 82 this.interpreter.ExecStack.Push(third, second, first);83 this.Test(new ExecSExpression());82 interpreter.ExecStack.Push(third, second, first); 83 Test(new ExecSExpression()); 84 84 85 Assert.AreEqual(result, this.interpreter.ExecStack[2]);86 Assert.AreEqual(third, this.interpreter.ExecStack[1]);87 Assert.AreEqual(first, this.interpreter.ExecStack.Top);88 this.TestStackCounts(3);85 Assert.AreEqual(result, interpreter.ExecStack[2]); 86 Assert.AreEqual(third, interpreter.ExecStack[1]); 87 Assert.AreEqual(first, interpreter.ExecStack.Top); 88 TestStackCounts(3); 89 89 } 90 90 … … 97 97 var result = PushParser.Parse("( EXEC.Y A )"); 98 98 99 this.interpreter.ExecStack.Push(first);100 this.Test(new ExecYExpression());99 interpreter.ExecStack.Push(first); 100 Test(new ExecYExpression()); 101 101 102 Assert.AreEqual(first, this.interpreter.ExecStack.Top);103 Assert.AreEqual(result, this.interpreter.ExecStack[1]);104 this.TestStackCounts(2);102 Assert.AreEqual(first, interpreter.ExecStack.Top); 103 Assert.AreEqual(result, interpreter.ExecStack[1]); 104 TestStackCounts(2); 105 105 } 106 106 … … 110 110 [TestCategory("ExecExpressionTest")] 111 111 public void TestNestedDoRange() { 112 this.interpreter.Run(112 interpreter.Run( 113 113 "( 0 2 EXEC.DO*RANGE ( 1 INTEGER.+ 0 3 EXEC.DO*RANGE ( 1 INTEGER.+ INTEGER.* ) INTEGER.+ )"); 114 114 115 Assert.AreEqual(144, this.interpreter.IntegerStack.Top);116 this.TestStackCounts(integerStack: 1);115 Assert.AreEqual(144, interpreter.IntegerStack.Top); 116 TestStackCounts(integerStack: 1); 117 117 } 118 118 … … 122 122 [TestCategory("ExecExpressionTest")] 123 123 public void TestNestedDoCount() { 124 this.interpreter.Run(124 interpreter.Run( 125 125 "( 2 EXEC.DO*COUNT ( 1 INTEGER.+ 3 EXEC.DO*COUNT ( 1 INTEGER.+ INTEGER.* ) INTEGER.+ )"); 126 126 127 Assert.AreEqual(144, this.interpreter.IntegerStack.Top);128 this.TestStackCounts(integerStack: 1);127 Assert.AreEqual(144, interpreter.IntegerStack.Top); 128 TestStackCounts(integerStack: 1); 129 129 } 130 130 … … 134 134 [TestCategory("ExecExpressionTest")] 135 135 public void TestNestedDoTimes() { 136 this.interpreter.Run("( 3 EXEC.DO*TIMES ( 2 3 EXEC.DO*TIMES ( 2 INTEGER.* ) INTEGER.+ )");136 interpreter.Run("( 3 EXEC.DO*TIMES ( 2 3 EXEC.DO*TIMES ( 2 INTEGER.* ) INTEGER.+ )"); 137 137 138 Assert.AreEqual(128, this.interpreter.IntegerStack.Top);139 this.TestStackCounts(integerStack: 1);138 Assert.AreEqual(128, interpreter.IntegerStack.Top); 139 TestStackCounts(integerStack: 1); 140 140 } 141 141 … … 153 153 154 154 protected override void CheckOtherStacksAreEmpty() { 155 this.TestStackCounts(null);155 TestStackCounts(null); 156 156 } 157 157 }
Note: See TracChangeset
for help on using the changeset viewer.