Jonas Maebe 23 years ago
parent
commit
d4b7f1e371
2 changed files with 82 additions and 0 deletions
  1. 24 0
      tests/webtbs/tw2031.pp
  2. 58 0
      tests/webtbs/tw2059.pp

+ 24 - 0
tests/webtbs/tw2031.pp

@@ -0,0 +1,24 @@
+program settest;
+const
+  size = 31;
+var
+  testset : set of 0..size;
+  i : integer;
+begin
+  testset := [];
+  testset := testset + [0,1,2,3,4];
+  if testset <> [0,1,2,3,4] then
+    begin
+      writeln('add wrong');
+      halt(1);
+    end;
+  testset := testset - [2];
+  if testset <> [0,1,3,4] then
+    begin
+      writeln('sub wrong');
+      halt(1);
+    end;
+end.
+
+
+

+ 58 - 0
tests/webtbs/tw2059.pp

@@ -0,0 +1,58 @@
+{$mode tp}
+type ProcType    = procedure(s:string);
+     GetProcType = function(s:string;var Proc:ProcType):boolean;
+
+var  ProcVar    : ProcType;
+     GetProcVar : GetProcType;
+
+procedure Default(s:string);
+
+begin
+  writeln('This is Default:',s);
+end;
+
+procedure Proc1(s:string);
+
+begin
+  writeln('This is Proc1:',s);
+end;
+
+procedure Proc2(s:string);
+
+begin
+  writeln('This is Proc2:',s);
+end;
+
+function GetProc(s:string;var ProcVar:ProcType):boolean;
+
+begin
+  if s='Proc1' then begin
+    ProcVar:=Proc1;
+    GetProc:=true;
+  end
+  else
+    if s='Proc2' then begin
+      ProcVar:=Proc2;
+      GetProc:=true;
+    end
+    else begin
+      ProcVar:=Default;
+      GetProc:=false;
+    end;
+end;
+
+begin
+  GetProcVar:=GetProc;
+  if GetProcVar('Proc1',ProcVar) then
+    ProcVar('ok')
+  else
+    halt(1);
+  if GetProcVar('Proc2',ProcVar) then
+    ProcVar('ok')
+  else
+    halt(1);
+  if GetProcVar('xyz',ProcVar) then
+    halt(1)
+  else 
+   writeln('ok');
+end.