Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/TestLessThan.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestLessThan.java?rev=673806&r1=673805&r2=673806&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestLessThan.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestLessThan.java Thu 
Jul  3 14:12:08 2008
@@ -17,8 +17,6 @@
  */
 package org.apache.pig.test;
 
-import static org.junit.Assert.assertEquals;
-
 import java.util.Map;
 import java.util.Random;
 
@@ -37,6 +35,8 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class TestLessThan extends junit.framework.TestCase {
 
     @Before
@@ -47,139 +47,274 @@
     public void tearDown() throws Exception {
     }
 
-    public static boolean test(byte type) throws ExecException {
-        Random r = new Random();
-        ConstantExpression lt = (ConstantExpression) GenPhyOp.exprConst();
-        lt.setResultType(type);
-        ConstantExpression rt = (ConstantExpression) GenPhyOp.exprConst();
-        rt.setResultType(type);
-        LessThanExpr g = (LessThanExpr) GenPhyOp.compLessThanExpr();
-        g.setLhs(lt);
-        g.setRhs(rt);
-
-        switch (type) {
-        case DataType.BAG:
-            DataBag inpdb1 = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
-            DataBag inpdb2 = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
-            lt.setValue(inpdb1);
-            rt.setValue(inpdb2);
-            Result resdb = g.getNext(inpdb1);
-            if (resdb.returnStatus == POStatus.STATUS_ERR) {
-                return true;
-            }
-            return false;
-        case DataType.BOOLEAN:
-            Boolean inpb1 = r.nextBoolean();
-            Boolean inpb2 = r.nextBoolean();
-            lt.setValue(inpb1);
-            rt.setValue(inpb2);
-            Result resb = g.getNext(inpb1);
-            if (resb.returnStatus == POStatus.STATUS_ERR) {
-                return true;
-            }
-            return false;
-        case DataType.BYTEARRAY:
-            DataByteArray inpba1 = GenRandomData.genRandDBA(r);
-            DataByteArray inpba2 = GenRandomData.genRandDBA(r);
-            lt.setValue(inpba1);
-            rt.setValue(inpba2);
-            Result resba = g.getNext(inpba1);
-            boolean retba = (inpba1.compareTo(inpba2) == -1);
-            if ((Boolean) resba.result == retba)
-                return true;
-            return false;
-        case DataType.CHARARRAY:
-            String inps1 = GenRandomData.genRandString(r);
-            String inps2 = GenRandomData.genRandString(r);
-            lt.setValue(inps1);
-            rt.setValue(inps2);
-            Result ress = g.getNext(inps1);
-            boolean rets = (inps1.compareTo(inps2) < 0);
-            if ((Boolean) ress.result == rets)
-                return true;
-            return false;
-        case DataType.DOUBLE:
-            Double inpd1 = r.nextDouble();
-            Double inpd2 = r.nextDouble();
-            lt.setValue(inpd1);
-            rt.setValue(inpd2);
-            Result resd = g.getNext(inpd1);
-            boolean retd = (inpd1 < inpd2);
-            if ((Boolean) resd.result == retd)
-                return true;
-            return false;
-        case DataType.FLOAT:
-            Float inpf1 = r.nextFloat();
-            Float inpf2 = r.nextFloat();
-            lt.setValue(inpf1);
-            rt.setValue(inpf2);
-            Result resf = g.getNext(inpf1);
-            boolean retf = (inpf1 < inpf2);
-            if ((Boolean) resf.result == retf)
-                return true;
-            return false;
-        case DataType.INTEGER:
-            Integer inpi1 = r.nextInt();
-            Integer inpi2 = r.nextInt();
-            lt.setValue(inpi1);
-            rt.setValue(inpi2);
-            Result resi = g.getNext(inpi1);
-            boolean reti = (inpi1 < inpi2);
-            if ((Boolean) resi.result == reti)
-                return true;
-            return false;
-        case DataType.LONG:
-            Long inpl1 = r.nextLong();
-            Long inpl2 = r.nextLong();
-            lt.setValue(inpl1);
-            rt.setValue(inpl2);
-            Result resl = g.getNext(inpl1);
-            boolean retl = (inpl1 < inpl2);
-            if ((Boolean) resl.result == retl)
-                return true;
-            return false;
-        case DataType.MAP:
-            Map<Integer, String> inpm1 = GenRandomData.genRandMap(r, 10);
-            Map<Integer, String> inpm2 = GenRandomData.genRandMap(r, 10);
-            lt.setValue(inpm1);
-            rt.setValue(inpm2);
-            Result resm = g.getNext(inpm1);
-            if (resm.returnStatus == POStatus.STATUS_ERR) {
-                return true;
-            }
-            return false;
-        case DataType.TUPLE:
-            Tuple inpt1 = GenRandomData.genRandSmallBagTuple(r, 10, 100);
-            Tuple inpt2 = GenRandomData.genRandSmallBagTuple(r, 10, 100);
-            lt.setValue(inpt1);
-            rt.setValue(inpt2);
-            Result rest = g.getNext(inpt1);
-            if (rest.returnStatus == POStatus.STATUS_ERR) {
-                return true;
-            }
-            return false;
-        }
-        return true;
-    }
-
-    @Test
-    public void testOperator() throws ExecException {
-        int TRIALS = 10;
-        byte[] types = DataType.genAllTypes();
-        // Map<Byte, String> map = DataType.genTypeToNameMap();
-        // System.out.println("Testing Less Than Expression:");
-        for (byte b : types) {
-            boolean succ = true;
-            // System.out.print("\t With " + map.get(b) + ": ");
-            for (int i = 0; i < TRIALS; i++) {
-                succ &= test(b);
-            }
-            assertEquals(true, succ);
-            /*
-             * if (succ) System.out.println("Success!!"); else
-             * System.out.println("Failure");
-             */
-        }
+    @Test
+    public void testIntegerGt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Integer(1));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Integer(0));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.INTEGER);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testIntegerLt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Integer(0));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Integer(1));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.INTEGER);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testIntegerEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Integer(1));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Integer(1));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.INTEGER);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testLongGt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Long(1L));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Long(0L));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.LONG);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testLongLt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Long(0L));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Long(1L));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.LONG);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testLongEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Long(1L));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Long(1L));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.LONG);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testFloatGt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Float(1.0f));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Float(0.0f));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.FLOAT);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testFloatLt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Float(0.0f));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Float(1.0f));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.FLOAT);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testFloatEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Float(1.0f));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Float(1.0f));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.FLOAT);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testDoubleGt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Double(1.0));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Double(0.0));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.DOUBLE);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testDoubleLt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Double(0.0));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Double(1.0));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.DOUBLE);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testDoubleEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Double(1.0));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Double(1.0));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.DOUBLE);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testStringGt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new String("b"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new String("a"));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.CHARARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testStringLt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new String("a"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new String("b"));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.CHARARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testStringEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new String("b"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new String("b"));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.CHARARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testDataByteArrayGt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new DataByteArray("b"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new DataByteArray("a"));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.BYTEARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testDataByteArrayLt() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new DataByteArray("a"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new DataByteArray("b"));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.BYTEARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testDataByteArrayEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new DataByteArray("b"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new DataByteArray("b"));
+        LessThanExpr g = GenPhyOp.compLessThanExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.BYTEARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
     }
 
 }

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/TestNotEqualTo.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestNotEqualTo.java?rev=673806&r1=673805&r2=673806&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestNotEqualTo.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestNotEqualTo.java 
Thu Jul  3 14:12:08 2008
@@ -17,8 +17,6 @@
  */
 package org.apache.pig.test;
 
