⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loopbreaktest.groovy

📁 大名鼎鼎的java动态脚本语言。已经通过了sun的认证
💻 GROOVY
字号:
class LoopBreakTest extends GroovyTestCase {    void testWhileWithBreak() {        def x = 0        while (true) {            if (x == 5) {                break            }            ++x            assert x < 10 , "Should never get here"        }                println "worked: while completed with value ${x}"    }        /**      We currently do not support do ... while in the JSR syntax    void testDoWhileWithBreak() {        def x = 0        do {            //println "in do-while loop and x = ${x}"            if (x == 5) {                break            }            ++x            assert x < 10 , "Should never get here"        }        while (true)        println "worked: do-while completed with value ${x}"    }    */    void testForWithBreak() {        def returnValue        for (x in 0..20) {            if (x == 5) {                returnValue = x                break            }            assert x < 10 , "Should never get here"        }                println "worked: for loop completed with value ${returnValue}"    } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -