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 2020/09/01 08:32:26 UTC
[groovy] branch GROOVY_2_5_X updated: GROOVY-9704: load minus one
as long integer (port to 2_5_X)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
new 3b3cdff GROOVY-9704: load minus one as long integer (port to 2_5_X)
3b3cdff is described below
commit 3b3cdff0bf8b1d3354736d2895040ab8d6004b93
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Aug 31 12:01:43 2020 -0500
GROOVY-9704: load minus one as long integer (port to 2_5_X)
---
.../asm/sc/StaticTypesUnaryExpressionHelper.java | 2 +-
.../transform/stc/UnaryOperatorSTCTest.groovy | 136 +++++++++++----------
2 files changed, 73 insertions(+), 65 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesUnaryExpressionHelper.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesUnaryExpressionHelper.java
index c02e0e2..e14554c 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesUnaryExpressionHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesUnaryExpressionHelper.java
@@ -69,7 +69,7 @@ public class StaticTypesUnaryExpressionHelper extends UnaryExpressionHelper impl
@Override
public void visit(final MethodVisitor mv) {
if (long_TYPE==top) {
- mv.visitLdcInsn(-1);
+ mv.visitLdcInsn(-1L);
mv.visitInsn(LXOR);
} else {
mv.visitInsn(ICONST_M1);
diff --git a/src/test/groovy/transform/stc/UnaryOperatorSTCTest.groovy b/src/test/groovy/transform/stc/UnaryOperatorSTCTest.groovy
index 9770160..e26dbfa 100644
--- a/src/test/groovy/transform/stc/UnaryOperatorSTCTest.groovy
+++ b/src/test/groovy/transform/stc/UnaryOperatorSTCTest.groovy
@@ -23,117 +23,125 @@ package groovy.transform.stc
*/
class UnaryOperatorSTCTest extends StaticTypeCheckingTestCase {
- void testUnaryPlusOnInt() {
- assertScript '''
+ // GROOVY-9704
+ void testBitwiseNegate_long() {
+ assertScript '''
+ long x = 1L
+ assert ~x == -2L
+ '''
+ }
+
+ void testUnaryPlusOnInt() {
+ assertScript '''
int x = 1
assert +x == 1
- '''
- }
+ '''
+ }
- void testUnaryPlusOnInteger() {
- assertScript '''
+ void testUnaryPlusOnInteger() {
+ assertScript '''
Integer x = new Integer(1)
assert +x == 1
- '''
- }
+ '''
+ }
- void testUnaryMinusOnInt() {
- assertScript '''
+ void testUnaryMinusOnInt() {
+ assertScript '''
int x = 1
assert -x == -1
- '''
- }
+ '''
+ }
- void testUnaryMinusOnInteger() {
- assertScript '''
+ void testUnaryMinusOnInteger() {
+ assertScript '''
Integer x = new Integer(1)
assert -x == -1
- '''
- }
+ '''
+ }
- void testUnaryPlusOnShort() {
- assertScript '''
+ void testUnaryPlusOnShort() {
+ assertScript '''
short x = 1
assert +x == 1
- '''
- }
+ '''
+ }
- void testUnaryPlusOnBoxedShort() {
- assertScript '''
+ void testUnaryPlusOnBoxedShort() {
+ assertScript '''
Short x = new Short((short)1)
assert +x == 1
- '''
- }
+ '''
+ }
- void testUnaryMinusOnShort() {
- assertScript '''
+ void testUnaryMinusOnShort() {
+ assertScript '''
short x = 1
assert -x == -1
- '''
- }
+ '''
+ }
- void testUnaryMinusOnBoxedShort() {
- assertScript '''
+ void testUnaryMinusOnBoxedShort() {
+ assertScript '''
Short x = new Short((short)1)
assert -x == -1
- '''
- }
+ '''
+ }
- void testUnaryPlusOnFloat() {
- assertScript '''
+ void testUnaryPlusOnFloat() {
+ assertScript '''
float x = 1f
assert +x == 1f
- '''
- }
+ '''
+ }
- void testUnaryPlusOnBoxedFloat() {
- assertScript '''
+ void testUnaryPlusOnBoxedFloat() {
+ assertScript '''
Float x = new Float(1f)
assert +x == 1f
- '''
- }
+ '''
+ }
- void testUnaryMinusOnFloat() {
- assertScript '''
+ void testUnaryMinusOnFloat() {
+ assertScript '''
float x = 1f
assert -x == -1f
- '''
- }
+ '''
+ }
- void testUnaryMinusOnBoxedFloat() {
- assertScript '''
+ void testUnaryMinusOnBoxedFloat() {
+ assertScript '''
Float x = new Float(1f)
assert -x == -1f
- '''
- }
+ '''
+ }
- void testUnaryPlusOnDouble() {
- assertScript '''
+ void testUnaryPlusOnDouble() {
+ assertScript '''
double x = 1d
assert +x == 1d
- '''
- }
+ '''
+ }
- void testUnaryPlusOnBoxedDouble() {
- assertScript '''
+ void testUnaryPlusOnBoxedDouble() {
+ assertScript '''
Double x = new Double(1d)
assert +x == 1d
- '''
- }
+ '''
+ }
- void testUnaryMinusOnDouble() {
- assertScript '''
+ void testUnaryMinusOnDouble() {
+ assertScript '''
double x = 1d
assert -x == -1d
- '''
- }
+ '''
+ }
- void testUnaryMinusOnBoxedDouble() {
- assertScript '''
+ void testUnaryMinusOnBoxedDouble() {
+ assertScript '''
Double x = new Double(1d)
assert -x == -1d
- '''
- }
+ '''
+ }
void testIntXIntInferredType() {
assertScript '''