-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
esnext.string.is-well-formed.js
35 lines (30 loc) · 1.36 KB
/
esnext.string.is-well-formed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { STRICT } from '../helpers/constants';
import Symbol from 'core-js-pure/es/symbol';
import isWellFormed from 'core-js-pure/actual/string/virtual/is-well-formed';
QUnit.test('String#isWellFormed', assert => {
assert.isFunction(isWellFormed);
assert.true(isWellFormed.call('a'), 'a');
assert.true(isWellFormed.call('abc'), 'abc');
assert.true(isWellFormed.call('💩'), '💩');
assert.true(isWellFormed.call('💩b'), '💩b');
assert.true(isWellFormed.call('a💩'), '💩');
assert.true(isWellFormed.call('a💩b'), 'a💩b');
assert.true(isWellFormed.call('💩a💩'), '💩a💩');
assert.true(!isWellFormed.call('\uD83D'), '\uD83D');
assert.true(!isWellFormed.call('\uDCA9'), '\uDCA9');
assert.true(!isWellFormed.call('\uDCA9\uD83D'), '\uDCA9\uD83D');
assert.true(!isWellFormed.call('a\uD83D'), 'a\uD83D');
assert.true(!isWellFormed.call('\uDCA9a'), '\uDCA9a');
assert.true(!isWellFormed.call('a\uD83Da'), 'a\uD83Da');
assert.true(!isWellFormed.call('a\uDCA9a'), 'a\uDCA9a');
assert.true(isWellFormed.call({
toString() {
return 'abc';
},
}), 'conversion #1');
if (STRICT) {
assert.throws(() => isWellFormed.call(null), TypeError, 'coercible #1');
assert.throws(() => isWellFormed.call(undefined), TypeError, 'coercible #2');
}
assert.throws(() => isWellFormed.call(Symbol()), 'throws on symbol context');
});