Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/18/17 01:15:25 (8 years ago)
Author:
pkimmesw
Message:

#2665 BenchmarkSuite, all examples, partially tested, VectorExpressions added

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  
    108108      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".SWAP"));
    109109
    110       Assert.AreEqual(values[0], this.Stack[0]);
     110      Assert.AreEqual(values[0], this.Stack[2]);
     111      Assert.AreEqual(values[1], this.Stack[0]);
    111112      Assert.AreEqual(values[2], this.Stack[1]);
    112       Assert.AreEqual(values[1], this.Stack[2]);
    113113
    114114      this.CheckOtherStacksAreEmpty();
     
    128128    [TestCategory("CommonExpressionTest")]
    129129    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]);
    139139
    140140      this.CheckOtherStacksAreEmpty();
     
    160160      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".SHOVE"));
    161161
    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]);
    165165
    166166      this.CheckOtherStacksAreEmpty();
     
    180180    [TestCategory("CommonExpressionTest")]
    181181    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();
    183193    }
    184194
     
    194204      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".YANK"));
    195205
    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]);
    199209
    200210      this.CheckOtherStacksAreEmpty();
     
    214224    [TestCategory("CommonExpressionTest")]
    215225    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();
    217237    }
    218238
     
    228248      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".YANKDUP"));
    229249
    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]);
    234254
    235255      this.CheckOtherStacksAreEmpty();
     
    249269    [TestCategory("CommonExpressionTest")]
    250270    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();
    252283    }
    253284
     
    277308        this.Stack.Push(values);
    278309
    279         var fullInstructionname = string.Format(FullInstructionNameFormat, this.TypeName, instructionName);
    280         this.Test(ExpressionTable.GetStatelessExpression(fullInstructionname));
    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));
    283314
    284315        this.CheckOtherStacksAreEmpty();
     
    288319
    289320    protected void TestWithNegativeIndex(string instructionName) {
    290       var values = this.GetValues(1);
     321      var values = this.GetValues(3);
    291322      this.Stack.Push(values);
    292323
     
    296327      this.Test(ExpressionTable.GetStatelessExpression(fullInstructionname));
    297328
    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]);
    299332    }
    300333  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExecExpressionTests.cs

    r14834 r14875  
    8383      this.Test(new ExecSExpression());
    8484
    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]);
    8787      Assert.AreEqual(first, this.interpreter.ExecStack.Top);
    8888      this.TestStackCounts(3);
     
    101101
    102102      Assert.AreEqual(first, this.interpreter.ExecStack.Top);
    103       Assert.AreEqual(result, this.interpreter.ExecStack.ReverseElementAt(1));
     103      Assert.AreEqual(result, this.interpreter.ExecStack[1]);
    104104      this.TestStackCounts(2);
    105105    }
Note: See TracChangeset for help on using the changeset viewer.