- Timestamp:
- 04/18/17 01:15:25 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CommonTests.cs
r14834 r14875 108 108 this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".SWAP")); 109 109 110 Assert.AreEqual(values[0], this.Stack[0]); 110 Assert.AreEqual(values[0], this.Stack[2]); 111 Assert.AreEqual(values[1], this.Stack[0]); 111 112 Assert.AreEqual(values[2], this.Stack[1]); 112 Assert.AreEqual(values[1], this.Stack[2]);113 113 114 114 this.CheckOtherStacksAreEmpty(); … … 128 128 [TestCategory("CommonExpressionTest")] 129 129 public virtual void TestRotate() { 130 var values = this.GetValues(4);131 this.Stack.Push(values);132 133 this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".ROT"));134 135 Assert.AreEqual(values[0], this.Stack[0]);136 Assert.AreEqual(values[3], this.Stack[1]);137 Assert.AreEqual(values[1], this.Stack[2]);138 Assert.AreEqual(values[2], this.Stack[3]);130 var values = GetValues(4); 131 Stack.Push(values); 132 133 Test(ExpressionTable.GetStatelessExpression(TypeName + ".ROT")); 134 135 Assert.AreEqual(values[0], Stack[3]); 136 Assert.AreEqual(values[3], Stack[2]); 137 Assert.AreEqual(values[1], Stack[1]); 138 Assert.AreEqual(values[2], Stack[0]); 139 139 140 140 this.CheckOtherStacksAreEmpty(); … … 160 160 this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".SHOVE")); 161 161 162 Assert.AreEqual(values[0], this.Stack[0]);163 Assert.AreEqual(values[ 2], this.Stack[1]);164 Assert.AreEqual(values[ 1], this.Stack[2]);162 Assert.AreEqual(values[0], Stack[2]); 163 Assert.AreEqual(values[1], Stack[0]); 164 Assert.AreEqual(values[2], Stack[1]); 165 165 166 166 this.CheckOtherStacksAreEmpty(); … … 180 180 [TestCategory("CommonExpressionTest")] 181 181 public virtual void TestShoveWithNegativeIndex() { 182 this.TestWithNegativeIndex("SHOVE"); 182 var values = this.GetValues(3); 183 this.Stack.Push(values); 184 185 this.interpreter.IntegerStack.Push(-1); 186 this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".SHOVE")); 187 188 Assert.AreEqual(values[0], Stack[2]); 189 Assert.AreEqual(values[1], Stack[0]); 190 Assert.AreEqual(values[2], Stack[1]); 191 192 this.CheckOtherStacksAreEmpty(); 183 193 } 184 194 … … 194 204 this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".YANK")); 195 205 196 Assert.AreEqual(values[0], this.Stack[0]);197 Assert.AreEqual(values[ 2], this.Stack[1]);198 Assert.AreEqual(values[ 1], this.Stack[2]);206 Assert.AreEqual(values[0], Stack[2]); 207 Assert.AreEqual(values[1], Stack[0]); 208 Assert.AreEqual(values[2], Stack[1]); 199 209 200 210 this.CheckOtherStacksAreEmpty(); … … 214 224 [TestCategory("CommonExpressionTest")] 215 225 public virtual void TestYankWithNegativeIndex() { 216 this.TestWithNegativeIndex("YANK"); 226 var values = this.GetValues(3); 227 this.Stack.Push(values); 228 229 this.interpreter.IntegerStack.Push(-1); 230 this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".YANK")); 231 232 Assert.AreEqual(values[0], Stack[2]); 233 Assert.AreEqual(values[1], Stack[0]); 234 Assert.AreEqual(values[2], Stack[1]); 235 236 this.CheckOtherStacksAreEmpty(); 217 237 } 218 238 … … 228 248 this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".YANKDUP")); 229 249 230 Assert.AreEqual(values[0], this.Stack[ 0]);231 Assert.AreEqual(values[1], this.Stack[ 1]);232 Assert.AreEqual(values[2], this.Stack[ 2]);233 Assert.AreEqual(values[1], this.Stack[ 3]);250 Assert.AreEqual(values[0], this.Stack[3]); 251 Assert.AreEqual(values[1], this.Stack[2]); 252 Assert.AreEqual(values[2], this.Stack[1]); 253 Assert.AreEqual(values[1], this.Stack[0]); 234 254 235 255 this.CheckOtherStacksAreEmpty(); … … 249 269 [TestCategory("CommonExpressionTest")] 250 270 public virtual void TestYankDuplicateWithNegativeIndex() { 251 this.TestWithNegativeIndex("YANKDUP"); 271 var values = this.GetValues(3); 272 this.Stack.Push(values); 273 274 this.interpreter.IntegerStack.Push(-1); 275 this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".YANKDUP")); 276 277 Assert.AreEqual(values[0], this.Stack[3]); 278 Assert.AreEqual(values[1], this.Stack[2]); 279 Assert.AreEqual(values[2], this.Stack[1]); 280 Assert.AreEqual(values[1], this.Stack[0]); 281 282 this.CheckOtherStacksAreEmpty(); 252 283 } 253 284 … … 277 308 this.Stack.Push(values); 278 309 279 var fullInstruction name = string.Format(FullInstructionNameFormat, this.TypeName, instructionName);280 this.Test(ExpressionTable.GetStatelessExpression(fullInstruction name));281 282 for (var j = 0; j < i; j++) Assert.AreEqual(values[j], this.Stack [j]);310 var fullInstructionName = string.Format(FullInstructionNameFormat, this.TypeName, instructionName); 311 this.Test(ExpressionTable.GetStatelessExpression(fullInstructionName)); 312 313 for (var j = 0; j < i; j++) Assert.AreEqual(values[j], this.Stack.ReverseElementAt(j)); 283 314 284 315 this.CheckOtherStacksAreEmpty(); … … 288 319 289 320 protected void TestWithNegativeIndex(string instructionName) { 290 var values = this.GetValues( 1);321 var values = this.GetValues(3); 291 322 this.Stack.Push(values); 292 323 … … 296 327 this.Test(ExpressionTable.GetStatelessExpression(fullInstructionname)); 297 328 298 Assert.AreEqual(values[0], this.Stack[0]); 329 Assert.AreEqual(values[0], Stack[2]); 330 Assert.AreEqual(values[1], Stack[0]); 331 Assert.AreEqual(values[2], Stack[1]); 299 332 } 300 333 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExecExpressionTests.cs
r14834 r14875 83 83 this.Test(new ExecSExpression()); 84 84 85 Assert.AreEqual(result, this.interpreter.ExecStack .ReverseElementAt(2));86 Assert.AreEqual(third, this.interpreter.ExecStack .ReverseElementAt(1));85 Assert.AreEqual(result, this.interpreter.ExecStack[2]); 86 Assert.AreEqual(third, this.interpreter.ExecStack[1]); 87 87 Assert.AreEqual(first, this.interpreter.ExecStack.Top); 88 88 this.TestStackCounts(3); … … 101 101 102 102 Assert.AreEqual(first, this.interpreter.ExecStack.Top); 103 Assert.AreEqual(result, this.interpreter.ExecStack .ReverseElementAt(1));103 Assert.AreEqual(result, this.interpreter.ExecStack[1]); 104 104 this.TestStackCounts(2); 105 105 }
Note: See TracChangeset
for help on using the changeset viewer.