Index: /trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/InfixExpressionParserTest.cs
===================================================================
--- /trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/InfixExpressionParserTest.cs	(revision 18166)
+++ /trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/InfixExpressionParserTest.cs	(revision 18167)
@@ -34,91 +34,91 @@
       var formatter = new InfixExpressionFormatter();
       var parser = new InfixExpressionParser();
-      Console.WriteLine(formatter.Format(parser.Parse("3")));
-      Console.WriteLine(formatter.Format(parser.Parse("3*3")));
-      Console.WriteLine(formatter.Format(parser.Parse("3 * 4")));
-      Console.WriteLine(formatter.Format(parser.Parse("123E-03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123e-03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123e+03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123E+03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0E-03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0e-03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0e+03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0E+03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0E-3")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0e-3")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0e+3")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0E+3")));
+      Assert.AreEqual("3", formatter.Format(parser.Parse("3")));
+      Assert.AreEqual("(3 * 3)", formatter.Format(parser.Parse("3*3")));
+      Assert.AreEqual("(3 * 4)",formatter.Format(parser.Parse("3 * 4")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123E-03")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123e-03")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123e+03")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123E+03")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123.0E-03")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123.0e-03")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123.0e+03")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123.0E+03")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123.0E-3")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123.0e-3")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123.0e+3")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123.0E+3")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415+2.0")));
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415/2.0")));
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415*2.0")));
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415-2.0")));
+      Assert.AreEqual("(3.1415 + 2)",formatter.Format(parser.Parse("3.1415+2.0")));
+      Assert.AreEqual("(3.1415 * 1/2)",formatter.Format(parser.Parse("3.1415/2.0")));
+      Assert.AreEqual("(3.1415 * 2)",formatter.Format(parser.Parse("3.1415*2.0")));
+      Assert.AreEqual("(3.1415 + (-(2)))", formatter.Format(parser.Parse("3.1415-2.0")));
       // round-trip
-      Console.WriteLine(formatter.Format(parser.Parse(formatter.Format(parser.Parse("3.1415-2.0")))));
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415+(2.0)")));
-      Console.WriteLine(formatter.Format(parser.Parse("(3.1415+(2.0))")));
+      Assert.AreEqual("(3.1415 + (-(2)))",formatter.Format(parser.Parse(formatter.Format(parser.Parse("3.1415-2.0")))));
+      Assert.AreEqual("(3.1415 + 2)",formatter.Format(parser.Parse("3.1415+(2.0)")));
+      Assert.AreEqual("(3.1415 + 2)", formatter.Format(parser.Parse("(3.1415+(2.0))")));
 
 
-      Console.WriteLine(formatter.Format(parser.Parse("log(3)")));
-      Console.WriteLine(formatter.Format(parser.Parse("log(-3)")));   // should produce log(-3) as output
-      Console.WriteLine(formatter.Format(parser.Parse("exp(3)")));
-      Console.WriteLine(formatter.Format(parser.Parse("exp(-3)")));  // should produce exp(-3) as output
-      Console.WriteLine(formatter.Format(parser.Parse("sqrt(3)")));
+      Assert.AreEqual("LOG(3)",formatter.Format(parser.Parse("log(3)")));
+      Assert.AreEqual("LOG((-(3)))",formatter.Format(parser.Parse("log(-3)")));   // should produce log(-3) as output
+      Assert.AreEqual("EXP(3)",formatter.Format(parser.Parse("exp(3)")));
+      Assert.AreEqual("EXP((-(3)))",formatter.Format(parser.Parse("exp(-3)")));  // should produce exp(-3) as output
+      Assert.AreEqual("SQRT(3)", formatter.Format(parser.Parse("sqrt(3)")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("sqr((-3))")));  // should produce sqr((-3)) as output
+      Assert.AreEqual("SQR((-(3)))", formatter.Format(parser.Parse("sqr((-3))")));  // should produce sqr((-3)) as output
 
