How to use the qunit.assert.ok function in qunit

To help you get started, we’ve selected a few qunit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gpujs / gpu.js / test / internal / backend / web-gl2 / kernel / setupConstants.js View on Github external
};
  const kernel = new WebGL2Kernel(source, Object.assign({ constants: { v: constant } }, settings, gpuSettings));
  kernel.constructor = {
    lookupKernelValueType: WebGL2Kernel.lookupKernelValueType,
    features: {
      maxTextureSize: 9999
    }
  };
  kernel.program = 'program';
  assert.equal(kernel.constantTextureCount, 0);
  kernel.setupConstants();
  assert.equal(kernel.constantBitRatios.v, expectedBitRatio);
  assert.equal(kernel.kernelConstants.length, 1);
  kernel.kernelConstants[0].updateValue(constant);
  assert.equal(kernel.constantTextureCount, expectedConstantTextureCount);
  assert.ok(texImage2DCalled);
  assert.ok(activeTextureCalled);
  assert.ok(bindTextureCalled);
  assert.equal(texParameteriCalls, 4);
  assert.equal(getUniformLocationCalls, 1);
  assert.notOk(uniform3ivCalled);
  assert.notOk(uniform2ivCalled);
  assert.ok(uniform1iCalled);
}
github gpujs / gpu.js / test / internal / texture-recycling.js View on Github external
.then(() => {
      assert.equal(result.texture._refs, 0);
      assert.equal(spy.callCount, 1);
      assert.ok(spy.calledWith(result.texture));
      spy.restore();
      done();
    });
}
github gpujs / gpu.js / test / features / nested-function.js View on Github external
function nestedSumABTest(mode) {
  const gpu = new GPU({ mode });
  const f = gpu.createKernel(function(a, b) {
    function custom_adder(a,b) {
      return a+b;
    }

    return custom_adder(a[this.thread.x], b[this.thread.x]);
  }, {
    output : [6]
  });

  assert.ok(f !== null, 'function generated test');

  const a = [1, 2, 3, 5, 6, 7];
  const b = [4, 5, 6, 1, 2, 3];

  const res = f(a,b);
  const exp = [5, 7, 9, 6, 8, 10];

  assert.deepEqual(Array.from(res), exp);
  gpu.destroy();
}
github gpujs / gpu.js / test / internal / math.random.js View on Github external
});
  try {
    gpu.addNativeFunction('getSeed', `highp float getSeed() {
    return randomSeedShift;
  }`);
    const kernel = gpu.createKernel(function () {
      const v = Math.random();
      return getSeed();
    }, {output: [1]});
    const results = [];
    for (let i = 0; i < checkCount; i++) {
      const result = kernel();
      assert.ok(results.indexOf(result[0]) === -1, `duplication at index ${results.indexOf(result[0])} from new value ${result[0]}.  Values ${JSON.stringify(results)}`);
      results.push(result[0]);
      seed2 = result[0];
      assert.ok(stub.called);
      stub.restore();
      stub.callsFake((kernel) => {
        kernel.setUniform1f('randomSeed1', seed1);
        kernel.setUniform1f('randomSeed2', seed2);
      });
    }
  } finally {
    stub.restore();
    gpu.destroy();
  }
}
github gpujs / gpu.js / test / issues / 346-uint8array-converted.js View on Github external
const gpu = new GPU({ mode });
  const largeArrayAddressKernel = gpu.createKernel(function(data) {
    return data[this.thread.x];
  }, { precision: 'unsigned' })
    .setOutput([DATA_MAX]);

  const result = largeArrayAddressKernel(data);
  let same = true;
  let i = 0;
  for (; i < DATA_MAX; i++) {
    if (result[i] !== data[i]) {
      same = false;
      break;
    }
  }
  assert.ok(same, "not all elements are the same, failed on index:" + i);
  gpu.destroy();
}
github gpujs / gpu.js / test / features / loops.js View on Github external
const gpu = new GPU({ mode });
  const f = gpu.createKernel(function(a, b) {
    let x = 0;
    for(let i = 0; i < this.constants.max; i++) {
      x = x + 1;
    }

    return (a[this.thread.x] + b[this.thread.x] + x);
  }, {
    output : [6],
    constants: {
      max: 10
    }
  });

  assert.ok( f !== null, 'function generated test');

  const a = [1, 2, 3, 5, 6, 7];
  const b = [4, 5, 6, 1, 2, 3];

  const res = f(a,b);
  const exp = [15, 17, 19, 16, 18, 20];

  assert.deepEqual(Array.from(res), exp);

  gpu.destroy();
}
github gpujs / gpu.js / test / issues / 349-division-by-factors-of-3.js View on Github external
output: [1],
    precision: 'single',
    fixIntegerDivisionAccuracy: false
  });

  if (!gpu.Kernel.features.isIntegerDivisionAccurate) {
    assert.ok(
      (
        idFix(6, 3)[0] === 2
        && idFix(6030401, 3991)[0] === 1511
      ) && (
        idDixOff(6, 3)[0] !== 2
        || idDixOff(6030401, 3991)[0] !== 1511
      ), "when bug is present should show bug!");
  } else {
    assert.ok(idFix(6, 3)[0] === 2 && idDixOff(6, 3)[0] === 2, "when bug isn't present should not show bug!");
  }
  gpu.destroy();
}
(GPU.isSinglePrecisionSupported ? test : skip)('Issue #349 - test disable fix integer division bug auto', () => {
github gpujs / gpu.js / test / internal / backend / web-gl / kernel / addArgument.js View on Github external
const kernel = new WebGLKernel(source, Object.assign({}, settings, gpuSettings));
  const args = [argument];
  kernel.program = 'program';
  assert.equal(kernel.argumentsLength, 0);
  kernel.setupArguments(args);
  assert.equal(kernel.argumentBitRatios[0], expectedBitRatio);
  kernel.addArgument(argument, kernel.argumentTypes[0], 'v');
  assert.equal(kernel.argumentsLength, 1);
  assert.ok(texImage2DCalled);
  assert.ok(activeTextureCalled);
  assert.ok(bindTextureCalled);
  assert.equal(texParameteriCalls, 4);
  assert.equal(getUniformLocationCalls, 3);
  assert.ok(uniform3ivCalled);
  assert.ok(uniform2ivCalled);
  assert.ok(uniform1iCalled);
}
github gpujs / gpu.js / test / internal / backend / web-gl / kernel / addArgument.js View on Github external
}
  }, gl);
  const source = `function(v) { return v[this.thread.x]; }`;
  const settings = {
    context: mockContext,
  };
  const kernel = new WebGLKernel(source, Object.assign({}, settings, gpuSettings));
  const args = [argument];
  kernel.program = 'program';
  assert.equal(kernel.argumentsLength, 0);
  kernel.setupArguments(args);
  assert.equal(kernel.argumentBitRatios[0], expectedBitRatio);
  kernel.addArgument(argument, kernel.argumentTypes[0], 'v');
  assert.equal(kernel.argumentsLength, 1);
  assert.ok(texImage2DCalled);
  assert.ok(activeTextureCalled);
  assert.ok(bindTextureCalled);
  assert.equal(texParameteriCalls, 4);
  assert.equal(getUniformLocationCalls, 3);
  assert.ok(uniform3ivCalled);
  assert.ok(uniform2ivCalled);
  assert.ok(uniform1iCalled);
}
github gpujs / gpu.js / test / internal / backend / web-gl2 / kernel / setupConstants.js View on Github external
};
  kernel.program = 'program';
  assert.equal(kernel.constantTextureCount, 0);
  kernel.setupConstants();
  assert.equal(kernel.constantBitRatios.v, expectedBitRatio);
  assert.equal(kernel.kernelConstants.length, 1);
  kernel.kernelConstants[0].updateValue(constant);
  assert.equal(kernel.constantTextureCount, expectedConstantTextureCount);
  assert.ok(texImage2DCalled);
  assert.ok(activeTextureCalled);
  assert.ok(bindTextureCalled);
  assert.equal(texParameteriCalls, 4);
  assert.equal(getUniformLocationCalls, 1);
  assert.notOk(uniform3ivCalled);
  assert.notOk(uniform2ivCalled);
  assert.ok(uniform1iCalled);
}