Exemplo n.º 1
0
        public virtual void TestTypes()
        {
            Expression     expr     = JavascriptCompiler.Compile("2*popularity");
            SimpleBindings bindings = new SimpleBindings();

            bindings.Add(new SortField("popularity", SortFieldType.INT64));
            ValueSource vs = expr.GetValueSource(bindings);

            Assert.AreEqual(1, reader.Leaves.Count);
            AtomicReaderContext leaf   = reader.Leaves[0];
            FunctionValues      values = vs.GetValues(new Dictionary <string, object>(), leaf);

            Assert.AreEqual(10, values.DoubleVal(0), 0);
            Assert.AreEqual(10, values.SingleVal(0), 0);
            Assert.AreEqual(10, values.Int64Val(0));
            Assert.AreEqual(10, values.Int32Val(0));
            Assert.AreEqual(10, values.Int16Val(0));
            Assert.AreEqual((byte)10, values.ByteVal(0));
            Assert.AreEqual("10.0", values.StrVal(0));
            Assert.AreEqual(J2N.Numerics.Double.GetInstance(10), values.ObjectVal(0));

            Assert.AreEqual(40, values.DoubleVal(1), 0);
            Assert.AreEqual(40, values.SingleVal(1), 0);
            Assert.AreEqual(40, values.Int64Val(1));
            Assert.AreEqual(40, values.Int32Val(1));
            Assert.AreEqual(40, values.Int16Val(1));
            Assert.AreEqual((byte)40, values.ByteVal(1));
            Assert.AreEqual("40.0", values.StrVal(1));
            Assert.AreEqual(J2N.Numerics.Double.GetInstance(40), values.ObjectVal(1));

            Assert.AreEqual(4, values.DoubleVal(2), 0);
            Assert.AreEqual(4, values.SingleVal(2), 0);
            Assert.AreEqual(4, values.Int64Val(2));
            Assert.AreEqual(4, values.Int32Val(2));
            Assert.AreEqual(4, values.Int16Val(2));
            Assert.AreEqual((byte)4, values.ByteVal(2));
            Assert.AreEqual("4.0", values.StrVal(2));
            Assert.AreEqual(J2N.Numerics.Double.GetInstance(4), values.ObjectVal(2));
        }
Exemplo n.º 2
0
 /// <summary>
 /// NOTE: This was shortVal() in Lucene
 /// </summary>
 public override short Int16Val(int doc)
 {
     return(ifVals.BoolVal(doc) ? trueVals.Int16Val(doc) : falseVals.Int16Val(doc));
 }
Exemplo n.º 3
0
 /// <summary>
 /// NOTE: This was shortVal() in Lucene
 /// </summary>
 public override void Int16Val(int doc, short[] vals)
 {
     vals[0] = x.Int16Val(doc);
     vals[1] = y.Int16Val(doc);
 }