diff options
author | daurnimator <quae@daurnimator.com> | 2017-08-18 13:49:16 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-08-18 13:52:20 +1000 |
commit | 36f446c3d43a90063962f8af790e7b58b08765f5 (patch) | |
tree | 7ffa6e9785440fa4b2c54b03cd97f8de80f7e4ae | |
parent | 389630abe2f44e122d29af7159dd1a0d5c585d15 (diff) | |
download | fengari-36f446c3d43a90063962f8af790e7b58b08765f5.tar.gz fengari-36f446c3d43a90063962f8af790e7b58b08765f5.tar.bz2 fengari-36f446c3d43a90063962f8af790e7b58b08765f5.zip |
Remove math.randomseed implementation
See #78
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/lmathlib.js | 20 | ||||
-rw-r--r-- | tests/test-suite/math.js | 10 | ||||
-rw-r--r-- | yarn.lock | 4 |
5 files changed, 6 insertions, 30 deletions
@@ -84,6 +84,7 @@ p(L); ## NYI +- `math.randomseed()` - `io.input()`: partially implemented - `io.lines()` - `io.open()` diff --git a/package.json b/package.json index 8aaa972..746ed93 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ }, "dependencies": { "readline-sync": "^1.4.7", - "seedrandom": "^2.4.2", "sprintf-js": "^1.1.1", "strftime": "^0.10.0", "tmp": "0.0.31" diff --git a/src/lmathlib.js b/src/lmathlib.js index 4a62d52..16e2ad3 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -1,22 +1,13 @@ "use strict"; -const seedrandom = require('seedrandom'); - -const lua = require('./lua.js'); -const lauxlib = require('./lauxlib.js'); -const llimit = require('./llimit.js'); -const luaconf = require('./luaconf.js'); - -var RNG = seedrandom(); - -const math_randomseed = function(L) { - RNG = seedrandom(Math.abs(lauxlib.luaL_checknumber(L, 1))); - return 0; -}; +const lua = require('./lua.js'); +const lauxlib = require('./lauxlib.js'); +const llimit = require('./llimit.js'); +const luaconf = require('./luaconf.js'); const math_random = function(L) { let low, up; - let r = RNG(); + let r = Math.random(); switch (lua.lua_gettop(L)) { /* check number of arguments */ case 0: lua.lua_pushnumber(L, r); /* Number between 0 and 1 */ @@ -252,7 +243,6 @@ const mathlib = { "modf": math_modf, "rad": math_rad, "random": math_random, - "randomseed": math_randomseed, "sin": math_sin, "sqrt": math_sqrt, "tan": math_tan, diff --git a/tests/test-suite/math.js b/tests/test-suite/math.js index b92d304..ea021d2 100644 --- a/tests/test-suite/math.js +++ b/tests/test-suite/math.js @@ -1395,8 +1395,6 @@ test("[test-suite] math: testing -0 and NaN", function (t) { test("[test-suite] math: test random for floats", function (t) { let luaCode = ` - math.randomseed(0) - do -- test random for floats local max = -math.huge local min = math.huge @@ -1438,8 +1436,6 @@ test("[test-suite] math: test random for floats", function (t) { test("[test-suite] math: test random for small intervals", function (t) { let luaCode = ` - math.randomseed(0) - do local function aux (p, lim) -- test random for small intervals local x1, x2 @@ -1496,8 +1492,6 @@ test("[test-suite] math: test random for small intervals", function (t) { test("[test-suite] math: test random for large intervals", function (t) { let luaCode = ` - math.randomseed(0) - do local function aux(p1, p2) -- test random for large intervals local max = minint @@ -1556,8 +1550,6 @@ test("[test-suite] math: test random for large intervals", function (t) { test("[test-suite] math: test random for empty interval", function (t) { let luaCode = ` - math.randomseed(0) - assert(not pcall(math.random, minint + 1, minint)) assert(not pcall(math.random, maxint, maxint - 1)) assert(not pcall(math.random, maxint, minint)) @@ -1586,8 +1578,6 @@ test("[test-suite] math: test random for empty interval", function (t) { test("[test-suite] math: interval too large", function (t) { let luaCode = ` - math.randomseed(0) - assert(not pcall(math.random, minint, 0)) assert(not pcall(math.random, -1, maxint)) assert(not pcall(math.random, minint // 2, maxint // 2 + 1)) @@ -1825,10 +1825,6 @@ safe-buffer@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" -seedrandom@^2.4.2: - version "2.4.3" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-2.4.3.tgz#2438504dad33917314bff18ac4d794f16d6aaecc" - "semver@2 || 3 || 4 || 5", semver@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" |