Browse Source

Commit r35010 also fixed Mantis #30524.
+ added tests

git-svn-id: trunk@35011 -

svenbarth 8 years ago
parent
commit
bfaa26d16a
3 changed files with 85 additions and 0 deletions
  1. 2 0
      .gitattributes
  2. 42 0
      tests/webtbs/tw30524a.pp
  3. 41 0
      tests/webtbs/tw30524b.pp

+ 2 - 0
.gitattributes

@@ -15247,6 +15247,8 @@ tests/webtbs/tw30443.pp svneol=native#text/plain
 tests/webtbs/tw3045.pp svneol=native#text/plain
 tests/webtbs/tw3045.pp svneol=native#text/plain
 tests/webtbs/tw3048.pp svneol=native#text/plain
 tests/webtbs/tw3048.pp svneol=native#text/plain
 tests/webtbs/tw30522.pp svneol=native#text/plain
 tests/webtbs/tw30522.pp svneol=native#text/plain
+tests/webtbs/tw30524a.pp svneol=native#text/pascal
+tests/webtbs/tw30524b.pp svneol=native#text/pascal
 tests/webtbs/tw30530.pp svneol=native#text/pascal
 tests/webtbs/tw30530.pp svneol=native#text/pascal
 tests/webtbs/tw30534.pp svneol=native#text/pascal
 tests/webtbs/tw30534.pp svneol=native#text/pascal
 tests/webtbs/tw30537.pp svneol=native#text/pascal
 tests/webtbs/tw30537.pp svneol=native#text/pascal

+ 42 - 0
tests/webtbs/tw30524a.pp

@@ -0,0 +1,42 @@
+{ %NORUN }
+
+program tw30524a;
+
+{$ifdef FPC}
+{$MODE DELPHI}
+{$endif}
+
+{uses
+  Generics.Defaults;}
+
+type
+  Tuple<T> = record
+    Item1: T;
+    class operator Equal( a, b: Tuple<T> ): Boolean; // FPC Error: Compilation raised exception internally
+    class operator NotEqual( a, b: Tuple<T> ): Boolean;
+  end;
+
+  Tuple = record
+    class function Create<T>( Item1: T ): Tuple<T>; overload; static;
+  end;
+
+class function Tuple.Create<T>( Item1: T ): Tuple<T>;
+begin
+  Result.Item1 := Item1;
+end;
+
+class operator Tuple<T>.Equal( a, b: Tuple<T> ): Boolean;
+begin
+  Result := False;//TEqualityComparer<T>.Default.Equals( a.Item1, b.Item1 );
+end;
+
+class operator Tuple<T>.NotEqual( a, b: Tuple<T> ): Boolean;
+begin
+  Result := not( a = b );
+end;
+
+var
+  t: Tuple<LongInt>;
+begin
+  t := Tuple.Create<LongInt>(42);
+end.

+ 41 - 0
tests/webtbs/tw30524b.pp

@@ -0,0 +1,41 @@
+{ %NORUN }
+
+program tw30524b;
+
+{$MODE objfpc}
+{$modeswitch advancedrecords}
+
+{uses
+  Generics.Defaults;}
+
+type
+  generic Tuple<T> = record
+    Item1: T;
+    class operator =( a, b: specialize Tuple<T> ): Boolean; // FPC Error: Compilation raised exception internally
+    class operator <>( a, b: specialize Tuple<T> ): Boolean;
+  end;
+
+  TTuple = record
+    generic class function Create<T>( Item1: T ): specialize Tuple<T>; overload; static;
+  end;
+
+generic class function TTuple.Create<T>( Item1: T ): specialize Tuple<T>;
+begin
+  Result.Item1 := Item1;
+end;
+
+class operator Tuple.=( a, b: specialize Tuple<T> ): Boolean;
+begin
+  Result := False;//TEqualityComparer<T>.Default.Equals( a.Item1, b.Item1 );
+end;
+
+class operator Tuple.<>( a, b: specialize Tuple<T> ): Boolean;
+begin
+  Result := not( a = b );
+end;
+
+var
+  t: specialize Tuple<LongInt>;
+begin
+  t := TTuple.specialize Create<LongInt>(42);
+end.