You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2022/04/29 05:06:57 UTC
[groovy] branch GROOVY_4_0_X updated: GROOVY-10608: The default toString for emulated records has caching enabled (add test)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
new ddfae89acd GROOVY-10608: The default toString for emulated records has caching enabled (add test)
ddfae89acd is described below
commit ddfae89acd97e0d0f11300f4459506344e0e3c8d
Author: Paul King <pa...@asert.com.au>
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 '''