summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-09 15:19:26 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-09 15:20:53 +0200
commit2b3a4790759168c4f17129f719f96f63a2c6765b (patch)
treef781ac366a71e0e1625cae200fbaebf32d36c9ae
parent8235d4e02fb6196886ed9162326eb46077291100 (diff)
downloadfengari-2b3a4790759168c4f17129f719f96f63a2c6765b.tar.gz
fengari-2b3a4790759168c4f17129f719f96f63a2c6765b.tar.bz2
fengari-2b3a4790759168c4f17129f719f96f63a2c6765b.zip
lvm.tonumber should return the integer value
-rw-r--r--src/lvm.js6
-rw-r--r--tests/test-suite/events.js6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/lvm.js b/src/lvm.js
index eba7d38..376e64e 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -859,8 +859,10 @@ const tonumber = function(v) {
if (v.ttnov() === CT.LUA_TNUMBER)
return v.value;
- if (v.ttnov() === CT.LUA_TSTRING)
- return lobject.luaO_str2num(v.svalue());
+ if (v.ttnov() === CT.LUA_TSTRING) {
+ let number = lobject.luaO_str2num(v.svalue());
+ return number ? number.value : false;
+ }
return false;
};
diff --git a/tests/test-suite/events.js b/tests/test-suite/events.js
index 64e8056..40dc30d 100644
--- a/tests/test-suite/events.js
+++ b/tests/test-suite/events.js
@@ -2,6 +2,8 @@
const test = require('tape');
+global.WEB = false;
+
const lauxlib = require("../../src/lauxlib.js");
const lua = require('../../src/lua.js');
@@ -59,7 +61,7 @@ test("[test-suite] events: testing metatable", function (t) {
setmetatable(t, t) -- causes a bug in 5.1 !
t.__newindex = f
a[1] = 30; a.x = "101"; a[5] = 200
- -- assert(a[1] == 27 and a.x == 98 and a[5] == 197)
+ assert(a[1] == 27 and a.x == 98 and a[5] == 197)
`, L;
t.plan(2);
@@ -80,4 +82,4 @@ test("[test-suite] events: testing metatable", function (t) {
}, "Lua program ran without error");
-}); \ No newline at end of file
+});