This is an automated email from the ASF dual-hosted git repository. paulk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 863f8d053d59c75994b30e4b73a37b96045df572 Author: Paul King <[email protected]> AuthorDate: Fri Apr 29 15:06:44 2022 +1000 GROOVY-10608: The default toString for emulated records has caching enabled (add test) --- src/test/org/codehaus/groovy/classgen/RecordTest.groovy | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/org/codehaus/groovy/classgen/RecordTest.groovy b/src/test/org/codehaus/groovy/classgen/RecordTest.groovy index 62fdb4042e..e93262ab3c 100644 --- a/src/test/org/codehaus/groovy/classgen/RecordTest.groovy +++ b/src/test/org/codehaus/groovy/classgen/RecordTest.groovy @@ -367,6 +367,21 @@ final class RecordTest { ''' } + + @Test + void testShallowImmutability() { + assertScript ''' + record HasItems(List items) { } + + def itemRec = new HasItems(['a', 'b']) + assert itemRec.items().size() == 2 + itemRec.items().clear() + itemRec.items() << 'c' + assert itemRec.items() == ['c'] + assert itemRec.toString() == 'HasItems[items=[c]]' + ''' + } + @Test void testCoerce() { assertScript '''
