function Scratch3OperatorsBlocks(runtime) {
    /**
     * The runtime instantiating this block package.
     * @type {Runtime}
     */
    this.runtime = runtime;
}

/**
 * Retrieve the block primitives implemented by this package.
 * @return {Object.<string, Function>} Mapping of opcode to Function.
 */
Scratch3OperatorsBlocks.prototype.getPrimitives = function() {
    return {
        'math_number': this.number,
        'text': this.text,
        'operator_add': this.add,
        'operator_subtract': this.subtract,
        'operator_multiply': this.multiply,
        'operator_divide': this.divide,
        'operator_lt': this.lt,
        'operator_equals': this.equals,
        'operator_gt': this.gt,
        'operator_and': this.and,
        'operator_or': this.or,
        'operator_not': this.not,
        'operator_random': this.random
    };
};

Scratch3OperatorsBlocks.prototype.number = function (args) {
    return Number(args.NUM);
};

Scratch3OperatorsBlocks.prototype.text = function (args) {
    return String(args.TEXT);
};

Scratch3OperatorsBlocks.prototype.add = function (args) {
    return args.NUM1 + args.NUM2;
};

Scratch3OperatorsBlocks.prototype.subtract = function (args) {
    return args.NUM1 - args.NUM2;
};

Scratch3OperatorsBlocks.prototype.multiply = function (args) {
    return args.NUM1 * args.NUM2;
};

Scratch3OperatorsBlocks.prototype.divide = function (args) {
    return args.NUM1 / args.NUM2;
};

Scratch3OperatorsBlocks.prototype.lt = function (args) {
    return args.OPERAND1 < args.OPERAND2;
};

Scratch3OperatorsBlocks.prototype.equals = function (args) {
    return args.OPERAND1 == args.OPERAND2;
};

Scratch3OperatorsBlocks.prototype.gt = function (args) {
    return args.OPERAND1 > args.OPERAND2;
};

Scratch3OperatorsBlocks.prototype.and = function (args) {
    if (!args.OPERAND1 || !args.OPERAND2) {
        return false;
    }
    return true;
};

Scratch3OperatorsBlocks.prototype.or = function (args) {
    return args.OPERAND1 || args.OPERAND2;
};

Scratch3OperatorsBlocks.prototype.not = function (args) {
    return !args.OPERAND;
};

Scratch3OperatorsBlocks.prototype.random = function (args, util) {
    // As a demo, this implementation of random returns after 1 second of yield.
    // @todo Match Scratch 2.0 implementation with int-truncation.
    // See: http://bit.ly/1Qc0GzC
    util.yieldAndBlock();
    setTimeout(function() {
        var randomValue = (Math.random() * (args.TO - args.FROM)) + args.FROM;
        util.report(randomValue);
    }, 1000);
};

module.exports = Scratch3OperatorsBlocks;

@@ -1499,32 +1499,40 @@
 s) %7B%0A    return 
+Boolean(
 args.OPERAND1 %3C 
@@ -1536,32 +1536,33 @@
  %3C args.OPERAND2
+)
 ;%0A%7D;%0A%0AScratch3Op
@@ -1615,32 +1615,40 @@
 s) %7B%0A    return 
+Boolean(
 args.OPERAND1 ==
@@ -1653,32 +1653,33 @@
 == args.OPERAND2
+)
 ;%0A%7D;%0A%0AScratch3Op
@@ -1728,32 +1728,40 @@
 s) %7B%0A    return 
+Boolean(
 args.OPERAND1 %3E 
@@ -1765,32 +1765,33 @@
  %3E args.OPERAND2
+)
 ;%0A%7D;%0A%0AScratch3Op
@@ -1846,13 +1846,23 @@
     
-if (!
+return Boolean(
 args
@@ -1875,12 +1875,11 @@
 ND1 
-%7C%7C !
+&& 
 args
@@ -1892,54 +1892,8 @@
 ND2)
- %7B%0A        return false;%0A    %7D%0A    return true
 ;%0A%7D;
@@ -1958,24 +1958,32 @@
 %0A    return 
+Boolean(
 args.OPERAND
@@ -2000,16 +2000,17 @@
 OPERAND2
+)
 ;%0A%7D;%0A%0ASc
@@ -2076,16 +2076,24 @@
  return 
+Boolean(
 !args.OP
@@ -2097,16 +2097,17 @@
 .OPERAND
+)
 ;%0A%7D;%0A%0ASc

Ensure predicates always return booleans