diff --git a/test/functions/ACos.cfc b/test/functions/ACos.cfc index 47b9e43940..fa8f4465c7 100644 --- a/test/functions/ACos.cfc +++ b/test/functions/ACos.cfc @@ -1,16 +1,31 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ + function beforeAll(){ + variables.preciseMath = getApplicationSettings().preciseMath; + }; + + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; function run( testResults , testBox ) { describe( title="Test suite for acos()", body=function() { + + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + it(title="checking acos(1) function", body = function( currentSpec ) { assertEquals(0,acos(1)); }); it(title="checking acos(0.7) function", body = function( currentSpec ) { - if ( getApplicationSettings().preciseMath ) - assertEquals("0.7953988301841436", toString(acos(0.7))); - else - assertEquals("0.795398830184", toString(acos(0.7))); - + application action="update" preciseMath=true; + assertEquals("0.7953988301841436", toString(acos(0.7))); + application action="update" preciseMath=false; + assertEquals("0.795398830184", toString(acos(0.7))); }); it(title="checking acos() function invalid range", body = function( currentSpec ) { diff --git a/test/functions/ASin.cfc b/test/functions/ASin.cfc index 88474811a5..0f679ee26f 100644 --- a/test/functions/ASin.cfc +++ b/test/functions/ASin.cfc @@ -1,11 +1,27 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ + + function beforeAll(){ + variables.preciseMath = getApplicationSettings().preciseMath; + }; + + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; + function run( testResults , testBox ) { describe( title="Test suite for ASin()", body=function() { + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); it(title="Checking ASin() function", body = function( currentSpec ) { - if ( getApplicationSettings().preciseMath ) - assertEquals("0.3046926540153975",tostring( asin(0.3) )); - else - assertEquals("0.304692654015",tostring( asin(0.3) )); + application action="update" preciseMath=true; + assertEquals("0.3046926540153975",tostring( asin(0.3) )); + application action="update" preciseMath=false; + assertEquals("0.304692654015",tostring( asin(0.3) )); }); it(title="Checking ASin() function invaid input", body = function( currentSpec ) { try{ diff --git a/test/functions/Atn.cfc b/test/functions/Atn.cfc index ce19abb2b7..0edbc97eda 100644 --- a/test/functions/Atn.cfc +++ b/test/functions/Atn.cfc @@ -1,16 +1,25 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ + + function beforeAll(){ + variables.preciseMath = getApplicationSettings().preciseMath; + }; + + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; + function run( testResults , testBox ) { describe( title="Test suite for Atn()", body=function() { it(title="Checking Atn() function", body = function( currentSpec ) { - if ( getApplicationSettings().preciseMath ){ - assertEquals( "0.2914567944778671",tostring(atn(0.3))); - assertEquals( "0.9151007005533605",tostring(atn(1.3))); - assertEquals("-1.5607966601082315",tostring(atn(-100))); - } else { - assertEquals( "0.291456794478",tostring(atn(0.3))); - assertEquals( "0.915100700553",tostring(atn(1.3))); - assertEquals("-1.560796660108",tostring(atn(-100))); - } + application action="update" preciseMath=true; + assertEquals( "0.2914567944778671",tostring(atn(0.3))); + assertEquals( "0.9151007005533605",tostring(atn(1.3))); + assertEquals("-1.5607966601082315",tostring(atn(-100))); + + application action="update" preciseMath=false; + assertEquals( "0.291456794478",tostring(atn(0.3))); + assertEquals( "0.915100700553",tostring(atn(1.3))); + assertEquals("-1.560796660108",tostring(atn(-100))); }); }); diff --git a/test/functions/BitAnd.cfc b/test/functions/BitAnd.cfc index eda19053c7..c8917784c0 100644 --- a/test/functions/BitAnd.cfc +++ b/test/functions/BitAnd.cfc @@ -4,8 +4,21 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ variables.preciseMath = getApplicationSettings().preciseMath; }; + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; + function run( testResults , testBox ) { describe( title="Test suite for BitAnd()", body=function() { + + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + it(title="Checking BitAnd() function integers", body = function( currentSpec ) { assertEquals("0",BitAnd(1, 0)); assertEquals("0",BitAnd(0, 0)); @@ -21,13 +34,13 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ it(title="Checking BitAnd() function float edge case ", body = function( currentSpec ) { // they can be converted because they are below the threshold + application action="update" preciseMath=true; assertEquals("0",BitAnd(1, 0.00000000000001)); - if ( variables.preciseMath ) { - assertEquals("1",BitAnd(1, 0.999999999999999)); - } else { - var Integer=createObject("java","java.lang.Integer"); - assertEquals("1",BitAnd(1, Integer.MAX_VALUE)); - } + assertEquals("1",BitAnd(1, 0.999999999999999)); + + application action="update" preciseMath=false; + var Integer=createObject("java","java.lang.Integer"); + assertEquals("1",BitAnd(1, Integer.MAX_VALUE)); }); it("should correctly perform bitwise AND between two positive numbers", function() { @@ -55,10 +68,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ }); it("should correctly perform bitwise AND between two large BigInteger values", function() { + application action="update" preciseMath=true; expect( BitAnd(9223372036854775808, 9223372036854775807) ).toBe(0); }); it("should correctly perform bitwise AND between a BigInteger and a smaller integer", function() { + application action="update" preciseMath=true; // Expect zero because 255 does not overlap with high bits of largeNumber expect( BitAnd(9223372036854775808, 255) ).toBe(0); }); diff --git a/test/functions/BitOr.cfc b/test/functions/BitOr.cfc index 7dd06aaaf1..e7e5b16351 100644 --- a/test/functions/BitOr.cfc +++ b/test/functions/BitOr.cfc @@ -4,8 +4,22 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ variables.preciseMath = getApplicationSettings().preciseMath; }; + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; + + function run( testResults , testBox ) { describe( title="Test suite for BitOr()", body=function() { + + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + it(title="Checking BitOr() function", body = function( currentSpec ) { assertEquals("1", BitOr(1, 0)); }); @@ -27,10 +41,10 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ }); it("should handle bitwise OR where one number is the maximum integer value", function() { - if ( variables.preciseMath ) - expect( BitOr(2147483647, 1) ).toBe(2147483647); - else - expect( BitOr(2147483647, 1) ).toBe(2147483648); + application action="update" preciseMath=true; + expect( BitOr(2147483647, 1) ).toBe(2147483647); + application action="update" preciseMath=false; + expect( BitOr(2147483647, 1) ).toBe(2147483648); }); it("should return the non-zero value when one number is zero", function() { @@ -38,16 +52,19 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ }); it("should correctly perform bitwise OR between two large String values", function() { - if ( variables.preciseMath ) - expect( BitOr("9223372036854775808", "9223372036854775807") ).toBe("18446744073709551615"); - else - expect( BitOr("9223372036854775808", "9223372036854775807") ).toBe("9223372036854775807"); + systemOutput("------", true); + application action="update" preciseMath=true; + systemOutput(getApplicationSettings().preciseMath, true); + expect( BitOr("9223372036854775808", "9223372036854775807") ).toBe("18446744073709551615"); + application action="update" preciseMath=false; + systemOutput(getApplicationSettings().preciseMath, true); + expect( BitOr("9223372036854775808", "9223372036854775807") ).toBe("9223372036854775807"); }); it("should correctly perform bitwise OR between two large Number values", function() { - if ( variables.preciseMath ) - expect( BitOr(9223372036854775808, 9223372036854775807) ).toBe(18446744073709551615); - else - expect( BitOr(9223372036854775808, 9223372036854775807) ).toBe(9223372036854775807); + application action="update" preciseMath=true; + expect( BitOr(9223372036854775808, 9223372036854775807) ).toBe(18446744073709551615); + application action="update" preciseMath=false; + expect( BitOr(9223372036854775808, 9223372036854775807) ).toBe(9223372036854775807); }); it("should correctly perform bitwise OR between a BigInteger and a smaller integer", function() { diff --git a/test/functions/sin.cfc b/test/functions/sin.cfc index 37059997ad..a2a12da6fe 100644 --- a/test/functions/sin.cfc +++ b/test/functions/sin.cfc @@ -1,6 +1,25 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { + + function beforeAll(){ + variables.preciseMath = getApplicationSettings().preciseMath; + }; + + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; + public function run( testResults, testBox ) { describe( title="Testcase for sin() function", body=function() { + + + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + it(title="Checking the sin() function", body=function( currentSpec ) { var a = 90; expect(sin(a)).toBe(0.8939966636005579); @@ -18,10 +37,10 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { it(title="Checking the sin() function to string", body=function( currentSpec ) { var a = 90; - if ( getApplicationSettings().preciseMath ) - expect("#tostring(sin(a))#").toBe("0.8939966636005579"); - else - expect("#tostring(sin(a))#").toBe("0.893996663601"); + application action="update" preciseMath=true; + expect("#tostring(sin(a))#").toBe("0.8939966636005579"); + application action="update" preciseMath=false; + expect("#tostring(sin(a))#").toBe("0.893996663601"); }); }); diff --git a/test/tickets/LDEV3661.cfc b/test/tickets/LDEV3661.cfc index 4ed336bf51..14b305a63b 100644 --- a/test/tickets/LDEV3661.cfc +++ b/test/tickets/LDEV3661.cfc @@ -1,8 +1,25 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ + + function beforeAll(){ + variables.preciseMath = getApplicationSettings().preciseMath; + }; + + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; + function run( testResults , testBox ) { describe( title="Test suite for LDEV-3661", body=function() { + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + it( title='check deserializeJSON 1',body=function( currentSpec ) { var myJSON = '{"lat":20.12283319000001}'; @@ -11,13 +28,14 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ }); it( title='check deserializeJSON 2',body=function( currentSpec ) { - + application action="update" preciseMath=true; var myJSON = '{"lat":20.12283319000001}'; var decoded = deserializeJSON( myJSON ); - if ( getApplicationSettings().preciseMath ) - expect( serializeJSON( decoded ) ).toBe( '{"lat":20.12283319000001}' ); - else - expect( serializeJSON( decoded ) ).toBe( '{"lat":20.12283319}' ); + expect( serializeJSON( decoded ) ).toBe( '{"lat":20.12283319000001}' ); + + application action="update" preciseMath=false; + decoded = deserializeJSON( myJSON ); + expect( serializeJSON( decoded ) ).toBe( '{"lat":20.12283319}' ); });