1 package org.drools.semantics.python;
2
3 import org.drools.rule.Declaration;
4 import org.drools.spi.MockTuple;
5 import org.drools.semantics.java.ClassObjectType;
6
7 import junit.framework.TestCase;
8
9 public class EvalTest extends TestCase
10 {
11 private Eval eval;
12 private Declaration aDecl;
13 private Declaration bDecl;
14
15 public EvalTest(String name)
16 {
17 super( name );
18 }
19
20 public void setUp()
21 {
22 this.eval = new Eval();
23 this.aDecl = new Declaration( new ClassObjectType( Integer.class ),
24 "a" );
25 this.bDecl = new Declaration( new ClassObjectType( Integer.class ),
26 "b" );
27 }
28
29 public void tearDown()
30 {
31 this.eval = null;
32 }
33
34 public void testSetText()
35 {
36 this.eval.setExpression( "42 + 42" );
37
38 assertNotNull( this.eval.getCode() );
39 }
40
41 public void testEvaluate_NoArg()
42 {
43 this.eval.setExpression( "42 + 12" );
44
45 assertEquals( new Integer( 54 ),
46 this.eval.evaluate() );
47 }
48
49 public void testEvaluate_WithTuple()
50 {
51 this.eval.setExpression( "a + b" );
52
53 MockTuple tuple = new MockTuple();
54
55 tuple.put( this.aDecl,
56 new Integer( 42 ) );
57
58 tuple.put( this.bDecl,
59 new Integer( 12 ) );
60
61 assertEquals( new Integer( 54 ),
62 this.eval.evaluate( tuple ) );
63 }
64 }
65
This page was automatically generated by Maven