mksh/tests/brkcont.t
tg a34b05d2e6 Import OpenBSD 3.3 source repository from CTM 3132 the first time
This opens an OpenBSD-mirabile (aka MirBSD) repository.

### MirBSD is:
# Copyright (c) 1982-2003 by Thorsten "mirabile" Glaser <x86@ePost.de>
# Copyright © 1968-2003  The authors of And contributors to UNIX®, the
#       C Language, BSD/Berkeley Unix; 386BSD, NetBSD 1.1 and OpenBSD.
#
# Anyone who obtained a copy of this work is hereby permitted to freely use,
# distribute, modify, merge, sublicence, give away or sell it as long as the
# authors are given due credit and the following notice is retained:
#
# This work is provided "as is", with no explicit or implicit warranty what-
# soever. Use it only at your own risk. In no event may an author or contri-
# butor be held liable for any damage, directly or indirectly, that origina-
# ted through or is caused by creation or modification of this work.

MirBSD is my private tree. MirBSD does not differ very much from OpenBSD
and intentionally tracks OpenBSD. That's why it _is_ OpenBSD, just not the
official one. It's like with DarrenBSD.

At time of this writing, no advertising for MirBSD must be done,
because the advertising clause has not yet been sorted out.

http://templeofhate.com/tglaser/MirBSD/index.php
2003-03-22 17:35:03 +00:00

196 lines
2.7 KiB
Raku

name: break-1
description:
See if break breaks out of loops
stdin:
for i in a b c; do echo $i; break; echo bad-$i; done
echo end-1
for i in a b c; do echo $i; break 1; echo bad-$i; done
echo end-2
for i in a b c; do
for j in x y z; do
echo $i:$j
break
echo bad-$i
done
echo end-$i
done
echo end-3
expected-stdout:
a
end-1
a
end-2
a:x
end-a
b:x
end-b
c:x
end-c
end-3
---
name: break-2
description:
See if break breaks out of nested loops
stdin:
for i in a b c; do
for j in x y z; do
echo $i:$j
break 2
echo bad-$i
done
echo end-$i
done
echo end
expected-stdout:
a:x
end
---
name: break-3
description:
What if break used outside of any loops
(ksh88,ksh93 don't print error messages here)
stdin:
break
expected-stderr-pattern:
/.*break.*/
---
name: break-4
description:
What if break N used when only N-1 loops
(ksh88,ksh93 don't print error messages here)
stdin:
for i in a b c; do echo $i; break 2; echo bad-$i; done
echo end
expected-stdout:
a
end
expected-stderr-pattern:
/.*break.*/
---
name: break-5
description:
Error if break argument isn't a number
stdin:
for i in a b c; do echo $i; break abc; echo more-$i; done
echo end
expected-stdout:
a
expected-exit: e != 0
expected-stderr-pattern:
/.*break.*/
---
name: continue-1
description:
See if continue continues loops
stdin:
for i in a b c; do echo $i; continue; echo bad-$i ; done
echo end-1
for i in a b c; do echo $i; continue 1; echo bad-$i; done
echo end-2
for i in a b c; do
for j in x y z; do
echo $i:$j
continue
echo bad-$i-$j
done
echo end-$i
done
echo end-3
expected-stdout:
a
b
c
end-1
a
b
c
end-2
a:x
a:y
a:z
end-a
b:x
b:y
b:z
end-b
c:x
c:y
c:z
end-c
end-3
---
name: continue-2
description:
See if continue breaks out of nested loops
stdin:
for i in a b c; do
for j in x y z; do
echo $i:$j
continue 2
echo bad-$i-$j
done
echo end-$i
done
echo end
expected-stdout:
a:x
b:x
c:x
end
---
name: continue-3
description:
What if continue used outside of any loops
(ksh88,ksh93 don't print error messages here)
stdin:
continue
expected-stderr-pattern:
/.*continue.*/
---
name: continue-4
description:
What if continue N used when only N-1 loops
(ksh88,ksh93 don't print error messages here)
stdin:
for i in a b c; do echo $i; continue 2; echo bad-$i; done
echo end
expected-stdout:
a
b
c
end
expected-stderr-pattern:
/.*continue.*/
---
name: continue-5
description:
Error if continue argument isn't a number
stdin:
for i in a b c; do echo $i; continue abc; echo more-$i; done
echo end
expected-stdout:
a
expected-exit: e != 0
expected-stderr-pattern:
/.*continue.*/
---