X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=tests%2Flanguage%2Fcontrol%2Floop.at;h=d8ed2878854904b97ddfacde469bbb9ed479486d;hb=a44be3bb9fe2d6744d9948f056788e2277bd354d;hp=af8d8aecf03d1745beba2a0851dd48d8dd9de49c;hpb=cd36f412b771fe2d88d2c3d9a9809f288afa38ca;p=pspp diff --git a/tests/language/control/loop.at b/tests/language/control/loop.at index af8d8aecf0..d8ed287885 100644 --- a/tests/language/control/loop.at +++ b/tests/language/control/loop.at @@ -1,3 +1,19 @@ +dnl PSPP - a program for statistical analysis. +dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl AT_BANNER([LOOP]) m4_define([LOOP_DATA], [dnl @@ -22,25 +38,15 @@ execute. AT_CHECK([pspp -o pspp.csv loop.sps]) AT_CHECK([cat pspp.csv], [0], [dnl 1.00 @&t@ - 2.00 @&t@ - -------- - 2.00 @&t@ - 4.00 @&t@ - -------- - 3.00 @&t@ - 6.00 @&t@ - 9.00 @&t@ - -------- - -------- ]) AT_CLEANUP @@ -59,25 +65,15 @@ execute. AT_CHECK([pspp -o pspp.csv loop.sps]) AT_CHECK([cat pspp.csv], [0], [dnl 1.00 @&t@ - 2.00 @&t@ - -------- - 2.00 @&t@ - 4.00 @&t@ - -------- - 3.00 @&t@ - 6.00 @&t@ - 9.00 @&t@ - -------- - -------- ]) AT_CLEANUP @@ -96,27 +92,16 @@ execute. AT_CHECK([pspp -o pspp.csv loop.sps]) AT_CHECK([cat pspp.csv], [0], [dnl 1.00 @&t@ - 2.00 @&t@ - -------- - 2.00 @&t@ - 4.00 @&t@ - -------- - 3.00 @&t@ - 6.00 @&t@ - 9.00 @&t@ - -------- - 4.00 @&t@ - -------- ]) AT_CLEANUP @@ -133,19 +118,12 @@ execute. AT_CHECK([pspp -o pspp.csv loop.sps]) AT_CHECK([cat pspp.csv], [0], [dnl 1.00 @&t@ - 2.00 @&t@ - -------- - 2.00 @&t@ - -------- - 3.00 @&t@ - -------- - -------- ]) AT_CLEANUP @@ -162,23 +140,14 @@ execute. AT_CHECK([pspp -o pspp.csv loop.sps]) AT_CHECK([cat pspp.csv], [0], [dnl 1.00 @&t@ - 2.00 @&t@ - -------- - 2.00 @&t@ - 4.00 @&t@ - -------- - 3.00 @&t@ - 6.00 @&t@ - -------- - -------- ]) AT_CLEANUP @@ -195,23 +164,17 @@ execute. AT_CHECK([pspp -o pspp.csv loop.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -------- - 2.00 @&t@ - 4.00 @&t@ - -------- - -------- - -------- ]) AT_CLEANUP -AT_SETUP([LOOP with no conditions]) +AT_SETUP([LOOP with no conditions containing BREAK]) AT_DATA([loop.sps], [dnl LOOP_DATA -set mxloops = 2. compute #p = x. loop. print /#p. @@ -226,23 +189,153 @@ execute. AT_CHECK([pspp -o pspp.csv loop.sps]) AT_CHECK([cat pspp.csv], [0], [dnl 1.00 @&t@ - -------- - 2.00 @&t@ - 4.00 @&t@ - -------- - 3.00 @&t@ - 6.00 @&t@ - -------- - 4.00 @&t@ +-------- +]) +AT_CLEANUP +AT_SETUP([LOOP with no conditions that ends due to MXLOOPS]) +AT_DATA([loop.sps], [dnl +LOOP_DATA +set mxloops=2. +loop. +compute #p = #p + 1. +print /x #p. +end loop. +print/'--------'. +execute. +]) +AT_CHECK([pspp -o pspp.csv loop.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +1 1.00 @&t@ +1 2.00 @&t@ +-------- +2 3.00 @&t@ +2 4.00 @&t@ +-------- +3 5.00 @&t@ +3 6.00 @&t@ +-------- +4 7.00 @&t@ +4 8.00 @&t@ -------- ]) AT_CLEANUP + +AT_SETUP([LOOP with IF condition that ends due to MXLOOPS]) +AT_DATA([loop.sps], [dnl +LOOP_DATA +set mxloops=3. +compute #p = x. +loop. +print /x #p. +compute #p = #p + 1. +end loop if #p >= 6. +print/'--------'. +execute. +]) +AT_CHECK([pspp -o pspp.csv loop.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +1 1.00 @&t@ +1 2.00 @&t@ +1 3.00 @&t@ +-------- +2 2.00 @&t@ +2 3.00 @&t@ +2 4.00 @&t@ +-------- +3 3.00 @&t@ +3 4.00 @&t@ +3 5.00 @&t@ +-------- +4 4.00 @&t@ +4 5.00 @&t@ +-------- +]) +AT_CLEANUP + +AT_SETUP([LOOP negative]) +AT_DATA([loop.sps], [dnl +DATA LIST NOTABLE /x 1. +BREAK. +END LOOP. + +LOOP A=1 TO 5 B=1 TO 5. +END LOOP. +LOOP 5. +END LOOP. +LOOP B !. +END LOOP. +LOOP B=!. +END LOOP. +LOOP A=1 TO !. +END LOOP. +LOOP A=1 BY !. +END LOOP. +LOOP A=1 TO 5 BY 5 TO !. +END LOOP. +LOOP A=1 BY 5 TO 10 BY !. +END LOOP. +LOOP A=1. +END LOOP. +LOOP !. +END LOOP. + +LOOP IF 1 IF 0. +END LOOP. + +LOOP IF !. +END LOOP. + +LOOP. +END LOOP IF !. + +LOOP. +END LOOP !. + +LOOP. +]) +AT_CHECK([pspp loop.sps], 1, [dnl +loop.sps:2: error: BREAK: This command cannot appear outside LOOP...END LOOP. + +loop.sps:3: error: END LOOP: This command cannot appear outside LOOP...END +LOOP. + +loop.sps:5: error: LOOP: Only one index clause may be specified. + +loop.sps:7.6: error: LOOP: Syntax error at `5'. + +loop.sps:9.8: error: LOOP: Syntax error at `!': expecting `='. + +loop.sps:11.8: error: LOOP: Syntax error at `!'. + +loop.sps:13.13: error: LOOP: Syntax error at `!'. + +loop.sps:15.13: error: LOOP: Syntax error at `!'. + +loop.sps:17: error: LOOP: Subcommand TO may only be specified once. + +loop.sps:19: error: LOOP: Subcommand BY may only be specified once. + +loop.sps:21: error: LOOP: Required subcommand TO was not specified. + +loop.sps:23.6: error: LOOP: Syntax error at `!'. + +loop.sps:26: error: LOOP: Subcommand IF may only be specified once. + +loop.sps:29.9: error: LOOP: Syntax error at `!'. + +loop.sps:33.13: error: LOOP: Syntax error at `!'. + +loop.sps:36.10: error: LOOP: Syntax error at `!': expecting end of command. + +error: LOOP: Syntax error at end of input. +]) +AT_CLEANUP \ No newline at end of file