Explorar o código

Merged revisions 1642 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r1642 | florian | 2005-11-04 22:05:18 +0100 (Fr, 04 Nov 2005) | 2 lines

+ binary operator support for booleans in variants

........

git-svn-id: branches/fixes_2_0@1643 -

florian %!s(int64=20) %!d(string=hai) anos
pai
achega
4ef64f39e6
Modificáronse 2 ficheiros con 39 adicións e 0 borrados
  1. 1 0
      .gitattributes
  2. 38 0
      tests/webtbs/tw4487.pp

+ 1 - 0
.gitattributes

@@ -6083,6 +6083,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.
+