You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/07/24 08:14:51 UTC
[groovy] branch master updated: Add 1 more test for
switch-expression
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new f81eb5b Add 1 more test for switch-expression
f81eb5b is described below
commit f81eb5b66566a84be515e33a993d29cc923f898f
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jul 24 16:14:39 2021 +0800
Add 1 more test for switch-expression
---
.../core/SwitchExpression_29x.groovy | 29 ++++++++++++++++++++++
.../groovy/parser/antlr4/GroovyParserTest.groovy | 1 +
2 files changed, 30 insertions(+)
diff --git a/src/test-resources/core/SwitchExpression_29x.groovy b/src/test-resources/core/SwitchExpression_29x.groovy
new file mode 100644
index 0000000..b4e4ea7
--- /dev/null
+++ b/src/test-resources/core/SwitchExpression_29x.groovy
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+class Coord {
+ int x
+ int y
+}
+
+def s = new Coord(x: 2, y: 5)
+def result = switch (s) {
+ case Coord(x, y): yield x * 3 + y
+}
+assert 11 == result
diff --git a/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index 7a15398..8a41f96 100644
--- a/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ b/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -452,6 +452,7 @@ final class GroovyParserTest extends GroovyTestCase {
doRunAndTestAntlr4('core/SwitchExpression_26x.groovy')
doRunAndTestAntlr4('core/SwitchExpression_27x.groovy')
doRunAndTestAntlr4('core/SwitchExpression_28x.groovy')
+ doRunAndTestAntlr4('core/SwitchExpression_29x.groovy')
}
void "test groovy core - BUG"() {