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 2016/06/04 23:36:01 UTC
groovy git commit: minor refactor: add missing assertions
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_4_X 7390d973d -> 984173f3f
minor refactor: add missing assertions
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/984173f3
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/984173f3
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/984173f3
Branch: refs/heads/GROOVY_2_4_X
Commit: 984173f3ff4f1004be77691153b435891a98bb89
Parents: 7390d97
Author: paulk <pa...@asert.com.au>
Authored: Sun Jun 5 09:34:35 2016 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sun Jun 5 09:35:47 2016 +1000
----------------------------------------------------------------------
.../groovy/PrimitiveDefaultValueTest.groovy | 90 ++++++++++----------
1 file changed, 43 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/984173f3/src/test/groovy/PrimitiveDefaultValueTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/PrimitiveDefaultValueTest.groovy b/src/test/groovy/PrimitiveDefaultValueTest.groovy
index 2520bf9..af84f3b 100644
--- a/src/test/groovy/PrimitiveDefaultValueTest.groovy
+++ b/src/test/groovy/PrimitiveDefaultValueTest.groovy
@@ -19,14 +19,8 @@
package groovy
/**
- * @todo GROOVY-1037
- *
- * $Revision 1.0
- * Test for non-initialized fields or variables of the primitive types.
- *
- * @author Pilho Kim
+ * Test for non-initialized fields or variables of the primitive types.
*/
-
class PrimitiveDefaultValueTest extends GroovyTestCase {
private int x
@@ -38,63 +32,65 @@ class PrimitiveDefaultValueTest extends GroovyTestCase {
private boolean flag
private char c
+ private static final Character ZERO = '\0'
+
void testThisPrimitiveDefaultValues() {
- this.x == 0
- this.y == 0L
- this.z == 0.0
- this.b == (byte) 0
- this.s == (short) 0
- this.f == 0.0F
- this.flag == false
- this.c == (char) 0
+ assertEquals(this.x, 0)
+ assertEquals(this.y, 0L)
+ assertEquals(this.z, 0.0d)
+ assertEquals(this.b, (byte) 0)
+ assertEquals(this.s, (short) 0)
+ assertEquals(this.f, 0.0f)
+ assertFalse(this.flag)
+ assertEquals(this.c, ZERO)
}
void testPrimitiveDefaultValues() {
def a = new ClassForPrimitiveDefaultValue()
- a.x == 0
- a.y == 0L
- a.z == 0.0
- a.b == (byte) 0
- a.s == (short) 0
- a.f == 0.0F
- a.flag == false
- a.c == (char) 0
+ assertEquals(a.x, 0)
+ assertEquals(a.y, 0L)
+ assertEquals(a.z, 0.0d)
+ assertEquals(a.b, (byte) 0)
+ assertEquals(a.s, (short) 0)
+ assertEquals(a.f, 0.0f)
+ assertFalse(a.flag)
+ assertEquals(a.c, ZERO)
}
void testDefaultPrimitiveValuesForAttributes() {
def a = new ClassForPrimitiveDefaultValue()
- a.@x == 0
- a.@y == 0L
- a.@z == 0.0
- a.@b == (byte) 0
- a.@s == (short) 0
- a.@f == 0.0F
- a.@flag == false
- a.@c == (char) 0
+ assertEquals(a.@x, 0)
+ assertEquals(a.@y, 0L)
+ assertEquals(a.@z, 0.0d)
+ assertEquals(a.@b, (byte) 0)
+ assertEquals(a.@s, (short) 0)
+ assertEquals(a.@f, 0.0f)
+ assertFalse(a.@flag)
+ assertEquals(a.@c, ZERO)
}
void testDefaultPrimitiveValuesForProperties() {
def a = new ClassForPrimitiveDefaultValue()
- a.x1 == 0
- a.y1 == 0L
- a.z1 == 0.0
- a.b1 == (byte) 0
- a.s1 == (short) 0
- a.f1 == 0.0F
- a.flag1 == false
- a.c1 == (char) 0
+ assertEquals(a.x1, 0)
+ assertEquals(a.y1, 0L)
+ assertEquals(a.z1, 0.0d)
+ assertEquals(a.b1, (byte) 0)
+ assertEquals(a.s1, (short) 0)
+ assertEquals(a.f1, 0.0f)
+ assertFalse(a.flag1)
+ assertEquals(a.c1, ZERO)
}
}
class ClassForPrimitiveDefaultValue {
- int x
- long y
- double z
- byte b
- short s
- float f
- boolean flag
- char c
+ public int x
+ public long y
+ public double z
+ public byte b
+ public short s
+ public float f
+ public boolean flag
+ public char c
int x1
long y1