diff --git a/Source/dwsCompiler.pas b/Source/dwsCompiler.pas index ba50462a..260af509 100644 --- a/Source/dwsCompiler.pas +++ b/Source/dwsCompiler.pas @@ -7968,9 +7968,12 @@ function TdwsCompiler.ReadArrayMethod(const name : String; const namePos : TScri CheckDynamicOrStatic; indexOfClass := TArrayIndexOfExpr.ArrayIndexOfExprClass(arraySym); if CheckArguments(1, 2) then begin - if (argList[0].Typ=nil) or not arraySym.Typ.IsCompatible(argList[0].Typ) then - IncompatibleTypes(argPosArray[0], CPE_IncompatibleParameterTypes, - arraySym.Typ, argList[0].Typ); + if (argList[0].Typ=nil) or not arraySym.Typ.IsCompatible(argList[0].Typ) then begin +// IncompatibleTypes(argPosArray[0], CPE_IncompatibleParameterTypes, +// arraySym.Typ, argList[0].Typ); + argList[0] := CompilerUtils.WrapWithImplicitConversion(FCompilerContext, argList[0], arraySym.Typ, + argPosArray[0], CPE_IncompatibleParameterTypes); + end; if argList.Count>1 then begin if (argList[1].Typ=nil) or not argList[1].Typ.IsOfType(FCompilerContext.TypInteger) then FMsgs.AddCompilerError(argPosArray[0], CPE_IntegerExpressionExpected); @@ -8085,6 +8088,8 @@ function TdwsCompiler.ReadArrayMethod(const name : String; const namePos : TScri Result:=TArraySortNaturalIntegerExpr.Create(FCompilerContext, namePos, baseExpr) else if arraySym.Typ.IsOfType(FCompilerContext.TypFloat) then Result:=TArraySortNaturalFloatExpr.Create(FCompilerContext, namePos, baseExpr) + else if arraySym.Typ.IsOfType(FCompilerContext.TypBoolean) then + Result:=TArraySortNaturalExpr.Create(FCompilerContext, namePos, baseExpr) else begin FMsgs.AddCompilerError(namePos, CPE_ArrayDoesNotHaveNaturalSortOrder); Result:=TArraySortNaturalExpr.Create(FCompilerContext, namePos, baseExpr); diff --git a/Source/dwsDynamicArrays.pas b/Source/dwsDynamicArrays.pas index cfd51aa2..12a88910 100644 --- a/Source/dwsDynamicArrays.pas +++ b/Source/dwsDynamicArrays.pas @@ -135,7 +135,7 @@ TScriptDynamicNativeArray = class abstract (TInterfacedSelfObject) function GetArrayLength : Integer; public - constructor Create(elemTyp : TTypeSymbol); + constructor Create(elemTyp : TTypeSymbol); virtual; function ToString : String; override; @@ -325,8 +325,67 @@ TScriptDynamicNativeStringArray = class (TScriptDynamicNativeArray, IScriptDy procedure WriteToJSON(writer : TdwsJSONWriter); end; - TScriptDynamicBooleanArray = class (TScriptDynamicValueArray) + TScriptDynamicNativeBooleanArray = class (TScriptDynamicNativeArray, IScriptDynArray, IJSONWriteAble) + protected + FBits : TBits; + public + constructor Create(elemTyp : TTypeSymbol); override; + destructor Destroy; override; + + procedure SetArrayLength(n : Integer); + + function ToStringArray : TStringDynArray; + function ToInt64Array : TInt64DynArray; + function ToData : TData; + + procedure Insert(index : Integer); + procedure Delete(index, count : Integer); + procedure MoveItem(source, destination : Integer); + procedure Swap(index1, index2 : Integer); + + function IndexOfValue(const item : Variant; fromIndex : Integer) : Integer; + function IndexOfInteger(item : Int64; fromIndex : Integer) : Integer; + function IndexOfFloat(item : Double; fromIndex : Integer) : Integer; + function IndexOfString(const item : String; fromIndex : Integer) : Integer; + function IndexOfFuncPtr(const item : Variant; fromIndex : Integer) : Integer; + + procedure WriteData(const src : TData; srcAddr, size : Integer); + procedure ReplaceData(const v : TData); + procedure Concat(const src : IScriptDynArray; index, size : Integer); + + procedure Reverse; + function Compare(index1, index2 : Integer) : Integer; + procedure NaturalSort; + + procedure AddStrings(sl : TStrings); + + function AsPDouble(var nbElements, stride : Integer) : PDouble; + + function GetAsFloat(index : Integer) : Double; + procedure SetAsFloat(index : Integer; const v : Double); + + function GetAsInteger(index : Integer) : Int64; + procedure SetAsInteger(index : Integer; const v : Int64); + + function GetAsBoolean(index : Integer) : Boolean; + procedure SetAsBoolean(index : Integer; const v : Boolean); + + procedure SetAsVariant(index : Integer; const v : Variant); + procedure EvalAsVariant(index : Integer; var result : Variant); + + procedure SetAsString(index : Integer; const v : String); + procedure EvalAsString(index : Integer; var result : String); + + procedure SetAsInterface(index : Integer; const v : IUnknown); + procedure EvalAsInterface(index : Integer; var result : IUnknown); + + function IsEmpty(addr : Integer) : Boolean; + function VarType(addr : Integer) : TVarType; + + function HashCode(addr : Integer; size : Integer) : Cardinal; + + procedure WriteToJSON(writer : TdwsJSONWriter); end; function CreateNewDynamicArray(elemTyp : TTypeSymbol) : IScriptDynArray; @@ -391,7 +450,7 @@ function CreateNewDynamicArray(elemTyp : TTypeSymbol) : IScriptDynArray; else if elemTypClass = TBaseIntegerSymbol then Result := TScriptDynamicNativeIntegerArray.Create(elemTyp) else if elemTypClass = TBaseBooleanSymbol then - Result := TScriptDynamicBooleanArray.Create(elemTyp) + Result := TScriptDynamicNativeBooleanArray.Create(elemTyp) else Result := TScriptDynamicValueArray.Create(elemTyp) end else Result := TScriptDynamicDataArray.Create(elemTyp); end; @@ -1162,7 +1221,7 @@ procedure TScriptDynamicNativeIntegerArray.NaturalSort; // procedure TScriptDynamicNativeIntegerArray.AddStrings(sl : TStrings); begin - DynamicArrayAddStrings(self, sl); + DynamicArrayAddStrings(Self, sl); end; // AsPDouble @@ -2006,4 +2065,388 @@ procedure TScriptDynamicNativeStringArray.WriteToJSON(writer : TdwsJSONWriter); writer.EndArray; end; +// ------------------ +// ------------------ TScriptDynamicNativeBooleanArray ------------------ +// ------------------ + +// Create +// +constructor TScriptDynamicNativeBooleanArray.Create(elemTyp : TTypeSymbol); +begin + inherited Create(elemTyp); + FBits := TBits.Create; +end; + +// Destroy +// +destructor TScriptDynamicNativeBooleanArray.Destroy; +begin + inherited; + FBits.Free; +end; + +// SetArrayLength +// +procedure TScriptDynamicNativeBooleanArray.SetArrayLength(n : Integer); +begin + FBits.Size := n; + FArrayLength := n; +end; + +// ToStringArray +// +function TScriptDynamicNativeBooleanArray.ToStringArray : TStringDynArray; +var + i : Integer; +begin + SetLength(Result, FArrayLength); + for i := 0 to FArrayLength-1 do + if FBits[i] then + Result[i] := 'True' + else Result[i] := 'False'; +end; + +// ToInt64Array +// +function TScriptDynamicNativeBooleanArray.ToInt64Array : TInt64DynArray; +var + i : Integer; +begin + SetLength(Result, FArrayLength); + for i := 0 to FArrayLength-1 do + Result[i] := Ord(FBits[i]); +end; + +// ToData +// +function TScriptDynamicNativeBooleanArray.ToData : TData; +var + i : Integer; +begin + SetLength(Result, FArrayLength); + for i := 0 to FArrayLength-1 do + VarCopySafe(Result[i], FBits[i]); +end; + +// Insert +// +procedure TScriptDynamicNativeBooleanArray.Insert(index : Integer); +var + i : Integer; +begin + SetArrayLength(FArrayLength + 1); + for i := FArrayLength-1 downto index+1 do + FBits[i] := FBits[i-1]; + FBits[index] := False; +end; + +// Delete +// +procedure TScriptDynamicNativeBooleanArray.Delete(index, count : Integer); +var + i : Integer; +begin + for i := index to FArrayLength-count-1 do + FBits[i] := FBits[i+count]; + SetArrayLength(FArrayLength - count); +end; + +// MoveItem +// +procedure TScriptDynamicNativeBooleanArray.MoveItem(source, destination : Integer); +var + buf : Boolean; + i : Integer; +begin + if source = destination then Exit; + + buf := FBits[source]; + + if source < destination then begin + for i := source to destination-1 do + FBits[i] := FBits[i+1]; + end else begin + for i := source downto destination+1 do + FBits[i] := FBits[i-1]; + end; + FBits[destination] := buf; +end; + +// Swap +// +procedure TScriptDynamicNativeBooleanArray.Swap(index1, index2 : Integer); +var + buf : Boolean; +begin + buf := FBits[index1]; + FBits[index1] := FBits[index2]; + FBits[index2] := buf; +end; + +// IndexOfValue +// +function TScriptDynamicNativeBooleanArray.IndexOfValue(const item : Variant; fromIndex : Integer) : Integer; +begin + Result := IndexOfInteger(VariantToInt64(item), fromIndex); +end; + +// IndexOfInteger +// +function TScriptDynamicNativeBooleanArray.IndexOfInteger(item : Int64; fromIndex : Integer) : Integer; +var + i : Integer; + v : Boolean; +begin + v := (item <> 0); + for i := fromIndex to FArrayLength-1 do + if FBits[i] = v then + Exit(i); + Result := -1; +end; + +// IndexOfFloat +// +function TScriptDynamicNativeBooleanArray.IndexOfFloat(item : Double; fromIndex : Integer) : Integer; +begin + Result := IndexOfInteger(Ord(item <> 0), fromIndex); +end; + +// IndexOfString +// +function TScriptDynamicNativeBooleanArray.IndexOfString(const item : String; fromIndex : Integer) : Integer; +begin + Result := IndexOfInteger(Ord(StringToBoolean(item)), fromIndex); +end; + +// IndexOfFuncPtr +// +function TScriptDynamicNativeBooleanArray.IndexOfFuncPtr(const item : Variant; fromIndex : Integer) : Integer; +begin + Result := -1; +end; + +// WriteData +// +procedure TScriptDynamicNativeBooleanArray.WriteData(const src : TData; srcAddr, size : Integer); +var + i : Integer; +begin + for i := 0 to size-1 do + FBits[i] := VariantToBool(src[i + srcAddr]); +end; + +// ReplaceData +// +procedure TScriptDynamicNativeBooleanArray.ReplaceData(const v : TData); +begin + SetArrayLength(Length(v)); + WriteData(v, 0, FArrayLength); +end; + +// Concat +// +procedure TScriptDynamicNativeBooleanArray.Concat(const src : IScriptDynArray; index, size : Integer); +var + srcSelf : TObject; + srcDyn : TScriptDynamicNativeBooleanArray; + i, n : Integer; +begin + srcSelf := src.GetSelf; + Assert(srcSelf.ClassType = TScriptDynamicNativeBooleanArray); + Assert(index >= 0); + + srcDyn := TScriptDynamicNativeBooleanArray(srcSelf); + if size > srcDyn.ArrayLength - index then + size := srcDyn.ArrayLength - index; + if size > 0 then begin + n := FArrayLength; + SetArrayLength(n + size); + for i := 0 to size-1 do + FBits[n + i] := srcDyn.FBits[index + i]; + end; +end; + +// Reverse +// +procedure TScriptDynamicNativeBooleanArray.Reverse; +var + i, j : Integer; + buf : Boolean; +begin + i := 0; + j := FArrayLength-1; + while i < j do begin + buf := FBits[i]; + FBits[i] := FBits[j]; + FBits[j] := buf; + Inc(i); + Dec(j); + end; +end; + +// Compare +// +function TScriptDynamicNativeBooleanArray.Compare(index1, index2 : Integer) : Integer; +begin + Result := Ord(FBits[index1]) - Ord(FBits[index2]); +end; + +// NaturalSort +// +procedure TScriptDynamicNativeBooleanArray.NaturalSort; +var + i, j : Integer; +begin + j := FArrayLength; + for i := 0 to FArrayLength-1 do begin + if FBits[i] then begin + Dec(j); + if i < j then + FBits[i] := False; + end; + end; + for i := j to FArrayLength-1 do + FBits[i] := True; +end; + +// AddStrings +// +procedure TScriptDynamicNativeBooleanArray.AddStrings(sl : TStrings); +begin + DynamicArrayAddStrings(Self, sl); +end; + +// AsPDouble +// +function TScriptDynamicNativeBooleanArray.AsPDouble(var nbElements, stride : Integer) : PDouble; +begin + Assert(False); + Result := nil; +end; + +// GetAsFloat +// +function TScriptDynamicNativeBooleanArray.GetAsFloat(index : Integer) : Double; +begin + Result := Ord(FBits[index]); +end; + +// SetAsFloat +// +procedure TScriptDynamicNativeBooleanArray.SetAsFloat(index : Integer; const v : Double); +begin + FBits[index] := (v <> 0); +end; + +// GetAsInteger +// +function TScriptDynamicNativeBooleanArray.GetAsInteger(index : Integer) : Int64; +begin + Result := Ord(FBits[index]); +end; + +// SetAsInteger +// +procedure TScriptDynamicNativeBooleanArray.SetAsInteger(index : Integer; const v : Int64); +begin + FBits[index] := (v <> 0); +end; + +// GetAsBoolean +// +function TScriptDynamicNativeBooleanArray.GetAsBoolean(index : Integer) : Boolean; +begin + Result := FBits[index]; +end; + +// SetAsBoolean +// +procedure TScriptDynamicNativeBooleanArray.SetAsBoolean(index : Integer; const v : Boolean); +begin + FBits[index] := v; +end; + +// SetAsVariant +// +procedure TScriptDynamicNativeBooleanArray.SetAsVariant(index : Integer; const v : Variant); +begin + FBits[index] := VariantToBool(v); +end; + +// EvalAsVariant +// +procedure TScriptDynamicNativeBooleanArray.EvalAsVariant(index : Integer; var result : Variant); +begin + VarCopySafe(result, FBits[index]); +end; + +// SetAsString +// +procedure TScriptDynamicNativeBooleanArray.SetAsString(index : Integer; const v : String); +begin + FBits[index] := StringToBoolean(v); +end; + +// EvalAsString +// +procedure TScriptDynamicNativeBooleanArray.EvalAsString(index : Integer; var result : String); +begin + if FBits[index] then + result := 'True' + else result := 'False'; +end; + +// SetAsInterface +// +procedure TScriptDynamicNativeBooleanArray.SetAsInterface(index : Integer; const v : IUnknown); +begin + Assert(False); +end; + +// EvalAsInterface +// +procedure TScriptDynamicNativeBooleanArray.EvalAsInterface(index : Integer; var result : IUnknown); +begin + Assert(False); +end; + +// IsEmpty +// +function TScriptDynamicNativeBooleanArray.IsEmpty(addr : Integer) : Boolean; +begin + Result := False; +end; + +// VarType +// +function TScriptDynamicNativeBooleanArray.VarType(addr : Integer) : TVarType; +begin + Result := varBoolean; +end; + +// HashCode +// +function TScriptDynamicNativeBooleanArray.HashCode(addr : Integer; size : Integer) : Cardinal; +var + i : Integer; +begin + Result := cFNV_basis; + for i := 0 to FArrayLength-1 do + Result := (Result xor SimpleIntegerHash(Ord(FBits[i]))) * cFNV_prime; + if Result = 0 then + Result := cFNV_basis; +end; + +// WriteToJSON +// +procedure TScriptDynamicNativeBooleanArray.WriteToJSON(writer : TdwsJSONWriter); +var + i : Integer; +begin + writer.BeginArray; + for i := 0 to FArrayLength-1 do + writer.WriteBoolean(FBits[i]); + writer.EndArray; +end; + end. diff --git a/Test/FailureScripts/array_sort.pas b/Test/FailureScripts/array_sort.pas index 9ed26e75..182353d3 100644 --- a/Test/FailureScripts/array_sort.pas +++ b/Test/FailureScripts/array_sort.pas @@ -4,8 +4,6 @@ TRec = record end; var ab : array of Boolean; -ab.Sort; - ab.Sort(1, 2, 3); var ar : array of TRec; diff --git a/Test/FailureScripts/array_sort.txt b/Test/FailureScripts/array_sort.txt index 65a46d93..f69a8d47 100644 --- a/Test/FailureScripts/array_sort.txt +++ b/Test/FailureScripts/array_sort.txt @@ -1,8 +1,7 @@ -Syntax Error: Array does not have a natural sort order [line: 7, column: 4] -Syntax Error: Too many arguments [line: 9, column: 16] -Syntax Error: Array does not have a natural sort order [line: 12, column: 4] -Syntax Error: More arguments expected [line: 14, column: 10] -Syntax Error: Incompatible types: "function (record TRec, record TRec): Integer" and "function CompareStr(String, String): Integer" [line: 14, column: 9] -Syntax Error: Incompatible parameter types - "function (record TRec, record TRec): Integer" expected (instead of "nil") [line: 14, column: 9] -Syntax Error: More arguments expected [line: 15, column: 9] -Syntax Error: Incompatible parameter types - "function (record TRec, record TRec): Integer" expected (instead of "Integer") [line: 15, column: 9] +Syntax Error: Too many arguments [line: 7, column: 16] +Syntax Error: Array does not have a natural sort order [line: 10, column: 4] +Syntax Error: More arguments expected [line: 12, column: 10] +Syntax Error: Incompatible types: "function (record TRec, record TRec): Integer" and "function CompareStr(String, String): Integer" [line: 12, column: 9] +Syntax Error: Incompatible parameter types - "function (record TRec, record TRec): Integer" expected (instead of "nil") [line: 12, column: 9] +Syntax Error: More arguments expected [line: 13, column: 9] +Syntax Error: Incompatible parameter types - "function (record TRec, record TRec): Integer" expected (instead of "Integer") [line: 13, column: 9] diff --git a/Test/JSONConnectorPass/stringify_array_of_float.pas b/Test/JSONConnectorPass/stringify_array_of_float.pas new file mode 100644 index 00000000..94529360 --- /dev/null +++ b/Test/JSONConnectorPass/stringify_array_of_float.pas @@ -0,0 +1,11 @@ +var a: array of Float; + +PrintLn(JSON.Stringify(a)); + +a.Add(123.5); + +PrintLn(JSON.Stringify(a)); + +a.Insert(0, 456.5); + +PrintLn(JSON.Stringify(a)); \ No newline at end of file diff --git a/Test/JSONConnectorPass/stringify_array_of_float.txt b/Test/JSONConnectorPass/stringify_array_of_float.txt new file mode 100644 index 00000000..23f219b7 --- /dev/null +++ b/Test/JSONConnectorPass/stringify_array_of_float.txt @@ -0,0 +1,3 @@ +[] +[123.5] +[456.5,123.5] \ No newline at end of file diff --git a/Test/JSONConnectorPass/stringify_array_of_integer.pas b/Test/JSONConnectorPass/stringify_array_of_integer.pas new file mode 100644 index 00000000..40a3a572 --- /dev/null +++ b/Test/JSONConnectorPass/stringify_array_of_integer.pas @@ -0,0 +1,11 @@ +var a: array of Integer; + +PrintLn(JSON.Stringify(a)); + +a.Add(123); + +PrintLn(JSON.Stringify(a)); + +a.Insert(0, 456); + +PrintLn(JSON.Stringify(a)); \ No newline at end of file diff --git a/Test/JSONConnectorPass/stringify_array_of_integer.txt b/Test/JSONConnectorPass/stringify_array_of_integer.txt new file mode 100644 index 00000000..5d72fa78 --- /dev/null +++ b/Test/JSONConnectorPass/stringify_array_of_integer.txt @@ -0,0 +1,3 @@ +[] +[123] +[456,123] \ No newline at end of file diff --git a/Test/SimpleScripts/array_of_boolean.pas b/Test/SimpleScripts/array_of_boolean.pas new file mode 100644 index 00000000..85de7f72 --- /dev/null +++ b/Test/SimpleScripts/array_of_boolean.pas @@ -0,0 +1,39 @@ +var a : array of Boolean; + + +a.Add(True, False); + +a.Move(0, 1); +PrintLn(a.Map(BoolToStr).Join(',')); + +a.Move(1, 0); +PrintLn(a.Map(BoolToStr).Join(',')); + +a.Insert(1, True); + +a.Move(0, 2); +PrintLn(a.Map(BoolToStr).Join(',')); + +a.Move(2, 0); +PrintLn(a.Map(BoolToStr).Join(',')); + +PrintLn(a.IndexOf(False)); +PrintLn(a.IndexOf(True)); + +a.Reverse; +PrintLn(a.Map(BoolToStr).Join(',')); + +a.Add(a); +PrintLn(a.Map(BoolToStr).Join(',')); + +a.Swap(0, 1); +PrintLn(a.Map(BoolToStr).Join(',')); + +a.Delete(0, 3); +PrintLn(a.Map(BoolToStr).Join(',')); +a.Delete(1); +PrintLn(a.Map(BoolToStr).Join(',')); + +a.Add(False); +a.Sort; +PrintLn(a.Map(BoolToStr).Join(',')); \ No newline at end of file diff --git a/Test/SimpleScripts/array_of_boolean.txt b/Test/SimpleScripts/array_of_boolean.txt new file mode 100644 index 00000000..17667028 --- /dev/null +++ b/Test/SimpleScripts/array_of_boolean.txt @@ -0,0 +1,12 @@ +False,True +True,False +True,False,True +True,True,False +2 +0 +False,True,True +False,True,True,False,True,True +True,False,True,False,True,True +False,True,True +False,True +False,False,True \ No newline at end of file diff --git a/Test/SimpleScripts/array_of_float.pas b/Test/SimpleScripts/array_of_float.pas new file mode 100644 index 00000000..4a77c983 --- /dev/null +++ b/Test/SimpleScripts/array_of_float.pas @@ -0,0 +1,27 @@ +var a : array of Float; + + +a.Add(1.5, 2.5); + +a.Move(0, 1); +PrintLn(a.Map(FloatToStr).Join(',')); + +a.Move(1, 0); +PrintLn(a.Map(FloatToStr).Join(',')); + +a.Add(3.5); + +a.Move(0, 2); +PrintLn(a.Map(FloatToStr).Join(',')); + +a.Move(2, 0); +PrintLn(a.Map(FloatToStr).Join(',')); + +PrintLn(a.IndexOf(4)); +PrintLn(a.IndexOf(2.5)); + +a.Reverse; +PrintLn(a.Map(FloatToStr).Join(',')); + +a.Add(a); +PrintLn(a.Map(FloatToStr).Join(',')); \ No newline at end of file diff --git a/Test/SimpleScripts/array_of_float.txt b/Test/SimpleScripts/array_of_float.txt new file mode 100644 index 00000000..80780e73 --- /dev/null +++ b/Test/SimpleScripts/array_of_float.txt @@ -0,0 +1,8 @@ +2.5,1.5 +1.5,2.5 +2.5,3.5,1.5 +1.5,2.5,3.5 +-1 +1 +3.5,2.5,1.5 +3.5,2.5,1.5,3.5,2.5,1.5 diff --git a/Test/SimpleScripts/array_of_integer.pas b/Test/SimpleScripts/array_of_integer.pas new file mode 100644 index 00000000..72a5499d --- /dev/null +++ b/Test/SimpleScripts/array_of_integer.pas @@ -0,0 +1,21 @@ +var a : array of Integer; + + +a.Add(1, 2); + +a.Move(0, 1); +PrintLn(a.Map(IntToStr).Join(',')); + +a.Move(1, 0); +PrintLn(a.Map(IntToStr).Join(',')); + +a.Add(3); + +a.Move(0, 2); +PrintLn(a.Map(IntToStr).Join(',')); + +a.Move(2, 0); +PrintLn(a.Map(IntToStr).Join(',')); + +PrintLn(a.IndexOf(4)); +PrintLn(a.IndexOf(2)); diff --git a/Test/SimpleScripts/array_of_integer.txt b/Test/SimpleScripts/array_of_integer.txt new file mode 100644 index 00000000..9c4ba0bd --- /dev/null +++ b/Test/SimpleScripts/array_of_integer.txt @@ -0,0 +1,6 @@ +2,1 +1,2 +2,3,1 +1,2,3 +-1 +1 \ No newline at end of file diff --git a/Test/SimpleScripts/array_of_string.pas b/Test/SimpleScripts/array_of_string.pas new file mode 100644 index 00000000..a0f75dea --- /dev/null +++ b/Test/SimpleScripts/array_of_string.pas @@ -0,0 +1,27 @@ +var a : array of String; + + +a.Add('hello', 'world'); + +a.Move(0, 1); +PrintLn(a.Join(',')); + +a.Move(1, 0); +PrintLn(a.Join(',')); + +a.Insert(1, 'foo'); + +a.Move(0, 2); +PrintLn(a.Join(',')); + +a.Move(2, 0); +PrintLn(a.Join(',')); + +PrintLn(a.IndexOf('bar')); +PrintLn(a.IndexOf('foo')); + +a.Reverse; +PrintLn(a.Join(',')); + +a.Add(a); +PrintLn(a.Join(',')); \ No newline at end of file diff --git a/Test/SimpleScripts/array_of_string.txt b/Test/SimpleScripts/array_of_string.txt new file mode 100644 index 00000000..b488092b --- /dev/null +++ b/Test/SimpleScripts/array_of_string.txt @@ -0,0 +1,8 @@ +world,hello +hello,world +foo,world,hello +hello,foo,world +-1 +1 +world,foo,hello +world,foo,hello,world,foo,hello