-      Console.WriteLine(formatter.Format(parser.Parse("3/3+2/2+1/1"))); // ((3 * 1 / 3) + (2 * 1 / 2) + (1 * 1 / 1))
-      Console.WriteLine(formatter.Format(parser.Parse("-3+30-2+20-1+10")));   //  not (30 + 20 + 10 + ((-1) * (3 + 2 + 1)))
+      Assert.AreEqual("((3 * 1/3) + (2 * 1/2) + (1 * 1/1))",formatter.Format(parser.Parse("3/3+2/2+1/1"))); // ((3 * 1 / 3) + (2 * 1 / 2) + (1 * 1 / 1))
+      Assert.AreEqual("(30 + 20 + 10 + ((-1) * (3 + 2 + 1)))", formatter.Format(parser.Parse("-3+30-2+20-1+10")));   //  not (30 + 20 + 10 + ((-1) * (3 + 2 + 1)))
       // round trip
-      Console.WriteLine(formatter.Format(parser.Parse(formatter.Format(parser.Parse("-3+30-2+20-1+10")))));   // not (30 + 20 + 10 + ((-(1)) * (3 + 2 + 1)))
+      Assert.AreEqual("(30 + 20 + 10 + ((-(1)) * (3 + 2 + 1)))", formatter.Format(parser.Parse(formatter.Format(parser.Parse("-3+30-2+20-1+10")))));   // not (30 + 20 + 10 + ((-(1)) * (3 + 2 + 1)))
 
