How to use the qunit.assert.deepEqual 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 / combine-kernels.js View on Github external
});

  const kernel2 = gpu.createKernel(function(c, d) {
    return c[this.thread.x] * d[this.thread.x];
  }, {
    output: [5],
    precision: 'single',
    optimizeFloatMemory: true,
  });

  const superKernel = gpu.combineKernels(kernel1, kernel2, function(array1, array2, array3) {
    return kernel2(kernel1(array1, array2), array3);
  });

  const result = superKernel([1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5]);
  assert.deepEqual(Array.from(result), [2, 8, 18, 32, 50]);
  gpu.destroy()
}
github gpujs / gpu.js / test / features / to-string / precision / single / arguments / array2.js View on Github external
argumentTypes: { a: 'Array(2)' }
  });

  const a = new Float32Array([1, 2]);
  const expected = [new Float32Array([1,2])];
  const originalResult = originalKernel(a);
  assert.deepEqual(originalResult, expected);
  const kernelString = originalKernel.toString(a);
  const newKernel = new Function('return ' + kernelString)()({ context });
  const newResult = newKernel(a);
  assert.deepEqual(newResult, expected);

  const b = new Float32Array([2, 1]);
  const expected2 = [new Float32Array([2,1])];
  const newResult2 = newKernel(b);
  assert.deepEqual(newResult2, expected2);
  gpu.destroy();
}
github gpujs / gpu.js / test / features / to-string / precision / single / arguments / array2d3.js View on Github external
];
  const expected = [
    [
      new Float32Array([2, 3, 4]),
      new Float32Array([5, 6, 7]),
    ],
    [
      new Float32Array([8, 9, 10]),
      new Float32Array([11, 12, 13]),
    ]
  ];
  const originalResult = originalKernel(a);
  assert.deepEqual(originalResult, expected);
  const kernelString = originalKernel.toString(a);
  const newResult = new Function('return ' + kernelString)()({ context })(a);
  assert.deepEqual(newResult, expected);
  gpu.destroy();
}
github gpujs / gpu.js / test / features / to-string / precision / single / arguments / array.js View on Github external
function testArgument(mode, context, canvas) {
  const gpu = new GPU({ mode });
  const originalKernel = gpu.createKernel(function(a) {
    return a[this.thread.x];
  }, {
    canvas,
    context,
    output: [4],
    precision: 'single',
  });

  const a = [1, 2, 3, 4];
  const expected = new Float32Array([1,2,3,4]);
  const originalResult = originalKernel(a);
  assert.deepEqual(originalResult, expected);
  const kernelString = originalKernel.toString(a);
  const newKernel = new Function('return ' + kernelString)()({ context });
  const newResult = newKernel(a);
  assert.deepEqual(newResult, expected);

  const b = [4,3,2,1];
  const expected2 = new Float32Array([4,3,2,1]);
  const newResult2 = newKernel(b);
  assert.deepEqual(newResult2, expected2);
  gpu.destroy();
}
github gpujs / gpu.js / test / features / optimize-float-memory.js View on Github external
const matrix = [
    [1,2,3,4,5],
    [6,7,8,9,10],
    [11,12,13,14,15],
  ];
  const kernel = gpu.createKernel(function(matrix) {
    return matrix[this.thread.y][this.thread.x];
  }, {
    output: [5, 3],
    optimizeFloatMemory: true,
    precision: 'single',
    pipeline: true,
  });
  const texture = kernel(matrix);
  const result = texture.toArray();
  assert.deepEqual(result.map(row => Array.from(row)), matrix);
  gpu.destroy();
}
github gpujs / gpu.js / test / issues / 96-param-names.js View on Github external
sum += m[y][i] * n[i][x];
    }
    return sum;
  }

  const kernels = gpu.createKernelMap({
    multiplyResult: multiply
  }, function (a, b) {
    return multiply(b, a, this.thread.y, this.thread.x);
  })
    .setOutput([B.length, A.length]);

  const result = kernels(A, B).result;
  assert.deepEqual(Array.from(result[0]), [2,2,2]);
  assert.deepEqual(Array.from(result[1]), [2,2,2]);
  assert.deepEqual(result.length, 2);
  gpu.destroy();
  return result;
}
(GPU.isKernelMapSupported ? test : skip)("Issue #96 - param names auto", () => {
github gpujs / gpu.js / test / features / to-string / precision / single / kernel-map / array / array2d.js View on Github external
output: [2, 2],
    precision: 'single',
  });

  const a = [1, 2, 3, 4, 5, 6];
  const expected = [
    new Float32Array([2, 3]),
    new Float32Array([2, 3]),
  ];
  const expectedZero = [
    new Float32Array([3, 4]),
    new Float32Array([3, 4]),
  ];
  const originalResult = originalKernel(a);
  assert.deepEqual(originalResult.result, expected);
  assert.deepEqual(originalResult[0], expectedZero);
  const kernelString = originalKernel.toString(a);
  const newResult = new Function('return ' + kernelString)()({ context })(a);
  assert.deepEqual(newResult.result, expected);
  assert.deepEqual(newResult[0], expectedZero);
  gpu.destroy();
}
github gpujs / gpu.js / test / features / to-string / precision / single / arguments / array2d3.js View on Github external
[7, 8, 9],
      [10, 11, 12],
    ]
  ];
  const expected = [
    [
      new Float32Array([2, 3, 4]),
      new Float32Array([5, 6, 7]),
    ],
    [
      new Float32Array([8, 9, 10]),
      new Float32Array([11, 12, 13]),
    ]
  ];
  const originalResult = originalKernel(a);
  assert.deepEqual(originalResult, expected);
  const kernelString = originalKernel.toString(a);
  const newResult = new Function('return ' + kernelString)()({ context })(a);
  assert.deepEqual(newResult, expected);
  gpu.destroy();
}
github gpujs / gpu.js / test / features / offscreen-canvas.js View on Github external
worker.onmessage = function (e) {
      const mode = e.data.mode;
      const result = e.data.result;
      assert.equal(mode, 'gpu', 'GPU mode used in Worker');
      assert.deepEqual(result, Float32Array.from([-2, 0, 2]));
      done();
    };
    worker.postMessage('test');
github gpujs / gpu.js / test / features / dynamic-output.js View on Github external
[10,11,12]
    ],
    [
      [10,11,12],
      [11,12,13],
      [12,13,14]
    ]
  ]);
  assert.deepEqual(Array.from(kernel.output), [3,3,3]);

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

  gpu.destroy();
}