Revision: 70b63d951a8b
Branch:   default
Author:   Pekka Klärck
Date:     Wed Jun 25 10:50:13 2014 UTC
Log: BuiltIn: Fixed Convert To Octal/Hex with inputs bigger that sys.maxint not to contain L at the end.

Update issue 1739
Summary: `BuiltIn.Convert to Hex/Octal` add 'L' suffix when input is bigger than sys.maxint
Status: Done
Owner: pekka.klarck
Fixed by stripping the offending 'L'. Cannot use 'format' as suggested
in comments because it is not supported by Python/Jython 2.5 that we
still need to support.
http://code.google.com/p/robotframework/source/detail?r=70b63d951a8b

Modified:
 /atest/robot/standard_libraries/builtin/converter.txt
 /atest/testdata/standard_libraries/builtin/converter.txt
 /src/robot/libraries/BuiltIn.py

=======================================
--- /atest/robot/standard_libraries/builtin/converter.txt Fri May 20 09:38:01 2011 UTC +++ /atest/robot/standard_libraries/builtin/converter.txt Wed Jun 25 10:50:13 2014 UTC
@@ -53,6 +53,9 @@

 Convert To Number With Precision
     Check Test Case  ${TEST NAME}
+
+Numeric conversions with long types
+    Check Test Case  ${TEST NAME}

 Convert To String
     ${tc}=  Check Test Case  ${TEST NAME}
=======================================
--- /atest/testdata/standard_libraries/builtin/converter.txt Wed Oct 24 12:45:45 2012 UTC +++ /atest/testdata/standard_libraries/builtin/converter.txt Wed Jun 25 10:50:13 2014 UTC
@@ -8,7 +8,7 @@
     [Template]  Test Convert To Integer
     1  1
     -42  -42
- 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 10**100L + 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 10**100
     ${OBJECT}  42
     ${OBJECT_FAILING}  This fails!

@@ -126,6 +126,22 @@
     Should Be Equal  ${res}  ${1.0}
     Convert to Number  1  invalid

+Numeric conversions with long types
+    [Template]    Numeric conversions with long types
+    # 0x8000000000000000 == sys.maxint+1 on 64bit machines
+    Convert To Integer    0                     0
+    Convert To Integer    42                    42
+    Convert To Integer    0x8000000000000000    9223372036854775808
+    Convert To Hex        0                     0
+    Convert To Hex        42                    2A
+    Convert To Hex        0x8000000000000000    8000000000000000
+    Convert To Octal      0                     0
+    Convert To Octal      42                    52
+    Convert To Octal      0x8000000000000000    1000000000000000000000
+    Convert To Binary     0                     0
+    Convert To Binary     42                    101010
+ Convert To Binary 0x8000000000000000 1000000000000000000000000000000000000000000000000000000000000000
+
 Convert To String
     ${int42} =  Convert To Integer  42
     Should Not Be Equal  ${int42}  42
@@ -190,3 +206,9 @@
     ${act} =  Convert To Number  ${item}
     ${exp} =  Evaluate  ${exp}
     Should Be True  round(${act}, 6) == ${exp}
+
+Numeric conversions with long types
+    [Arguments]    ${keyword}    ${input}    ${expected}
+    ${input} =    Evaluate    long(${input})
+    ${result} =    Run Keyword    ${keyword}    ${input}
+    Should Be Equal As Strings    ${result}    ${expected}
=======================================
--- /src/robot/libraries/BuiltIn.py     Wed Apr 23 13:39:14 2014 UTC
+++ /src/robot/libraries/BuiltIn.py     Wed Jun 25 10:50:13 2014 UTC
@@ -202,7 +202,7 @@
     def _convert_to_bin_oct_hex(self, method, item, base, prefix, length,
                                 lowercase=False):
         self._log_types(item)
-        ret = method(self._convert_to_integer(item, base)).upper()
+ ret = method(self._convert_to_integer(item, base)).upper().rstrip('L')
         prefix = prefix or ''
         if ret[0] == '-':
             prefix = '-' + prefix

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to