mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Ensure _.words detects compound words where an all caps word is next to a capitalized word. [closes #2163]
This commit is contained in:
@@ -229,7 +229,7 @@
|
|||||||
].join('|'), 'g');
|
].join('|'), 'g');
|
||||||
|
|
||||||
/** Used to detect strings that need a more robust regexp to match words. */
|
/** Used to detect strings that need a more robust regexp to match words. */
|
||||||
var reHasComplexWord = /[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
|
var reHasComplexWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
|
||||||
|
|
||||||
/** Used to assign default `context` object properties. */
|
/** Used to assign default `context` object properties. */
|
||||||
var contextProps = [
|
var contextProps = [
|
||||||
|
|||||||
@@ -24020,17 +24020,20 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should work with compound words', function(assert) {
|
QUnit.test('should work with compound words', function(assert) {
|
||||||
assert.expect(9);
|
assert.expect(12);
|
||||||
|
|
||||||
assert.deepEqual(_.words('12Feet'), ['12', 'Feet']);
|
assert.deepEqual(_.words('12Feet'), ['12', 'Feet']);
|
||||||
|
assert.deepEqual(_.words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']);
|
||||||
assert.deepEqual(_.words('enable 6h format'), ['enable', '6', 'h', 'format']);
|
assert.deepEqual(_.words('enable 6h format'), ['enable', '6', 'h', 'format']);
|
||||||
assert.deepEqual(_.words('enable 24H format'), ['enable', '24', 'H', 'format']);
|
assert.deepEqual(_.words('enable 24H format'), ['enable', '24', 'H', 'format']);
|
||||||
assert.deepEqual(_.words('isISO8601'), ['is', 'ISO', '8601']);
|
assert.deepEqual(_.words('isISO8601'), ['is', 'ISO', '8601']);
|
||||||
|
assert.deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']);
|
||||||
assert.deepEqual(_.words('tooLegit2Quit'), ['too', 'Legit', '2', 'Quit']);
|
assert.deepEqual(_.words('tooLegit2Quit'), ['too', 'Legit', '2', 'Quit']);
|
||||||
assert.deepEqual(_.words('walk500Miles'), ['walk', '500', 'Miles']);
|
assert.deepEqual(_.words('walk500Miles'), ['walk', '500', 'Miles']);
|
||||||
assert.deepEqual(_.words('xhr2Request'), ['xhr', '2', 'Request']);
|
assert.deepEqual(_.words('xhr2Request'), ['xhr', '2', 'Request']);
|
||||||
assert.deepEqual(_.words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']);
|
assert.deepEqual(_.words('XMLHttp'), ['XML', 'Http']);
|
||||||
assert.deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']);
|
assert.deepEqual(_.words('XmlHTTP'), ['Xml', 'HTTP']);
|
||||||
|
assert.deepEqual(_.words('XmlHttp'), ['Xml', 'Http']);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should work with compound words containing diacritical marks', function(assert) {
|
QUnit.test('should work with compound words containing diacritical marks', function(assert) {
|
||||||
|
|||||||
Reference in New Issue
Block a user