private static void CreteArrayTest(DWSProgramContext context, DWSValue[] agrs) { try { var v = context.CreateTypedValue("TIntArray"); var array = new DWSArray(v); array.Resize(10); //var ival = context.CreateTypedValue("Integer"); //ival.Value = 14; //array.Set("2", ival); array[0] = 12; } catch { } }
public void DynamicArray_TestStringArrayLength() { context.DefineType(new DWSArrayDefinition("TStringArray", "String")); var action = new DWSMethodDefinition("Test", (x, a) => { var array = new DWSArray(a[0]); int length = 0; Assert.DoesNotThrow(() => length = array.Length); Assert.AreEqual(3, length); }); action.Args.Add(new DWSParameterDefinition("a", "TStringArray")); context.DefineMethod(action); context.EvaluateScript("Test(['a', 'b', 'c']);"); Assert.IsNull(this.LastErrorMessage); GC.KeepAlive(action); }
public void DynamicArray_TestStringArrayElements() { context.DefineType(new DWSArrayDefinition("TStringArray", "String")); var action = new DWSMethodDefinition("Test", (x, a) => { var array = new DWSArray(a[0]); Assert.AreEqual("a", array[0]); Assert.AreEqual("b", array[1]); Assert.AreEqual("c", array[2]); }); action.Args.Add(new DWSParameterDefinition("a", "TStringArray")); context.DefineMethod(action); context.EvaluateScript("Test(['a', 'b', 'c']);"); Assert.IsNull(this.LastErrorMessage); GC.KeepAlive(action); }