// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage


shader
test ()
{
     printf ("Testing break: (should never let i get beyond 3)\n");
     for (int i = 0;  i < 10; ++i) {
         if (i > 3)
             break;
         printf ("  i = %d\n", i);
	 }
  	 printf ("\nTesting continue:\n");
     for (int i = 0;  i < 10;  ++i) {
   	     printf ("  i = %d\n", i);
   	     if (i > 3)
              continue;
         printf ("  should only print this if i <= 3.\n");
     }

     printf ("\nTesting nested break/continue:\n");
     for (int j = 0;  j < 10;  ++j) {
         printf ("start of outer, j=%d\n", j);
         for (int i = 0;  i < 10; ++i) {
             if (i == 1)
                 continue;
             printf ("  i = %d\n", i);
             if (i > 3)
                 break;
         }
         if (j > 2) {
             break;
         }
     }
     printf ("\nTesting break in an infinite for loop:\n");
     for ( ; ; ) {
	     break;
     }
     printf ("worked\n");
}
