File tree Expand file tree Collapse file tree 4 files changed +31
-3
lines changed
regression/strings/CharacterGetNumericValue Expand file tree Collapse file tree 4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.class
3
+ --refine-strings
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ assertion at file test.java line 8 .* SUCCESS$
7
+ assertion at file test.java line 10 .* FAILURE$
8
+ --
9
+ ^warning: ignoring
Original file line number Diff line number Diff line change
1
+ public class test
2
+ {
3
+
4
+ public static void main (String [] args )
5
+ {
6
+ char c = 'a' ;
7
+ if (args .length >1 )
8
+ assert Character .getNumericValue (c ) == 10 ;
9
+ else
10
+ assert Character .getNumericValue (c ) != 10 ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change @@ -126,15 +126,22 @@ codet character_refine_preprocesst::convert_compare(conversion_inputt &target)
126
126
127
127
128
128
// / Converts function call to an assignment of an expression corresponding to
129
- // / the java method Character.digit:(CI)I
129
+ // / the java method Character.digit:(CI)I. The function call has one character
130
+ // / argument and an optional integer radix argument. If the radix is not given
131
+ // / it is set to 36 by default.
130
132
// / \param target: a position in a goto program
133
+ // / \return code assigning the result of the Character.digit function to the
134
+ // / left-hand-side of the given target
131
135
codet character_refine_preprocesst::convert_digit_char (
132
136
conversion_inputt &target)
133
137
{
134
138
const code_function_callt &function_call=target;
135
- assert (function_call.arguments ().size ()==2 );
139
+ const std::size_t nb_args=function_call.arguments ().size ();
140
+ PRECONDITION (nb_args==1 || nb_args==2 );
136
141
const exprt &arg=function_call.arguments ()[0 ];
137
- const exprt &radix=function_call.arguments ()[1 ];
142
+ // If there is no radix argument we set it to 36 which is the maximum possible
143
+ const exprt &radix=
144
+ nb_args>1 ?function_call.arguments ()[1 ]:from_integer (36 , arg.type ());
138
145
const exprt &result=function_call.lhs ();
139
146
const typet &type=result.type ();
140
147
You can’t perform that action at this time.
0 commit comments