Optimize _.unescape.

This commit is contained in:
John-David Dalton
2013-12-06 09:13:38 -08:00
parent 9a0465eb05
commit 3633d3cd73
9 changed files with 65 additions and 15 deletions

View File

@@ -1942,12 +1942,16 @@
var escaped = '&<>"'\/',
unescaped = '&<>"\'\/';
test('should escape values', 1, function() {
equal(_.escape(unescaped), escaped);
});
test('should not escape the "/" character', 1, function() {
equal(_.escape('/'), '/');
});
test('should escape values', 1, function() {
equal(_.escape(unescaped), escaped);
test('should handle strings with nothing to escape', 1, function() {
equal(_.escape('abc'), 'abc');
});
test('should return an empty string when provided `null` or `undefined`', 2, function() {
@@ -7788,6 +7792,14 @@
equal(_.unescape(escaped), unescaped);
});
test('should not unescape the "&#x2F;" entity', 1, function() {
equal(_.unescape('&#x2F;'), '&#x2F;');
});
test('should handle strings with nothing to unescape', 1, function() {
equal(_.unescape('abc'), 'abc');
});
test('should unescape the same characters escaped by `_.escape`', 1, function() {
equal(_.unescape(_.escape(unescaped)), unescaped);
});