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