-import static org.junit.Assert.*;
-
 import java.util.Map;
 import java.util.Random;
 
@@ -27,6 +25,7 @@
 import org.apache.pig.data.DataByteArray;
 import org.apache.pig.data.DataType;
 import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.physicalLayer.POStatus;
 import org.apache.pig.impl.physicalLayer.Result;
 import 
org.apache.pig.impl.physicalLayer.expressionOperators.ConstantExpression;
 import org.apache.pig.impl.physicalLayer.expressionOperators.NotEqualToExpr;
@@ -36,6 +35,8 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class TestNotEqualTo extends junit.framework.TestCase {
 
     @Before
@@ -46,195 +47,183 @@
     public void tearDown() throws Exception {
     }
 
-    public static boolean test(byte type) throws ExecException {
-        Random r = new Random();
-        ConstantExpression lt = (ConstantExpression) GenPhyOp.exprConst();
-        lt.setResultType(type);
-        ConstantExpression rt = (ConstantExpression) GenPhyOp.exprConst();
-        rt.setResultType(type);
-        NotEqualToExpr g = (NotEqualToExpr) GenPhyOp.compNotEqualToExpr();
-        g.setLhs(lt);
-        g.setRhs(rt);
-
-        Object inp1;
-        Object inp2;
-        Result res;
-        Boolean ret;
-        switch (type) {
-        case DataType.BAG:
-            inp1 = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
-            inp2 = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((DataBag) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((DataBag) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.BOOLEAN:
-            inp1 = r.nextBoolean();
-            inp2 = r.nextBoolean();
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((Boolean) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((Boolean) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.BYTEARRAY:
-            inp1 = GenRandomData.genRandDBA(r);
-            inp2 = GenRandomData.genRandDBA(r);
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((DataByteArray) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((DataByteArray) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.CHARARRAY:
-            inp1 = GenRandomData.genRandString(r);
-            inp2 = GenRandomData.genRandString(r);
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((String) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((String) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.DOUBLE:
-            inp1 = r.nextDouble();
-            inp2 = r.nextDouble();
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((Double) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((Double) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.FLOAT:
-            inp1 = r.nextFloat();
-            inp2 = r.nextFloat();
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((Float) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((Float) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.INTEGER:
-            inp1 = r.nextInt();
-            inp2 = r.nextInt();
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((Integer) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((Integer) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.LONG:
-            inp1 = r.nextLong();
-            inp2 = r.nextLong();
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((Long) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((Long) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.MAP:
-            inp1 = GenRandomData.genRandMap(r, 10);
-            inp2 = GenRandomData.genRandMap(r, 10);
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((Map) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((Map) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        case DataType.TUPLE:
-            inp1 = GenRandomData.genRandSmallBagTuple(r, 10, 100);
-            inp2 = GenRandomData.genRandSmallBagTuple(r, 10, 100);
-            lt.setValue(inp1);
-            rt.setValue(inp1);
-            res = g.getNext((Tuple) inp1);
-            if ((Boolean) res.result == true)
-                return false;
-            lt.setValue(inp1);
-            rt.setValue(inp2);
-            res = g.getNext((Tuple) inp1);
-            ret = (DataType.compare(inp1, inp2) != 0);
-            if (res.result.equals(ret))
-                return true;
-            return false;
-        }
-        return true;
-    }
-
-    @Test
-    public void testOperator() throws ExecException {
-        int TRIALS = 10;
-        byte[] types = DataType.genAllTypes();
-        Map<Byte, String> map = DataType.genTypeToNameMap();
-        // System.out.println("Testing Not Equal To Expression:");
-
-        long t1 = System.currentTimeMillis();
-
-        for (byte b : types) {
-            boolean succ = true;
-            // System.out.print("\t With " + map.get(b) + ": ");
-            for (int i = 0; i < TRIALS; i++) {
-                succ &= test(b);
-            }
-            assertEquals(true, succ);
-            /*
-             * if (succ) System.out.println("Success!!"); else
-             * System.out.println("Failure");
-             */
-        }
+    @Test
+    public void testIntegerNe() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Integer(1));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Integer(0));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.INTEGER);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testIntegerEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Integer(1));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Integer(1));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.INTEGER);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testLongNe() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Long(1L));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Long(0L));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.LONG);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testLongEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Long(1L));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Long(1L));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.LONG);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testFloatNe() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Float(0.0f));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Float(1.0f));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.FLOAT);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testFloatEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Float(1.0f));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Float(1.0f));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.FLOAT);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testDoubleNe() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Double(0.0));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Double(1.0));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.DOUBLE);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testDoubleEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new Double(1.0));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new Double(1.0));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.DOUBLE);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testStringNe() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new String("a"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new String("b"));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.CHARARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testStringEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new String("b"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new String("b"));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.CHARARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
+    }
+
+    @Test
+    public void testDataByteArrayNe() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new DataByteArray("a"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new DataByteArray("b"));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.BYTEARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertTrue((Boolean)r.result);
+    }
+
+    @Test
+    public void testDataByteArrayEq() throws Exception {
+        ConstantExpression lt = GenPhyOp.exprConst();
+        lt.setValue(new DataByteArray("b"));
+        ConstantExpression rt = GenPhyOp.exprConst();
+        rt.setValue(new DataByteArray("b"));
+        NotEqualToExpr g = GenPhyOp.compNotEqualToExpr();
+        g.setLhs(lt);
+        g.setRhs(rt);
+        g.setOperandType(DataType.BYTEARRAY);
+        Result r = g.getNext(new Boolean(true));
+        assertEquals(POStatus.STATUS_OK, r.returnStatus);
+        assertFalse((Boolean)r.result);
     }
 }

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/TestPOBinCond.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestPOBinCond.java?rev=673806&r1=673805&r2=673806&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestPOBinCond.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestPOBinCond.java 
Thu Jul  3 14:12:08 2008
@@ -68,6 +68,7 @@
         EqualToExpr equal = (EqualToExpr) GenPhyOp.compEqualToExpr();
         equal.setLhs(prj1);
         equal.setRhs(rt);
