-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createConversionChecker } from '../helpers/helpers.js'; | ||
|
||
QUnit.test('RegExp.escape', assert => { | ||
const { escape } = RegExp; | ||
assert.isFunction(escape); | ||
assert.arity(escape, 1); | ||
assert.name(escape, 'escape'); | ||
assert.looksNative(escape); | ||
assert.nonEnumerable(RegExp, 'escape'); | ||
|
||
assert.same(escape('10$'), '\\x310\\$', '10$'); | ||
assert.same(escape('abcdefg_123456'), 'abcdefg_123456', 'abcdefg_123456'); | ||
assert.same( | ||
escape('(){}[]|,.?*+-^$=<>\\/#&!%:;@~\'"`'), | ||
'\\(\\)\\{\\}\\[\\]\\|\\,\\.\\?\\*\\+\\-\\^\\$\\=\\<\\>\\\\\\/\\#\\&\\!\\%\\:\\;\\@\\~\\\'\\"\\`', | ||
'(){}[]|,.?*+-^$=<>\\/#&!%:;@~\'"`', | ||
); | ||
|
||
const checker = createConversionChecker('10$'); | ||
assert.same(escape(checker), '\\x310\\$', 'checker result'); | ||
assert.same(checker.$valueOf, 0, 'checker valueOf calls'); | ||
assert.same(checker.$toString, 1, 'checker toString calls'); | ||
|
||
if (typeof Symbol == 'function' && !Symbol.sham) { | ||
assert.throws(() => escape(Symbol('thrower')), TypeError, 'throws on symbol'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import escape from 'core-js-pure/full/regexp/escape'; | ||
import Symbol from 'core-js-pure/es/symbol'; | ||
import { createConversionChecker } from '../helpers/helpers.js'; | ||
|
||
QUnit.test('RegExp.escape', assert => { | ||
assert.isFunction(escape); | ||
assert.arity(escape, 1); | ||
assert.name(escape, 'escape'); | ||
|
||
assert.same(escape('10$'), '\\x310\\$', '10$'); | ||
assert.same(escape('abcdefg_123456'), 'abcdefg_123456', 'abcdefg_123456'); | ||
assert.same( | ||
escape('(){}[]|,.?*+-^$=<>\\/#&!%:;@~\'"`'), | ||
'\\(\\)\\{\\}\\[\\]\\|\\,\\.\\?\\*\\+\\-\\^\\$\\=\\<\\>\\\\\\/\\#\\&\\!\\%\\:\\;\\@\\~\\\'\\"\\`', | ||
'(){}[]|,.?*+-^$=<>\\/#&!%:;@~\'"`', | ||
); | ||
|
||
const checker = createConversionChecker('10$'); | ||
assert.same(escape(checker), '\\x310\\$', 'checker result'); | ||
assert.same(checker.$valueOf, 0, 'checker valueOf calls'); | ||
assert.same(checker.$toString, 1, 'checker toString calls'); | ||
|
||
if (!Symbol.sham) { | ||
assert.throws(() => escape(Symbol('thrower')), TypeError, 'throws on symbol'); | ||
} | ||
}); |