[Tarantool-patches] [PATCH luajit] test: add test case for math.modf

Maksim Kokryashkin max.kokryashkin at gmail.com
Fri Feb 3 15:45:50 MSK 2023


Follows up commit 9b6c0cd8eafdd2e5a8a7ac4b33f6e33b3d8a93b9
("Don't compile math.modf() anymore.").

This patch introduces the test case for the issue with
compiled `math.modf`, that was fixed by disabling the
compilation for it.

Part of tarantool/tarantool#7230
---
Branch: https://github.com/tarantool/luajit/tree/fckxorg/modf-test
PR: https://github.com/tarantool/tarantool/pull/8251

 test/tarantool-tests/math-modf.test.lua | 31 +++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 test/tarantool-tests/math-modf.test.lua

diff --git a/test/tarantool-tests/math-modf.test.lua b/test/tarantool-tests/math-modf.test.lua
new file mode 100644
index 00000000..2aaa5189
--- /dev/null
+++ b/test/tarantool-tests/math-modf.test.lua
@@ -0,0 +1,31 @@
+local tap = require('tap')
+local test = tap.test('math-modf')
+test:plan(1)
+
+local function isnan(x)
+    return x ~= x
+end
+
+local function array_is_consistent(res)
+  for i = 1, #res - 1 do
+    if res[i] ~= res[i + 1] and not (isnan(res[i]) and isnan(res[i + 1])) then
+      return false
+    end
+  end
+  return true
+end
+
+jit.opt.start('hotloop=1')
+jit.on()
+
+local modf = math.modf
+local inf = math.huge
+
+local r1 = {nil, nil, nil, nil}
+local r2 = {nil, nil, nil, nil}
+
+for i = 1, 4 do
+  r1[i], r2[i] = modf(inf)
+end
+
+test:ok(array_is_consistent(r1) and array_is_consistent(r2), 'wrong modf')
--
2.37.1 (Apple Git-137.1)



More information about the Tarantool-patches mailing list