diff --git a/test/functions/BitSHLN.cfc b/test/functions/BitSHLN.cfc index 101e87498f..1002366360 100644 --- a/test/functions/BitSHLN.cfc +++ b/test/functions/BitSHLN.cfc @@ -1,11 +1,25 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ + function beforeAll(){ variables.preciseMath = getApplicationSettings().preciseMath; }; - function run( testResults , testBox ) { - describe( title="Test suite for BitSHLN()", body=function() { - it(title="Checking BitSHLN() function with small shifts", body = function(currentSpec) { + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; + + function run( testResults , testBox ) { + describe( title="Test suite for BitSHLN()", body=function() { + + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + it(title="Checking BitSHLN() function with small shifts", body = function(currentSpec) { assertEquals("2", BitSHLN(1, 1)); // 1 << 1 = 2 assertEquals("1073741824", BitSHLN(1, 30)); assertEquals("2147483648", BitSHLN(1, 31)); @@ -18,10 +32,10 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ it(title="Checking BitSHLN() function with large number shift", body = function(currentSpec) { // Shift a large number that's already near the boundary of 32-bit integer range - if ( variables.preciseMath ) - assertEquals("4294967294", toString(BitSHLN(2147483647, 1))); // 2147483647 << 1 = 0 (overflow) - else - assertEquals("4294967296", toString(BitSHLN(2147483647, 1))); // 2147483647 << 1 = 0 (overflow) + application action="update" preciseMath=true; + assertEquals("4294967294", toString(BitSHLN(2147483647, 1))); // 2147483647 << 1 = 0 (overflow) + application action="update" preciseMath=false; + assertEquals("4294967296", toString(BitSHLN(2147483647, 1))); // 2147483647 << 1 = 0 (overflow) }); it(title="Checking BitSHLN() function with negative shift", body = function(currentSpec) { @@ -38,19 +52,21 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ it(title="Checking BitSHLN() function with extreme shifts 16", body = function(currentSpec) { // Extreme shift cases where the shift count is very large + application action="update" preciseMath=true; assertEquals(65536, BitSHLN(1, 16)); // 1 << 64 = 0 (all bits shifted out in a 64-bit context) }); it(title="Checking BitSHLN() function with extreme shifts 64", body = function(currentSpec) { // Extreme shift cases where the shift count is very large + application action="update" preciseMath=true; assertEquals("18446744073709551616",toString(BitSHLN(1, 64))); // 1 << 64 = 0 (all bits shifted out in a 64-bit context) }); it(title="Checking BitSHLN() function with extreme shifts 128", body = function(currentSpec) { // Extreme shift cases where the shift count is very large - if ( variables.preciseMath ) - assertEquals("340282366920938463463374607431768211456",toString(BitSHLN(1, 128))); // 1 << 64 = 0 (all bits shifted out in a 64-bit context) - else - assertEquals("0", BitSHLN(1, 64)); // 1 << 64 = 0 (all bits shifted out in a 64-bit context) + application action="update" preciseMath=true; + assertEquals("340282366920938463463374607431768211456",toString(BitSHLN(1, 128))); // 1 << 64 = 0 (all bits shifted out in a 64-bit context) + application action="update" preciseMath=false; + assertEquals("0", BitSHLN(1, 64)); // 1 << 64 = 0 (all bits shifted out in a 64-bit context) }); - }); - } + }); + } } \ No newline at end of file diff --git a/test/functions/BitSHRN.cfc b/test/functions/BitSHRN.cfc index 21f2344b56..da0b122473 100644 --- a/test/functions/BitSHRN.cfc +++ b/test/functions/BitSHRN.cfc @@ -1,40 +1,55 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ + function beforeAll(){ - variables.preciseMath = getApplicationSettings().preciseMath; - }; - - function run( testResults , testBox ) { - describe( title="Test suite for BitSHRN()", body=function() { - it(title="Checking BitSHRN() function", body = function( currentSpec ) { - assertEquals("0",BitSHRN(1,1)); - assertEquals("0",BitSHRN(1,30)); - assertEquals("0",BitSHRN(1,31)); - assertEquals("0",BitSHRN(2,31)); - assertEquals("32",BitSHRN(128,2)); - }); + variables.preciseMath = getApplicationSettings().preciseMath; + }; + + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; + + function run( testResults , testBox ) { + describe( title="Test suite for BitSHRN()", body=function() { + + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + it(title="Checking BitSHRN() function", body = function( currentSpec ) { + assertEquals("0",BitSHRN(1,1)); + assertEquals("0",BitSHRN(1,30)); + assertEquals("0",BitSHRN(1,31)); + assertEquals("0",BitSHRN(2,31)); + assertEquals("32",BitSHRN(128,2)); + }); it(title="Checking BitSHRN() function with shifting zero", body = function(currentSpec) { assertEquals("1", BitSHRN(1, 0)); // 1 >> 0 = 1 (no shift should occur) }); it(title="Checking BitSHRN() function with large numbers", body = function(currentSpec) { - if ( variables.preciseMath ) - assertEquals("2147483647", BitSHRN(4294967295, 1)); // Large number shifted right - else - assertEquals("2147483648", BitSHRN(4294967295, 1)); // Large number shifted right + application action="update" preciseMath=true; + assertEquals("2147483647", BitSHRN(4294967295, 1)); // Large number shifted right + application action="update" preciseMath=false; + assertEquals("2147483648", BitSHRN(4294967295, 1)); // Large number shifted right }); it(title="Checking BitSHRN() function with negative numbers", body = function(currentSpec) { + application action="update" preciseMath=true; assertEquals("-1", BitSHRN(-2, 1)); // -2 >> 1 = -1 (propagating the sign bit) assertEquals("-64", BitSHRN(-255, 2)); // -255 >> 2 = -64 (propagating the sign bit) }); it(title="Checking BitSHRN() function with extreme shift values", body = function(currentSpec) { - if ( variables.preciseMath ) - assertEquals("8", BitSHRN(147573952589676412928, 64)); // 128 >> 64 = 0 (all bits shifted out) - else - assertEquals("0", BitSHRN(128, 64)); // 128 >> 64 = 0 (all bits shifted out) + application action="update" preciseMath=true; + assertEquals("8", BitSHRN(147573952589676412928, 64)); // 128 >> 64 = 0 (all bits shifted out) + application action="update" preciseMath=false; + assertEquals("0", BitSHRN(128, 64)); // 128 >> 64 = 0 (all bits shifted out) }); - }); - } + }); + } } diff --git a/test/functions/BitXor.cfc b/test/functions/BitXor.cfc index a772a223ea..b26517bd18 100644 --- a/test/functions/BitXor.cfc +++ b/test/functions/BitXor.cfc @@ -1,11 +1,24 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ - function beforeAll(){ - variables.preciseMath = getApplicationSettings().preciseMath; - }; + function beforeAll(){ + variables.preciseMath = getApplicationSettings().preciseMath; + }; + + function afterAll(){ + application action="update" preciseMath=variables.preciseMath; + }; function run( testResults , testBox ) { describe( title="Test suite for BitXOr()", body=function() { + + beforeEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + + afterEach( function(){ + application action="update" preciseMath=variables.preciseMath; + }); + it(title="Checking BitXOr() function", body = function( currentSpec ) { assertEquals("2",BitXOr(1, 3)); }); @@ -32,12 +45,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ // Both numbers are large and outside the standard int range assertEquals("0", BitXOr("18446744073709551615", "18446744073709551615")); // All bits are the same, so XOR results in 0 }); - it(title="Checking BitXOr() function with different large numbers", body = function(currentSpec) { - if ( variables.preciseMath ) - assertEquals("18446744073709551614", BitXOr("18446744073709551615", "1")); // 111...11111111 XOR 000...00000001 = 111...11111110 - else - assertEquals("9223372036854775807", BitXOr("18446744073709551615", "1")); // 111...11111111 XOR 000...00000001 = 111...11111110 + application action="update" preciseMath=true; + assertEquals("18446744073709551614", BitXOr("18446744073709551615", "1")); // 111...11111111 XOR 000...00000001 = 111...11111110 + + application action="update" preciseMath=false; + assertEquals("9223372036854775807", BitXOr("18446744073709551615", "1")); // 111...11111111 XOR 000...00000001 = 111...11111110 }); });