summaryrefslogtreecommitdiff
path: root/src/lauxlib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann@users.noreply.github.com>2017-05-22 20:06:57 +0200
committerGitHub <noreply@github.com>2017-05-22 20:06:57 +0200
commite3bdd1fea3665df28de25ed76f6399faf957179d (patch)
tree6884757b43064fa7163b54b86aa4561d185b5ca2 /src/lauxlib.js
parent25e2110a5eac0a2e6c7b4d502ffbd53fc61af301 (diff)
parent8a439e5563f12335e3d35dd63b4f8cbcc25a9bd8 (diff)
downloadfengari-e3bdd1fea3665df28de25ed76f6399faf957179d.tar.gz
fengari-e3bdd1fea3665df28de25ed76f6399faf957179d.tar.bz2
fengari-e3bdd1fea3665df28de25ed76f6399faf957179d.zip
Merge pull request #63 from daurnimator/fix-skipped-tests
Investigated + fixed some skipped tests
Diffstat (limited to 'src/lauxlib.js')
-rw-r--r--src/lauxlib.js21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 559e1bc..3959817 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -473,24 +473,9 @@ const luaL_tolstring = function(L, idx) {
switch(t) {
case lua.LUA_TNUMBER: {
if (lua.lua_isinteger(L, idx))
- lua.lua_pushstring(L, lua.to_luastring(lua.lua_tointeger(L, idx).toString()));
- else {
- let n = lua.lua_tonumber(L, idx);
- let a = Math.abs(n);
- let s;
- if (Object.is(n, Infinity))
- s = 'inf';
- else if (Object.is(n, -Infinity))
- s = '-inf';
- else if (Number.isNaN(n))
- s = 'nan';
- else if (a >= 100000000000000 || (a > 0 && a < 0.0001))
- s = n.toExponential();
- else
- s = n.toPrecision(16).replace(/(\.[0-9][1-9]*)0+$/, "$1");
-
- lua.lua_pushstring(L, lua.to_luastring(s));
- }
+ lua.lua_pushfstring(L, lua.to_luastring("%I"), lua.lua_tointeger(L, idx));
+ else
+ lua.lua_pushfstring(L, lua.to_luastring("%f"), lua.lua_tonumber(L, idx));
break;
}
case lua.LUA_TSTRING: