Skip to content

Commit

Permalink
GROOVY-7291: add test to cover all primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
jwagenleitner committed Oct 21, 2016
1 parent b24d30d commit fe8914e
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/test/groovy/bugs/Groovy7291Bug.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,52 @@ class Groovy7291Bug extends GroovyTestCase {
''')
}

void testPrimitiveDeclarationHasDefaultValueInClosure() {
assertScript '''
boolean z
byte b
char c
short s
int i
long j
float f
double d
def cl = {
assert z == false && z.class == Boolean
assert b == 0 && b.class == Byte
assert c == '\u0000' && c.class == Character
assert s == 0 && s.class == Short
assert i == 0 && i.class == Integer
assert j == 0L && j.class == Long
assert f == 0.0f && f.class == Float
assert d == 0.0d && d.class == Double
}
cl()
'''
}

void testWrapperDeclarationIsNullInClosure() {
assertScript '''
Boolean z
Byte b
Character c
Short s
Integer i
Long j
Float f
Double d
def cl = {
assert z == null
assert b == null
assert c == null
assert s == null
assert i == null
assert j == null
assert f == null
assert d == null
}
cl()
'''
}

}

0 comments on commit fe8914e

Please sign in to comment.