Ejemplo n.º 1
0
        private FREObject RunArrayTests(FREContext ctx, uint argc, FREObject[] argv)
        {
            Trace("***********Start Array test***********");
            if (argc < 4)
            {
                return(new FreException("Not enough args").RawValue);
            }

            var airArray = new FREArray(argv[0]);
            var inFre1   = new FREArray(argv[1]);
            var inFre2   = new FREArray(argv[2]);
            var inFre3   = new FREArray(argv[3]);

            var airArrayList = airArray.AsArrayList();

            Trace("Convert FREArray to ArrayList :", airArrayList.Count, airArray.Length.Equals(6) ? "✅" : "❌");

            airArray.Push(77.ToFREObject(), 88);
            Trace("Get FREArray length after 2 appends:", airArray.Length, airArray.Length.Equals(8) ? "✅" : "❌");

            airArray[0] = 123.ToFREObject();
            foreach (var fre in airArray)
            {
                Trace("iterate over FREArray", fre.AsInt());
            }

            var airVectorString  = inFre1.AsStringArray();
            var airVectorNumber  = inFre2.AsDoubleArray();
            var airVectorBoolean = inFre3.AsBoolArray();

            Trace("Vector.<String> passed from AIR :",
                  string.Join(",", airVectorString.ToArray()),
                  string.Join(",", airVectorString.ToArray()).Equals("a,b,c,d") ? "✅" : "❌");

            Trace("Vector.<Number> passed from AIR :",
                  string.Join(",", airVectorNumber.ToArray()),
                  string.Join(",", airVectorNumber.ToArray()).Equals("1,0.5,2,3.3") ? "✅" : "❌");

            Trace("Vector.<Boolean> passed from AIR :",
                  string.Join(",", airVectorBoolean.ToArray()),
                  string.Join(",", airVectorBoolean.ToArray()).Equals("True,True,False,True") ? "✅" : "❌");

            var newFreArray = new FREArray("Object", 5, true);

            Trace("New FREArray of fixed length :", newFreArray.Length, newFreArray.Length.Equals(5) ? "✅" : "❌");

            airArray.Set(0, 56);
            var itemZero = airArray[0].AsInt();

            Trace("Set item 0 of FREArray:", itemZero, itemZero.Equals(56) ? "✅" : "❌");

            var marks = new[] { 99, 98, 92, 97, 95 };

            return(marks.ToFREObject());
        }
Ejemplo n.º 2
0
        private FREObject RunArrayTests(FREContext ctx, uint argc, FREObject[] argv)
        {
            Trace("***********Start Array test***********");
            if (argc < 4)
            {
                return(new FreException("Not enough args").RawValue);
            }

            var inFre0 = new FREArray(argv[0]);
            var inFre1 = new FREArray(argv[1]);
            var inFre2 = new FREArray(argv[2]);
            var inFre3 = new FREArray(argv[3]);

            var airArray    = inFre0.ToArrayList();
            var airArrayLen = inFre0.Length;

            inFre0[1] = 123.ToFREObject();
            foreach (var fre in inFre0)
            {
                Trace("iterate over FREArray", fre.AsInt());
            }

            var airVectorString  = inFre1.AsStringArray();
            var airVectorNumber  = inFre2.AsDoubleArray();
            var airVectorBoolean = inFre3.AsBoolArray();

            Trace("Array passed from AIR:", string.Join(",", airArray.ToArray()));
            Trace("AIR Array length:", airArrayLen);

            Trace("Vector.<String> passed from AIR:", string.Join(",", airVectorString.ToArray()));
            Trace("Vector.<Number> passed from AIR:", string.Join(",", airVectorNumber.ToArray()));
            Trace("Vector.<Boolean> passed from AIR:", string.Join(",", airVectorBoolean.ToArray()));

            var newFreArray = new FREArray("Object", 5, true);

            Trace("New Array of Objects should be 5?", newFreArray.Length);

            var itemZero    = inFre0[0];
            var itemZeroVal = itemZero.AsInt();

            Trace("AIR Array item 0 before change:", itemZeroVal);

            inFre0.Set(0, 56);

            var marks = new[] { 99, 98, 92, 97, 95 };

            return(marks.ToFREObject());
        }