ReportFromForeach
  globals [glob1]
  to-report foo foreach (list 1 2 3) [ set glob1 glob1 + ? if (? = 2) [ report "done" ] ] end
  foo => "done"
  glob1 => 3

StopFromDynamicallyNestedRepeat
  to p1 repeat 5 [ crt 1 p2 crt 1 ] end
  to p2 repeat 2 [ stop error "oops 1" ] error "oops 2" end
  O> p1
  count turtles => 10

ReportFromDynamicallyNestedForeach
  globals [glob1]
  to p1 repeat 5 [ crt 1 set glob1 p2 ] end
  to-report p2 foreach [1 2 3] [ report 9 error "oops 1" ] error "oops 2" end
  O> p1
  count turtles => 5
  glob1 => 9

StopFromForeach1
  globals [glob1]
  O> foreach [1 2 3 4] [ set glob1 glob1 + ?  if ? = 3 [ stop ] ] error "oops"
  glob1 => 6

StopFromForeach2
  globals [glob1]
  to test foreach [1 2 3] [ if ? = 2 [ stop ] set glob1 glob1 + ? ] end
  O> test
  glob1 => 1

StopFromForeach3
  globals [glob1]
  to test1 test2 test2 end
  to test2 foreach [1 2 3 4 5] [ set glob1 glob1 + ? stop ] end
  O> test1
  glob1 => 2

StopFromForeachInsideReporterProcedure
  to-report foo foreach [1 2 3] [ stop ] end
  O> __ignore foo => ERROR STOP is not allowed inside TO-REPORT.

StopFromNestedForeachInsideReporterProcedure
  to-report foo foreach [1 2] [ foreach [3 4] [ stop ] ] end
  O> __ignore foo => ERROR STOP is not allowed inside TO-REPORT.

StopTask1
  globals [glob1 glob2]
  O> set glob1 task [ stop ]
  to foo foreach [1 2] [ foreach [3 4] [ set glob2 5 run glob1 error "1" ] error "2" ] error "3" end
  O> foo
  glob2 => 5

#StopInsideWithoutInterruption1
#  to go crt 1 [ foo ] end
#  to foo without-interruption [ stop ] end
#  O> go
#
#StopInsideWithoutInterruption2
#  to go crt 1 [ foo set glob1 glob1 + 1 ] set glob1 glob1 + 2 end
#  to foo without-interruption [ set glob1 glob1 + 4 stop set glob1 glob1 + 8 ] set glob1 glob1 + 16 end
#  O> set glob1 0 go
#  glob1 => 7
#
#StopInsideWithoutInterruption3
#  to go ask patch 0 0 [ foo set glob1 glob1 + 1 ] set glob1 glob1 + 2 end
#  to foo without-interruption [ set glob1 glob1 + 4 stop set glob1 glob1 + 8 ] set glob1 glob1 + 16 end
#  O> set glob1 0 go
#  glob1 => 7

StopInsideAsk1
  to go crt 1 ask turtles [ stop hatch 10 ] crt 1 end
  O> go
  count turtles => 2

StopInsideAsk2
  to-report foo crt 1 ask turtles [ stop hatch 10 ] report count turtles end
  foo => 1

StopInsideRunOfCommandTask
  globals [glob1]
  to test let x task [ set glob1 1 stop ] run x set glob1 2 end
  O> test set glob1 glob1 * 10
  glob1 => 10

FallOffEndOfReporterProcedure
  to-report foo1 report 0 end
  to-report foo2 end
  foo1 => 0
  foo2 => ERROR Reached end of reporter procedure without REPORT being called.

Bug86-1
  to setup ca go1 go2 end
  to go1 stop end
  to go2 foreach [0] [ ifelse true [] [] ] end
  O> setup

Bug86-2
  globals [glob1]
  to setup ca go1 go2 end
  to go1 stop end
  to go2 foreach [0] [ ifelse true [ set glob1 5 ] [] ] end
  O> setup
  glob1 => 5

Bug86-3
  globals [glob1]
  to setup ca go1 go2 end
  to go1 stop end
  to go2 foreach [0] [ set glob1 5 ] end
  O> setup
  glob1 => 5
