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

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

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

            AreEqual(10, values.DoubleVal(0), 0);
            AreEqual(10, values.FloatVal(0), 0);
            AreEqual(10, values.LongVal(0));
            AreEqual(10, values.IntVal(0));
            AreEqual(10, values.ShortVal(0));
            AreEqual(10, values.ByteVal(0));
            AreEqual("10", values.StrVal(0));
            AreEqual(System.Convert.ToDouble(10), values.ObjectVal(0));
            AreEqual(40, values.DoubleVal(1), 0);
            AreEqual(40, values.FloatVal(1), 0);
            AreEqual(40, values.LongVal(1));
            AreEqual(40, values.IntVal(1));
            AreEqual(40, values.ShortVal(1));
            AreEqual(40, values.ByteVal(1));
            AreEqual("40", values.StrVal(1));
            AreEqual(System.Convert.ToDouble(40), values.ObjectVal(1));
            AreEqual(4, values.DoubleVal(2), 0);
            AreEqual(4, values.FloatVal(2), 0);
            AreEqual(4, values.LongVal(2));
            AreEqual(4, values.IntVal(2));
            AreEqual(4, values.ShortVal(2));
            AreEqual(4, values.ByteVal(2));
            AreEqual("4", values.StrVal(2));
            AreEqual(System.Convert.ToDouble(4), values.ObjectVal(2));
        }
Ejemplo n.º 2
0
 public override short ShortVal(int doc)
 {
     return(ifVals.BoolVal(doc) ? trueVals.ShortVal(doc) : falseVals.ShortVal(doc));
 }
Ejemplo n.º 3
0
 public override void ShortVal(int doc, short[] vals)
 {
     vals[0] = x.ShortVal(doc);
     vals[1] = y.ShortVal(doc);
 }