Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 46f78717f -> c34a4a11f
Add one more test for break statement (cherry picked from commit 39fda7f) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c34a4a11 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c34a4a11 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c34a4a11 Branch: refs/heads/GROOVY_2_6_X Commit: c34a4a11fa82faea2a50954e54047813a588c120 Parents: 46f7871 Author: sunlan <sun...@apache.org> Authored: Fri Jan 26 08:47:19 2018 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Jan 26 08:47:53 2018 +0800 ---------------------------------------------------------------------- .../parser/antlr4/GroovyParserTest.groovy | 4 +++ .../src/test/resources/core/Break_01.groovy | 37 ++++++++++++++++++++ 2 files changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/c34a4a11/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy ---------------------------------------------------------------------- diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy index 330b030..d43fbe0 100644 --- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy +++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy @@ -273,6 +273,10 @@ class GroovyParserTest extends GroovyTestCase { doTest('core/Synchronized_01.groovy') } + void "test groovy core - Break"() { + doTest('core/Break_01.groovy') + } + void "test groovy core - Return"() { doTest('core/Return_01.groovy') } http://git-wip-us.apache.org/repos/asf/groovy/blob/c34a4a11/subprojects/parser-antlr4/src/test/resources/core/Break_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/parser-antlr4/src/test/resources/core/Break_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Break_01.groovy new file mode 100644 index 0000000..29b98b2 --- /dev/null +++ b/subprojects/parser-antlr4/src/test/resources/core/Break_01.groovy @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +while (true) { + if (r == n) { + return maxFlipsCount + } + int perm0 = perm1[0] + int i = 0 + while (i < r) { + int j = i + 1 + perm1[i] = perm1[j] + i = j + } + perm1[r] = perm0 + + count[r] = count[r] - 1 + if (count[r] > 0) { + break + } + r++ +}