Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • joe.parks@hyperproductive.com
    replied
    Tests pass now. Thanks.

    Leave a comment:


  • alius
    replied
    Hi,

    Thanks. Corrected.
    You can test it with next nightly build.

    Regards,
    Alius

    Leave a comment:


  • joe.parks@hyperproductive.com
    replied
    Looking at the bytecode, it seems like the code is not converting this set to true: {"t", "y", "true", "yes"}. Instead, it's converting *this* set to true: {"t", "y", "true", "false"}.
    I updated the test case to verify this:
    Code:
    /**
     * Test Functionality of the isomorphic castValue method.
     */
    public class DataToolsCastValue {
        @Test
        public void castFalseValue() throws Exception {
            final String falseString = "false";
            final Boolean output = (Boolean) DataTools.castValue(falseString, Boolean.class);
            assertFalse("'false' is not cast to false.", output);  // fails
        }
    
        @Test
        public void castTrueValue() throws Exception {
            final String trueString = "true";
            final Boolean output = (Boolean) DataTools.castValue(trueString, Boolean.class);
            assertTrue("'true' is not cast to true.", output);  // passes
        }
    
        @Test
        public void castYesValue() throws Exception {
            final String yesString = "yes";
            final Boolean output = (Boolean) DataTools.castValue(yesString, Boolean.class);
            assertTrue("'yes' is not cast to true.", output);  // fails
        }
    }

    Leave a comment:


  • joe.parks@hyperproductive.com
    replied
    The test case shows that the behavior is not as documented. The String, "false", is not in the set {"true", "t", "yes", "y"}, so it should be converted to false.
    The assertion in the test case fails: the value "false" is not converted to false; it is converted to true.

    Leave a comment:


  • Isomorphic
    replied
    This is exactly what the method is documented to do:

    If targetType is Boolean and passed value is instance of String then "true", "t", "yes" and "y" (ignoring case) converted to true; any other string converted to false
    From here.

    It's not clear how your code ends up relying on "false" -> false conversion in the first place; possibly that's what to correct. But if you need to rely on this conversion and prefer a different conversion behavior you'll need to add it yourself, because we won't be changing the documented behavior of this method.

    Leave a comment:


  • DataTools.castValue() returns incorrect value for "false"

    1. SmartClient Version: v8.3p_2013-02-06/Enterprise Deployment (built 2013-02-06)
    The same result occurs with the 4.0d build from 2013-05-30

    2. N/A (Server-side), but IE 9 and Firefox 21.0

    3. Logs do not indicate any error

    4. no problem processing the response

    5. no error

    6. JUnit test cases:
    Code:
    /**
     * Test Functionality of the isomorphic castValue method.
     */
    public class DataToolsCastValue {
        @Test
        public void castFalseValue() throws Exception {
            final String falseString = "false";
            final Boolean output = (Boolean) DataTools.castValue(falseString, Boolean.class);
            assertFalse("'false' is not cast to false.", output);  // fails
        }
    
        @Test
        public void castTrueValue() throws Exception {
            final String trueString = "true";
            final Boolean output = (Boolean) DataTools.castValue(trueString, Boolean.class);
            assertTrue("'true' is not cast to true.", output);  // passes
        }
    }
    This incorrect behavior is causing some hibernate queries to fail, when searching for objects containing an attribute of type boolean that are set to false.
Working...
X