+        equal.setOperandType(DataType.INTEGER);
         
         POProject prjLhs = GenPhyOp.exprProject();
         prjLhs.setResultType(DataType.INTEGER);

Modified: incubator/pig/branches/types/test/org/apache/pig/test/TestRegexp.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestRegexp.java?rev=673806&r1=673805&r2=673806&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestRegexp.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestRegexp.java Thu 
Jul  3 14:12:08 2008
@@ -38,7 +38,7 @@
 
     Random r = new Random();
     ConstantExpression lt, rt;
-    BinaryExpressionOperator op;
+    BinaryComparisonOperator op;
 
     @Before
     public void setUp() throws Exception {
@@ -49,6 +49,7 @@
         op = new PORegexp(new OperatorKey("", r.nextLong()));
         op.setLhs(lt);
         op.setRhs(rt);
+        op.setOperandType(DataType.CHARARRAY);
     }
 
     @Test
@@ -56,7 +57,7 @@
         lt.setValue(new String(
             "The quick sly fox jumped over the lazy brown dog"));
         rt.setValue(".*s.y.*");
-        Result res = op.getNext(new String());
+        Result res = op.getNext(new Boolean(true));
         assertEquals(POStatus.STATUS_OK, res.returnStatus);
         assertTrue((Boolean)res.result);
     }
