File: esnext.string.cooked.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 (21 lines) | stat: -rw-r--r-- 870 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
QUnit.test('String.cooked', assert => {
  const { cooked } = String;
  assert.isFunction(cooked);
  assert.arity(cooked, 1);
  assert.name(cooked, 'cooked');
  assert.looksNative(cooked);
  assert.nonEnumerable(String, 'cooked');
  assert.same(cooked(['Hi\\n', '!'], 'Bob'), 'Hi\\nBob!', 'template is an array');
  assert.same(cooked('test', 0, 1, 2), 't0e1s2t', 'template is a string');
  assert.same(cooked('test', 0), 't0est', 'lacks substituting');
  assert.same(cooked([]), '', 'empty template');

  if (typeof Symbol == 'function' && !Symbol.sham) {
    const symbol = Symbol('cooked test');
    assert.throws(() => cooked([symbol]), TypeError, 'throws on symbol #1');
    assert.throws(() => cooked('test', symbol), TypeError, 'throws on symbol #2');
  }

  assert.throws(() => cooked([undefined]), TypeError);
  assert.throws(() => cooked(null), TypeError);
});