[gcc r15-137] PR modula2/114929 extra for loop iteration count regression tests

Gaius Mulley gaius@gcc.gnu.org
Fri May 3 19:48:40 GMT 2024


https://gcc.gnu.org/g:c943d7b5c40f447b12431df9ad27a47dad95026d

commit r15-137-gc943d7b5c40f447b12431df9ad27a47dad95026d
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Fri May 3 20:48:01 2024 +0100

    PR modula2/114929 extra for loop iteration count regression tests
    
    This patch introduces three more for loop tests checking the iteration
    count using the CHAR and enumeration data types.
    
    gcc/testsuite/ChangeLog:
    
            PR modula2/114929
            * gm2/pim/run/pass/testforloopchar.mod: New test.
            * gm2/pim/run/pass/testforloopchar2.mod: New test.
            * gm2/pim/run/pass/testforloopenum.mod: New test.
    
    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

Diff:
---
 gcc/testsuite/gm2/pim/run/pass/testforloopchar.mod | 27 +++++++++++++++++++
 .../gm2/pim/run/pass/testforloopchar2.mod          | 27 +++++++++++++++++++
 gcc/testsuite/gm2/pim/run/pass/testforloopenum.mod | 30 ++++++++++++++++++++++
 3 files changed, 84 insertions(+)

diff --git a/gcc/testsuite/gm2/pim/run/pass/testforloopchar.mod b/gcc/testsuite/gm2/pim/run/pass/testforloopchar.mod
new file mode 100644
index 00000000000..be26ecb7149
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/run/pass/testforloopchar.mod
@@ -0,0 +1,27 @@
+MODULE testforloopchar ;
+
+FROM libc IMPORT printf, exit ;
+
+PROCEDURE test ;
+VAR
+   ch   : CHAR ;
+   count: CARDINAL ;
+BEGIN
+   count := 0 ;
+   FOR ch := 'a' TO 'z' DO
+      INC (count) ;
+      printf ("ch = %c, count = %d\n", ch, count)
+   END ;
+   IF count = 26
+   THEN
+      printf ("passed\n")
+   ELSE
+      printf ("failed\n") ;
+      exit (1)
+   END
+END test ;
+
+
+BEGIN
+   test
+END testforloopchar.
diff --git a/gcc/testsuite/gm2/pim/run/pass/testforloopchar2.mod b/gcc/testsuite/gm2/pim/run/pass/testforloopchar2.mod
new file mode 100644
index 00000000000..05478b2d5f2
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/run/pass/testforloopchar2.mod
@@ -0,0 +1,27 @@
+MODULE testforloopchar2 ;
+
+FROM libc IMPORT printf, exit ;
+
+PROCEDURE test ;
+VAR
+   ch   : CHAR ;
+   count: CARDINAL ;
+BEGIN
+   count := 0 ;
+   FOR ch := 'a' TO 'z' BY CHR (2) DO
+      INC (count) ;
+      printf ("ch = %c, count = %d\n", ch, count)
+   END ;
+   IF count = 13
+   THEN
+      printf ("passed\n")
+   ELSE
+      printf ("failed\n") ;
+      exit (1)
+   END
+END test ;
+
+
+BEGIN
+   test
+END testforloopchar2.
diff --git a/gcc/testsuite/gm2/pim/run/pass/testforloopenum.mod b/gcc/testsuite/gm2/pim/run/pass/testforloopenum.mod
new file mode 100644
index 00000000000..3855cae0012
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/run/pass/testforloopenum.mod
@@ -0,0 +1,30 @@
+MODULE testforloopenum ;
+
+FROM libc IMPORT printf, exit ;
+
+TYPE
+   colour = (red, green, blue, yellow) ;
+
+PROCEDURE test ;
+VAR
+   c    : colour ;
+   count: CARDINAL ;
+BEGIN
+   count := 0 ;
+   FOR c := red TO blue BY colour (2) DO
+      INC (count) ;
+      printf ("c = %d, count = %d\n", c, count)
+   END ;
+   IF count = 2
+   THEN
+      printf ("passed\n")
+   ELSE
+      printf ("failed\n") ;
+      exit (1)
+   END
+END test ;
+
+
+BEGIN
+   test
+END testforloopenum.


More information about the Gcc-cvs mailing list