@@ -66,7 +67,7 @@
         lt.setValue(new String(
             "The quick sly fox jumped over the lazy brown dog"));
         rt.setValue(new String("zzz"));
-        Result res = op.getNext(new String());
+        Result res = op.getNext(new Boolean(true));
         assertEquals(POStatus.STATUS_OK, res.returnStatus);
         assertFalse((Boolean)res.result);
     }

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/TestTypeCheckingValidator.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestTypeCheckingValidator.java?rev=673806&r1=673805&r2=673806&view=diff
==============================================================================
--- 
incubator/pig/branches/types/test/org/apache/pig/test/TestTypeCheckingValidator.java
 (original)
+++ 
incubator/pig/branches/types/test/org/apache/pig/test/TestTypeCheckingValidator.java
 Thu Jul  3 14:12:08 2008
@@ -654,7 +654,8 @@
         LOConst constant1 = new LOConst(plan, genNewOperatorKey(), 10) ;
         constant1.setType(DataType.CHARARRAY) ;
 
-        LORegexp regex = new LORegexp(plan, genNewOperatorKey(), constant1, 
"Regex") ;
+        LORegexp regex = new LORegexp(plan, genNewOperatorKey(), constant1,
+            new LOConst(plan, genNewOperatorKey(), "Regex")) ;
 
         plan.add(constant1) ;
         plan.add(regex) ;
@@ -680,7 +681,8 @@
         LOConst constant1 = new LOConst(plan, genNewOperatorKey(), 10) ;
         constant1.setType(DataType.BYTEARRAY) ;
 
