First Commit
This commit is contained in:
230
wasm_pthread_fast/web/node_modules/i/test/inflector/cases.js
generated
vendored
Normal file
230
wasm_pthread_fast/web/node_modules/i/test/inflector/cases.js
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
(function() {
|
||||
|
||||
module.exports = {
|
||||
SingularToPlural: {
|
||||
"search": "searches",
|
||||
"switch": "switches",
|
||||
"fix": "fixes",
|
||||
"box": "boxes",
|
||||
"process": "processes",
|
||||
"address": "addresses",
|
||||
"case": "cases",
|
||||
"stack": "stacks",
|
||||
"wish": "wishes",
|
||||
"fish": "fish",
|
||||
"jeans": "jeans",
|
||||
"funky jeans": "funky jeans",
|
||||
"my money": "my money",
|
||||
"category": "categories",
|
||||
"query": "queries",
|
||||
"ability": "abilities",
|
||||
"agency": "agencies",
|
||||
"movie": "movies",
|
||||
"archive": "archives",
|
||||
"index": "indices",
|
||||
"wife": "wives",
|
||||
"safe": "saves",
|
||||
"half": "halves",
|
||||
"move": "moves",
|
||||
"salesperson": "salespeople",
|
||||
"person": "people",
|
||||
"spokesman": "spokesmen",
|
||||
"man": "men",
|
||||
"woman": "women",
|
||||
"basis": "bases",
|
||||
"diagnosis": "diagnoses",
|
||||
"diagnosis_a": "diagnosis_as",
|
||||
"datum": "data",
|
||||
"medium": "media",
|
||||
"stadium": "stadia",
|
||||
"analysis": "analyses",
|
||||
"node_child": "node_children",
|
||||
"child": "children",
|
||||
"experience": "experiences",
|
||||
"day": "days",
|
||||
"comment": "comments",
|
||||
"foobar": "foobars",
|
||||
"newsletter": "newsletters",
|
||||
"old_news": "old_news",
|
||||
"news": "news",
|
||||
"series": "series",
|
||||
"species": "species",
|
||||
"quiz": "quizzes",
|
||||
"perspective": "perspectives",
|
||||
"ox": "oxen",
|
||||
"photo": "photos",
|
||||
"buffalo": "buffaloes",
|
||||
"tomato": "tomatoes",
|
||||
"dwarf": "dwarves",
|
||||
"elf": "elves",
|
||||
"information": "information",
|
||||
"equipment": "equipment",
|
||||
"bus": "buses",
|
||||
"status": "statuses",
|
||||
"status_code": "status_codes",
|
||||
"mouse": "mice",
|
||||
"louse": "lice",
|
||||
"house": "houses",
|
||||
"octopus": "octopi",
|
||||
"virus": "viri",
|
||||
"alias": "aliases",
|
||||
"portfolio": "portfolios",
|
||||
"vertex": "vertices",
|
||||
"matrix": "matrices",
|
||||
"matrix_fu": "matrix_fus",
|
||||
"axis": "axes",
|
||||
"testis": "testes",
|
||||
"crisis": "crises",
|
||||
"rice": "rice",
|
||||
"shoe": "shoes",
|
||||
"horse": "horses",
|
||||
"prize": "prizes",
|
||||
"edge": "edges",
|
||||
"cow": "kine",
|
||||
"database": "databases",
|
||||
"safe": "safes",
|
||||
"belief": "beliefs",
|
||||
"gaffe": "gaffes",
|
||||
"cafe": "cafes",
|
||||
"caffe": "caffes",
|
||||
"life": "lives",
|
||||
"wife": "wives",
|
||||
"save": "saves",
|
||||
"fife": "fifes",
|
||||
"carafe": "carafes",
|
||||
"giraffe": "giraffes",
|
||||
"elf": "elves",
|
||||
"calf": "calves",
|
||||
"bookshelf": "bookshelves",
|
||||
"wolf": "wolves",
|
||||
"half": "halves",
|
||||
"meatloaf": "meatloaves",
|
||||
"loaf": "loaves",
|
||||
"oaf": "oafs",
|
||||
"jefe": "jefes",
|
||||
"afterlife": "afterlives",
|
||||
},
|
||||
CamelToUnderscore: {
|
||||
"Product": "product",
|
||||
"SpecialGuest": "special_guest",
|
||||
"ApplicationController": "application_controller",
|
||||
"Area51Controller": "area51_controller"
|
||||
},
|
||||
UnderscoreToLowerCamel: {
|
||||
"product": "product",
|
||||
"Widget": "widget",
|
||||
"special_guest": "specialGuest",
|
||||
"application_controller": "applicationController",
|
||||
"area51_controller": "area51Controller"
|
||||
},
|
||||
CamelToUnderscoreWithoutReverse: {
|
||||
"HTMLTidy": "html_tidy",
|
||||
"HTMLTidyGenerator": "html_tidy_generator",
|
||||
"FreeBSD": "free_bsd",
|
||||
"HTML": "html"
|
||||
},
|
||||
CamelWithModuleToUnderscoreWithSlash: {
|
||||
"Admin.Product": "admin/product",
|
||||
"Users.Commission.Department": "users/commission/department",
|
||||
"UsersSection.CommissionDepartment": "users_section/commission_department"
|
||||
},
|
||||
ClassNameToForeignKeyWithUnderscore: {
|
||||
"Person": "person_id",
|
||||
"MyApplication.Billing.Account": "account_id"
|
||||
},
|
||||
ClassNameToForeignKeyWithoutUnderscore: {
|
||||
"Person": "personid",
|
||||
"MyApplication.Billing.Account": "accountid"
|
||||
},
|
||||
ClassNameToTableName: {
|
||||
"PrimarySpokesman": "primary_spokesmen",
|
||||
"NodeChild": "node_children"
|
||||
},
|
||||
UnderscoreToHuman: {
|
||||
"employee_salary": "Employee salary",
|
||||
"employee_id": "Employee",
|
||||
"underground": "Underground"
|
||||
},
|
||||
MixtureToTitleCase: {
|
||||
'bullet_record': 'Bullet Record',
|
||||
'BulletRecord': 'Bullet Record',
|
||||
'bullet web service': 'Bullet Web Service',
|
||||
'Bullet Web Service': 'Bullet Web Service',
|
||||
'Bullet web service': 'Bullet Web Service',
|
||||
'bulletwebservice': 'Bulletwebservice',
|
||||
'Bulletwebservice': 'Bulletwebservice',
|
||||
"pavan's code": "Pavan's Code",
|
||||
"Pavan's code": "Pavan's Code",
|
||||
"pavan's Code": "Pavan's Code"
|
||||
},
|
||||
OrdinalNumbers: {
|
||||
"-1": "-1st",
|
||||
"-2": "-2nd",
|
||||
"-3": "-3rd",
|
||||
"-4": "-4th",
|
||||
"-5": "-5th",
|
||||
"-6": "-6th",
|
||||
"-7": "-7th",
|
||||
"-8": "-8th",
|
||||
"-9": "-9th",
|
||||
"-10": "-10th",
|
||||
"-11": "-11th",
|
||||
"-12": "-12th",
|
||||
"-13": "-13th",
|
||||
"-14": "-14th",
|
||||
"-20": "-20th",
|
||||
"-21": "-21st",
|
||||
"-22": "-22nd",
|
||||
"-23": "-23rd",
|
||||
"-24": "-24th",
|
||||
"-100": "-100th",
|
||||
"-101": "-101st",
|
||||
"-102": "-102nd",
|
||||
"-103": "-103rd",
|
||||
"-104": "-104th",
|
||||
"-110": "-110th",
|
||||
"-111": "-111th",
|
||||
"-112": "-112th",
|
||||
"-113": "-113th",
|
||||
"-1000": "-1000th",
|
||||
"-1001": "-1001st",
|
||||
"0": "0th",
|
||||
"1": "1st",
|
||||
"2": "2nd",
|
||||
"3": "3rd",
|
||||
"4": "4th",
|
||||
"5": "5th",
|
||||
"6": "6th",
|
||||
"7": "7th",
|
||||
"8": "8th",
|
||||
"9": "9th",
|
||||
"10": "10th",
|
||||
"11": "11th",
|
||||
"12": "12th",
|
||||
"13": "13th",
|
||||
"14": "14th",
|
||||
"20": "20th",
|
||||
"21": "21st",
|
||||
"22": "22nd",
|
||||
"23": "23rd",
|
||||
"24": "24th",
|
||||
"100": "100th",
|
||||
"101": "101st",
|
||||
"102": "102nd",
|
||||
"103": "103rd",
|
||||
"104": "104th",
|
||||
"110": "110th",
|
||||
"111": "111th",
|
||||
"112": "112th",
|
||||
"113": "113th",
|
||||
"1000": "1000th",
|
||||
"1001": "1001st"
|
||||
},
|
||||
UnderscoresToDashes: {
|
||||
"street": "street",
|
||||
"street_address": "street-address",
|
||||
"person_street_address": "person-street-address"
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
87
wasm_pthread_fast/web/node_modules/i/test/inflector/inflections-test.js
generated
vendored
Normal file
87
wasm_pthread_fast/web/node_modules/i/test/inflector/inflections-test.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
(function() {
|
||||
var assert, vows;
|
||||
|
||||
vows = require('vows');
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
vows.describe('Module Inflector inflections').addBatch({
|
||||
'Test inflector inflections': {
|
||||
topic: require('../../lib/inflections'),
|
||||
'clear': {
|
||||
'single': function(topic) {
|
||||
topic.uncountables = [1, 2, 3];
|
||||
topic.humans = [1, 2, 3];
|
||||
topic.clear('uncountables');
|
||||
assert.isEmpty(topic.uncountables);
|
||||
return assert.deepEqual(topic.humans, [1, 2, 3]);
|
||||
},
|
||||
'all': function(topic) {
|
||||
assert.deepEqual(topic.humans, [1, 2, 3]);
|
||||
topic.uncountables = [1, 2, 3];
|
||||
topic.clear();
|
||||
assert.isEmpty(topic.uncountables);
|
||||
return assert.isEmpty(topic.humans);
|
||||
}
|
||||
},
|
||||
'uncountable': {
|
||||
'one item': function(topic) {
|
||||
topic.clear();
|
||||
assert.isEmpty(topic.uncountables);
|
||||
topic.uncountable('money');
|
||||
return assert.deepEqual(topic.uncountables, ['money']);
|
||||
},
|
||||
'many items': function(topic) {
|
||||
topic.clear();
|
||||
assert.isEmpty(topic.uncountables);
|
||||
topic.uncountable(['money', 'rice']);
|
||||
return assert.deepEqual(topic.uncountables, ['money', 'rice']);
|
||||
}
|
||||
},
|
||||
'human': function(topic) {
|
||||
topic.clear();
|
||||
assert.isEmpty(topic.humans);
|
||||
topic.human("legacy_col_person_name", "Name");
|
||||
return assert.deepEqual(topic.humans, [["legacy_col_person_name", "Name"]]);
|
||||
},
|
||||
'plural': function(topic) {
|
||||
topic.clear();
|
||||
assert.isEmpty(topic.plurals);
|
||||
topic.plural('ox', 'oxen');
|
||||
assert.deepEqual(topic.plurals, [['ox', 'oxen']]);
|
||||
topic.uncountable('money');
|
||||
assert.deepEqual(topic.uncountables, ['money']);
|
||||
topic.uncountable('monies');
|
||||
topic.plural('money', 'monies');
|
||||
assert.deepEqual(topic.plurals, [['money', 'monies'], ['ox', 'oxen']]);
|
||||
return assert.isEmpty(topic.uncountables);
|
||||
},
|
||||
'singular': function(topic) {
|
||||
topic.clear();
|
||||
assert.isEmpty(topic.singulars);
|
||||
topic.singular('ox', 'oxen');
|
||||
assert.deepEqual(topic.singulars, [['ox', 'oxen']]);
|
||||
topic.uncountable('money');
|
||||
assert.deepEqual(topic.uncountables, ['money']);
|
||||
topic.uncountable('monies');
|
||||
topic.singular('money', 'monies');
|
||||
assert.deepEqual(topic.singulars, [['money', 'monies'], ['ox', 'oxen']]);
|
||||
return assert.isEmpty(topic.uncountables);
|
||||
},
|
||||
'irregular': function(topic) {
|
||||
topic.clear();
|
||||
topic.uncountable(['octopi', 'octopus']);
|
||||
assert.deepEqual(topic.uncountables, ['octopi', 'octopus']);
|
||||
topic.irregular('octopus', 'octopi');
|
||||
assert.isEmpty(topic.uncountables);
|
||||
assert.equal(topic.singulars[0][0].toString(), /(o)ctopi$/i.toString());
|
||||
assert.equal(topic.singulars[0][1], '$1ctopus');
|
||||
assert.equal(topic.plurals[0][0].toString(), /(o)ctopi$/i.toString());
|
||||
assert.equal(topic.plurals[0][1], '$1ctopi');
|
||||
assert.equal(topic.plurals[1][0].toString(), /(o)ctopus$/i.toString());
|
||||
return assert.equal(topic.plurals[1][1].toString(), '$1ctopi');
|
||||
}
|
||||
}
|
||||
})["export"](module);
|
||||
|
||||
}).call(this);
|
||||
348
wasm_pthread_fast/web/node_modules/i/test/inflector/methods-test.js
generated
vendored
Normal file
348
wasm_pthread_fast/web/node_modules/i/test/inflector/methods-test.js
generated
vendored
Normal file
@@ -0,0 +1,348 @@
|
||||
(function() {
|
||||
var assert, cases, vows, util;
|
||||
|
||||
vows = require('vows');
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
util = require('../../lib/util');
|
||||
|
||||
cases = require('./cases');
|
||||
|
||||
vows.describe('Module Inflector methods').addBatch({
|
||||
'Test inflector method': {
|
||||
topic: require('../../lib/methods'),
|
||||
'camelize': {
|
||||
'word': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.CamelToUnderscore;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.camelize(words[i]), i));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'word with first letter lower': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.UnderscoreToLowerCamel;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.camelize(i, false), words[i]));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'path': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.CamelWithModuleToUnderscoreWithSlash;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.camelize(words[i]), i));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'path with first letter lower': function(topic) {
|
||||
return assert.equal(topic.camelize('bullet_record/errors', false), 'bulletRecord.Errors');
|
||||
}
|
||||
},
|
||||
'underscore': {
|
||||
'word': function(topic) {
|
||||
var i, words, _i, _j, _len, _len2, _ref, _ref2, _results;
|
||||
words = cases.CamelToUnderscore;
|
||||
_ref = Object.keys(words);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
assert.equal(topic.underscore(i), words[i]);
|
||||
}
|
||||
words = cases.CamelToUnderscoreWithoutReverse;
|
||||
_ref2 = Object.keys(words);
|
||||
_results = [];
|
||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||
i = _ref2[_j];
|
||||
_results.push(assert.equal(topic.underscore(i), words[i]));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'path': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.CamelWithModuleToUnderscoreWithSlash;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.underscore(i), words[i]));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'from dasherize': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.UnderscoresToDashes;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.underscore(topic.dasherize(i)), i));
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
},
|
||||
'dasherize': {
|
||||
'underscored_word': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.UnderscoresToDashes;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.dasherize(i), words[i]));
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
},
|
||||
'demodulize': {
|
||||
'module name': function(topic) {
|
||||
return assert.equal(topic.demodulize('BulletRecord.CoreExtensions.Inflections'), 'Inflections');
|
||||
},
|
||||
'isolated module name': function(topic) {
|
||||
return assert.equal(topic.demodulize('Inflections'), 'Inflections');
|
||||
}
|
||||
},
|
||||
'foreign_key': {
|
||||
'normal': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.ClassNameToForeignKeyWithoutUnderscore;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.foreign_key(i, false), words[i]));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'with_underscore': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.ClassNameToForeignKeyWithUnderscore;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.foreign_key(i), words[i]));
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
},
|
||||
'ordinalize': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.OrdinalNumbers;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.ordinalize(i), words[i]));
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
}
|
||||
}).addBatch({
|
||||
'Test inflector inflection methods': {
|
||||
topic: function() {
|
||||
var Inflector;
|
||||
Inflector = require('../../lib/methods');
|
||||
Inflector.inflections["default"]();
|
||||
return Inflector;
|
||||
},
|
||||
'pluralize': {
|
||||
'empty': function(topic) {
|
||||
return assert.equal(topic.pluralize(''), '');
|
||||
},
|
||||
'uncountable': function(topic) {
|
||||
return assert.equal(topic.pluralize('money'), 'money');
|
||||
},
|
||||
'normal': function(topic) {
|
||||
topic.inflections.irregular('octopus', 'octopi');
|
||||
return assert.equal(topic.pluralize('octopus'), 'octopi');
|
||||
},
|
||||
'cases': function(topic) {
|
||||
var i, words, _i, _j, _len, _len2, _ref, _ref2, _results;
|
||||
words = cases.SingularToPlural;
|
||||
_ref = Object.keys(words);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
assert.equal(topic.pluralize(i), words[i]);
|
||||
}
|
||||
_ref2 = Object.keys(words);
|
||||
_results = [];
|
||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||
i = _ref2[_j];
|
||||
_results.push(assert.equal(topic.pluralize(util.string.capitalize(i)), util.string.capitalize(words[i])));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'cases plural': function(topic) {
|
||||
var i, words, _i, _j, _len, _len2, _ref, _ref2, _results;
|
||||
words = cases.SingularToPlural;
|
||||
_ref = Object.keys(words);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
assert.equal(topic.pluralize(words[i]), words[i]);
|
||||
}
|
||||
_ref2 = Object.keys(words);
|
||||
_results = [];
|
||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||
i = _ref2[_j];
|
||||
_results.push(assert.equal(topic.pluralize(util.string.capitalize(words[i])), util.string.capitalize(words[i])));
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
},
|
||||
'singuralize': {
|
||||
'empty': function(topic) {
|
||||
return assert.equal(topic.singularize(''), '');
|
||||
},
|
||||
'uncountable': function(topic) {
|
||||
return assert.equal(topic.singularize('money'), 'money');
|
||||
},
|
||||
'normal': function(topic) {
|
||||
topic.inflections.irregular('octopus', 'octopi');
|
||||
return assert.equal(topic.singularize('octopi'), 'octopus');
|
||||
},
|
||||
'cases': function(topic) {
|
||||
var i, words, _i, _j, _len, _len2, _ref, _ref2, _results;
|
||||
words = cases.SingularToPlural;
|
||||
_ref = Object.keys(words);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
assert.equal(topic.singularize(words[i]), i);
|
||||
}
|
||||
_ref2 = Object.keys(words);
|
||||
_results = [];
|
||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||
i = _ref2[_j];
|
||||
_results.push(assert.equal(topic.singularize(util.string.capitalize(words[i])), util.string.capitalize(i)));
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
},
|
||||
'uncountablility': {
|
||||
'normal': function(topic) {
|
||||
var i, words, _i, _j, _k, _len, _len2, _len3, _results;
|
||||
words = topic.inflections.uncountables;
|
||||
for (_i = 0, _len = words.length; _i < _len; _i++) {
|
||||
i = words[_i];
|
||||
assert.equal(topic.singularize(i), i);
|
||||
}
|
||||
for (_j = 0, _len2 = words.length; _j < _len2; _j++) {
|
||||
i = words[_j];
|
||||
assert.equal(topic.pluralize(i), i);
|
||||
}
|
||||
_results = [];
|
||||
for (_k = 0, _len3 = words.length; _k < _len3; _k++) {
|
||||
i = words[_k];
|
||||
_results.push(assert.equal(topic.singularize(i), topic.pluralize(i)));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'greedy': function(topic) {
|
||||
var countable_word, uncountable_word;
|
||||
uncountable_word = "ors";
|
||||
countable_word = "sponsor";
|
||||
topic.inflections.uncountable(uncountable_word);
|
||||
assert.equal(topic.singularize(uncountable_word), uncountable_word);
|
||||
assert.equal(topic.pluralize(uncountable_word), uncountable_word);
|
||||
assert.equal(topic.pluralize(uncountable_word), topic.singularize(uncountable_word));
|
||||
assert.equal(topic.singularize(countable_word), 'sponsor');
|
||||
assert.equal(topic.pluralize(countable_word), 'sponsors');
|
||||
return assert.equal(topic.singularize(topic.pluralize(countable_word)), 'sponsor');
|
||||
}
|
||||
},
|
||||
'humanize': {
|
||||
'normal': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.UnderscoreToHuman;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.humanize(i), words[i]));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'with rule': function(topic) {
|
||||
topic.inflections.human(/^(.*)_cnt$/i, '$1_count');
|
||||
topic.inflections.human(/^prefix_(.*)$/i, '$1');
|
||||
assert.equal(topic.humanize('jargon_cnt'), 'Jargon count');
|
||||
return assert.equal(topic.humanize('prefix_request'), 'Request');
|
||||
},
|
||||
'with string': function(topic) {
|
||||
topic.inflections.human('col_rpted_bugs', 'Reported bugs');
|
||||
assert.equal(topic.humanize('col_rpted_bugs'), 'Reported bugs');
|
||||
return assert.equal(topic.humanize('COL_rpted_bugs'), 'Col rpted bugs');
|
||||
},
|
||||
'with _id': function(topic) {
|
||||
return assert.equal(topic.humanize('author_id'), 'Author');
|
||||
},
|
||||
'with just _id': function(topic) {
|
||||
return assert.equal(topic.humanize('_id'), '');
|
||||
}
|
||||
},
|
||||
'titleize': {
|
||||
'normal': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.MixtureToTitleCase;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.titleize(i), words[i]));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'with hyphens': function(topic) {
|
||||
return assert.equal(topic.titleize('x-men: the last stand'), 'X Men: The Last Stand');
|
||||
},
|
||||
'with ampersands': function(topic) {
|
||||
return assert.equal(topic.titleize('garfunkel & oates'), 'Garfunkel & Oates');
|
||||
}
|
||||
},
|
||||
'tableize': function(topic) {
|
||||
var i, words, _i, _len, _ref, _results;
|
||||
words = cases.ClassNameToTableName;
|
||||
_ref = Object.keys(words);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results.push(assert.equal(topic.tableize(i), words[i]));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'classify': {
|
||||
'underscore': function(topic) {
|
||||
var i, words, _i, _j, _len, _len2, _ref, _ref2, _results;
|
||||
words = cases.ClassNameToTableName;
|
||||
_ref = Object.keys(words);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
assert.equal(topic.classify(words[i]), i);
|
||||
}
|
||||
_ref2 = Object.keys(words);
|
||||
_results = [];
|
||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||
i = _ref2[_j];
|
||||
_results.push(assert.equal(topic.classify('table_prefix.' + words[i]), i));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
'normal': function(topic) {
|
||||
topic.inflections.irregular('octopus', 'octopi');
|
||||
return assert.equal(topic.classify('octopi'), 'Octopus');
|
||||
}
|
||||
}
|
||||
}
|
||||
})["export"](module);
|
||||
|
||||
}).call(this);
|
||||
39
wasm_pthread_fast/web/node_modules/i/test/utils/array-test.js
generated
vendored
Normal file
39
wasm_pthread_fast/web/node_modules/i/test/utils/array-test.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
(function() {
|
||||
var assert, vows, util;
|
||||
|
||||
vows = require('vows');
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
util = require('../../lib/util');
|
||||
|
||||
vows.describe('Module core extension Array').addBatch({
|
||||
'Testing del': {
|
||||
topic: ['a', 'b', 'c'],
|
||||
'element exists': {
|
||||
'first element': function(topic) {
|
||||
return assert.deepEqual(util.array.del(topic, 'a'), ['b', 'c']);
|
||||
},
|
||||
'middle element': function(topic) {
|
||||
return assert.deepEqual(util.array.del(topic, 'b'), ['a', 'c']);
|
||||
},
|
||||
'last element': function(topic) {
|
||||
return assert.deepEqual(util.array.del(topic, 'c'), ['a', 'b']);
|
||||
}
|
||||
},
|
||||
'element does not exist': function(topic) {
|
||||
return assert.deepEqual(util.array.del(topic, 'd'), ['a', 'b', 'c']);
|
||||
}
|
||||
},
|
||||
'Testing utils': {
|
||||
topic: ['a', 'b', 'c'],
|
||||
'first': function(topic) {
|
||||
return assert.equal(util.array.first(topic), 'a');
|
||||
},
|
||||
'last': function(topic) {
|
||||
return assert.equal(util.array.last(topic), 'c');
|
||||
}
|
||||
}
|
||||
})["export"](module);
|
||||
|
||||
}).call(this);
|
||||
88
wasm_pthread_fast/web/node_modules/i/test/utils/string-test.js
generated
vendored
Normal file
88
wasm_pthread_fast/web/node_modules/i/test/utils/string-test.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
(function() {
|
||||
var assert, vows, util;
|
||||
|
||||
vows = require('vows');
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
util = require('../../lib/util');
|
||||
|
||||
vows.describe('Module core extension String').addBatch({
|
||||
'Testing value': {
|
||||
topic: 'bullet',
|
||||
'join the keys': function(topic) {
|
||||
return assert.equal(util.string.value(topic), 'bullet');
|
||||
}
|
||||
},
|
||||
'Testing gsub': {
|
||||
topic: 'bullet',
|
||||
'when no args': function(topic) {
|
||||
return assert.equal(util.string.gsub(topic), 'bullet');
|
||||
},
|
||||
'when only 1 arg': function(topic) {
|
||||
return assert.equal(util.string.gsub(topic, /./), 'bullet');
|
||||
},
|
||||
'when given proper args': function(topic) {
|
||||
return assert.equal(util.string.gsub(topic, /[aeiou]/, '*'), 'b*ll*t');
|
||||
},
|
||||
'when replacement is a function': {
|
||||
'with many groups': function(topic) {
|
||||
var str;
|
||||
str = util.string.gsub(topic, /([aeiou])(.)/, function($) {
|
||||
return "<" + $[1] + ">" + $[2];
|
||||
});
|
||||
return assert.equal(str, 'b<u>ll<e>t');
|
||||
},
|
||||
'with no groups': function(topic) {
|
||||
var str;
|
||||
str = util.string.gsub(topic, /[aeiou]/, function($) {
|
||||
return "<" + $[1] + ">";
|
||||
});
|
||||
return assert.equal(str, 'b<u>ll<e>t');
|
||||
}
|
||||
},
|
||||
'when replacement is special': {
|
||||
'with many groups': function(topic) {
|
||||
return assert.equal(util.string.gsub(topic, /([aeiou])(.)/, '<$1>$2'), 'b<u>ll<e>t');
|
||||
},
|
||||
'with no groups': function(topic) {
|
||||
return assert.equal(util.string.gsub(topic, /[aeiou]/, '<$1>'), 'b<u>ll<e>t');
|
||||
}
|
||||
}
|
||||
},
|
||||
'Testing capitalize': {
|
||||
topic: 'employee salary',
|
||||
'normal': function(topic) {
|
||||
return assert.equal(util.string.capitalize(topic), 'Employee Salary');
|
||||
}
|
||||
},
|
||||
'Testing upcase': {
|
||||
topic: 'bullet',
|
||||
'only first letter should be upcase': function(topic) {
|
||||
return assert.equal(util.string.upcase(topic), 'Bullet');
|
||||
},
|
||||
'letter after underscore': function(topic) {
|
||||
return assert.equal(util.string.upcase('bullet_record'), 'Bullet_Record');
|
||||
},
|
||||
'letter after slash': function(topic) {
|
||||
return assert.equal(util.string.upcase('bullet_record/errors'), 'Bullet_Record/Errors');
|
||||
},
|
||||
'no letter after space': function(topic) {
|
||||
return assert.equal(util.string.upcase('employee salary'), 'Employee salary');
|
||||
}
|
||||
},
|
||||
'Testing downcase': {
|
||||
topic: 'BULLET',
|
||||
'only first letter should be downcase': function(topic) {
|
||||
return assert.equal(util.string.downcase(topic), 'bULLET');
|
||||
},
|
||||
'letter after underscore': function(topic) {
|
||||
return assert.equal(util.string.downcase('BULLET_RECORD'), 'bULLET_rECORD');
|
||||
},
|
||||
'letter after slash': function(topic) {
|
||||
return assert.equal(util.string.downcase('BULLET_RECORD/ERRORS'), 'bULLET_rECORD/eRRORS');
|
||||
}
|
||||
}
|
||||
})["export"](module);
|
||||
|
||||
}).call(this);
|
||||
Reference in New Issue
Block a user