-      Console.WriteLine(formatter.Format(parser.Parse("\"x1\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("\'var name\'")));
-      Console.WriteLine(formatter.Format(parser.Parse("\"var name\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("\"1\"")));
+      Assert.AreEqual("'x1'",formatter.Format(parser.Parse("\"x1\"")));
+      Assert.AreEqual("'var name'",formatter.Format(parser.Parse("\'var name\'")));
+      Assert.AreEqual("'var name'",formatter.Format(parser.Parse("\"var name\"")));
+      Assert.AreEqual("'1'",formatter.Format(parser.Parse("\"1\"")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("'var \" name\'")));
-      Console.WriteLine(formatter.Format(parser.Parse("\"var \' name\"")));
+      Assert.AreEqual("'var \" name'",formatter.Format(parser.Parse("'var \" name\'")));
+      Assert.AreEqual("\"var ' name\"", formatter.Format(parser.Parse("\"var \' name\"")));
 
 
-      Console.WriteLine(formatter.Format(parser.Parse("\"x1\"*\"x2\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("\"x1\"*\"x2\"+\"x3\"*\"x4\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("x1*x2+x3*x4")));
+      Assert.AreEqual("('x1' * 'x2')",formatter.Format(parser.Parse("\"x1\"*\"x2\"")));
+      Assert.AreEqual("(('x1' * 'x2') + ('x3' * 'x4'))",formatter.Format(parser.Parse("\"x1\"*\"x2\"+\"x3\"*\"x4\"")));
+      Assert.AreEqual("(('x1' * 'x2') + ('x3' * 'x4'))", formatter.Format(parser.Parse("x1*x2+x3*x4")));
 
 
-      Console.WriteLine(formatter.Format(parser.Parse("POW(3, 2)")));
-      Console.WriteLine(formatter.Format(parser.Parse("POW(3.1, 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("POW(3.1 , 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("POW(3.1 ,2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("POW(-3.1 , - 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(3, 2)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(3.1, 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(3.1 , 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(3.1 ,2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(-3.1 , - 2.1)")));
+      Assert.AreEqual("(3 ^ 2)",formatter.Format(parser.Parse("POW(3, 2)")));
+      Assert.AreEqual("(3.1 ^ 2.1)",formatter.Format(parser.Parse("POW(3.1, 2.1)")));
+      Assert.AreEqual("(3.1 ^ 2.1)",formatter.Format(parser.Parse("POW(3.1 , 2.1)")));
+      Assert.AreEqual("(3.1 ^ 2.1)",formatter.Format(parser.Parse("POW(3.1 ,2.1)")));
+      Assert.AreEqual("((-(3.1)) ^ (-(2.1)))",formatter.Format(parser.Parse("POW(-3.1 , - 2.1)")));
+      Assert.AreEqual("ROOT(3, 2)",formatter.Format(parser.Parse("ROOT(3, 2)")));
+      Assert.AreEqual("ROOT(3.1, 2.1)",formatter.Format(parser.Parse("ROOT(3.1, 2.1)")));
+      Assert.AreEqual("ROOT(3.1, 2.1)",formatter.Format(parser.Parse("ROOT(3.1 , 2.1)")));
+      Assert.AreEqual("ROOT(3.1, 2.1)",formatter.Format(parser.Parse("ROOT(3.1 ,2.1)")));
+      Assert.AreEqual("ROOT((-(3.1)), (-(2.1)))", formatter.Format(parser.Parse("ROOT(-3.1 , - 2.1)")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("IF(GT( 0, 1), 1, 0)")));
-      Console.WriteLine(formatter.Format(parser.Parse("IF(LT(0,1), 1 , 0)")));
+      Assert.AreEqual("IF(GT(0, 1), 1, 0)",formatter.Format(parser.Parse("IF(GT( 0, 1), 1, 0)")));
+      Assert.AreEqual("IF(LT(0, 1), 1, 0)",formatter.Format(parser.Parse("IF(LT(0,1), 1 , 0)")));
+      Assert.AreEqual("LAG('x', 1)",formatter.Format(parser.Parse("LAG(x, 1)")));
+      Assert.AreEqual("LAG('x', -1)",formatter.Format(parser.Parse("LAG(x, -1)")));
+      Assert.AreEqual("LAG('x', 1)",formatter.Format(parser.Parse("LAG(x, +1)")));
+      Assert.AreEqual("('x' * LAG('x', 1))", formatter.Format(parser.Parse("x * LAG('x', +1)")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("LAG(x, 1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("LAG(x, -1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("LAG(x, +1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("x * LAG('x', +1)")));
+      // factor variables
+      Assert.AreEqual("('x'[1] * 'y')",formatter.Format(parser.Parse("x [1.0] * y")));
+      Assert.AreEqual("('x'[1, 2] * 'y'[1, 2])",formatter.Format(parser.Parse("x [1.0, 2.0] * y [1.0, 2.0]")));
+      Assert.AreEqual("('x'[1] * 'y')",formatter.Format(parser.Parse("x[1] * y")));
+      Assert.AreEqual("('x'[1, 2] * 'y'[1, 2])",formatter.Format(parser.Parse("x[1, 2] * y [1, 2]")));
+      Assert.AreEqual("('x'[1] * 'y')",formatter.Format(parser.Parse("x [+1.0] * y")));
+      Assert.AreEqual("('x'[-1] * 'y')",formatter.Format(parser.Parse("x [-1.0] * y")));
+      Assert.AreEqual("('x'[-1, -2] * 'y'[1, 2])", formatter.Format(parser.Parse("x [-1.0, -2.0] * y [+1.0, +2.0]")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("x [1.0] * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x [1.0, 2.0] * y [1.0, 2.0]")));
-      Console.WriteLine(formatter.Format(parser.Parse("x[1] * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x[1, 2] * y [1, 2]")));
-
-      Console.WriteLine(formatter.Format(parser.Parse("x [+1.0] * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x [-1.0] * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x [-1.0, -2.0] * y [+1.0, +2.0]")));
-
-      Console.WriteLine(formatter.Format(parser.Parse("x='bla' * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x = 'bla'")));
-      Console.WriteLine(formatter.Format(parser.Parse("x = \"bla\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("1.0 * x = bla")));
-      Console.WriteLine(formatter.Format(parser.Parse("-1.0 * x = bla")));
-      Console.WriteLine(formatter.Format(parser.Parse("+1.0 * \"x\" = bla + y = \"bla2\"")));
+      // one-hot for factor
+      Assert.AreEqual("('x' = 'val' * 'y')",formatter.Format(parser.Parse("x='val' * y")));
+      Assert.AreEqual("'x' = 'val'",formatter.Format(parser.Parse("x = 'val'")));
+      Assert.AreEqual("'x' = 'val'",formatter.Format(parser.Parse("x = \"val\"")));
+      Assert.AreEqual("(1 * 'x' = 'val')",formatter.Format(parser.Parse("1.0 * x = val")));
+      Assert.AreEqual("(-((1 * 'x' = 'val')))",formatter.Format(parser.Parse("-1.0 * x = val")));
+      Assert.AreEqual("((1 * 'x' = 'val1') + 'y' = 'val2')", formatter.Format(parser.Parse("+1.0 * \"x\" = val1 + y = \"val2\"")));
     }
   }
