@@ -5817,6 +5817,104 @@ async def test_edgeql_functions_math_floor_02(self):
58175817 {True },
58185818 )
58195819
5820+ async def test_edgeql_functions_math_exp_01 (self ):
5821+ # test math::exp basics
5822+
5823+ await self .assert_query_result (
5824+ r'''SELECT math::exp(0);''' ,
5825+ {1.0 },
5826+ )
5827+
5828+ await self .assert_query_result (
5829+ r'''SELECT math::exp(1);''' ,
5830+ {math .e },
5831+ )
5832+
5833+ await self .assert_query_result (
5834+ r'''SELECT math::exp(2.0);''' ,
5835+ {math .exp (2 )},
5836+ )
5837+
5838+ await self .assert_query_result (
5839+ r'''SELECT math::exp(<decimal>1.0);''' ,
5840+ {math .e },
5841+ )
5842+
5843+ await self .assert_query_result (
5844+ r'''SELECT math::exp({1, 2, 3});''' ,
5845+ {math .e , math .exp (2 ), math .exp (3 )},
5846+ )
5847+
5848+ async def test_edgeql_functions_math_exp_02 (self ):
5849+ # test return type of math::exp
5850+
5851+ await self .assert_query_result (
5852+ r'''SELECT math::exp(<int64>1) IS float64;''' ,
5853+ {True },
5854+ )
5855+
5856+ await self .assert_query_result (
5857+ r'''SELECT math::exp(<float64>1.0) IS float64;''' ,
5858+ {True },
5859+ )
5860+
5861+ await self .assert_query_result (
5862+ r'''SELECT math::exp(<decimal>1.0) IS decimal;''' ,
5863+ {True },
5864+ )
5865+
5866+ async def test_edgeql_functions_math_exp_03 (self ):
5867+ # test math::exp edge cases
5868+
5869+ await self .assert_query_result (
5870+ r'''SELECT math::exp(-1);''' ,
5871+ {1 / math .e },
5872+ abs_tol = 1e-5 ,
5873+ )
5874+
5875+ await self .assert_query_result (
5876+ r'''SELECT math::exp(-2.0);''' ,
5877+ {1 / (math .e ** 2 )},
5878+ abs_tol = 1e-5 ,
5879+ )
5880+
5881+ async with self .assertRaisesRegexTx (
5882+ edgedb .NumericOutOfRangeError , 'value out of range: overflow'
5883+ ):
5884+ await self .con .query (r'''SELECT math::exp(1000);''' )
5885+
5886+ await self .assert_query_result (
5887+ r'''SELECT math::exp(<decimal>1000);''' ,
5888+ {
5889+ int (
5890+ '1970071114017046993888879352243323125316937985323845789952'
5891+ '8029913850638507824411934749780765630268899309638179875202'
5892+ '2693598298173054461289923262783660152825232320535169584566'
5893+ '7561922715676027880714224668263140068551685086534979416603'
5894+ '1604536781793809290529972858013286994585647028653437590045'
5895+ '6564355589156220422320260518826112288638358372248724725214'
5896+ '5061504188819374941008712642322484363157605603774399306239'
5897+ '59705844189509050047074217568'
5898+ )
5899+ }
5900+ )
5901+
5902+ await self .assert_query_result (
5903+ r'''SELECT math::exp(<decimal>100);''' ,
5904+ {math .e ** 100 }
5905+ )
5906+
5907+ await self .assert_query_result (
5908+ r'''SELECT math::exp(<float64>'inf');''' ,
5909+ {'Infinity' },
5910+ {math .inf },
5911+ )
5912+ await self .assert_query_result (
5913+ r'''SELECT math::exp(<float64>'nan');''' ,
5914+ {'NaN' },
5915+ {math .nan }
5916+ )
5917+
58205918 async def test_edgeql_functions_math_log_01 (self ):
58215919 await self .assert_query_result (
58225920 r'''SELECT math::ln({1, 10, 32});''' ,
0 commit comments