[506213] Calling "Double" services with "Float" values fail
The call was resolved using the widening enabled for the validation
but not working at evaluation:
- cast was not maid on the fly (which is a good thing regarding performence)
- collection operations are not working with widening (Double value 1 and Integer value 1 are not equals)
The widening has been removed from the validation and lookup:
- Long and Float services has been added
- toDouble() and toLong() services also have been added for explicite conversion
Change-Id: I640a1c5ba05bf5cbde3ea05d1c114a3e93e2da3a
diff --git a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/services/NumberServices.java b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/services/NumberServices.java
index e68efc1..3c19573 100644
--- a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/services/NumberServices.java
+++ b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/services/NumberServices.java
@@ -435,4 +435,460 @@
return Integer.valueOf((int)(self.intValue() % i.intValue()));
}
+ // @formatter:off
+ @Documentation(
+ value = "Performs the negation of the specified argument.",
+ params = {
+ @Param(name = "self", value = "The argument to be negated.")
+ },
+ result = "The negation of the argument.",
+ examples = {
+ @Example(expression = "1.unaryMin()", result = "-1"),
+ @Example(expression = "-1.unaryMin()", result = "1")
+ },
+ comment = "You can use \"-expression\" for the same result."
+ )
+ // @formatter:on
+ public Long unaryMin(Long self) {
+ return Long.valueOf(-self.longValue());
+ }
+
+ /**
+ * Performs the addition of the specified arguments.
+ *
+ * @param a
+ * the first operand
+ * @param b
+ * the second operand
+ * @return the addition of the arguments.
+ */
+ public Long add(Long a, Long b) {
+ return Long.valueOf(a.longValue() + b.longValue());
+ }
+
+ /**
+ * Performs the substraction of the specified arguments.
+ *
+ * @param a
+ * the first operand
+ * @param b
+ * the second operand
+ * @return the substraction of the arguments.
+ */
+ public Long sub(Long a, Long b) {
+ return Long.valueOf(a.longValue() - b.longValue());
+ }
+
+ /**
+ * Performs the multiplication of the specified arguments.
+ *
+ * @param a
+ * the first operand
+ * @param b
+ * the second operand
+ * @return the multiplication of the arguments.
+ */
+
+ public Long mult(Long a, Long b) {
+ return Long.valueOf(a.longValue() * b.longValue());
+ }
+
+ /**
+ * Performs the division of the specified arguments.
+ *
+ * @param a
+ * the first operand
+ * @param b
+ * the second operand
+ * @return the division of the arguments.
+ */
+
+ public Long divOp(Long a, Long b) {
+ return Long.valueOf(a.longValue() / b.longValue());
+ }
+
+ /**
+ * Performs the addition of the specified arguments.
+ *
+ * @param a
+ * the first operand
+ * @param b
+ * the second operand
+ * @return the addition of the arguments.
+ */
+
+ public Float add(Float a, Float b) {
+ return Float.valueOf(a.floatValue() + b.floatValue());
+ }
+
+ /**
+ * Performs the substraction of the specified arguments.
+ *
+ * @param a
+ * the first operand
+ * @param b
+ * the second operand
+ * @return the substraction of the arguments.
+ */
+
+ public Float sub(Float a, Float b) {
+ return Float.valueOf(a.floatValue() - b.floatValue());
+ }
+
+ /**
+ * Performs the multiplication of the specified arguments.
+ *
+ * @param a
+ * the first operand
+ * @param b
+ * the second operand
+ * @return the multiplication of the arguments.
+ */
+
+ public Float mult(Float a, Float b) {
+ return Float.valueOf(a.floatValue() * b.floatValue());
+ }
+
+ /**
+ * Performs the division of the specified arguments.
+ *
+ * @param a
+ * the first operand
+ * @param b
+ * the second operand
+ * @return the division of the arguments.
+ */
+ public Float divOp(Float a, Float b) {
+ return Float.valueOf(a.floatValue() / b.floatValue());
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Performs the negation of the specified argument.",
+ params = {
+ @Param(name = "self", value = "The argument to be negated.")
+ },
+ result = "The negation of the argument.",
+ examples = {
+ @Example(expression = "3.14.unaryMin()", result = "-3.14"),
+ @Example(expression = "-3.14.unaryMin()", result = "3.14")
+ },
+ comment = "You can use \"-expression\" for the same result."
+ )
+ // @formatter:on
+ public Float unaryMin(Float value) {
+ return Float.valueOf(-value.floatValue());
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the absolute value of self, self if it is already a positive number.",
+ params = {
+ @Param(name = "self", value = "The current value.")
+ },
+ result = "The absolute value of self, self if it is already a positive number",
+ examples = {
+ @Example(expression = "-3.14.abs()", result = "3.14"),
+ @Example(expression = "3.14.abs()", result = "3.14")
+ }
+ )
+ // @formatter:on
+ public Float abs(Float self) {
+ return Float.valueOf(Math.abs(self.floatValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the absolute value of self, self if it is already a positive number.",
+ params = {
+ @Param(name = "self", value = "The current value.")
+ },
+ result = "The absolute value of self, self if it is already a positive number",
+ examples = {
+ @Example(expression = "-3.abs()", result = "3"),
+ @Example(expression = "3.abs()", result = "3")
+ }
+ )
+ // @formatter:on
+ public Long abs(Long self) {
+ return Long.valueOf(Math.abs(self.longValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the integer part of self.",
+ params = {
+ @Param(name = "self", value = "The current value.")
+ },
+ result = "The integer part of self.",
+ examples = {
+ @Example(expression = "3.14.floor()", result = "3"),
+ @Example(expression = "3.66.floor()", result = "3")
+ }
+ )
+ // @formatter:on
+ public Integer floor(Float self) {
+ return Integer.valueOf((int)Math.floor(self.floatValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns self.",
+ params = {
+ @Param(name = "self", value = "The current value.")
+ },
+ result = "Self.",
+ examples = {
+ @Example(expression = "3.floor()", result = "3")
+ }
+ )
+ // @formatter:on
+ public Long floor(Long self) {
+ return self;
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the greatest number between self and r.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ @Param(name = "r", value = "The other value.")
+ },
+ result = "The greatest number between self and r.",
+ examples = {
+ @Example(expression = "3.max(6)", result = "6"),
+ @Example(expression = "6.max(3)", result = "6")
+ }
+ )
+ // @formatter:on
+ public Long max(Long self, Long r) {
+ return Long.valueOf(Math.max(self.longValue(), r.longValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the greatest number between self and r.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ @Param(name = "r", value = "The other value.")
+ },
+ result = "The greatest number between self and r.",
+ examples = {
+ @Example(expression = "3.14.max(6.7)", result = "6.7"),
+ @Example(expression = "6.7.max(3.14)", result = "6.7")
+ }
+ )
+ // @formatter:on
+ public Float max(Float self, Float r) {
+ return Float.valueOf(Math.max(self.floatValue(), r.floatValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the lowest number between self and r.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ @Param(name = "r", value = "The other value.")
+ },
+ result = "The lowest number between self and r.",
+ examples = {
+ @Example(expression = "3.min(6)", result = "3"),
+ @Example(expression = "6.min(3)", result = "3")
+ }
+ )
+ // @formatter:on
+ public Long min(Long self, Long r) {
+ return Long.valueOf(Math.min(self.longValue(), r.longValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the lowest number between self and r.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ @Param(name = "r", value = "The other value.")
+ },
+ result = "The lowest number between self and r.",
+ examples = {
+ @Example(expression = "3.14.min(6.7)", result = "3.14"),
+ @Example(expression = "6.7.min(3.14)", result = "3.14")
+ }
+ )
+ // @formatter:on
+ public Float min(Float self, Float r) {
+ return Float.valueOf(Math.min(self.floatValue(), r.floatValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the nearest integer to self.",
+ params = {
+ @Param(name = "self", value = "The current value.")
+ },
+ result = "The nearest integer to self.",
+ examples = {
+ @Example(expression = "3.14.round()", result = "3"),
+ @Example(expression = "3.66.round()", result = "4")
+ }
+ )
+ // @formatter:on
+ public Integer round(Float self) {
+ return Integer.valueOf((int)Math.round(self.floatValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns self.",
+ params = {
+ @Param(name = "self", value = "The current value.")
+ },
+ result = "Self.",
+ examples = {
+ @Example(expression = "3.round()", result = "3")
+ }
+ )
+ // @formatter:on
+ public Long round(Long self) {
+ return self;
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the long quotient of the division of self by i.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ @Param(name = "i", value = "The divider.")
+ },
+ result = "The integer quotient of the division of self by i.",
+ examples = {
+ @Example(expression = "6.9.div(3.1)", result = "2")
+ }
+ )
+ // @formatter:on
+ public Integer div(Float self, Float i) {
+ /*
+ * 0d/0d doesn't fail in ArithmeticsException but rather returns Float#POSITIVE_INFINITY. We want the
+ * same failure for both operations, hence the explicit test.
+ */
+ if (i.equals(Float.valueOf(0))) {
+ throw new IllegalArgumentException(CAN_T_DIVIDE_BY_ZERO);
+ }
+ return Integer.valueOf((int)(self.floatValue() / i.floatValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the long quotient of the division of self by i.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ @Param(name = "i", value = "The divider.")
+ },
+ result = "The long quotient of the division of self by i.",
+ examples = {
+ @Example(expression = "7.div(3)", result = "2")
+ }
+ )
+ // @formatter:on
+ public Long div(Long self, Long i) {
+ // see comment in #div(Float, Float) for this test
+ if (i.equals(Long.valueOf(0))) {
+ throw new IllegalArgumentException(CAN_T_DIVIDE_BY_ZERO);
+ }
+ return Long.valueOf((long)(self.longValue() / i.longValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the integer remainder of the division of self by i.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ @Param(name = "i", value = "The divider.")
+ },
+ result = "The integer remainder of the division of self by i.",
+ examples = {
+ @Example(expression = "7.5.div(3.1)", result = "1")
+ }
+ )
+ // @formatter:on
+ public Integer mod(Float self, Float i) {
+ /*
+ * As with division, mod operation will not fail in exception when using zero as divisor, but rather
+ * return Float#NaN. We want this operation to fail as does its version with Long, hence the explicit
+ * test.
+ */
+ if (i.equals(Float.valueOf(0))) {
+ throw new IllegalArgumentException(CAN_T_DIVIDE_BY_ZERO);
+ }
+ return Integer.valueOf((int)Math.ceil(self.floatValue() % i.floatValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the long remainder of the division of self by i.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ @Param(name = "i", value = "The divider.")
+ },
+ result = "The long remainder of the division of self by i.",
+ examples = {
+ @Example(expression = "7.div(3)", result = "1")
+ }
+ )
+ // @formatter:on
+ public Long mod(Long self, Long i) {
+ // see comment in #mod(Float, Float) for this test
+ if (i.equals(Long.valueOf(0))) {
+ throw new IllegalArgumentException(CAN_T_DIVIDE_BY_ZERO);
+ }
+ return Long.valueOf((long)(self.longValue() % i.longValue()));
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the double value of the given integer.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ },
+ result = "The double value.",
+ examples = {
+ @Example(expression = "1.toDouble()", result = "1.0")
+ }
+ )
+ // @formatter:on
+ public Double toDouble(Integer self) {
+ return Double.valueOf(self.intValue());
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the double value of the given float.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ },
+ result = "The double value.",
+ examples = {
+ @Example(expression = "1.0.toDouble()", result = "1.0")
+ }
+ )
+ // @formatter:on
+ public Double toDouble(Float self) {
+ return Double.valueOf(self.floatValue());
+ }
+
+ // @formatter:off
+ @Documentation(
+ value = "Returns the long value of the given integer.",
+ params = {
+ @Param(name = "self", value = "The current value."),
+ },
+ result = "The long value.",
+ examples = {
+ @Example(expression = "1.toDouble()", result = "1")
+ }
+ )
+ // @formatter:on
+ public Long toLong(Integer self) {
+ return Long.valueOf(self.intValue());
+ }
+
}
diff --git a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/validation/type/AbstractType.java b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/validation/type/AbstractType.java
index 46c2538..11a1ce3 100644
--- a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/validation/type/AbstractType.java
+++ b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/validation/type/AbstractType.java
@@ -82,37 +82,9 @@
boolean result = false;
if (toType == null || fromType == null) {
result = false;
- } else if (wrappedToType.isAssignableFrom(wrappedFromType)) {
- result = true;
} else {
- // Widening conversions
- // - byte to short, int, long, float, or double
- // - short to int, long, float, or double
- // - char to int, long, float, or double
- // - int to long, float, or double
- // - long to float or double
- // - float to double
- // CHECKSTYLE:OFF not much to do here since we're testing against all conversions
- if (wrappedFromType == Byte.class) {
- result = wrappedToType == Short.class || wrappedToType == Integer.class
- || wrappedToType == Long.class || wrappedToType == Float.class
- || wrappedToType == Double.class;
- } else if (wrappedFromType == Short.class) {
- result = wrappedToType == Integer.class || wrappedToType == Long.class
- || wrappedToType == Float.class || wrappedToType == Double.class;
- } else if (wrappedFromType == Character.class) {
- result = wrappedToType == Integer.class || wrappedToType == Long.class
- || wrappedToType == Float.class || wrappedToType == Double.class;
- } else if (wrappedFromType == Integer.class) {
- result = wrappedToType == Long.class || wrappedToType == Float.class
- || wrappedToType == Double.class;
- } else if (wrappedFromType == Long.class) {
- result = wrappedToType == Float.class || wrappedToType == Double.class;
- } else if (wrappedFromType == Float.class) {
- result = wrappedToType == Double.class;
- }
+ result = wrappedToType.isAssignableFrom(wrappedFromType);
}
- // CHECKSTYLE:ON
return result;
}
diff --git a/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/CollectionServicesAstValidationTest.java b/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/CollectionServicesAstValidationTest.java
index 582de96..0e8f5b9 100644
--- a/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/CollectionServicesAstValidationTest.java
+++ b/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/CollectionServicesAstValidationTest.java
@@ -5587,12 +5587,17 @@
public void testIntersectionIntListRealList() {
final IValidationResult validationResult = validate("Sequence{1, 2, 3}->intersection(Sequence{2.0})");
- assertTrue(validationResult.getMessages().isEmpty());
+ assertEquals(1, validationResult.getMessages().size());
AstResult ast = validationResult.getAstResult();
Set<IType> types = validationResult.getPossibleTypes(ast.getAst());
- assertEquals(ImmutableSet.of(sequenceType(classType(Integer.class))), types);
+ String message = "Nothing left after intersection:\n Nothing left after intersection of Sequence(java.lang.Integer) and Sequence(java.lang.Double)";
+ assertEquals(1, types.size());
+ IType type = types.iterator().next();
+ assertTrue(type instanceof SequenceType);
+ assertTrue(((SequenceType)type).getCollectionType() instanceof NothingType);
+ assertEquals(message, ((NothingType)((SequenceType)type).getCollectionType()).getMessage());
}
@Test
@@ -5671,12 +5676,17 @@
public void testIntersectionIntListRealSet() {
final IValidationResult validationResult = validate("Sequence{1, 2, 3}->intersection(OrderedSet{2.0})");
- assertTrue(validationResult.getMessages().isEmpty());
+ assertEquals(1, validationResult.getMessages().size());
AstResult ast = validationResult.getAstResult();
Set<IType> types = validationResult.getPossibleTypes(ast.getAst());
- assertEquals(ImmutableSet.of(sequenceType(classType(Integer.class))), types);
+ String message = "Nothing left after intersection:\n Nothing left after intersection of Sequence(java.lang.Integer) and Set(java.lang.Double)";
+ assertEquals(1, types.size());
+ IType type = types.iterator().next();
+ assertTrue(type instanceof SequenceType);
+ assertTrue(((SequenceType)type).getCollectionType() instanceof NothingType);
+ assertEquals(message, ((NothingType)((SequenceType)type).getCollectionType()).getMessage());
}
@Test
@@ -5887,12 +5897,17 @@
public void testIntersectionIntSetRealSet() {
final IValidationResult validationResult = validate("OrderedSet{1, 2, 3}->intersection(OrderedSet{2.0})");
- assertTrue(validationResult.getMessages().isEmpty());
+ assertEquals(1, validationResult.getMessages().size());
AstResult ast = validationResult.getAstResult();
Set<IType> types = validationResult.getPossibleTypes(ast.getAst());
- assertEquals(ImmutableSet.of(setType(classType(Integer.class))), types);
+ String message = "Nothing left after intersection:\n Nothing left after intersection of Set(java.lang.Integer) and Set(java.lang.Double)";
+ assertEquals(1, types.size());
+ IType type = types.iterator().next();
+ assertTrue(type instanceof SetType);
+ assertTrue(((SetType)type).getCollectionType() instanceof NothingType);
+ assertEquals(message, ((NothingType)((SetType)type).getCollectionType()).getMessage());
}
@Test
@@ -5948,6 +5963,7 @@
final IValidationResult validationResult = validate("OrderedSet{}->intersection(Sequence{})");
assertEquals(1, validationResult.getMessages().size());
+
ValidationTest
.assertValidationMessage(
validationResult.getMessages().get(0),
@@ -5971,12 +5987,17 @@
public void testIntersectionIntSetRealList() {
final IValidationResult validationResult = validate("OrderedSet{1, 2, 3}->intersection(Sequence{2.0})");
- assertTrue(validationResult.getMessages().isEmpty());
+ assertEquals(1, validationResult.getMessages().size());
AstResult ast = validationResult.getAstResult();
Set<IType> types = validationResult.getPossibleTypes(ast.getAst());
- assertEquals(ImmutableSet.of(setType(classType(Integer.class))), types);
+ String message = "Nothing left after intersection:\n Nothing left after intersection of Set(java.lang.Integer) and Sequence(java.lang.Double)";
+ assertEquals(1, types.size());
+ IType type = types.iterator().next();
+ assertTrue(type instanceof SetType);
+ assertTrue(((SetType)type).getCollectionType() instanceof NothingType);
+ assertEquals(message, ((NothingType)((SetType)type).getCollectionType()).getMessage());
}
@Test
diff --git a/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/CollectionServicesTest.java b/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/CollectionServicesTest.java
index a191f30..afa3019 100644
--- a/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/CollectionServicesTest.java
+++ b/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/CollectionServicesTest.java
@@ -4780,6 +4780,23 @@
}
@Test
+ public void testIntersectionSetIntegerDouble() {
+ Set<Object> set1 = Sets.newLinkedHashSet();
+ set1.add(Integer.valueOf(1));
+ set1.add(Integer.valueOf(2));
+ set1.add(Integer.valueOf(3));
+ set1.add(Integer.valueOf(4));
+
+ Set<Object> set2 = Sets.newLinkedHashSet();
+ set2.add(Double.valueOf(3));
+ set2.add(Double.valueOf(5));
+ set2.add(Double.valueOf(1));
+
+ Set<Object> result = collectionServices.intersection(set1, set2);
+ assertEquals(0, result.size());
+ }
+
+ @Test
public void testIntersectionSetDifferentClasses() {
Set<Object> set1 = Sets.newLinkedHashSet();
set1.add("aString");
@@ -4918,6 +4935,23 @@
}
@Test
+ public void testIntersectionListIntegerDouble() {
+ List<Object> list1 = Lists.newArrayList();
+ list1.add(Integer.valueOf(1));
+ list1.add(Integer.valueOf(2));
+ list1.add(Integer.valueOf(3));
+ list1.add(Integer.valueOf(4));
+
+ List<Object> list2 = Lists.newArrayList();
+ list2.add(Double.valueOf(3));
+ list2.add(Double.valueOf(5));
+ list2.add(Double.valueOf(1));
+
+ List<Object> result = collectionServices.intersection(list1, list2);
+ assertEquals(0, result.size());
+ }
+
+ @Test
public void testIntersectionListDifferentClasses() {
List<Object> list1 = Lists.newArrayList();
list1.add("aString");
diff --git a/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/NumberServicesTest.java b/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/NumberServicesTest.java
index 7e494d5..101f7e4 100644
--- a/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/NumberServicesTest.java
+++ b/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/services/tests/NumberServicesTest.java
@@ -19,13 +19,12 @@
import org.junit.Test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class NumberServicesTest extends AbstractServicesTest {
private NumberServices numServices;
- NumberServices services = new NumberServices();
-
@Override
public void before() throws Exception {
super.before();
@@ -42,11 +41,11 @@
@Test
public void testUnaryMinInteger() {
- Integer int1 = new Integer(1);
- Integer int2 = new Integer(5);
+ Integer integer1 = new Integer(1);
+ Integer integer2 = new Integer(5);
- assertEquals("-1", numServices.unaryMin(int1).toString());
- assertEquals("-5", numServices.unaryMin(int2).toString());
+ assertEquals("-1", numServices.unaryMin(integer1).toString());
+ assertEquals("-5", numServices.unaryMin(integer2).toString());
}
@Test(expected = java.lang.NullPointerException.class)
@@ -70,27 +69,27 @@
@Test(expected = java.lang.NullPointerException.class)
public void testAddIntegerIntegerNull() {
- Integer int0 = new Integer(0);
+ Integer integer0 = new Integer(0);
- numServices.add(int0, (Integer)null);
+ numServices.add(integer0, (Integer)null);
}
@Test(expected = java.lang.NullPointerException.class)
public void testAddIntegerNullInteger() {
- Integer int0 = new Integer(0);
+ Integer integer0 = new Integer(0);
- numServices.add((Integer)null, int0);
+ numServices.add((Integer)null, integer0);
}
@Test
public void testAddInteger() throws IllegalAccessException, IllegalArgumentException,
InvocationTargetException {
- Integer int0 = new Integer(0);
- Integer int1 = new Integer(1);
+ Integer integer0 = new Integer(0);
+ Integer integer1 = new Integer(1);
- assertEquals("2", numServices.add(int1, int1).toString());
- assertEquals("1", numServices.add(int1, int0).toString());
- assertEquals("1", numServices.add(int0, int1).toString());
+ assertEquals("2", numServices.add(integer1, integer1).toString());
+ assertEquals("1", numServices.add(integer1, integer0).toString());
+ assertEquals("1", numServices.add(integer0, integer1).toString());
}
@Test(expected = java.lang.NullPointerException.class)
@@ -100,27 +99,27 @@
@Test(expected = java.lang.NullPointerException.class)
public void testSubIntegerIntegerNull() {
- Integer int0 = new Integer(0);
+ Integer integer0 = new Integer(0);
- numServices.sub(int0, (Integer)null);
+ numServices.sub(integer0, (Integer)null);
}
@Test(expected = java.lang.NullPointerException.class)
public void testSubIntegerNullInteger() {
- Integer int0 = new Integer(0);
+ Integer integer0 = new Integer(0);
- numServices.sub((Integer)null, int0);
+ numServices.sub((Integer)null, integer0);
}
@Test
public void testSubInteger() throws IllegalAccessException, IllegalArgumentException,
InvocationTargetException {
- Integer int0 = new Integer(0);
- Integer int1 = new Integer(1);
- Integer int3 = new Integer(3);
+ Integer integer0 = new Integer(0);
+ Integer integer1 = new Integer(1);
+ Integer integer3 = new Integer(3);
- assertEquals("-1", numServices.sub(int0, int1).toString());
- assertEquals("2", numServices.sub(int3, int1).toString());
+ assertEquals("-1", numServices.sub(integer0, integer1).toString());
+ assertEquals("2", numServices.sub(integer3, integer1).toString());
}
@Test(expected = java.lang.NullPointerException.class)
@@ -130,27 +129,27 @@
@Test(expected = java.lang.NullPointerException.class)
public void testDivIntegerIntegerNull() {
- Integer int0 = new Integer(0);
+ Integer integer0 = new Integer(0);
- numServices.div(int0, (Integer)null);
+ numServices.div(integer0, (Integer)null);
}
@Test(expected = java.lang.IllegalArgumentException.class)
public void testDivIntegerNullInteger() {
- Integer int0 = new Integer(0);
+ Integer integer0 = new Integer(0);
- numServices.div((Integer)null, int0);
+ numServices.div((Integer)null, integer0);
}
@Test
public void testDivInteger() throws IllegalAccessException, IllegalArgumentException,
InvocationTargetException {
- Integer int1 = new Integer(1);
- Integer int2 = new Integer(2);
- Integer int4 = new Integer(4);
+ Integer integer1 = new Integer(1);
+ Integer integer2 = new Integer(2);
+ Integer integer4 = new Integer(4);
- assertEquals("2", numServices.divOp(int4, int2).toString());
- assertEquals("0", numServices.divOp(int1, int2).toString());
+ assertEquals("2", numServices.divOp(integer4, integer2).toString());
+ assertEquals("0", numServices.divOp(integer1, integer2).toString());
}
@Test(expected = java.lang.NullPointerException.class)
@@ -160,30 +159,30 @@
@Test(expected = java.lang.NullPointerException.class)
public void testMultIntegerIntegerNull() {
- Integer int0 = new Integer(0);
+ Integer integer0 = new Integer(0);
- numServices.mult(int0, (Integer)null);
+ numServices.mult(integer0, (Integer)null);
}
@Test(expected = java.lang.NullPointerException.class)
public void testMultIntegerNullInteger() {
- Integer int0 = new Integer(0);
+ Integer integer0 = new Integer(0);
- numServices.mult((Integer)null, int0);
+ numServices.mult((Integer)null, integer0);
}
@Test
public void testMultInteger() throws IllegalAccessException, IllegalArgumentException,
InvocationTargetException {
- Integer int0 = new Integer(0);
- Integer int1 = new Integer(1);
- Integer int2 = new Integer(2);
- Integer int4 = new Integer(4);
+ Integer integer0 = new Integer(0);
+ Integer integer1 = new Integer(1);
+ Integer integer2 = new Integer(2);
+ Integer integer4 = new Integer(4);
- assertEquals("8", numServices.mult(int4, int2).toString());
- assertEquals("2", numServices.mult(int1, int2).toString());
- assertEquals("0", numServices.mult(int0, int2).toString());
- assertEquals("0", numServices.mult(int2, int0).toString());
+ assertEquals("8", numServices.mult(integer4, integer2).toString());
+ assertEquals("2", numServices.mult(integer1, integer2).toString());
+ assertEquals("0", numServices.mult(integer0, integer2).toString());
+ assertEquals("0", numServices.mult(integer2, integer0).toString());
}
@Test(expected = java.lang.NullPointerException.class)
@@ -193,16 +192,16 @@
@Test(expected = java.lang.NullPointerException.class)
public void testAddDoubleDoubleNull() {
- Double int0 = new Double(0);
+ Double integer0 = new Double(0);
- numServices.add(int0, (Double)null);
+ numServices.add(integer0, (Double)null);
}
@Test(expected = java.lang.NullPointerException.class)
public void testAddDoubleNullDouble() {
- Double int0 = new Double(0);
+ Double integer0 = new Double(0);
- numServices.add((Double)null, int0);
+ numServices.add((Double)null, integer0);
}
@Test
@@ -223,16 +222,16 @@
@Test(expected = java.lang.NullPointerException.class)
public void testSubDoubleDoubleNull() {
- Double int0 = new Double(0);
+ Double integer0 = new Double(0);
- numServices.sub(int0, (Double)null);
+ numServices.sub(integer0, (Double)null);
}
@Test(expected = java.lang.NullPointerException.class)
public void testSubDoubleNullDouble() {
- Double int0 = new Double(0);
+ Double integer0 = new Double(0);
- numServices.sub((Double)null, int0);
+ numServices.sub((Double)null, integer0);
}
@Test
@@ -253,16 +252,16 @@
@Test(expected = java.lang.NullPointerException.class)
public void testDivDoubleDoubleNull() {
- Double int0 = new Double(0);
+ Double integer0 = new Double(0);
- numServices.div(int0, (Double)null);
+ numServices.div(integer0, (Double)null);
}
@Test(expected = java.lang.IllegalArgumentException.class)
public void testDivDoubleNullDouble() {
- Double int0 = new Double(0);
+ Double integer0 = new Double(0);
- numServices.div((Double)null, int0);
+ numServices.div((Double)null, integer0);
}
@Test
@@ -283,16 +282,16 @@
@Test(expected = java.lang.NullPointerException.class)
public void testMultDoubleDoubleNull() {
- Double int0 = new Double(0);
+ Double integer0 = new Double(0);
- numServices.mult(int0, (Double)null);
+ numServices.mult(integer0, (Double)null);
}
@Test(expected = java.lang.NullPointerException.class)
public void testMultDoubleNullDouble() {
- Double int0 = new Double(0);
+ Double integer0 = new Double(0);
- numServices.mult((Double)null, int0);
+ numServices.mult((Double)null, integer0);
}
@Test
@@ -581,4 +580,583 @@
assertEquals(Integer.valueOf(1), result);
}
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testUnaryMinLongNull() {
+ numServices.unaryMin((Long)null);
+ }
+
+ @Test
+ public void testUnaryMinLong() {
+ Long long1 = new Long(1);
+ Long long2 = new Long(5);
+
+ assertEquals("-1", numServices.unaryMin(long1).toString());
+ assertEquals("-5", numServices.unaryMin(long2).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testUnaryMinFloatNull() {
+ numServices.unaryMin((Float)null);
+ }
+
+ @Test
+ public void testUnaryMinFloat() {
+ Float float1 = new Float(1);
+ Float float2 = new Float(5);
+
+ assertEquals("-1.0", numServices.unaryMin(float1).toString());
+ assertEquals("-5.0", numServices.unaryMin(float2).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testAddLongNullNull() {
+ numServices.add((Long)null, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testAddLongLongNull() {
+ Long long0 = new Long(0);
+
+ numServices.add(long0, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testAddLongNullLong() {
+ Long long0 = new Long(0);
+
+ numServices.add((Long)null, long0);
+ }
+
+ @Test
+ public void testAddLong() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException {
+ Long long0 = new Long(0);
+ Long long1 = new Long(1);
+
+ assertEquals("2", numServices.add(long1, long1).toString());
+ assertEquals("1", numServices.add(long1, long0).toString());
+ assertEquals("1", numServices.add(long0, long1).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testSubLongNullNull() {
+ numServices.sub((Long)null, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testSubLongLongNull() {
+ Long long0 = new Long(0);
+
+ numServices.sub(long0, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testSubLongNullLong() {
+ Long long0 = new Long(0);
+
+ numServices.sub((Long)null, long0);
+ }
+
+ @Test
+ public void testSubLong() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException {
+ Long long0 = new Long(0);
+ Long long1 = new Long(1);
+ Long long3 = new Long(3);
+
+ assertEquals("-1", numServices.sub(long0, long1).toString());
+ assertEquals("2", numServices.sub(long3, long1).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testDivLongNullNull() {
+ numServices.div((Long)null, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testDivLongLongNull() {
+ Long long0 = new Long(0);
+
+ numServices.div(long0, (Long)null);
+ }
+
+ @Test(expected = java.lang.IllegalArgumentException.class)
+ public void testDivLongNullLong() {
+ Long long0 = new Long(0);
+
+ numServices.div((Long)null, long0);
+ }
+
+ @Test
+ public void testDivLong() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException {
+ Long long1 = new Long(1);
+ Long long2 = new Long(2);
+ Long long4 = new Long(4);
+
+ assertEquals("2", numServices.divOp(long4, long2).toString());
+ assertEquals("0", numServices.divOp(long1, long2).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testMultLongNullNull() {
+ numServices.mult((Long)null, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testMultLongLongNull() {
+ Long long0 = new Long(0);
+
+ numServices.mult(long0, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testMultLongNullLong() {
+ Long long0 = new Long(0);
+
+ numServices.mult((Long)null, long0);
+ }
+
+ @Test
+ public void testMultLong() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException {
+ Long long0 = new Long(0);
+ Long long1 = new Long(1);
+ Long long2 = new Long(2);
+ Long long4 = new Long(4);
+
+ assertEquals("8", numServices.mult(long4, long2).toString());
+ assertEquals("2", numServices.mult(long1, long2).toString());
+ assertEquals("0", numServices.mult(long0, long2).toString());
+ assertEquals("0", numServices.mult(long2, long0).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testAddFloatNullNull() {
+ numServices.add((Float)null, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testAddFloatFloatNull() {
+ Float long0 = new Float(0);
+
+ numServices.add(long0, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testAddFloatNullFloat() {
+ Float long0 = new Float(0);
+
+ numServices.add((Float)null, long0);
+ }
+
+ @Test
+ public void testAddFloat() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException {
+ Float float0 = new Float(0);
+ Float float1 = new Float(1);
+
+ assertEquals("2.0", numServices.add(float1, float1).toString());
+ assertEquals("1.0", numServices.add(float1, float0).toString());
+ assertEquals("1.0", numServices.add(float0, float1).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testSubFloatNullNull() {
+ numServices.sub((Float)null, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testSubFloatFloatNull() {
+ Float long0 = new Float(0);
+
+ numServices.sub(long0, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testSubFloatNullFloat() {
+ Float long0 = new Float(0);
+
+ numServices.sub((Float)null, long0);
+ }
+
+ @Test
+ public void testSubFloat() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException {
+ Float float0 = new Float(0);
+ Float float1 = new Float(1);
+ Float float3 = new Float(3);
+
+ assertEquals("-1.0", numServices.sub(float0, float1).toString());
+ assertEquals("2.0", numServices.sub(float3, float1).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testDivFloatNullNull() {
+ numServices.div((Float)null, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testDivFloatFloatNull() {
+ Float long0 = new Float(0);
+
+ numServices.div(long0, (Float)null);
+ }
+
+ @Test(expected = java.lang.IllegalArgumentException.class)
+ public void testDivFloatNullFloat() {
+ Float long0 = new Float(0);
+
+ numServices.div((Float)null, long0);
+ }
+
+ @Test
+ public void testDivFloat() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException {
+ Float float1 = new Float(1);
+ Float float2 = new Float(2);
+ Float float4 = new Float(4);
+
+ assertEquals("2.0", numServices.divOp(float4, float2).toString());
+ assertEquals("0.5", numServices.divOp(float1, float2).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testMultFloatNullNull() {
+ numServices.mult((Float)null, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testMultFloatFloatNull() {
+ Float long0 = new Float(0);
+
+ numServices.mult(long0, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void testMultFloatNullFloat() {
+ Float long0 = new Float(0);
+
+ numServices.mult((Float)null, long0);
+ }
+
+ @Test
+ public void testMultFloat() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException {
+ Float float0 = new Float(0);
+ Float float1 = new Float(1);
+ Float float2 = new Float(2);
+ Float float4 = new Float(4);
+
+ assertEquals("8.0", numServices.mult(float4, float2).toString());
+ assertEquals("2.0", numServices.mult(float1, float2).toString());
+ assertEquals("0.0", numServices.mult(float0, float2).toString());
+ assertEquals("0.0", numServices.mult(float2, float0).toString());
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void absFloatNull() {
+ numServices.abs((Float)null);
+ }
+
+ @Test
+ public void absFloatPositive() {
+ Float result = numServices.abs(Float.valueOf(3.14f));
+ assertEquals(Float.valueOf(3.14f), result);
+ }
+
+ @Test
+ public void absFloatNegative() {
+ Float result = numServices.abs(Float.valueOf(-3.14f));
+ assertEquals(Float.valueOf(3.14f), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void absLongNull() {
+ numServices.abs((Long)null);
+ }
+
+ @Test
+ public void absLongPositive() {
+ Long result = numServices.abs(Long.valueOf(3));
+ assertEquals(Long.valueOf(3), result);
+ }
+
+ @Test
+ public void absLongNegative() {
+ Long result = numServices.abs(Long.valueOf(-3));
+ assertEquals(Long.valueOf(3), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void floorFloatNull() {
+ numServices.floor((Float)null);
+ }
+
+ @Test
+ public void floorFloat() {
+ Integer result = numServices.floor(Float.valueOf(3.14f));
+ assertEquals(Integer.valueOf(3), result);
+ }
+
+ @Test
+ public void floorLongNull() {
+ Long result = numServices.floor((Long)null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void floorLong() {
+ Long result = numServices.floor(Long.valueOf(3));
+ assertEquals(Long.valueOf(3), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void maxFloatNullNull() {
+ numServices.max((Float)null, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void maxFloatFloatNull() {
+ numServices.max(Float.valueOf(3.14f), (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void maxFloatNullFloat() {
+ numServices.max((Float)null, Float.valueOf(3.14f));
+ }
+
+ @Test
+ public void maxFloat() {
+ Float result = numServices.max(Float.valueOf(6.28f), Float.valueOf(3.14f));
+ assertEquals(Float.valueOf(6.28f), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void maxLongNullNull() {
+ numServices.max((Long)null, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void maxLongLongNull() {
+ numServices.max(Long.valueOf(3), (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void maxLongNullLong() {
+ numServices.max((Long)null, Long.valueOf(3));
+ }
+
+ @Test
+ public void maxLong() {
+ Long result = numServices.max(Long.valueOf(6), Long.valueOf(3));
+ assertEquals(Long.valueOf(6), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void minFloatNullNull() {
+ numServices.min((Float)null, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void minFloatFloatNull() {
+ numServices.min(Float.valueOf(3.14f), (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void minFloatNullFloat() {
+ numServices.min((Float)null, Float.valueOf(3.14f));
+ }
+
+ @Test
+ public void minFloat() {
+ Float result = numServices.min(Float.valueOf(6.28f), Float.valueOf(3.14f));
+ assertEquals(Float.valueOf(3.14f), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void minLongNullNull() {
+ numServices.min((Long)null, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void minLongLongNull() {
+ numServices.min(Long.valueOf(3), (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void minLongNullLong() {
+ numServices.min((Long)null, Long.valueOf(3));
+ }
+
+ @Test
+ public void minLong() {
+ Long result = numServices.min(Long.valueOf(6), Long.valueOf(3));
+ assertEquals(Long.valueOf(3), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void roundFloatNull() {
+ numServices.round((Float)null);
+ }
+
+ @Test
+ public void roundFloat() {
+ Integer result = numServices.round(Float.valueOf(3.64f));
+ assertEquals(Integer.valueOf(4), result);
+ }
+
+ @Test
+ public void roundLongNull() {
+ Long result = numServices.round((Long)null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void roundLong() {
+ Long result = numServices.round(Long.valueOf(3));
+ assertEquals(Long.valueOf(3), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void divFloatNullNull() {
+ numServices.div((Float)null, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void divFloatFloatNull() {
+ numServices.div(Float.valueOf(3.14f), (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void divFloatNullFloat() {
+ numServices.div((Float)null, Float.valueOf(3.14f));
+ }
+
+ @Test(expected = java.lang.IllegalArgumentException.class)
+ public void divFloatByZero() {
+ Integer result = numServices.div(Float.valueOf(3.14f), Float.valueOf(0));
+ assertEquals(Integer.valueOf(0), result);
+ }
+
+ @Test
+ public void divFloat() {
+ Integer result = numServices.div(Float.valueOf(3.14f * 7 + 1), Float.valueOf(3.14f));
+ assertEquals(Integer.valueOf(7), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void divLongNullNull() {
+ numServices.div((Long)null, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void divLongLongNull() {
+ numServices.div(Long.valueOf(3), (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void divLongNullLong() {
+ numServices.div((Long)null, Long.valueOf(3));
+ }
+
+ @Test(expected = java.lang.IllegalArgumentException.class)
+ public void divLongByZero() {
+ Long result = numServices.div(Long.valueOf(3), Long.valueOf(0));
+ assertEquals(Long.valueOf(0), result);
+ }
+
+ @Test
+ public void divLong() {
+ Long result = numServices.div(Long.valueOf(3 * 7 + 1), Long.valueOf(3));
+ assertEquals(Long.valueOf(7), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void modFloatNullNull() {
+ numServices.mod((Float)null, (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void modFloatFloatNull() {
+ numServices.mod(Float.valueOf(3.14f), (Float)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void modFloatNullFloat() {
+ numServices.mod((Float)null, Float.valueOf(3.14f));
+ }
+
+ @Test(expected = java.lang.IllegalArgumentException.class)
+ public void modFloatByZero() {
+ Integer result = numServices.mod(Float.valueOf(3.14f), Float.valueOf(0));
+ assertEquals(Integer.valueOf(0), result);
+ }
+
+ @Test
+ public void modFloat() {
+ Integer result = numServices.mod(Float.valueOf(3.13f * 7 + 1), Float.valueOf(3.13f));
+ assertEquals(Integer.valueOf(1), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void modLongNullNull() {
+ numServices.mod((Long)null, (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void modLongLongNull() {
+ numServices.mod(Long.valueOf(3), (Long)null);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void modLongNullLong() {
+ numServices.mod((Long)null, Long.valueOf(3));
+ }
+
+ @Test(expected = java.lang.IllegalArgumentException.class)
+ public void modLongByZero() {
+ Long result = numServices.mod(Long.valueOf(3), Long.valueOf(0));
+ assertEquals(Long.valueOf(0), result);
+ }
+
+ @Test
+ public void modLong() {
+ Long result = numServices.mod(Long.valueOf(3 * 7 + 1), Long.valueOf(3));
+ assertEquals(Long.valueOf(1), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void toDoubleIntegerNull() {
+ numServices.toDouble((Integer)null);
+ }
+
+ @Test
+ public void toDoubleInteger() {
+ Double result = numServices.toDouble(Integer.valueOf(3));
+ assertEquals(Double.valueOf(3), result);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void toDoubleFloatNull() {
+ numServices.toDouble((Float)null);
+ }
+
+ @Test
+ public void toDoubleFloat() {
+ Double result = numServices.toDouble(Float.valueOf(3.14f));
+ assertTrue((result.doubleValue() - 3.14) < 0.001);
+ }
+
+ @Test(expected = java.lang.NullPointerException.class)
+ public void toLongNull() {
+ numServices.toLong((Integer)null);
+ }
+
+ @Test
+ public void toLong() {
+ Long result = numServices.toLong(Integer.valueOf(3));
+ assertEquals(Long.valueOf(3), result);
+ }
+
}
diff --git a/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/tests/validation/types/TypeTests.java b/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/tests/validation/types/TypeTests.java
index bc4a6b4..dc8fee6 100644
--- a/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/tests/validation/types/TypeTests.java
+++ b/query/tests/org.eclipse.acceleo.query.tests/src/org/eclipse/acceleo/query/tests/validation/types/TypeTests.java
@@ -189,54 +189,6 @@
}
@Test
- public void testWideningConversions() {
- for (Map.Entry<TypeVariants, Set<TypeVariants>> entry : wideningConversions.entrySet()) {
- for (IType fromType : entry.getKey().getVariants()) {
- assertFalse(entry.getValue().isEmpty());
- for (TypeVariants toVariant : entry.getValue()) {
- assertFalse(toVariant.getVariants().isEmpty());
- for (IType toType : toVariant.getVariants()) {
- assertTrue(toType.getType() + " should have been assignable from "
- + fromType.getType(), toType.isAssignableFrom(fromType));
- }
- }
- }
- }
- }
-
- @Test
- public void testWideningConversionsWithEcore() {
- getQueryEnvironment().registerEPackage(EcorePackage.eINSTANCE);
- addEcoreDataTypesAndClassifiersToVariants();
-
- testWideningConversions();
- }
-
- @Test
- public void testWideningConversionsWithUnregisteredEcore() {
- addEcoreDataTypesAndClassifiersToVariants();
-
- for (Map.Entry<TypeVariants, Set<TypeVariants>> entry : wideningConversions.entrySet()) {
- for (IType fromType : entry.getKey().getVariants()) {
- assertFalse(entry.getValue().isEmpty());
- for (TypeVariants toVariant : entry.getValue()) {
- assertFalse(toVariant.getVariants().isEmpty());
- for (IType toType : toVariant.getVariants()) {
- if (toType instanceof EClassifierType || fromType instanceof EClassifierType) {
- assertFalse(toType.getType() + " should not have been assignable from "
- + fromType.getType() + " as ecore is not registered in the environment.",
- toType.isAssignableFrom(fromType));
- } else {
- assertTrue(toType.getType() + " should have been assignable from "
- + fromType.getType(), toType.isAssignableFrom(fromType));
- }
- }
- }
- }
- }
- }
-
- @Test
public void testNarrowingConversions() {
for (Map.Entry<TypeVariants, Set<TypeVariants>> entry : narrowingConversions.entrySet()) {
for (IType fromType : entry.getKey().getVariants()) {