@@ -17,6 +17,17 @@ Synopsis: math.log(x [, b])
1717local luzer = require (" luzer" )
1818local test_lib = require (" lib" )
1919
20+ -- The function `math.pow()` has been deprecated in PUC Rio Lua 5.3,
21+ -- see Lua 5.3 Reference Manual, 8.2 – Changes in the Libraries.
22+ --
23+ -- 1. https://www.lua.org/manual/5.3/manual.html
24+ local pow
25+ if test_lib .lua_version () == " LuaJIT" then
26+ pow = math.pow
27+ else
28+ pow = test_lib .math_pow
29+ end
30+
2031local function TestOneInput (buf , _size )
2132 local fdp = luzer .FuzzedDataProvider (buf )
2233 -- The natural logarithm (base e) of x. If x is ±0,
@@ -30,16 +41,14 @@ local function TestOneInput(buf, _size)
3041 assert (test_lib .approx_equal (math.log (x * y , b ),
3142 math.log (x , b ) + math.log (y , b ), 0.01 ))
3243 -- Quotient rule.
33- -- FIXME: assert(test_lib.approx_equal(math.log(x / y, b), math.log(x, b) - math.log(y, b), 0.5))
34-
35- if test_lib .lua_version () == " LuaJIT" then
36- -- Power rule.
37- assert (test_lib .approx_equal (math.log (math.pow (x , y ), b ), y * math.log (x , b ), 0.01 ))
38- -- Inverse property of logarithm.
39- assert (test_lib .approx_equal (math.log (math.pow (b , x ), b ), x , 0.01 ))
40- -- Inverse property of exponent.
41- assert (test_lib .approx_equal (math.pow (b , math.log (x , b )), x , 0.01 ))
42- end
44+ -- assert(test_lib.approx_equal(math.log(x / y, b), math.log(x, b) - math.log(y, b), 0.5))
45+
46+ -- Power rule.
47+ assert (test_lib .approx_equal (math.log (pow (x , y ), b ), y * math.log (x , b ), 0.01 ))
48+ -- Inverse property of logarithm.
49+ assert (test_lib .approx_equal (math.log (pow (b , x ), b ), x , 0.01 ))
50+ -- Inverse property of exponent.
51+ assert (test_lib .approx_equal (pow (b , math.log (x , b )), x , 0.01 ))
4352 -- Zero rule.
4453 assert (math.log (1 , b ) == 0 )
4554 -- Identity rule.
0 commit comments