]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR modula2/114929 extra for loop iteration count regression tests
authorGaius Mulley <gaiusmod2@gmail.com>
Fri, 3 May 2024 19:48:01 +0000 (20:48 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Fri, 3 May 2024 19:48:01 +0000 (20:48 +0100)
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>
gcc/testsuite/gm2/pim/run/pass/testforloopchar.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/run/pass/testforloopchar2.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/run/pass/testforloopenum.mod [new file with mode: 0644]

diff --git a/gcc/testsuite/gm2/pim/run/pass/testforloopchar.mod b/gcc/testsuite/gm2/pim/run/pass/testforloopchar.mod
new file mode 100644 (file)
index 0000000..be26ecb
--- /dev/null
@@ -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 (file)
index 0000000..05478b2
--- /dev/null
@@ -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 (file)
index 0000000..3855cae
--- /dev/null
@@ -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.