How to use the qunit.assert.equal 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 / features / dynamic-output.js View on Github external
}, function() {
    return map(this.output.x + this.output.y + this.thread.x + this.thread.y);
  }, { dynamicOutput: true });

  kernel.setOutput([2,2]);
  let result = kernel();
  assert.equal(result.result.length, 2);
  assert.equal(result.result1.length, 2);
  assert.deepEqual(result.result.map(row => Array.from(row)), [[4,5],[5,6]]);
  assert.deepEqual(result.result1.map(row => Array.from(row)), [[4,5],[5,6]]);
  assert.deepEqual(Array.from(kernel.output), [2,2]);

  kernel.setOutput([3,3]);
  result = kernel();
  assert.equal(result.result.length, 3);
  assert.equal(result.result1.length, 3);
  assert.deepEqual(result.result.map(row => Array.from(row)), [[6,7,8],[7,8,9],[8,9,10]]);
  assert.deepEqual(result.result1.map(row => Array.from(row)), [[6,7,8],[7,8,9],[8,9,10]]);
  assert.deepEqual(Array.from(kernel.output), [3,3]);

  gpu.destroy();
}
github gpujs / gpu.js / test / features / to-string.js View on Github external
assert.equal(originalResult.length, expected.length);
  for(let i = 0; i < expected.length; ++i) {
    assert.equal(originalResult[i], expected[i], 'Result index: ' + i);
  }
  assert.strictEqual(textureKernel.canvas, numberKernel.canvas);
  assert.strictEqual(textureKernel.context, numberKernel.context);

  const textureKernelString = textureKernel.toString(a);
  const numberKernelString = numberKernel.toString(textureResult);
  const newTextureKernel = new Function('return ' + textureKernelString)()(context);
  const newNumberKernel = new Function('return ' + numberKernelString)()(context);
  const newKernelResult = newTextureKernel(a);
  assert.equal(textureResult.constructor.name, 'GLTextureUnsigned');
  const newResult = newNumberKernel(newKernelResult);
  assert.equal(newResult.constructor, Float32Array);
  assert.equal(newResult.length, expected.length);
  for(let i = 0; i < expected.length; ++i) {
    assert.equal(newResult[i], expected[i], 'Result index: ' + i);
  }

  gpu.destroy();
}
github gpujs / gpu.js / test / features / optimize-float-memory.js View on Github external
function whenEnabledCallsCorrectRenderFunction3D(mode) {
  const gpu = new GPU({ mode });
  const fn = gpu.createKernel(function() { return 1 }, {
    output: [2, 2, 2],
    precision: 'single',
    optimizeFloatMemory: true,
  });
  const result = fn();
  assert.equal(fn.TextureConstructor.name, 'GLTextureMemoryOptimized3D');
  assert.equal(fn.formatValues, utils.erectMemoryOptimized3DFloat);
  assert.deepEqual(result.map(matrix => matrix.map(row => Array.from(row))), [[[1,1],[1,1]],[[1,1],[1,1]]]);
}
github gpujs / gpu.js / test / internal / deep-types.js View on Github external
gpu
    .addFunction(child1Function)
    .addFunction(child2Function)
    .addFunction(child3Function);
  const kernel = gpu.createKernel(function(kernelArgument1) {
    return child1Function(kernelArgument1);
  }, { output: [1] });
  sinon.spy(FunctionBuilder.prototype, 'lookupReturnType');
  try {
    const result = kernel(1.5);
    assert.equal(result[0], 3.5);
    assert.equal(FunctionBuilder.prototype.lookupReturnType.callCount, 5);
    assert.equal(FunctionBuilder.prototype.lookupReturnType.args[0][0], 'child1Function');
    assert.equal(FunctionBuilder.prototype.lookupReturnType.args[1][0], 'child2Function');
    assert.equal(FunctionBuilder.prototype.lookupReturnType.args[2][0], 'child3Function');
    assert.equal(FunctionBuilder.prototype.lookupReturnType.args[3][0], 'child2Function');
    assert.equal(FunctionBuilder.prototype.lookupReturnType.args[4][0], 'child3Function');
  } finally {
    FunctionBuilder.prototype.lookupReturnType.restore();
  }
}
github gpujs / gpu.js / test / features / return-arrays.js View on Github external
function returnArray2D3FromKernel(mode) {
  const gpu = new GPU({ mode });
  const kernel = gpu.createKernel(function() {
    return [this.thread.x, this.thread.y, this.thread.x * this.thread.y];
  }, { output : [3, 7] ,precision: 'single' });
  const res = kernel();
  for (let y = 0; y < 7; ++y) {
    for (let x = 0; x < 3; ++x) {
        assert.equal(res[y][x][0], x);
        assert.equal(res[y][x][1], y);
        assert.equal(res[y][x][2], x * y);
    }
  }
  gpu.destroy();
}
github gpujs / gpu.js / test / features / istanbul.js View on Github external
function testOnIstanbulCoverageVariable(mode) {
  const onIstanbulCoverageVariableSpy = sinon.stub().returns('');
  const gpu = new GPU({
    mode,
    onIstanbulCoverageVariable: onIstanbulCoverageVariableSpy,
    removeIstanbulCoverage: false,
  });
  try {
    const kernel = gpu.createKernel(`function() {
    mockGlobalValue.f[100]++;
    mockGlobalValue.f[101][100]++;
    return 1;
  }`, {output: [1]});
    assert.equal(kernel.removeIstanbulCoverage, false);
    kernel();
    assert.equal(onIstanbulCoverageVariableSpy.args[0][0], 'mockGlobalValue');
    assert.equal(onIstanbulCoverageVariableSpy.args[0][1], kernel.kernel);
    assert.equal(g.mockGlobalValue.f[100], 1);
    assert.equal(g.mockGlobalValue.f[101][100], 1);
    gpu.destroy();
  }
  catch(e) {
    gpu.destroy();
    throw e;
  }
}
github gpujs / gpu.js / test / internal / backend / web-gl / kernel / addArgument.js View on Github external
case 0:
          assert.equal(target, 'TEXTURE_2D');
          assert.equal(pname, 'TEXTURE_WRAP_S');
          assert.equal(param, 'CLAMP_TO_EDGE');
          texParameteriCalls++;
          break;
        case 1:
          assert.equal(target, 'TEXTURE_2D');
          assert.equal(pname, 'TEXTURE_WRAP_T');
          assert.equal(param, 'CLAMP_TO_EDGE');
          texParameteriCalls++;
          break;
        case 2:
          assert.equal(target, 'TEXTURE_2D');
          assert.equal(pname, 'TEXTURE_MIN_FILTER');
          assert.equal(param, 'NEAREST');
          texParameteriCalls++;
          break;
        case 3:
          assert.equal(target, 'TEXTURE_2D');
          assert.equal(pname, 'TEXTURE_MAG_FILTER');
          assert.equal(param, 'NEAREST');
          texParameteriCalls++;
          break;
        default:
          throw new Error('called too many times');
      }
    },
    createTexture: () => 'TEXTURE',
