Skip to content

Commit 940a4ff

Browse files
author
Troy Melhase
committed
Fix for uppercase 'f' and 'd' in float/decimal literals.
1 parent 6578ed1 commit 940a4ff

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

java2python/mod/transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def syntaxSafeFloatLiteral(node, config):
4848
value = node.token.text
4949
if value.startswith('.'):
5050
value = '0' + value
51-
if value.endswith(('f', 'd')):
51+
if value.lower().endswith(('f', 'd')):
5252
value = value[:-1]
5353
elif value.endswith(('l', 'L')):
5454
value = value[:-1] + 'L'

test/BasicTypes2.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
class BasicTypes2 {
2+
public static void main(String[] args) {
3+
4+
Integer I = 32;
5+
System.out.println(I);
6+
7+
Boolean B = true;
8+
System.out.println( B ? "ok" : "nope" );
9+
10+
Byte Y = 0;
11+
System.out.println(Y);
12+
13+
Character C = 'c';
14+
System.out.println(C);
15+
16+
Short S = 128;
17+
System.out.println(S);
18+
19+
Long L = 128L;
20+
System.out.println(L);
21+
22+
Float F = 1.5F;
23+
System.out.println(F);
24+
25+
Double D = 1.5;
26+
System.out.println(D);
27+
28+
String T = "done";
29+
System.out.println(T);
30+
31+
32+
}
33+
}

0 commit comments

Comments
 (0)