How to use the qunit.assert.throws 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 / index.js View on Github external
test('.validateSettings() checks output texture size - too large', () => {
  const mockContext = {
    constructor: {
      features: {
        maxTextureSize: 1,
      },
    },
    checkOutput: () => {},
    output: [2],
    validate: true,
    checkTextureSize: WebGL2Kernel.prototype.checkTextureSize,
  };
  assert.throws(() => {
    WebGL2Kernel.prototype.validateSettings.apply(mockContext, []);
  }, new Error('Texture size [1,2] generated by kernel is larger than supported size [1,1]'));
});
github gpujs / gpu.js / test / internal / backend / web-gl / function-node / getVariableSignature.js View on Github external
test('binary expression divide', () => {
  assert.throws(() => {
    run('value[0] / value[0]');
  });
});
github gpujs / gpu.js / test / internal / backend / gl-kernel.js View on Github external
test('setOutput() throws when not dynamicOutput and already compiled', () => {
  assert.throws(() => {
    GLKernel.prototype.setOutput.call({
      program: {},
      toKernelOutput: () => {},
      dynamicOutput: false
    });
  }, new Error('Resizing a kernel with dynamicOutput: false is not possible'));
});
github gpujs / gpu.js / test / internal / backend / web-gl / kernel / index.js View on Github external
test('.validateSettings() checks output texture size - too large', () => {
  const mockContext = {
    constructor: {
      features: {
        maxTextureSize: 1,
      },
    },
    checkOutput: () => {},
    output: [2],
    validate: true,
    checkTextureSize: WebGLKernel.prototype.checkTextureSize,
  };
  assert.throws(() => {
    WebGLKernel.prototype.validateSettings.apply(mockContext, []);
  }, new Error('Texture size [1,2] generated by kernel is larger than supported size [1,1]'));
});
github gpujs / gpu.js / test / features / read-color-texture.js View on Github external
test('colorSyntaxTest (cpu) throws', () => {
  assert.throws(() => {
    colorSyntaxTest('cpu');
  });
});
github gpujs / gpu.js / test / features / constants-image-array.js View on Github external
(GPU.isWebGLSupported && typeof Image !== 'undefined' ? test : skip)('webgl', t => {
  assert.throws(() => {
    feature('webgl')
  }, 'imageArray are not compatible with webgl');
});
github gpujs / gpu.js / test / features / output.js View on Github external
function outputGraphicalArray(mode) {
  const gpu = new GPU({ mode });
  const mockContext = {
    getExtension: () => {}
  };
  const mockCanvas = {
    getContext: () => mockContext,
  };
  assert.throws(() => {
    const kernel = gpu.createKernel(function(input) {
      return input[this.thread.x];
    }, {
      canvas: mockCanvas,
      output: [5],
      graphical: true
    });
    kernel([1]);
  }, new Error('Output must have 2 dimensions on graphical mode'));
  gpu.destroy();
}
github gpujs / gpu.js / test / features / istanbul.js View on Github external
if (!kernel.hasPrependString(string1)) {
        kernel.prependString(string1);
      }

      const string2 = '__coverage__();\n';
      if (!kernel.hasPrependString(string2)) {
        kernel.prependString(string2);
      }
    }
  });
  const kernel = gpu.createKernel(`function() {
    mockGlobalValue.f[100]++;
    return (mockGlobalValue.f[100]++, 1);
  }`, { output: [1] });
  assert.deepEqual(kernel(), new Float32Array([1]));
  assert.throws(() => {
    kernel.prependString('null');
  }, new Error('Kernel already built'));
  gpu.destroy();
}
github gpujs / gpu.js / test / features / output.js View on Github external
function outputGraphicalCube(mode) {
  const gpu = new GPU({ mode });
  const mockContext = {
    getExtension: () => {}
  };
  const mockCanvas = {
    getContext: () => mockContext
  };
  assert.throws(() => {
    const kernel = gpu.createKernel(function(input) {
      return input[this.thread.x];
    }, {
      canvas: mockCanvas,
      output: [5,5,5],
      graphical: true
    });
    kernel([1]);
  }, new Error('Output must have 2 dimensions on graphical mode'));
  gpu.destroy();
}
github gpujs / gpu.js / test / internal / backend / web-gl / kernel-value / dynamic-memory-optimized-number-texture.js View on Github external
features: { maxTextureSize: 1 },
    },
    validate: true,
  };

  const v = new webGLKernelValueMaps.unsigned.dynamic.MemoryOptimizedNumberTexture({ size: [1, 1] }, {
    kernel: mockKernel,
    name: 'test',
    type: 'MemoryOptimizedNumberTexture',
    origin: 'user',
    tactic: 'speed',
    onRequestContextHandle: () => 1,
    onRequestTexture: () => null,
    onRequestIndex: () => 1
  });
  assert.throws(() => {
    v.updateValue({
      size: [2,1]
    })
  }, new Error('Argument width of 2 larger than maximum size of 1 for your GPU'));
});