diff --git a/test/strings.js b/test/strings.js index e75b8879..a4d41260 100644 --- a/test/strings.js +++ b/test/strings.js @@ -6,145 +6,145 @@ $(document).ready(function() { module('String extensions'); test('Strings: trim', function() { - equals(_.trim(123), '123', 'Non string'); - equals(_(' foo').trim(), 'foo'); - equals(_('foo ').trim(), 'foo'); - equals(_(' foo ').trim(), 'foo'); - equals(_(' foo ').trim(), 'foo'); - equals(_(' foo ').trim(' '), 'foo', 'Manually set whitespace'); - equals(_('\t foo \t ').trim(/\s/), 'foo', 'Manually set RegExp /\\s+/'); + equal(_.trim(123), '123', 'Non string'); + equal(_(' foo').trim(), 'foo'); + equal(_('foo ').trim(), 'foo'); + equal(_(' foo ').trim(), 'foo'); + equal(_(' foo ').trim(), 'foo'); + equal(_(' foo ').trim(' '), 'foo', 'Manually set whitespace'); + equal(_('\t foo \t ').trim(/\s/), 'foo', 'Manually set RegExp /\\s+/'); - equals(_('ffoo').trim('f'), 'oo'); - equals(_('ooff').trim('f'), 'oo'); - equals(_('ffooff').trim('f'), 'oo'); + equal(_('ffoo').trim('f'), 'oo'); + equal(_('ooff').trim('f'), 'oo'); + equal(_('ffooff').trim('f'), 'oo'); - equals(_('_-foobar-_').trim('_-'), 'foobar'); + equal(_('_-foobar-_').trim('_-'), 'foobar'); - equals(_('http://foo/').trim('/'), 'http://foo'); - equals(_('c:\\').trim('\\'), 'c:'); + equal(_('http://foo/').trim('/'), 'http://foo'); + equal(_('c:\\').trim('\\'), 'c:'); - equals(_(123).trim(), '123'); - equals(_(123).trim(3), '12'); - equals(_('').trim(), '', 'Trim empty string should return empty string'); - equals(_(null).trim(), '', 'Trim null should return empty string'); - equals(_(undefined).trim(), '', 'Trim undefined should return empty string'); + equal(_(123).trim(), '123'); + equal(_(123).trim(3), '12'); + equal(_('').trim(), '', 'Trim empty string should return empty string'); + equal(_(null).trim(), '', 'Trim null should return empty string'); + equal(_(undefined).trim(), '', 'Trim undefined should return empty string'); }); test('String: levenshtein', function() { - equals(_.levenshtein('Godfather', 'Godfather'), 0); - equals(_.levenshtein('Godfather', 'Godfathe'), 1); - equals(_.levenshtein('Godfather', 'odfather'), 1); - equals(_.levenshtein('Godfather', 'Gdfthr'), 3); - equals(_.levenshtein('seven', 'eight'), 5); - equals(_.levenshtein('123', 123), 0); - equals(_.levenshtein(321, '321'), 0); - equals(_.levenshtein('lol', null), 3); - equals(_.levenshtein('lol'), 3); - equals(_.levenshtein(null, 'lol'), 3); - equals(_.levenshtein(undefined, 'lol'), 3); - equals(_.levenshtein(), 0); + equal(_.levenshtein('Godfather', 'Godfather'), 0); + equal(_.levenshtein('Godfather', 'Godfathe'), 1); + equal(_.levenshtein('Godfather', 'odfather'), 1); + equal(_.levenshtein('Godfather', 'Gdfthr'), 3); + equal(_.levenshtein('seven', 'eight'), 5); + equal(_.levenshtein('123', 123), 0); + equal(_.levenshtein(321, '321'), 0); + equal(_.levenshtein('lol', null), 3); + equal(_.levenshtein('lol'), 3); + equal(_.levenshtein(null, 'lol'), 3); + equal(_.levenshtein(undefined, 'lol'), 3); + equal(_.levenshtein(), 0); }); test('Strings: ltrim', function() { - equals(_(' foo').ltrim(), 'foo'); - equals(_(' foo').ltrim(), 'foo'); - equals(_('foo ').ltrim(), 'foo '); - equals(_(' foo ').ltrim(), 'foo '); - equals(_('').ltrim(), '', 'ltrim empty string should return empty string'); - equals(_(null).ltrim(), '', 'ltrim null should return empty string'); - equals(_(undefined).ltrim(), '', 'ltrim undefined should return empty string'); + equal(_(' foo').ltrim(), 'foo'); + equal(_(' foo').ltrim(), 'foo'); + equal(_('foo ').ltrim(), 'foo '); + equal(_(' foo ').ltrim(), 'foo '); + equal(_('').ltrim(), '', 'ltrim empty string should return empty string'); + equal(_(null).ltrim(), '', 'ltrim null should return empty string'); + equal(_(undefined).ltrim(), '', 'ltrim undefined should return empty string'); - equals(_('ffoo').ltrim('f'), 'oo'); - equals(_('ooff').ltrim('f'), 'ooff'); - equals(_('ffooff').ltrim('f'), 'ooff'); + equal(_('ffoo').ltrim('f'), 'oo'); + equal(_('ooff').ltrim('f'), 'ooff'); + equal(_('ffooff').ltrim('f'), 'ooff'); - equals(_('_-foobar-_').ltrim('_-'), 'foobar-_'); + equal(_('_-foobar-_').ltrim('_-'), 'foobar-_'); - equals(_(123).ltrim(1), '23'); + equal(_(123).ltrim(1), '23'); }); test('Strings: rtrim', function() { - equals(_('http://foo/').rtrim('/'), 'http://foo', 'clean trailing slash'); - equals(_(' foo').rtrim(), ' foo'); - equals(_('foo ').rtrim(), 'foo'); - equals(_('foo ').rtrim(), 'foo'); - equals(_('foo bar ').rtrim(), 'foo bar'); - equals(_(' foo ').rtrim(), ' foo'); + equal(_('http://foo/').rtrim('/'), 'http://foo', 'clean trailing slash'); + equal(_(' foo').rtrim(), ' foo'); + equal(_('foo ').rtrim(), 'foo'); + equal(_('foo ').rtrim(), 'foo'); + equal(_('foo bar ').rtrim(), 'foo bar'); + equal(_(' foo ').rtrim(), ' foo'); - equals(_('ffoo').rtrim('f'), 'ffoo'); - equals(_('ooff').rtrim('f'), 'oo'); - equals(_('ffooff').rtrim('f'), 'ffoo'); + equal(_('ffoo').rtrim('f'), 'ffoo'); + equal(_('ooff').rtrim('f'), 'oo'); + equal(_('ffooff').rtrim('f'), 'ffoo'); - equals(_('_-foobar-_').rtrim('_-'), '_-foobar'); + equal(_('_-foobar-_').rtrim('_-'), '_-foobar'); - equals(_(123).rtrim(3), '12'); - equals(_('').rtrim(), '', 'rtrim empty string should return empty string'); - equals(_(null).rtrim(), '', 'rtrim null should return empty string'); + equal(_(123).rtrim(3), '12'); + equal(_('').rtrim(), '', 'rtrim empty string should return empty string'); + equal(_(null).rtrim(), '', 'rtrim null should return empty string'); }); test('Strings: capitalize', function() { - equals(_('fabio').capitalize(), 'Fabio', 'First letter is upper case'); - equals(_.capitalize('fabio'), 'Fabio', 'First letter is upper case'); - equals(_.capitalize('FOO'), 'FOO', 'Other letters unchanged'); - equals(_(123).capitalize(), '123', 'Non string'); - equals(_.capitalize(''), '', 'Capitalizing empty string returns empty string'); - equals(_.capitalize(null), '', 'Capitalizing null returns empty string'); - equals(_.capitalize(undefined), '', 'Capitalizing undefined returns empty string'); + equal(_('fabio').capitalize(), 'Fabio', 'First letter is upper case'); + equal(_.capitalize('fabio'), 'Fabio', 'First letter is upper case'); + equal(_.capitalize('FOO'), 'FOO', 'Other letters unchanged'); + equal(_(123).capitalize(), '123', 'Non string'); + equal(_.capitalize(''), '', 'Capitalizing empty string returns empty string'); + equal(_.capitalize(null), '', 'Capitalizing null returns empty string'); + equal(_.capitalize(undefined), '', 'Capitalizing undefined returns empty string'); }); test('Strings: join', function() { - equals(_.join('', 'foo', 'bar'), 'foobar', 'basic join'); - equals(_.join('', 1, 'foo', 2), '1foo2', 'join numbers and strings'); - equals(_.join(' ','foo', 'bar'), 'foo bar', 'join with spaces'); - equals(_.join('1', '2', '2'), '212', 'join number strings'); - equals(_.join(1, 2, 2), '212', 'join numbers'); - equals(_.join('','foo', null), 'foo', 'join null with string returns string'); - equals(_.join(null,'foo', 'bar'), 'foobar', 'join strings with null returns string'); - equals(_(' ').join('foo', 'bar'), 'foo bar', 'join object oriented'); + equal(_.join('', 'foo', 'bar'), 'foobar', 'basic join'); + equal(_.join('', 1, 'foo', 2), '1foo2', 'join numbers and strings'); + equal(_.join(' ','foo', 'bar'), 'foo bar', 'join with spaces'); + equal(_.join('1', '2', '2'), '212', 'join number strings'); + equal(_.join(1, 2, 2), '212', 'join numbers'); + equal(_.join('','foo', null), 'foo', 'join null with string returns string'); + equal(_.join(null,'foo', 'bar'), 'foobar', 'join strings with null returns string'); + equal(_(' ').join('foo', 'bar'), 'foo bar', 'join object oriented'); }); test('Strings: reverse', function() { - equals(_.str.reverse('foo'), 'oof' ); - equals(_.str.reverse('foobar'), 'raboof' ); - equals(_.str.reverse('foo bar'), 'rab oof' ); - equals(_.str.reverse('saippuakauppias'), 'saippuakauppias' ); - equals(_.str.reverse(123), '321', 'Non string'); - equals(_.str.reverse(123.45), '54.321', 'Non string'); - equals(_.str.reverse(''), '', 'reversing empty string returns empty string' ); - equals(_.str.reverse(null), '', 'reversing null returns empty string' ); - equals(_.str.reverse(undefined), '', 'reversing undefined returns empty string' ); + equal(_.str.reverse('foo'), 'oof' ); + equal(_.str.reverse('foobar'), 'raboof' ); + equal(_.str.reverse('foo bar'), 'rab oof' ); + equal(_.str.reverse('saippuakauppias'), 'saippuakauppias' ); + equal(_.str.reverse(123), '321', 'Non string'); + equal(_.str.reverse(123.45), '54.321', 'Non string'); + equal(_.str.reverse(''), '', 'reversing empty string returns empty string' ); + equal(_.str.reverse(null), '', 'reversing null returns empty string' ); + equal(_.str.reverse(undefined), '', 'reversing undefined returns empty string' ); }); test('Strings: clean', function() { - equals(_(' foo bar ').clean(), 'foo bar'); - equals(_(123).clean(), '123'); - equals(_('').clean(), '', 'claning empty string returns empty string'); - equals(_(null).clean(), '', 'claning null returns empty string'); - equals(_(undefined).clean(), '', 'claning undefined returns empty string'); + equal(_(' foo bar ').clean(), 'foo bar'); + equal(_(123).clean(), '123'); + equal(_('').clean(), '', 'claning empty string returns empty string'); + equal(_(null).clean(), '', 'claning null returns empty string'); + equal(_(undefined).clean(), '', 'claning undefined returns empty string'); }); test('Strings: sprintf', function() { // Should be very tested function already. Thanks to // http://www.diveintojavascript.com/projects/sprintf-for-javascript - equals(_.sprintf('Hello %s', 'me'), 'Hello me', 'basic'); - equals(_('Hello %s').sprintf('me'), 'Hello me', 'object'); - equals(_('hello %s').chain().sprintf('me').capitalize().value(), 'Hello me', 'Chaining works'); - equals(_.sprintf('%.1f', 1.22222), '1.2', 'round'); - equals(_.sprintf('%.1f', 1.17), '1.2', 'round 2'); - equals(_.sprintf('%(id)d - %(name)s', {id: 824, name: 'Hello World'}), '824 - Hello World', 'Named replacements work'); - equals(_.sprintf('%(args[0].id)d - %(args[1].name)s', {args: [{id: 824}, {name: 'Hello World'}]}), '824 - Hello World', 'Named replacements with arrays work'); + equal(_.sprintf('Hello %s', 'me'), 'Hello me', 'basic'); + equal(_('Hello %s').sprintf('me'), 'Hello me', 'object'); + equal(_('hello %s').chain().sprintf('me').capitalize().value(), 'Hello me', 'Chaining works'); + equal(_.sprintf('%.1f', 1.22222), '1.2', 'round'); + equal(_.sprintf('%.1f', 1.17), '1.2', 'round 2'); + equal(_.sprintf('%(id)d - %(name)s', {id: 824, name: 'Hello World'}), '824 - Hello World', 'Named replacements work'); + equal(_.sprintf('%(args[0].id)d - %(args[1].name)s', {args: [{id: 824}, {name: 'Hello World'}]}), '824 - Hello World', 'Named replacements with arrays work'); }); test('Strings: vsprintf', function() { - equals(_.vsprintf('Hello %s', ['me']), 'Hello me', 'basic'); - equals(_('Hello %s').vsprintf(['me']), 'Hello me', 'object'); - equals(_('hello %s').chain().vsprintf(['me']).capitalize().value(), 'Hello me', 'Chaining works'); - equals(_.vsprintf('%.1f', [1.22222]), '1.2', 'round'); - equals(_.vsprintf('%.1f', [1.17]), '1.2', 'round 2'); - equals(_.vsprintf('%(id)d - %(name)s', [{id: 824, name: 'Hello World'}]), '824 - Hello World', 'Named replacement works'); - equals(_.vsprintf('%(args[0].id)d - %(args[1].name)s', [{args: [{id: 824}, {name: 'Hello World'}]}]), '824 - Hello World', 'Named replacement with arrays works'); + equal(_.vsprintf('Hello %s', ['me']), 'Hello me', 'basic'); + equal(_('Hello %s').vsprintf(['me']), 'Hello me', 'object'); + equal(_('hello %s').chain().vsprintf(['me']).capitalize().value(), 'Hello me', 'Chaining works'); + equal(_.vsprintf('%.1f', [1.22222]), '1.2', 'round'); + equal(_.vsprintf('%.1f', [1.17]), '1.2', 'round 2'); + equal(_.vsprintf('%(id)d - %(name)s', [{id: 824, name: 'Hello World'}]), '824 - Hello World', 'Named replacement works'); + equal(_.vsprintf('%(args[0].id)d - %(args[1].name)s', [{args: [{id: 824}, {name: 'Hello World'}]}]), '824 - Hello World', 'Named replacement with arrays works'); }); test('Strings: startsWith', function() { @@ -187,160 +187,160 @@ $(document).ready(function() { }); test('String: clean', function(){ - equals(_.clean(' foo bar '), 'foo bar'); - equals(_.clean(''), ''); - equals(_.clean(null), ''); - equals(_.clean(1), '1'); + equal(_.clean(' foo bar '), 'foo bar'); + equal(_.clean(''), ''); + equal(_.clean(null), ''); + equal(_.clean(1), '1'); }); test('String: count', function(){ - equals(_('Hello world').count('l'), 3); - equals(_('Hello world').count('Hello'), 1); - equals(_('Hello world').count('foo'), 0); - equals(_('x.xx....x.x').count('x'), 5); - equals(_('').count('x'), 0); - equals(_(null).count('x'), 0); - equals(_(undefined).count('x'), 0); - equals(_(12345).count(1), 1); - equals(_(11345).count(1), 2); + equal(_('Hello world').count('l'), 3); + equal(_('Hello world').count('Hello'), 1); + equal(_('Hello world').count('foo'), 0); + equal(_('x.xx....x.x').count('x'), 5); + equal(_('').count('x'), 0); + equal(_(null).count('x'), 0); + equal(_(undefined).count('x'), 0); + equal(_(12345).count(1), 1); + equal(_(11345).count(1), 2); }); test('String: insert', function(){ - equals(_('Hello ').insert(6, 'Jessy'), 'Hello Jessy'); - equals(_('Hello ').insert(100, 'Jessy'), 'Hello Jessy'); - equals(_('').insert(100, 'Jessy'), 'Jessy'); - equals(_(null).insert(100, 'Jessy'), 'Jessy'); - equals(_(undefined).insert(100, 'Jessy'), 'Jessy'); - equals(_(12345).insert(6, 'Jessy'), '12345Jessy'); + equal(_('Hello ').insert(6, 'Jessy'), 'Hello Jessy'); + equal(_('Hello ').insert(100, 'Jessy'), 'Hello Jessy'); + equal(_('').insert(100, 'Jessy'), 'Jessy'); + equal(_(null).insert(100, 'Jessy'), 'Jessy'); + equal(_(undefined).insert(100, 'Jessy'), 'Jessy'); + equal(_(12345).insert(6, 'Jessy'), '12345Jessy'); }); test('String: splice', function(){ - equals(_('https://edtsech@bitbucket.org/edtsech/underscore.strings').splice(30, 7, 'epeli'), + equal(_('https://edtsech@bitbucket.org/edtsech/underscore.strings').splice(30, 7, 'epeli'), 'https://edtsech@bitbucket.org/epeli/underscore.strings'); - equals(_.splice(12345, 1, 2, 321), '132145', 'Non strings'); + equal(_.splice(12345, 1, 2, 321), '132145', 'Non strings'); }); test('String: succ', function(){ - equals(_('a').succ(), 'b'); - equals(_('A').succ(), 'B'); - equals(_('+').succ(), ','); - equals(_(1).succ(), '2'); + equal(_('a').succ(), 'b'); + equal(_('A').succ(), 'B'); + equal(_('+').succ(), ','); + equal(_(1).succ(), '2'); }); test('String: titleize', function(){ - equals(_('the titleize string method').titleize(), 'The Titleize String Method'); - equals(_('the titleize string method').titleize(), 'The Titleize String Method'); - equals(_('').titleize(), '', 'Titleize empty string returns empty string'); - equals(_(null).titleize(), '', 'Titleize null returns empty string'); - equals(_(undefined).titleize(), '', 'Titleize undefined returns empty string'); - equals(_('let\'s have some fun').titleize(), 'Let\'s Have Some Fun'); - equals(_(123).titleize(), '123'); + equal(_('the titleize string method').titleize(), 'The Titleize String Method'); + equal(_('the titleize string method').titleize(), 'The Titleize String Method'); + equal(_('').titleize(), '', 'Titleize empty string returns empty string'); + equal(_(null).titleize(), '', 'Titleize null returns empty string'); + equal(_(undefined).titleize(), '', 'Titleize undefined returns empty string'); + equal(_('let\'s have some fun').titleize(), 'Let\'s Have Some Fun'); + equal(_(123).titleize(), '123'); }); test('String: camelize', function(){ - equals(_('the_camelize_string_method').camelize(), 'theCamelizeStringMethod'); - equals(_('-the-camelize-string-method').camelize(), 'TheCamelizeStringMethod'); - equals(_('the camelize string method').camelize(), 'theCamelizeStringMethod'); - equals(_(' the camelize string method').camelize(), 'theCamelizeStringMethod'); - equals(_('the camelize string method').camelize(), 'theCamelizeStringMethod'); - equals(_('').camelize(), '', 'Camelize empty string returns empty string'); - equals(_(null).camelize(), '', 'Camelize null returns empty string'); - equals(_(undefined).camelize(), '', 'Camelize undefined returns empty string'); - equals(_(123).camelize(), '123'); + equal(_('the_camelize_string_method').camelize(), 'theCamelizeStringMethod'); + equal(_('-the-camelize-string-method').camelize(), 'TheCamelizeStringMethod'); + equal(_('the camelize string method').camelize(), 'theCamelizeStringMethod'); + equal(_(' the camelize string method').camelize(), 'theCamelizeStringMethod'); + equal(_('the camelize string method').camelize(), 'theCamelizeStringMethod'); + equal(_('').camelize(), '', 'Camelize empty string returns empty string'); + equal(_(null).camelize(), '', 'Camelize null returns empty string'); + equal(_(undefined).camelize(), '', 'Camelize undefined returns empty string'); + equal(_(123).camelize(), '123'); }); test('String: underscored', function(){ - equals(_('the-underscored-string-method').underscored(), 'the_underscored_string_method'); - equals(_('theUnderscoredStringMethod').underscored(), 'the_underscored_string_method'); - equals(_('TheUnderscoredStringMethod').underscored(), 'the_underscored_string_method'); - equals(_(' the underscored string method').underscored(), 'the_underscored_string_method'); - equals(_('').underscored(), ''); - equals(_(null).underscored(), ''); - equals(_(undefined).underscored(), ''); - equals(_(123).underscored(), '123'); + equal(_('the-underscored-string-method').underscored(), 'the_underscored_string_method'); + equal(_('theUnderscoredStringMethod').underscored(), 'the_underscored_string_method'); + equal(_('TheUnderscoredStringMethod').underscored(), 'the_underscored_string_method'); + equal(_(' the underscored string method').underscored(), 'the_underscored_string_method'); + equal(_('').underscored(), ''); + equal(_(null).underscored(), ''); + equal(_(undefined).underscored(), ''); + equal(_(123).underscored(), '123'); }); test('String: dasherize', function(){ - equals(_('the_dasherize_string_method').dasherize(), 'the-dasherize-string-method'); - equals(_('TheDasherizeStringMethod').dasherize(), '-the-dasherize-string-method'); - equals(_('thisIsATest').dasherize(), 'this-is-a-test'); - equals(_('this Is A Test').dasherize(), 'this-is-a-test'); - equals(_('thisIsATest123').dasherize(), 'this-is-a-test123'); - equals(_('123thisIsATest').dasherize(), '123this-is-a-test'); - equals(_('the dasherize string method').dasherize(), 'the-dasherize-string-method'); - equals(_('the dasherize string method ').dasherize(), 'the-dasherize-string-method'); - equals(_('téléphone').dasherize(), 'téléphone'); - equals(_('foo$bar').dasherize(), 'foo$bar'); - equals(_('').dasherize(), ''); - equals(_(null).dasherize(), ''); - equals(_(undefined).dasherize(), ''); - equals(_(123).dasherize(), '123'); + equal(_('the_dasherize_string_method').dasherize(), 'the-dasherize-string-method'); + equal(_('TheDasherizeStringMethod').dasherize(), '-the-dasherize-string-method'); + equal(_('thisIsATest').dasherize(), 'this-is-a-test'); + equal(_('this Is A Test').dasherize(), 'this-is-a-test'); + equal(_('thisIsATest123').dasherize(), 'this-is-a-test123'); + equal(_('123thisIsATest').dasherize(), '123this-is-a-test'); + equal(_('the dasherize string method').dasherize(), 'the-dasherize-string-method'); + equal(_('the dasherize string method ').dasherize(), 'the-dasherize-string-method'); + equal(_('téléphone').dasherize(), 'téléphone'); + equal(_('foo$bar').dasherize(), 'foo$bar'); + equal(_('').dasherize(), ''); + equal(_(null).dasherize(), ''); + equal(_(undefined).dasherize(), ''); + equal(_(123).dasherize(), '123'); }); test('String: camelize', function(){ - equals(_.camelize('-moz-transform'), 'MozTransform'); - equals(_.camelize('webkit-transform'), 'webkitTransform'); - equals(_.camelize('under_scored'), 'underScored'); - equals(_.camelize(' with spaces'), 'withSpaces'); - equals(_('').camelize(), ''); - equals(_(null).camelize(), ''); - equals(_(undefined).camelize(), ''); + equal(_.camelize('-moz-transform'), 'MozTransform'); + equal(_.camelize('webkit-transform'), 'webkitTransform'); + equal(_.camelize('under_scored'), 'underScored'); + equal(_.camelize(' with spaces'), 'withSpaces'); + equal(_('').camelize(), ''); + equal(_(null).camelize(), ''); + equal(_(undefined).camelize(), ''); }); test('String: join', function(){ - equals(_.join(1, 2, 3, 4), '21314'); - equals(_.join('|', 'foo', 'bar', 'baz'), 'foo|bar|baz'); - equals(_.join('',2,3,null), '23'); - equals(_.join(null,2,3), '23'); + equal(_.join(1, 2, 3, 4), '21314'); + equal(_.join('|', 'foo', 'bar', 'baz'), 'foo|bar|baz'); + equal(_.join('',2,3,null), '23'); + equal(_.join(null,2,3), '23'); }); test('String: classify', function(){ - equals(_.classify(1), '1'); - equals(_('some_class_name').classify(), 'SomeClassName'); + equal(_.classify(1), '1'); + equal(_('some_class_name').classify(), 'SomeClassName'); }); test('String: humanize', function(){ - equals(_('the_humanize_string_method').humanize(), 'The humanize string method'); - equals(_('ThehumanizeStringMethod').humanize(), 'Thehumanize string method'); - equals(_('the humanize string method').humanize(), 'The humanize string method'); - equals(_('the humanize_id string method_id').humanize(), 'The humanize id string method'); - equals(_('the humanize string method ').humanize(), 'The humanize string method'); - equals(_(' capitalize dash-CamelCase_underscore trim ').humanize(), 'Capitalize dash camel case underscore trim'); - equals(_(123).humanize(), '123'); - equals(_('').humanize(), ''); - equals(_(null).humanize(), ''); - equals(_(undefined).humanize(), ''); + equal(_('the_humanize_string_method').humanize(), 'The humanize string method'); + equal(_('ThehumanizeStringMethod').humanize(), 'Thehumanize string method'); + equal(_('the humanize string method').humanize(), 'The humanize string method'); + equal(_('the humanize_id string method_id').humanize(), 'The humanize id string method'); + equal(_('the humanize string method ').humanize(), 'The humanize string method'); + equal(_(' capitalize dash-CamelCase_underscore trim ').humanize(), 'Capitalize dash camel case underscore trim'); + equal(_(123).humanize(), '123'); + equal(_('').humanize(), ''); + equal(_(null).humanize(), ''); + equal(_(undefined).humanize(), ''); }); test('String: truncate', function(){ - equals(_('Hello world').truncate(6, 'read more'), 'Hello read more'); - equals(_('Hello world').truncate(5), 'Hello...'); - equals(_('Hello').truncate(10), 'Hello'); - equals(_('').truncate(10), ''); - equals(_(null).truncate(10), ''); - equals(_(undefined).truncate(10), ''); - equals(_(1234567890).truncate(5), '12345...'); + equal(_('Hello world').truncate(6, 'read more'), 'Hello read more'); + equal(_('Hello world').truncate(5), 'Hello...'); + equal(_('Hello').truncate(10), 'Hello'); + equal(_('').truncate(10), ''); + equal(_(null).truncate(10), ''); + equal(_(undefined).truncate(10), ''); + equal(_(1234567890).truncate(5), '12345...'); }); test('String: prune', function(){ - equals(_('Hello, cruel world').prune(6, ' read more'), 'Hello read more'); - equals(_('Hello, world').prune(5, 'read a lot more'), 'Hello, world'); - equals(_('Hello, world').prune(5), 'Hello...'); - equals(_('Hello, world').prune(8), 'Hello...'); - equals(_('Hello, cruel world').prune(15), 'Hello, cruel...'); - equals(_('Hello world').prune(22), 'Hello world'); - equals(_('Привет, жестокий мир').prune(6, ' read more'), 'Привет read more'); - equals(_('Привет, мир').prune(6, 'read a lot more'), 'Привет, мир'); - equals(_('Привет, мир').prune(6), 'Привет...'); - equals(_('Привет, мир').prune(8), 'Привет...'); - equals(_('Привет, жестокий мир').prune(16), 'Привет, жестокий...'); - equals(_('Привет, мир').prune(22), 'Привет, мир'); - equals(_('alksjd!!!!!!....').prune(100, ''), 'alksjd!!!!!!....'); - equals(_(123).prune(10), '123'); - equals(_(123).prune(1, 321), '321'); - equals(_('').prune(5), ''); - equals(_(null).prune(5), ''); - equals(_(undefined).prune(5), ''); + equal(_('Hello, cruel world').prune(6, ' read more'), 'Hello read more'); + equal(_('Hello, world').prune(5, 'read a lot more'), 'Hello, world'); + equal(_('Hello, world').prune(5), 'Hello...'); + equal(_('Hello, world').prune(8), 'Hello...'); + equal(_('Hello, cruel world').prune(15), 'Hello, cruel...'); + equal(_('Hello world').prune(22), 'Hello world'); + equal(_('Привет, жестокий мир').prune(6, ' read more'), 'Привет read more'); + equal(_('Привет, мир').prune(6, 'read a lot more'), 'Привет, мир'); + equal(_('Привет, мир').prune(6), 'Привет...'); + equal(_('Привет, мир').prune(8), 'Привет...'); + equal(_('Привет, жестокий мир').prune(16), 'Привет, жестокий...'); + equal(_('Привет, мир').prune(22), 'Привет, мир'); + equal(_('alksjd!!!!!!....').prune(100, ''), 'alksjd!!!!!!....'); + equal(_(123).prune(10), '123'); + equal(_(123).prune(1, 321), '321'); + equal(_('').prune(5), ''); + equal(_(null).prune(5), ''); + equal(_(undefined).prune(5), ''); }); test('String: isBlank', function(){ @@ -356,38 +356,38 @@ $(document).ready(function() { }); test('String: escapeRegExp', function(){ - equals(_.escapeRegExp(/hello(?=\sworld)/.source), 'hello\\(\\?\\=\\\\sworld\\)', 'with lookahead'); - equals(_.escapeRegExp(/hello(?!\shell)/.source), 'hello\\(\\?\\!\\\\shell\\)', 'with negative lookahead'); + equal(_.escapeRegExp(/hello(?=\sworld)/.source), 'hello\\(\\?\\=\\\\sworld\\)', 'with lookahead'); + equal(_.escapeRegExp(/hello(?!\shell)/.source), 'hello\\(\\?\\!\\\\shell\\)', 'with negative lookahead'); }); test('String: escapeHTML', function(){ - equals(_('
+ A representative sample of the functions are benchmarked here, to provide
+ a sense of how fast they might run in different browsers.
+ Each iteration runs on an array of 1000 elements.
+ For example, the 'intersection' test measures the number of times you can
+ find the intersection of two thousand-element arrays in one second.
+