-        LORegexp regex = new LORegexp(plan, genNewOperatorKey(), constant1, 
"Regex") ;
+        LORegexp regex = new LORegexp(plan, genNewOperatorKey(), constant1,
+            new LOConst(plan, genNewOperatorKey(), "Regex"));
 
         plan.add(constant1) ;
         plan.add(regex) ;
@@ -714,7 +716,8 @@
         LOConst constant1 = new LOConst(plan, genNewOperatorKey(), 10) ;
         constant1.setType(DataType.INTEGER) ;
 
-        LORegexp regex = new LORegexp(plan, genNewOperatorKey(), constant1, 
"Regex") ;
+        LORegexp regex = new LORegexp(plan, genNewOperatorKey(), constant1,
+            new LOConst(plan, genNewOperatorKey(), "Regex"));
 
         plan.add(constant1) ;
         plan.add(regex) ;

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java?rev=673806&r1=673805&r2=673806&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java 
Thu Jul  3 14:12:08 2008
@@ -25,6 +25,7 @@
 
 import org.apache.pig.backend.executionengine.ExecException;
 import org.apache.pig.builtin.BinStorage;
+import org.apache.pig.data.DataBag;
 import org.apache.pig.data.DataType;
 import org.apache.pig.data.Tuple;
 import org.apache.pig.impl.PigContext;
@@ -75,11 +76,39 @@
         return ret;
     }
 
+    public static GreaterThanExpr compGreaterThanExpr(
+            ExpressionOperator lhs,
+            ExpressionOperator rhs,
+            byte type) {
+        GreaterThanExpr ret = new GreaterThanExpr(new OperatorKey("", r
+                .nextLong()));
+        ret.setLhs(lhs);
+        ret.setRhs(rhs);
+        ret.setOperandType(type);
+        return ret;
+    }
+
+    public static POAnd compAndExpr(
+            ExpressionOperator lhs,
+            ExpressionOperator rhs) {
+        POAnd ret = new POAnd(new OperatorKey("", r
+                .nextLong()));
+        ret.setLhs(lhs);
+        ret.setRhs(rhs);
+        ret.setOperandType(DataType.BOOLEAN);
+        return ret;
+    }
+
     public static POProject exprProject() {
         POProject ret = new POProject(new OperatorKey("", r.nextLong()));
         return ret;
     }
 
+    public static POProject exprProject(int col) {
+        POProject ret = new POProject(new OperatorKey("", r.nextLong()), 1, 
col);
+        return ret;
+    }
+
     public static GTOrEqualToExpr compGTOrEqualToExpr() {
         GTOrEqualToExpr ret = new GTOrEqualToExpr(new OperatorKey("", r
                 .nextLong()));
@@ -91,6 +120,18 @@
         return ret;
     }
 
+    public static EqualToExpr compEqualToExpr(
+            ExpressionOperator lhs,
+            ExpressionOperator rhs,
+            byte type) {
+        EqualToExpr ret = new EqualToExpr(new OperatorKey("", r
+                .nextLong()));
+        ret.setLhs(lhs);
+        ret.setRhs(rhs);
+        ret.setOperandType(type);
+        return ret;
+    }
+
     public static NotEqualToExpr compNotEqualToExpr() {
         NotEqualToExpr ret = new NotEqualToExpr(new OperatorKey("", r
                 .nextLong()));
@@ -535,6 +576,13 @@
         POFilter ret = new POFilter(new OperatorKey("", r.nextLong()));
         return ret;
     }
+    
+    public static POFilter connectedFilterOp(PhysicalOperator input) {
+        List<PhysicalOperator> ops = new ArrayList<PhysicalOperator>(1);
+        ops.add(input);
+        POFilter ret = new POFilter(new OperatorKey("", r.nextLong()), ops);
+        return ret;
+    }
 
     public static POFilter topFilterOpWithExPlan(int lhsVal, int rhsVal)
             throws ExecException, PlanException {
@@ -688,6 +736,11 @@
         return ret;
     }
     
+    public static PORead topReadOp(DataBag bag) {
+        PORead ret = new PORead(new OperatorKey("", r.nextLong()), bag);
+        return ret;
+    }
+
     public static POStore topStoreOp() {
         POStore ret = new POStore(new OperatorKey("", r.nextLong()));
         ret.setPc(pc);


Reply via email to