File: es.reflect.apply.js

package info (click to toggle)
node-core-js 3.33.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,828 kB
  • sloc: javascript: 87,204; makefile: 13
file content (17 lines) | stat: -rw-r--r-- 757 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
QUnit.test('Reflect.apply', assert => {
  const { apply } = Reflect;
  assert.isFunction(apply);
  assert.arity(apply, 3);
  assert.name(apply, 'apply');
  assert.looksNative(apply);
  assert.nonEnumerable(Reflect, 'apply');
  assert.same(apply(Array.prototype.push, [1, 2], [3, 4, 5]), 5);
  function f(a, b, c) {
    return a + b + c;
  }
  f.apply = 42;
  assert.same(apply(f, null, ['foo', 'bar', 'baz']), 'foobarbaz', 'works with redefined apply');
  assert.throws(() => apply(42, null, []), TypeError, 'throws on primitive');
  assert.throws(() => apply(() => { /* empty */ }, null), TypeError, 'throws without third argument');
  assert.throws(() => apply(() => { /* empty */ }, null, '123'), TypeError, 'throws on primitive as third argument');
});