Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Loops-Wrong-ranges/Seed7/loops-wrong-ranges.seed7
Normal file
37
Task/Loops-Wrong-ranges/Seed7/loops-wrong-ranges.seed7
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const proc: testLoop (in integer: start, in integer: stop, in integer: incr, in string: comment) is func
|
||||
local
|
||||
const integer: limit is 10;
|
||||
var integer: number is 0;
|
||||
var integer: count is 0;
|
||||
begin
|
||||
writeln(comment);
|
||||
write("Range(" <& start <& ", " <& stop <& ", " <& incr <& ") -> [ ");
|
||||
block
|
||||
for number range start to stop step incr do
|
||||
write(number <& " ");
|
||||
incr(count);
|
||||
if count >= limit then
|
||||
raise RANGE_ERROR;
|
||||
end if;
|
||||
end for;
|
||||
exception
|
||||
catch RANGE_ERROR: noop;
|
||||
end block;
|
||||
writeln("]");
|
||||
writeln;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
testLoop(-2, 2, 1, "Normal");
|
||||
testLoop(-2, 2, 0, "Zero increment");
|
||||
testLoop(-2, 2, -1, "Increments away from stop value");
|
||||
testLoop(-2, 2, 10, "First increment is beyond stop value");
|
||||
testLoop( 2, -2, 1, "Start more than stop: positive increment");
|
||||
testLoop( 2, 2, 1, "Start equal stop: positive increment");
|
||||
testLoop( 2, 2, -1, "Start equal stop: negative increment");
|
||||
testLoop( 2, 2, 0, "Start equal stop: zero increment");
|
||||
testLoop( 0, 0, 0, "Start equal stop equal zero: zero increment");
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue