Browse Source

+ binary operator support for booleans in variants

git-svn-id: trunk@1642 -
florian 20 years ago
parent
commit
c1e968abf9
2 changed files with 39 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 38 0
      tests/webtbs/tw4487.pp

+ 1 - 0
.gitattributes

@@ -6347,6 +6347,7 @@ tests/webtbs/tw4398.pp svneol=native#text/plain
 tests/webtbs/tw4427.pp svneol=native#text/plain
 tests/webtbs/tw4428.pp svneol=native#text/plain
 tests/webtbs/tw4450.pp svneol=native#text/plain
+tests/webtbs/tw4487.pp -text svneol=unset#text/plain
 tests/webtbs/tw4489.pp -text svneol=unset#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain

+ 38 - 0
tests/webtbs/tw4487.pp

@@ -0,0 +1,38 @@
+{ Source provided for Free Pascal Bug Report 4487 }
+{ Submitted by "Phil H." on  2005-11-02 }
+{ e-mail: [email protected] }
+program TestVarBug;
+
+{$IFDEF FPC}
+{$mode objfpc}
+uses
+  Variants;
+{$ENDIF}
+
+type
+  TMyClass = class
+  private
+    function GetValue(AsInt : Boolean) : Variant;
+  public
+    property Value[AsInt : Boolean] : Variant read GetValue;
+  end;
+  
+function TMyClass.GetValue(AsInt : Boolean) : Variant;
+begin
+  if AsInt then
+    Result := 1
+  else
+    Result := True;
+end;
+
+var
+  AClass : TMyClass;  
+begin
+  AClass := TMyClass.Create;
+  if (AClass.Value[True] = 1) and
+     AClass.Value[False] then  //Throws exception with FPC (requires "= True")
+    WriteLn('Value is True')
+  else
+    WriteLn('Value is False');
+end.
+