浏览代码

* added test that already works (mantis #33205)

git-svn-id: trunk@38729 -
Jonas Maebe 7 年之前
父节点
当前提交
2eeda5d06f
共有 2 个文件被更改,包括 79 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 78 0
      tests/webtbs/tw33205.pp

+ 1 - 0
.gitattributes

@@ -16083,6 +16083,7 @@ tests/webtbs/tw33098.pp svneol=native#text/pascal
 tests/webtbs/tw33167.pp svneol=native#text/pascal
 tests/webtbs/tw3320.pp svneol=native#text/plain
 tests/webtbs/tw33202.pp svneol=native#text/pascal
+tests/webtbs/tw33205.pp -text svneol=native#text/plain
 tests/webtbs/tw33222.pp svneol=native#text/pascal
 tests/webtbs/tw33230.pp svneol=native#text/pascal
 tests/webtbs/tw3324.pp svneol=native#text/plain

+ 78 - 0
tests/webtbs/tw33205.pp

@@ -0,0 +1,78 @@
+program BugFPC;
+
+{$IFDEF FPC}
+{$MODE DELPHI}
+{$ENDIF FPC}
+
+uses
+  SysUtils;
+
+type
+  TBug = record
+
+  strict private
+
+    class constructor Bugger();
+
+  public
+  var
+    a: Int32;
+    st: string;
+    arr: TBytes;
+
+    class var
+
+      skim: TBug;
+
+    constructor Create(b: Int32);
+
+  end;
+
+  { TBug }
+
+class constructor TBug.Bugger;
+begin
+  skim := Default (TBug);
+  skim.a := 5;
+  skim.st := 'fish';
+  skim.arr := TBytes.Create(1, 2, 3);
+
+  Writeln(skim.a); // should be 5
+  Writeln(skim.st); // should be 'fish'
+  Writeln(Length(skim.arr)); // should be 3
+  if skim.a<>5 then
+    halt(1);
+  if skim.st<>'fish' then
+    halt(2);
+  if length(skim.arr)<>3 then
+    halt(3);
+end;
+
+constructor TBug.Create(b: Int32);
+var
+  temp: TBug;
+begin
+  temp := skim;
+  Writeln(temp.a); // should be 5
+  Writeln(temp.st); // should be 'fish' but got ''
+  Writeln(Length(skim.arr)); // should be 3 but got 0
+  if skim.a<>5 then
+    halt(4);
+  if skim.st<>'fish' then
+    halt(5);
+  if length(skim.arr)<>3 then
+    halt(6);
+end;
+
+begin
+  try
+    TBug.Create(9);
+  except
+    on E: Exception do
+      begin
+        Writeln(E.ClassName, ': ', E.Message);
+        halt(7);
+      end;
+  end;
+
+end.