You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2019/04/16 09:43:17 UTC
[groovy] 04/04: remove codenarc warnings (take 2)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 5d34fd3abfafdb55ab58ca3f0f7bc2290da7d948
Author: Paul King <pa...@asert.com.au>
AuthorDate: Tue Apr 16 19:42:27 2019 +1000
remove codenarc warnings (take 2)
---
src/test/groovy/bugs/Groovy4078Bug.groovy | 98 +++++++++++-----------
.../operator/BigIntegerOperationsTest.groovy | 2 +-
.../transform/tailrec/TailRecursiveExamples.groovy | 4 +-
3 files changed, 52 insertions(+), 52 deletions(-)
diff --git a/src/test/groovy/bugs/Groovy4078Bug.groovy b/src/test/groovy/bugs/Groovy4078Bug.groovy
index 1f755d5..fc13e28 100644
--- a/src/test/groovy/bugs/Groovy4078Bug.groovy
+++ b/src/test/groovy/bugs/Groovy4078Bug.groovy
@@ -1,49 +1,49 @@
-/*
- * 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.
- */
-package groovy.bugs
-
-class Groovy4078Bug extends GroovyTestCase {
- void testInfiniteLoopDetectionInStepUsage() {
- (2..2).step 0, {assert it != null} //IntRange
-
- ('b'..'b').step 0, {assert it != null} //ObjectRange
-
- 5.step( 5, 1 ) { assert it != null } // DGM.step(), int
-
- 5.0.step (5.0, 1 ) { assert it != null } // DGM.step(), BigDecimal
-
- def from = new BigInteger(5)
- def to = new BigInteger(5)
- from.step (to, 1 ) { assert it != null } // DGM.step(), BigInteger
-
- try{
- (1..2).step 0, {assert it != null} //IntRange
- fail('Should have failed as step size 0 causes infinite loop')
- } catch(ex) {
- assert ex.message.contains('Infinite loop detected due to step size of 0')
- }
-
- try{
- ('a'..'b').step 0, {assert it != null} // ObjectRange
- fail('Should have failed as step size 0 causes infinite loop')
- } catch(ex) {
- assert ex.message.contains('Infinite loop detected due to step size of 0')
- }
- }
-}
+/*
+ * 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.
+ */
+package groovy.bugs
+
+class Groovy4078Bug extends GroovyTestCase {
+ void testInfiniteLoopDetectionInStepUsage() {
+ (2..2).step 0, {assert it != null} //IntRange
+
+ ('b'..'b').step 0, {assert it != null} //ObjectRange
+
+ 5.step( 5, 1 ) { assert it != null } // DGM.step(), int
+
+ 5.0.step (5.0, 1 ) { assert it != null } // DGM.step(), BigDecimal
+
+ def from = BigInteger.valueOf(5)
+ def to = BigInteger.valueOf(5)
+ from.step (to, 1 ) { assert it != null } // DGM.step(), BigInteger
+
+ try{
+ (1..2).step 0, {assert it != null} //IntRange
+ fail('Should have failed as step size 0 causes infinite loop')
+ } catch(ex) {
+ assert ex.message.contains('Infinite loop detected due to step size of 0')
+ }
+
+ try{
+ ('a'..'b').step 0, {assert it != null} // ObjectRange
+ fail('Should have failed as step size 0 causes infinite loop')
+ } catch(ex) {
+ assert ex.message.contains('Infinite loop detected due to step size of 0')
+ }
+ }
+}
diff --git a/src/test/groovy/operator/BigIntegerOperationsTest.groovy b/src/test/groovy/operator/BigIntegerOperationsTest.groovy
index 22bffc8..21f79e8 100644
--- a/src/test/groovy/operator/BigIntegerOperationsTest.groovy
+++ b/src/test/groovy/operator/BigIntegerOperationsTest.groovy
@@ -58,7 +58,7 @@ class BigIntegerOperationsTest extends GroovyTestCase {
}
void testAsOperatorPrecisionLoss() {
- def value = new BigInteger(Long.MAX_VALUE) + 1
+ def value = BigInteger.valueOf(Long.MAX_VALUE) + 1
def value2 = value as BigInteger
assert value == value2
}
diff --git a/src/test/org/codehaus/groovy/transform/tailrec/TailRecursiveExamples.groovy b/src/test/org/codehaus/groovy/transform/tailrec/TailRecursiveExamples.groovy
index 11d916e..f89d7bb 100644
--- a/src/test/org/codehaus/groovy/transform/tailrec/TailRecursiveExamples.groovy
+++ b/src/test/org/codehaus/groovy/transform/tailrec/TailRecursiveExamples.groovy
@@ -66,8 +66,8 @@ class TailRecursiveExamples {
assert target.reduce(0, plus, 1, 5, 10) == 16
assert target.reduce(99, plus, 1, 5, 10, 98) == 213
- def numbersFrom1to1000 = (1..1000).collect { new BigInteger(it) }.toArray()
- assert target.reduce(new BigInteger(1), { BigInteger a, BigInteger b -> a * b }, numbersFrom1to1000).bitCount() == 3788
+ def numbersFrom1to1000 = (1..1000).collect { BigInteger.valueOf(it) }.toArray()
+ assert target.reduce(BigInteger.valueOf(1), { BigInteger a, BigInteger b -> a * b }, numbersFrom1to1000).bitCount() == 3788
}
@Test