[14727] | 1 | namespace HeuristicLab.Tests.Interpreter {
|
---|
[15017] | 2 | using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Boolean;
|
---|
| 3 | using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Float;
|
---|
| 4 | using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.FloatVector;
|
---|
| 5 | using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.IntegerVector;
|
---|
| 6 | using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.StringVector;
|
---|
[14727] | 7 |
|
---|
| 8 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
[15017] | 9 | using Problems.ProgramSynthesis.Base.Erc;
|
---|
| 10 | using Problems.ProgramSynthesis.Base.Erc.Char;
|
---|
| 11 | using Problems.ProgramSynthesis.Base.Erc.Integer;
|
---|
| 12 | using Problems.ProgramSynthesis.Base.Erc.String;
|
---|
| 13 | using Problems.ProgramSynthesis.Push.Configuration;
|
---|
| 14 | using Problems.ProgramSynthesis.Push.Interpreter;
|
---|
[14727] | 15 |
|
---|
| 16 | public class ExpressionTest {
|
---|
[14744] | 17 | protected PushInterpreter interpreter;
|
---|
[14727] | 18 |
|
---|
[15017] | 19 | protected PushConfiguration configuration = new PushConfiguration {
|
---|
| 20 | TopLevelPushCode = false,
|
---|
| 21 | ErcOptions = new ErcOptions {
|
---|
| 22 | ErcProbability = 0.05,
|
---|
| 23 | CharErcOptions = new CharErcOptions(new IntegerRangeErc(0x20, 0x7e)),
|
---|
| 24 | StringErcOptions = new StringErcOptions(new StringRandomErc {
|
---|
| 25 | IsEnabled = true,
|
---|
| 26 | AllowDigits = true,
|
---|
| 27 | NewStringProbability = 1,
|
---|
| 28 | AllowLowercaseLetters = true,
|
---|
| 29 | AllowUppercaseLetters = true
|
---|
| 30 | }),
|
---|
| 31 | IntegerErcOptions = new IntegerErcOptions(new IntegerRangeErc(-10000, 10000)),
|
---|
| 32 | FloatErcOptions = new FloatErcOptions(new FloatRangeErc(-10000, 10000)),
|
---|
| 33 | BooleanErcOptions = new BooleanErcOptions(new BooleanRandomErc(true, true, true)),
|
---|
| 34 | StringVectorErcOptions = new StringVectorErcOptions(
|
---|
| 35 | new StringVectorConstantsErc(new[] { "test", "123", "asdf", "a", "b" })),
|
---|
| 36 | IntegerVectorErcOptions = new IntegerVectorErcOptions(
|
---|
| 37 | new IntegerVectorConstantsErc(new[] { 0, -5, 10, 8, -3 })),
|
---|
| 38 | FloatVectorErcOptions = new FloatVectorErcOptions(
|
---|
| 39 | new FloatVectorConstantsErc(new[] { 0.0, -5.2, 10.3, 8.1, -3.4 }))
|
---|
| 40 | }
|
---|
| 41 | };
|
---|
[14727] | 42 |
|
---|
| 43 | [TestInitialize]
|
---|
| 44 | public void BeforeTest() {
|
---|
[15017] | 45 | interpreter = new PushInterpreter(1337, configuration);
|
---|
[14727] | 46 | }
|
---|
| 47 |
|
---|
| 48 | protected void TestStackCounts(
|
---|
| 49 | int? execStack = 0,
|
---|
| 50 | int? codeStack = 0,
|
---|
| 51 | int? nameStack = 0,
|
---|
| 52 | int? booleanStack = 0,
|
---|
| 53 | int? floatStack = 0,
|
---|
[15017] | 54 | int? integerStack = 0,
|
---|
| 55 | int? charStack = 0,
|
---|
| 56 | int? stringStack = 0,
|
---|
| 57 | int? integerVectorStack = 0,
|
---|
| 58 | int? floatVectorStack = 0,
|
---|
| 59 | int? booleanVectorStack = 0,
|
---|
| 60 | int? stringVectorStack = 0) {
|
---|
[14908] | 61 | if (execStack.HasValue) Assert.AreEqual(execStack, interpreter.ExecStack.Count);
|
---|
| 62 | if (codeStack.HasValue) Assert.AreEqual(codeStack, interpreter.CodeStack.Count);
|
---|
| 63 | if (nameStack.HasValue) Assert.AreEqual(nameStack, interpreter.NameStack.Count);
|
---|
| 64 | if (booleanStack.HasValue) Assert.AreEqual(booleanStack, interpreter.BooleanStack.Count);
|
---|
| 65 | if (floatStack.HasValue) Assert.AreEqual(floatStack, interpreter.FloatStack.Count);
|
---|
| 66 | if (integerStack.HasValue) Assert.AreEqual(integerStack, interpreter.IntegerStack.Count);
|
---|
[15017] | 67 | if (charStack.HasValue) Assert.AreEqual(charStack, interpreter.CharStack.Count);
|
---|
| 68 | if (stringStack.HasValue) Assert.AreEqual(stringStack, interpreter.StringStack.Count);
|
---|
| 69 | if (integerVectorStack.HasValue) Assert.AreEqual(integerVectorStack, interpreter.IntegerVectorStack.Count);
|
---|
| 70 | if (floatVectorStack.HasValue) Assert.AreEqual(floatVectorStack, interpreter.FloatVectorStack.Count);
|
---|
| 71 | if (booleanVectorStack.HasValue) Assert.AreEqual(booleanVectorStack, interpreter.BooleanVectorStack.Count);
|
---|
| 72 | if (stringVectorStack.HasValue) Assert.AreEqual(stringVectorStack, interpreter.StringVectorStack.Count);
|
---|
[14727] | 73 | }
|
---|
| 74 | }
|
---|
| 75 | } |
---|