GROOVY-7291: add test to cover all primitives
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/fe8914e0 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/fe8914e0 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/fe8914e0 Branch: refs/heads/parrot Commit: fe8914e0799f54b24fa4a52613e4eb0371973e53 Parents: b24d30d Author: John Wagenleitner <[email protected]> Authored: Fri Oct 21 07:33:15 2016 -0700 Committer: John Wagenleitner <[email protected]> Committed: Fri Oct 21 07:36:07 2016 -0700 ---------------------------------------------------------------------- src/test/groovy/bugs/Groovy7291Bug.groovy | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/fe8914e0/src/test/groovy/bugs/Groovy7291Bug.groovy ---------------------------------------------------------------------- diff --git a/src/test/groovy/bugs/Groovy7291Bug.groovy b/src/test/groovy/bugs/Groovy7291Bug.groovy index 22203d0..f82925c 100644 --- a/src/test/groovy/bugs/Groovy7291Bug.groovy +++ b/src/test/groovy/bugs/Groovy7291Bug.groovy @@ -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() + ''' + } + }
