Browse Source

* also test passing enums to formal parameter types

git-svn-id: branches/jvmbackend@18812 -
Jonas Maebe 14 years ago
parent
commit
c07c633b6a
1 changed files with 33 additions and 1 deletions
  1. 33 1
      tests/test/jvm/tformalpara.pp

+ 33 - 1
tests/test/jvm/tformalpara.pp

@@ -32,7 +32,7 @@ begin
 end;
 end;
 
 
 type
 type
-  tformalkind = (fboolean,fbyte,fsmallint,fcardinal,fint64,fchar,fwidechar,fsingle,fdouble,fsetint,fsetenum,frec,fshortstring,funicodestring,farrbyte,farrset);
+  tformalkind = (fboolean,fbyte,fsmallint,fcardinal,fint64,fchar,fwidechar,fsingle,fdouble,fsetint,fsetenum,frec,fshortstring,funicodestring,farrbyte,farrset,fenum);
 
 
   tsetint = set of 30..40;
   tsetint = set of 30..40;
   tsetenum = set of tformalkind;
   tsetenum = set of tformalkind;
@@ -60,6 +60,7 @@ const
   cunicodestringin: unicodestring = 'a bit longer!';
   cunicodestringin: unicodestring = 'a bit longer!';
   carrbytein: tarrbyte = (4,2,5);
   carrbytein: tarrbyte = (4,2,5);
   carrsetin: tarrset = ([31,33,37],[]);
   carrsetin: tarrset = ([31,33,37],[]);
+  cenumin: tformalkind = fsmallint;
   
   
   cbooleanout: boolean = false;
   cbooleanout: boolean = false;
   cbyteout: byte = 128;
   cbyteout: byte = 128;
@@ -77,6 +78,7 @@ const
   cunicodestringout: unicodestring = 'yet another bit longer!';
   cunicodestringout: unicodestring = 'yet another bit longer!';
   carrbyteout: tarrbyte = (6,6,6);
   carrbyteout: tarrbyte = (6,6,6);
   carrsetout: tarrset = ([30,31],[33..38]);
   carrsetout: tarrset = ([30,31],[33..38]);
+  cenumout: tformalkind = farrbyte;
 
 
 procedure testformalvar(var x; typ: tformalkind);
 procedure testformalvar(var x; typ: tformalkind);
   var
   var
@@ -185,6 +187,12 @@ procedure testformalvar(var x; typ: tformalkind);
               raise jlexception.create('arrset in');
               raise jlexception.create('arrset in');
           x:=carrsetout;
           x:=carrsetout;
         end;
         end;
+      fenum:
+        begin
+          if cenumin<>tformalkind(x) then
+            raise jlexception.create('enum in');
+          x:=cenumout;
+        end;
     end;
     end;
   end;
   end;
 
 
@@ -267,6 +275,10 @@ procedure testformalout(out x; typ: tformalkind);
         begin
         begin
           x:=carrsetout;
           x:=carrsetout;
         end;
         end;
+      fenum:
+        begin
+          x:=cenumout;
+        end;
     end;
     end;
   end;
   end;
 
 
@@ -362,6 +374,11 @@ procedure testformalconst(const x; typ: tformalkind);
             if carrsetin[i]<>tarrset(x)[i] then
             if carrsetin[i]<>tarrset(x)[i] then
               raise jlexception.create('const arrset in');
               raise jlexception.create('const arrset in');
         end;
         end;
+      fenum:
+        begin
+          if cenumin<>tformalkind(x) then
+            raise jlexception.create('const enum in');
+        end;
     end;
     end;
   end;
   end;
 
 
@@ -384,6 +401,7 @@ procedure testformalvars;
     vunicodestring: unicodestring;
     vunicodestring: unicodestring;
     varrbyte: tarrbyte;
     varrbyte: tarrbyte;
     varrset: tarrset;
     varrset: tarrset;
+    venum: tformalkind;
     i: longint;
     i: longint;
   begin
   begin
     vboolean:=cbooleanin;
     vboolean:=cbooleanin;
@@ -464,6 +482,10 @@ procedure testformalvars;
     for i:=low(carrsetout) to high(carrsetout) do
     for i:=low(carrsetout) to high(carrsetout) do
       if varrset[i]<>carrsetout[i] then
       if varrset[i]<>carrsetout[i] then
         raise jlexception.create('arrset out');
         raise jlexception.create('arrset out');
+    venum:=cenumin;
+    testformalvar(venum,fenum);
+    if venum<>cenumout then
+      raise jlexception.create('enum out');
   end;
   end;
 
 
 
 
@@ -485,6 +507,7 @@ procedure testformalouts;
     vunicodestring: unicodestring;
     vunicodestring: unicodestring;
     varrbyte: tarrbyte;
     varrbyte: tarrbyte;
     varrset: tarrset;
     varrset: tarrset;
+    venum: tformalkind;
     i: longint;
     i: longint;
   begin
   begin
     vboolean:=cbooleanin;
     vboolean:=cbooleanin;
@@ -565,6 +588,10 @@ procedure testformalouts;
     for i:=low(carrsetout) to high(carrsetout) do
     for i:=low(carrsetout) to high(carrsetout) do
       if varrset[i]<>carrsetout[i] then
       if varrset[i]<>carrsetout[i] then
         raise jlexception.create('out arrset out');
         raise jlexception.create('out arrset out');
+    venum:=cenumin;
+    testformalout(venum,fenum);
+    if venum<>cenumout then
+      raise jlexception.create('out enum out');
   end;
   end;
 
 
 
 
@@ -586,6 +613,7 @@ procedure testformalconsts;
     vunicodestring: unicodestring;
     vunicodestring: unicodestring;
     varrbyte: tarrbyte;
     varrbyte: tarrbyte;
     varrset: tarrset;
     varrset: tarrset;
+    venum: tformalkind;
     i: longint;
     i: longint;
   begin
   begin
     vboolean:=cbooleanin;
     vboolean:=cbooleanin;
@@ -666,6 +694,10 @@ procedure testformalconsts;
     for i:=low(carrsetin) to high(carrsetin) do
     for i:=low(carrsetin) to high(carrsetin) do
       if varrset[i]<>carrsetin[i] then
       if varrset[i]<>carrsetin[i] then
         raise jlexception.create('const arrset out');
         raise jlexception.create('const arrset out');
+    venum:=cenumin;
+    testformalconst(venum,fenum);
+    if venum<>cenumin then
+      raise jlexception.create('const enum out');
   end;
   end;