Skip to content

Commit

Permalink
BL-754
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed Nov 8, 2024
1 parent 8434592 commit b8e134d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public List<AbstractInsnNode> transform( BoxNode node, TransformerContext contex
BoxIntegerLiteral literal = ( BoxIntegerLiteral ) node;
int len = literal.getValue().length();
// 10 or fewer chars can use an int literal
if ( len <= 10 ) {
if ( len < 10 ) {
return List.of(
new LdcInsnNode( Integer.valueOf( literal.getValue() ) ),
new MethodInsnNode( Opcodes.INVOKESTATIC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Node transform( BoxNode node, TransformerContext context ) throws Illegal
int len = literal.getValue().length();
Expression javaExpr;
// 10 or fewer chars can use an int literal
if ( len <= 10 ) {
if ( len < 10 ) {
javaExpr = new IntegerLiteralExpr( literal.getValue() );
} else if ( len <= 19 ) {
// 11-19 chars needs a long literal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private static Number parseNumber( String value ) {
}

// 10 or fewer chars can use an int literal
if ( len <= 10 ) {
if ( len < 10 ) {
return Integer.parseInt( value );
} else if ( len <= 19 ) {
// 11-19 chars needs a long literal
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/TestCases/phase1/CoreLangTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3942,4 +3942,12 @@ public void testNativeListIndexes() {
assertThat( variables.get( Key.of( "resultNeg4" ) ) ).isEqualTo( "b" );
}

@Test
public void testBigNumber() {
instance.executeSource(
"""
l = 9876543210
""", context );
}

}

0 comments on commit b8e134d

Please sign in to comment.