github gpujs / gpu.js / test / features / switches.js View on Github external
function testBasic(mode) {
  const gpu = new GPU({ mode });
  const kernel = gpu.createKernel(function(value) {
    switch (value) {
      case 1: return 1;
      case 2: return 2;
      case 3: return 3;
    }
    return 0;
  }, {
    argumentTypes: ['Integer'],
    output: [1],
  });
  assert.equal(kernel(1)[0], 1);
  assert.equal(kernel(2)[0], 2);
  assert.equal(kernel(3)[0], 3);
  assert.equal(kernel(4)[0], 0);
  gpu.destroy();
}
github gpujs / gpu.js / test / features / function-return.js View on Github external
function functionReturnArray4( mode ) {
  const gpu = new GPU({ mode });
  const f = gpu.createKernel(function() {
    return [42, 43, 44, 45];
  }, {
    output : [1]
  });

  const result = f();
  assert.equal(result[0].constructor, Float32Array);
  assert.equal(result[0][0], 42);
  assert.equal(result[0][1], 43);
  assert.equal(result[0][2], 44);
  assert.equal(result[0][3], 45);
  gpu.destroy();
}
github gpujs / gpu.js / test / features / switches.js View on Github external
function testBasic(mode) {
  const gpu = new GPU({ mode });
  const kernel = gpu.createKernel(function(value) {
    switch (value) {
      case 1: return 1;
      case 2: return 2;
      case 3: return 3;
    }
    return 0;
  }, {
    argumentTypes: ['Integer'],
    output: [1],
  });
  assert.equal(kernel(1)[0], 1);
  assert.equal(kernel(2)[0], 2);
  assert.equal(kernel(3)[0], 3);
  assert.equal(kernel(4)[0], 0);
  gpu.destroy();
}