|
| 1 | +component extends="org.lucee.cfml.test.LuceeTestCase" { |
| 2 | + |
| 3 | + function beforeAll() { |
| 4 | + variables.preciseMath = getApplicationSettings().preciseMath; |
| 5 | + } |
| 6 | + |
| 7 | + function afterAll() { |
| 8 | + application action="update" preciseMath=variables.preciseMath; |
| 9 | + } |
| 10 | + |
| 11 | + function run( testResults, testBox ) { |
| 12 | + describe( title="test case for LDEV-6043", body=function() { |
| 13 | + |
| 14 | + afterEach( function() { |
| 15 | + application action="update" preciseMath=variables.preciseMath; |
| 16 | + }); |
| 17 | + |
| 18 | + it( "DecimalFormat with large numbers should not use scientific notation", function() { |
| 19 | + expect( DecimalFormat( 10000000 ) ).toBe( "10,000,000.00" ); |
| 20 | + expect( DecimalFormat( 20000000 ) ).toBe( "20,000,000.00" ); |
| 21 | + expect( DecimalFormat( 100000000 ) ).toBe( "100,000,000.00" ); |
| 22 | + expect( DecimalFormat( 1000000000 ) ).toBe( "1,000,000,000.00" ); |
| 23 | + }); |
| 24 | + |
| 25 | + it( "DecimalFormat with negative large numbers", function() { |
| 26 | + expect( DecimalFormat( -10000000 ) ).toBe( "-10,000,000.00" ); |
| 27 | + expect( DecimalFormat( -20000000 ) ).toBe( "-20,000,000.00" ); |
| 28 | + }); |
| 29 | + |
| 30 | + it( "DecimalFormat boundary values around scientific notation threshold", function() { |
| 31 | + expect( DecimalFormat( 9999999 ) ).toBe( "9,999,999.00" ); |
| 32 | + expect( DecimalFormat( 19999999 ) ).toBe( "19,999,999.00" ); |
| 33 | + expect( DecimalFormat( 20000001 ) ).toBe( "20,000,001.00" ); |
| 34 | + }); |
| 35 | + |
| 36 | + it( "DecimalFormat with large numbers and preciseMath=true", function() { |
| 37 | + application action="update" preciseMath=true; |
| 38 | + expect( DecimalFormat( 10000000 ) ).toBe( "10,000,000.00" ); |
| 39 | + expect( DecimalFormat( 20000000 ) ).toBe( "20,000,000.00" ); |
| 40 | + expect( DecimalFormat( 100000000 ) ).toBe( "100,000,000.00" ); |
| 41 | + }); |
| 42 | + |
| 43 | + it( "DecimalFormat with large numbers and preciseMath=false", function() { |
| 44 | + application action="update" preciseMath=false; |
| 45 | + expect( DecimalFormat( 10000000 ) ).toBe( "10,000,000.00" ); |
| 46 | + expect( DecimalFormat( 20000000 ) ).toBe( "20,000,000.00" ); |
| 47 | + expect( DecimalFormat( 100000000 ) ).toBe( "100,000,000.00" ); |
| 48 | + }); |
| 49 | + |
| 50 | + }); |
| 51 | + } |
| 52 | + |
| 53 | +} |
0 commit comments