    1   package groovy.util;
    2
    3   import junit.framework.TestCase;
    4   import org.codehaus.groovy.control.CompilationFailedException;
    5
    6   /***
    7    * Testing the simple Groovy integration with Eval.
    8    *
    9    * @author Dierk Koenig
    10   */
    11  public class EvalTest extends TestCase {
    12      public void testMeSimple() throws CompilationFailedException {
    13          Object result = Eval.me("10");
    14          assertEquals("10", result.toString());
    15      }
    16
    17      public void testMeWithSymbolAndObject() throws CompilationFailedException {
    18          Object result = Eval.me("x", new Integer(10), "x");
    19          assertEquals("10", result.toString());
    20      }
    21
    22      public void testX() throws CompilationFailedException {
    23          Object result = Eval.x(new Integer(10), "x");
    24          assertEquals("10", result.toString());
    25      }
    26
    27      public void testXY() throws CompilationFailedException {
    28          Integer ten = new Integer(10);
    29          Object result = Eval.xy(ten,ten, "x+y");
    30          assertEquals("20", result.toString());
    31      }
    32
    33       public void testXYZ() throws CompilationFailedException {
    34          Integer ten = new Integer(10);
    35          Object result = Eval.xyz(ten,ten,ten, "x+y+z");
    36          assertEquals("30", result.toString());
    37      }
    38  }