|
Groovy example source code file (BadLineNumberOnExceptionBugTest.groovy)
The Groovy BadLineNumberOnExceptionBugTest.groovy source codepackage groovy.bugs /** * Ensure that the correct line information is reported when an exception is thrown. * <p> * This test covers: <ul> * <li>GROOVY-3067 * <li>GROOVY-2983 * * @author Guillaume Laforge */ class BadLineNumberOnExceptionBugTest extends GroovyTestCase { void testGroovy3067() { assertScript """ class Foo { boolean hello() { true } } try { foo = new Foo() if(foo.hello()()) { // line 9 println "do" println "do" println "do" println "do" } assert false } catch (MissingMethodException e) { def scriptTraceElement = e.stackTrace.find { it.declaringClass.startsWith(GroovyTestCase.TEST_SCRIPT_NAME_PREFIX) } assert 9 == scriptTraceElement.lineNumber } """ } void testGroovy2983() { assertScript """ def foo() { integer.metaClass = null // line 3 integer.metaClass = null integer.metaClass = null integer.metaClass = null } try { foo() assert false } catch (MissingPropertyException e) { def scriptTraceElement = e.stackTrace.find { it.declaringClass.startsWith(GroovyTestCase.TEST_SCRIPT_NAME_PREFIX) } assert 3 == scriptTraceElement.lineNumber } """ } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy BadLineNumberOnExceptionBugTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.