Forráskód Böngészése

+ add tests for the adjusted message handling, especially one that checks that messages inside generics can be silenced correctly

Sven/Sarah Barth 7 hónapja
szülő
commit
70c153123b

+ 17 - 0
tests/tbs/tb0718.pp

@@ -0,0 +1,17 @@
+{ %NORUN }
+{ %EXPECTMSGS=5024 }
+{ %OPT=-vh }
+
+program tb0718;
+
+{$warn 5024 off}
+
+{$warn 5024 on}
+
+procedure Test(aArg: LongInt);
+begin
+end;
+
+begin
+  Test(42);
+end.

+ 27 - 0
tests/tbs/tb0719.pp

@@ -0,0 +1,27 @@
+{ %NORUN }
+{ %EXPECTMSGS=5024 }
+{ %OPT=-vh }
+
+program tb0718;
+
+{$warn 5024 on}
+
+{$push}
+{$warn 5024 off}
+
+procedure Test(aArg: LongInt);
+begin
+  { message 5024 should be hidden for this }
+end;
+
+{$pop}
+
+procedure Test2(aArg: LongInt);
+begin
+  { message 5024 should be visible for this }
+end;
+
+begin
+  Test(42);
+  Test2(42);
+end.

+ 35 - 0
tests/test/tgeneric119.pp

@@ -0,0 +1,35 @@
+{ %NORUN }
+
+program tgeneric119;
+
+{$mode objfpc}
+{$warn 5024 error}
+{$warn 5036 error}
+
+type
+  generic TTest<T> = class
+    procedure Test(aArg: T);
+  end;
+
+{$push}
+{$warn 5024 off}
+procedure TTest.Test(aArg: T);
+var
+  v: LongInt;
+begin
+  {$push}
+  {$warn 5036 off}
+  Writeln(v);
+  {$pop}
+end;
+{$pop}
+
+type
+  TTestLongInt = specialize TTest<LongInt>;
+
+var
+  t: TTestLongInt;
+begin
+  t := TTestLongInt.Create;
+  t.Free;
+end.

+ 30 - 0
tests/test/tgeneric120.pp

@@ -0,0 +1,30 @@
+{ %NORUN }
+{ %OPT=-Sew }
+
+program tgeneric120;
+
+{$mode objfpc}
+
+type
+  generic TTest<T> = class
+    constructor Create; virtual;
+  end;
+
+  {$warn 3018 off}
+
+  generic TTestSub<T> = class(specialize TTest<T>)
+  protected
+    constructor Create; override;
+  end;
+
+constructor TTest.Create;
+begin
+end;
+
+constructor TTestSub.Create;
+begin
+end;
+
+begin
+
+end.

+ 37 - 0
tests/test/tgeneric121.pp

@@ -0,0 +1,37 @@
+{ %NORUN }
+{ %OPT=-Sew }
+
+program tgeneric121;
+
+{$mode objfpc}
+
+type
+  generic TTest<T> = class
+    constructor Create; virtual;
+  end;
+
+  {$push}
+  {$warn 3018 off}
+
+  generic TTestSub<T> = class(specialize TTest<T>)
+  protected
+    constructor Create; override;
+  end;
+
+  {$pop}
+
+  generic TTestSub2<T> = class(specialize TTestSub<T>)
+
+  end;
+
+constructor TTest.Create;
+begin
+end;
+
+constructor TTestSub.Create;
+begin
+end;
+
+begin
+
+end.