Details
-
Type:
Test
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: groovy-jdk
-
Labels:None
-
Environment:Mac OS X 10.4
-
Testcase included:yes
-
Number of attachments :
Description
I added some additional tests to GStringTest.groovy and GStringTest.java.
I also added an additional GStringMockTest.java which extends org.jmock.MockObjectTestCase and uses jMock to test GString.build().
I made a few minor changes to GString.java.
I made it return and store a copy of its "values" array instead of storing the array passed in and returning the internal array from getValues(). The expected behavior wasn't documented, but this way seems better to me for a few reasons. A user can't unintentionally modify a GString by storing the a different value in the value array after creating a GString. It also allows for the internal implementation to change more easily in the future. Instead of storing an array of values, for example, it could use an ArrayList, etc., and only convert to an array in getValues(). If users are expecting to be able to directly modify the contents of the array, this kind of change is difficult to make.
I checked the source, and the only class using GString.getValues() is groovy.sql.Sql.getParameters(), and it is not trying to change the contents of the values array. Since getValues() is so rarely used, an alternative might be to make Sql.getParameters() call GString.getValue(int) and deprecate GString.getValues().
I also added some additional JavaDoc and a little argument validation to GString.java.
I added tests for
GROOVY-1139(seems fixed),GROOVY-626(still broken), andGROOVY-781(still broken). I named the tests fixmeTest...() for the still unresolved issues.Please use gstring_tests_10_27.patch instead of gstring_tests.patch.