2 new revisions:

Revision: f70318543b28
Author:   Pekka Klärck
Date:     Sat May  7 03:13:27 2011
Log: Convert to Integer keyword must use explicitly given base. Also some m...
http://code.google.com/p/robotframework/source/detail?r=f70318543b28

Revision: 1bc0485c5093
Author:   Pekka Klärck
Date:     Sat May  7 03:15:37 2011
Log:      base is not anymore ignored if integers have base as prefix
http://code.google.com/p/robotframework/source/detail?r=1bc0485c5093

==============================================================================
Revision: f70318543b28
Author:   Pekka Klärck
Date:     Sat May  7 03:13:27 2011
Log: Convert to Integer keyword must use explicitly given base. Also some more tests for Convert to Integer.

Update issue 808
I had earlier implemented this so that possible prefix wins over explicit base.
I realized that this wasn't a good idea because, for example, following
would give result 2 when you would expect 2832:

    ${result} =  Convert to Integer  0b10  base=16

I reverted the decision and now explicit base always wins over possible prefix.
http://code.google.com/p/robotframework/source/detail?r=f70318543b28

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 Thu May 5 16:04:57 2011 +++ /atest/robot/standard_libraries/builtin/converter.txt Sat May 7 03:13:27 2011
@@ -18,14 +18,17 @@
Verify argument type message ${tc.kws[0].kws[0].msgs[0]} java.lang.String

 Convert To Integer With Base
-    ${tc}=  Check Test Case  ${TEST NAME}
+    Check Test Case  ${TEST NAME}
+
+Convert To Integer With Invalid Base
+    Check Test Case  ${TEST NAME}

 Convert To Integer With Embedded Base
-    ${tc}=  Check Test Case  ${TEST NAME}
+    Check Test Case  ${TEST NAME}

 Convert To Integer With Base And Java Objects
     [Tags]  jybot
-    ${tc}=  Check Test Case  ${TEST NAME}
+    Check Test Case  ${TEST NAME}

 Convert To Number
     ${tc}=  Check Test Case  ${TEST NAME}
=======================================
--- /atest/testdata/standard_libraries/builtin/converter.txt Thu May 5 16:04:57 2011 +++ /atest/testdata/standard_libraries/builtin/converter.txt Sat May 7 03:13:27 2011
@@ -32,15 +32,20 @@
     10  2   2
     B   -   2

+Convert To Integer With Invalid Base
+ [Documentation] FAIL STARTS: '1' cannot be converted to an integer: 'invalid' cannot be converted to an integer: ValueError:
+    Convert To Integer  1  invalid
+
 Convert To Integer With Embedded Base
[Documentation] FAIL STARTS: 'XXX' cannot be converted to an integer: ValueError:
     [Template]  Test Convert To Integer
-    0xF00  3840
+    0xf00  3840
     0XF00  3840
-    0b101  5     base is ignored
-    0B101  5
-    0o101  65    10
-    0O101  65
+    0b10   2
+    0B10   2
+    0B10   2832  base=16  # Explicit base wins
+    0o101  65
+    0O102  66
     0xXXX  -

 Convert To Integer With Base And Java Objects
=======================================
--- /src/robot/libraries/BuiltIn.py     Fri May  6 00:54:42 2011
+++ /src/robot/libraries/BuiltIn.py     Sat May  7 03:13:27 2011
@@ -42,7 +42,7 @@

         2) Prefix the given string with the base so that `0b` means base 2
         (binary), `0o` means base 8 (octal), and `0x` means base 16 (hex).
-        In this case possible `base` argument is ignored.
+        The prefix is considered only when `base` argument is not given.

         Examples:
         | ${result} = | Convert To Integer | 100   |   | # Result is 100 |
@@ -75,7 +75,7 @@

     def _get_base(self, item, base):
         bases = {'0b': 2, '0o': 8, '0x': 16}
-        if isinstance(item, basestring) \
+        if not base and isinstance(item, basestring) \
                 and item.lower().startswith(tuple(bases)):
             return item[2:], bases[item.lower()[:2]]
         return item, base

==============================================================================
Revision: 1bc0485c5093
Author:   Pekka Klärck
Date:     Sat May  7 03:15:37 2011
Log:      base is not anymore ignored if integers have base as prefix
http://code.google.com/p/robotframework/source/detail?r=1bc0485c5093

Modified:
 /atest/testdata/standard_libraries/builtin/verify.txt

=======================================
--- /atest/testdata/standard_libraries/builtin/verify.txt Thu May 5 16:04:57 2011 +++ /atest/testdata/standard_libraries/builtin/verify.txt Sat May 7 03:15:37 2011
@@ -85,7 +85,7 @@
[Documentation] Conversion functionality tested with `Convert To Integer`
     Should Be Equal As Integers  ABCD  abcd   base=16
     Should Be Equal As Integers  0b10  2
-    Should Be Equal As Integers  0xFF  0o377  base=ignored
+    Should Be Equal As Integers  0xFF  0o377
     Should Be Equal As Integers  0b0   0
     Should Be Equal As Integers  0x0   0o0
     Should Be Equal As Integers  0b1   1

Reply via email to