While I don't know exactly what the se3 object is, I suspect it has a String
message property, and the toString() method displays the content of the String,
such as below.
Object se3 = new Object() { String message String toString() { message }}
se3.message = 'LAZY DEVELOPER! This is a Test'
assert se3.message == "'LAZY DEVELOPER! This is a Test'"
Output:assert se3.message == "'LAZY DEVELOPER! This is a Test'"
| | | | | false | 'LAZY DEVELOPER! This is
a Test' LAZY DEVELOPER! This is a Test
The assert call does something a bit interesting with what it displays for the
comparisons. For everything EXCEPT for the final object being compared, it
does _NOT_ show single quotes around Strings.
If you alter the assert to compare against an object instead of a constant, it
might be more obvious what is happening:
Object se3 = new Object() { String message String toString() { message }}
se3.message = 'LAZY DEVELOPER! This is a Test'String testMessage = "'LAZY
DEVELOPER! This is a Test'"
assert se3.message == testMessage
Output:assert se3.message == testMessage
| | | | | | | '\'LAZY DEVELOPER! This is a
Test\'' | | false | 'LAZY DEVELOPER! This is a Test'
LAZY DEVELOPER! This is a Test
-Spencer
On Monday, May 13, 2024 at 12:46:02 PM EDT, Tommy Svensson
<[email protected]> wrote:
Here is a test I have been forced to comment out since it is 100% impossible
to make work due to ' character keeps getting removed!
assert se3.message == "'" +"LAZY DEVELOPER! This is a test" + "'"
No matter what you do here the result will be:
Assertion failed:
assert se3.message == "'" +"LAZY DEVELOPER! This is a test" +
"'" | | | 'LAZY DEVELOPER! This
is a Test' LAZY DEVELOPER! This is a Test
That is the "'" character will be removed in the constant
comparison text and thus the test will always fail, not matter what
I do!!!
Any suggestions ?
I'm using release 21 of Groovy.
______________________
Tommy Svensson
[email protected]