- Timestamp:
- 06/01/17 09:28:34 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions
- Files:
-
- 9 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CodeExpressionTests.cs
r14908 r15017 430 430 431 431 Assert.AreEqual(3, interpreter.IntegerStack.Top); 432 TestStackCounts( codeStack: 1, integerStack: 2);432 TestStackCounts(integerStack: 1); 433 433 } 434 434 … … 455 455 var prog = PushParser.Parse("( INTEGER.DUP INTEGER.+ )"); 456 456 457 interpreter.IntegerStack.Push(2, 3);457 interpreter.IntegerStack.Push(2, 4); 458 458 interpreter.CodeStack.Push(prog); 459 459 interpreter.Run(new CodeDoTimesExpression()); … … 508 508 public void TestNestedDoTimes() { 509 509 interpreter.Run( 510 "( 3 CODE.QUOTE ( 2 3CODE.QUOTE ( 2 INTEGER.* ) CODE.DO*TIMES INTEGER.+ ) CODE.DO*TIMES )");510 "( 4 CODE.QUOTE ( 2 4 CODE.QUOTE ( 2 INTEGER.* ) CODE.DO*TIMES INTEGER.+ ) CODE.DO*TIMES )"); 511 511 512 512 Assert.AreEqual(128, interpreter.IntegerStack.Top); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CommonTests.cs
r14908 r15017 35 35 36 36 var isBooleanStack = interpreter.BooleanStack.Count == 2; 37 38 37 Test(ExpressionTable.GetStatelessExpression(TypeName + ".=")); 39 38 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExampleTests.cs
r14908 r15017 145 145 public void Example10() { 146 146 interpreter.IntegerStack.Push(5); 147 interpreter.Run("( 1 INTEGER.MAX 1 EXEC.DO*RANGE ( 2 INTEGER.* ) )");148 149 Assert.AreEqual( 2, interpreter.IntegerStack.Top);147 interpreter.Run("( 1 INTEGER.MAX 1 EXEC.DO*RANGE ( 2 INTEGER.* INTEGER.* ) )"); 148 149 Assert.AreEqual(3840, interpreter.IntegerStack.Top); 150 150 Assert.IsTrue(interpreter.CodeStack.IsEmpty); 151 151 Assert.IsTrue(interpreter.ExecStack.IsEmpty); … … 254 254 interpreter.FloatStack.Push(2); 255 255 interpreter.Run(@"( ARG FLOAT.DEFINE 256 257 258 259 260 261 262 256 EXEC.Y ( 257 ARG FLOAT.* 258 1 INTEGER.- 259 INTEGER.DUP 1 INTEGER.> 260 EXEC.IF ( ) EXEC.POP 261 ) 262 )"); 263 263 264 264 Assert.AreEqual(1024, interpreter.FloatStack.Top, Delta); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExecExpressionTests.cs
r14908 r15017 111 111 public void TestNestedDoRange() { 112 112 interpreter.Run( 113 "( 0 2 EXEC.DO*RANGE ( 1 INTEGER.+ 0 3 EXEC.DO*RANGE ( 1 INTEGER.+ INTEGER.* ) INTEGER.+)");113 "( 1 0 2 EXEC.DO*RANGE ( INTEGER.POP 1 1 4 EXEC.DO*RANGE INTEGER.* INTEGER.* ) )"); 114 114 115 Assert.AreEqual(1 44, interpreter.IntegerStack.Top);115 Assert.AreEqual(13824, interpreter.IntegerStack.Top); 116 116 TestStackCounts(integerStack: 1); 117 117 } … … 134 134 [TestCategory("ExecExpressionTest")] 135 135 public void TestNestedDoTimes() { 136 interpreter.Run("( 3 EXEC.DO*TIMES ( 2 3EXEC.DO*TIMES ( 2 INTEGER.* ) INTEGER.+ )");136 interpreter.Run("( 4 EXEC.DO*TIMES ( 2 4 EXEC.DO*TIMES ( 2 INTEGER.* ) INTEGER.+ )"); 137 137 138 138 Assert.AreEqual(128, interpreter.IntegerStack.Top); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/IntegerExpressionTests.cs
r14908 r15017 32 32 33 33 Assert.AreEqual(10, interpreter.IntegerStack.Top); 34 35 34 TestStackCounts(integerStack: 1); 36 35 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/StandardTests.cs
r14746 r15017 13 13 public class StandardTests { 14 14 [TestMethod] 15 [TestProperty("Time", "Short")] 16 [TestCategory("ExpressionTest")] 17 [TestCategory("StandartTests")] 15 18 public void TestGetHashCode() { 16 19 var expressionTypes = from domainAssembly in AppDomain.CurrentDomain.GetAssemblies() … … 22 25 23 26 var expressions = expressionTypes.Select(et => Activator.CreateInstance(et) as Expression); 24 var ids = expressions.Select(e => new { E pxression = e, Id = e.GetHashCode() });27 var ids = expressions.Select(e => new { Expression = e, Id = e.GetHashCode() }); 25 28 26 var duplicate s = ids.GroupBy(s => s).SelectMany(grp => grp.Skip(1));29 var duplicateGroups = ids.GroupBy(s => s.Id).Where(grp => grp.Count() > 2).ToList(); 27 30 28 if (!duplicate s.Any())31 if (!duplicateGroups.Any()) 29 32 return; 30 33 31 34 Debug.WriteLine("Duplicates: "); 32 foreach (var duplicate in duplicates) 33 Debug.WriteLine("Id: {0}, Expression: {1}", duplicate.Id, duplicate.Epxression); 35 foreach (var group in duplicateGroups) { 36 foreach (var duplicate in group) { 37 string name; 38 if (!ExpressionTable.TypeToNameTable.TryGetValue(duplicate.Expression.GetType(), out name)) { 39 name = duplicate.Expression.ToString(); 40 } 41 42 Debug.WriteLine("Id: {0}, Expression: {1}", duplicate.Id, name); 43 } 44 45 Debug.WriteLine(""); 46 } 34 47 35 48 Assert.Fail(); … … 37 50 38 51 [TestMethod] 52 [TestProperty("Time", "Short")] 53 [TestCategory("ExpressionTest")] 54 [TestCategory("StandartTests")] 39 55 public void TestExpandGetHashCode() { 40 56 var expand = PushParser.Parse("( A B C D E F )"); … … 44 60 45 61 [TestMethod] 62 [TestProperty("Time", "Short")] 63 [TestCategory("ExpressionTest")] 64 [TestCategory("StandartTests")] 46 65 public void TestExecExpandCopy() { 47 66 var expressions = new Expression[] … … 59 78 60 79 [TestMethod] 80 [TestProperty("Time", "Short")] 81 [TestCategory("ExpressionTest")] 82 [TestCategory("StandartTests")] 61 83 public void TestExecExpandRecursiveCopy() { 62 84 var expressions = new List<Expression> … … 83 105 84 106 [TestMethod] 107 [TestProperty("Time", "Short")] 108 [TestCategory("ExpressionTest")] 109 [TestCategory("StandartTests")] 85 110 public void TestExecExpandRecursiveGetHashCode() { 86 111 var expressions = new List<Expression>
Note: See TracChangeset
for help on using the changeset viewer.