This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test | |
class DeclaredFieldsTest | |
{ | |
static { | |
Class.metaClass.getNonSyntheticFields = { -> | |
delegate.declaredFields.grep { !it.synthetic } | |
} | |
} | |
class Data { | |
public String name | |
public int count | |
static def field(name) { Data.class.getField(name) } | |
} | |
@Test void getDeclaredFields() { | |
def expectedFields = [Data.field('name'), Data.field('count')] | |
assert expectedFields == Data.class.nonSyntheticFields | |
} | |
} |