add some more tests (and fixes for resulting bugs :-)

This commit is contained in:
dceejay
2015-03-31 15:15:38 +01:00
parent 3c4d4b91d9
commit 9b56b6f4c3
4 changed files with 418 additions and 9 deletions

View File

@@ -18,12 +18,12 @@ module.exports = function(RED) {
"use strict";
function RandomNode(n) {
RED.nodes.createNode(this,n);
this.low = Number(n.low);
this.high = Number(n.high);
this.inte = n.inte;
this.low = Number(n.low || 1);
this.high = Number(n.high || 10);
this.inte = n.inte || false;
var node = this;
this.on("input", function(msg) {
if (node.inte === "true") {
if (node.inte === true) {
msg.payload = Math.round(Number(Math.random()) * (node.high - node.low + 1) + node.low - 0.5);
} else {
msg.payload = Number(Math.random()) * (node.high - node.low) + node.low;