Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F3FB71013D for ; Thu, 27 Mar 2014 15:09:34 +0000 (UTC) Received: (qmail 27632 invoked by uid 500); 27 Mar 2014 15:09:33 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 27457 invoked by uid 500); 27 Mar 2014 15:09:30 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 20646 invoked by uid 99); 27 Mar 2014 15:08:17 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Mar 2014 15:08:17 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E309E837FF2; Thu, 27 Mar 2014 15:08:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: bhiggins@apache.org To: commits@cordova.apache.org Date: Thu, 27 Mar 2014 15:08:48 -0000 Message-Id: <8f6b0f58f19b4ed286061d9e96e72621@git.apache.org> In-Reply-To: <7ff2dd5126814391a5a90b25e779661f@git.apache.org> References: <7ff2dd5126814391a5a90b25e779661f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [34/51] [partial] CB-6346 - Add node_modules to source control http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/lib/xml.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/lib/xml.js b/blackberry10/node_modules/jake/node_modules/utilities/lib/xml.js new file mode 100644 index 0000000..42b0f39 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/lib/xml.js @@ -0,0 +1,282 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +var core = require('./core') + , inflection = require('./inflection') + +/** + @name xml + @namespace xml +*/ + +exports.XML = new (function () { + + // Default indention level + var indentLevel = 4 + , tagFromType + , obj2xml; + + tagFromType = function (item, prev) { + var ret + , type + , types; + + if (item instanceof Array) { + ret = 'array'; + } else { + types = ['string', 'number', 'boolean', 'object']; + for (var i = 0, ii = types.length; i < ii; i++) { + type = types[i]; + if (typeof item == type) { + ret = type; + } + } + } + + if (prev && ret != prev) { + return 'record' + } else { + return ret; + } + }; + + obj2xml = function (o, opts) { + var name = opts.name + , level = opts.level + , arrayRoot = opts.arrayRoot + , pack + , item + , n + , currentIndent = (new Array(level * indentLevel)).join(' ') + , nextIndent = (new Array((level + 1) * indentLevel)).join(' ') + , xml = ''; + + switch (typeof o) { + case 'string': + case 'number': + case 'boolean': + xml = o.toString(); + break; + case 'object': + // Arrays + if (o instanceof Array) { + + // Pack the processed version of each item into an array that + // can be turned into a tag-list with a `join` method below + // As the list gets iterated, if all items are the same type, + // that's the tag-name for the individual tags. If the items are + // a mixed, the tag-name is 'record' + pack = []; + for (var i = 0, ii = o.length; i < ii; i++) { + item = o[i]; + if (!name) { + // Pass any previous tag-name, so it's possible to know if + // all items are the same type, or it's mixed types + n = tagFromType(item, n); + } + pack.push(obj2xml(item, { + name: name + , level: level + 1 + , arrayRoot: arrayRoot + })); + } + + // If this thing is attached to a named property on an object, + // use the name for the containing tag-name + if (name) { + n = name; + } + + // If this is a top-level item, wrap in a top-level containing tag + if (level == 0) { + xml += currentIndent + '<' + inflection.pluralize(n) + ' type="array">\n' + } + xml += nextIndent + '<' + n + '>' + + pack.join('\n' + nextIndent + + '<' + n + '>') + '\n'; + + // If this is a top-level item, close the top-level containing tag + if (level == 0) { + xml += currentIndent + ''; + } + } + // Generic objects + else { + n = name || 'object'; + + // If this is a top-level item, wrap in a top-level containing tag + if (level == 0) { + xml += currentIndent + '<' + n; + // Lookahead hack to allow tags to have attributes + for (var p in o) { + if (p.indexOf('attr:') == 0) { + xml += ' ' + p.replace(/^attr:/, '') + '="' + + o[p] + '"' + } + } + xml += '>\n'; + } + for (var p in o) { + item = o[p]; + + // Data properties only + if (typeof item == 'function') { + continue; + } + // No attr hack properties + if (p.indexOf('attr:') == 0) { + continue; + } + + xml += nextIndent; + + if (p == '#cdata') { + xml += '\n'; + } + else { + + // Complex values, going to have items with multiple tags + // inside + if (typeof item == 'object') { + if (item instanceof Array) { + if (arrayRoot) { + xml += '<' + p + ' type="array">\n' + } + } + else { + xml += '<' + p; + // Lookahead hack to allow tags to have attributes + for (var q in item) { + if (q.indexOf('attr:') == 0) { + xml += ' ' + q.replace(/^attr:/, '') + '="' + + item[q] + '"' + } + } + xml += '>\n'; + } + } + // Scalars, just a value and closing tag + else { + xml += '<' + p + '>' + } + xml += obj2xml(item, { + name: p + , level: level + 1 + , arrayRoot: arrayRoot + }); + + // Objects and Arrays, need indentation before closing tag + if (typeof item == 'object') { + if (item instanceof Array) { + if (arrayRoot) { + xml += nextIndent; + xml += '\n'; + } + } + else { + xml += nextIndent; + xml += '\n'; + } + } + // Scalars, just close + else { + xml += '\n'; + } + } + } + // If this is a top-level item, close the top-level containing tag + if (level == 0) { + xml += currentIndent + '\n'; + } + } + break; + default: + // No default + } + return xml; + } + + /* + * XML configuration + * + */ + this.config = { + whitespace: true + , name: null + , fragment: false + , level: 0 + , arrayRoot: true + }; + + /** + @name xml#setIndentLevel + @public + @function + @return {Number} Return the given `level` + @description SetIndentLevel changes the indent level for XML.stringify and returns it + @param {Number} level The indent level to use + */ + this.setIndentLevel = function (level) { + if(!level) { + return; + } + + return indentLevel = level; + }; + + /** + @name xml#stringify + @public + @function + @return {String} Return the XML entities of the given `obj` + @description Stringify returns an XML representation of the given `obj` + @param {Object} obj The object containing the XML entities to use + @param {Object} opts + @param {Boolean} [opts.whitespace=true] Don't insert indents and newlines after xml entities + @param {String} [opts.name=typeof obj] Use custom name as global namespace + @param {Boolean} [opts.fragment=false] If true no header fragment is added to the top + @param {Number} [opts.level=0] Remove this many levels from the output + @param {Boolean} [opts.arrayRoot=true] + */ + this.stringify = function (obj, opts) { + var config = core.mixin({}, this.config) + , xml = ''; + core.mixin(config, (opts || {})); + + if (!config.whitespace) { + indentLevel = 0; + } + + if (!config.fragment) { + xml += '\n'; + } + + xml += obj2xml(obj, { + name: config.name + , level: config.level + , arrayRoot: config.arrayRoot + }); + + if (!config.whitespace) { + xml = xml.replace(/>\n/g, '>'); + } + + return xml; + }; + +})(); + http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/package.json ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/package.json b/blackberry10/node_modules/jake/node_modules/utilities/package.json new file mode 100644 index 0000000..ee68c2a --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/package.json @@ -0,0 +1,34 @@ +{ + "name": "utilities", + "description": "A classic collection of JavaScript utilities", + "keywords": [ + "utilities", + "utils", + "jake", + "geddy" + ], + "version": "0.0.24", + "author": { + "name": "Matthew Eernisse", + "email": "mde@fleegix.org", + "url": "http://fleegix.org" + }, + "main": "./lib/index.js", + "scripts": { + "test": "jake test" + }, + "repository": { + "type": "git", + "url": "git://github.com/mde/utilities.git" + }, + "engines": { + "node": "*" + }, + "readme": "utilities\n=========\n\n[![build status](https://secure.travis-ci.org/mde/utilities.png)](http://travis-ci.org/mde/utilities)\n\nA classic collection of JavaScript utilities", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/mde/utilities/issues" + }, + "_id": "utilities@0.0.24", + "_from": "utilities@0.0.x" +} http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/array.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/array.js b/blackberry10/node_modules/jake/node_modules/utilities/test/array.js new file mode 100644 index 0000000..07ad592 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/array.js @@ -0,0 +1,71 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +var assert = require('assert') + , array = require('../lib/array') + , tests; + +tests = { + + 'test basic humanize for array': function () { + var actual = array.humanize(["array", "array", "array"]) + , expected = "array, array and array"; + assert.equal(expected, actual); + } + +, 'test humanize with two items for array': function () { + var actual = array.humanize(["array", "array"]) + , expected = "array and array"; + assert.equal(expected, actual); + } + +, 'test humanize with a single item for array': function () { + var actual = array.humanize(["array"]) + , expected = "array"; + assert.equal(expected, actual); + } + +, 'test humanize with no items for array': function () { + var actual = array.humanize([]) + , expected = ""; + assert.equal(expected, actual); + } + +, 'test basic include for array': function () { + var test = ["array"] + , actual = array.include(test, "array"); + assert.equal(true, actual); + } + +, 'test false include for array': function () { + var test = ["array"] + , actual = array.include(test, 'nope'); + assert.equal(false, actual); + } + +, 'test false boolean include for array': function () { + var test = ["array", false] + , actual = array.include(test, false); + assert.equal(true, actual); + } + +}; + +module.exports = tests; + + http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/core.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/core.js b/blackberry10/node_modules/jake/node_modules/utilities/test/core.js new file mode 100644 index 0000000..18e73b1 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/core.js @@ -0,0 +1,75 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +var assert = require('assert') + , core = require('../lib/core') + , tests; + +tests = { + + 'simple mixin for core': function () { + var expected = {secret: 'asdf', geddy: 'geddyKey'} + , result = core.mixin({secret: 'asdf'}, {geddy: 'geddyKey'}); + assert.deepEqual(expected, result); + } + +, 'mixin with overiding key for core': function () { + var expected = {secret: 'geddySecret', geddy: 'geddyKey'} + , result = core.mixin({secret: 'asdf'}, {geddy: 'geddyKey', secret: 'geddySecret'}); + assert.deepEqual(expected, result); + } + +, 'simple enhance for core': function () { + var expected = {secret: 'asdf', geddy: 'geddyKey'} + , result = core.enhance({secret: 'asdf'}, {geddy: 'geddyKey'}); + assert.deepEqual(expected, result); + } + +, 'enhance with overiding key for core': function () { + var expected = {secret: 'geddySecret', geddy: 'geddyKey'} + , result = core.enhance({secret: 'asdf'}, {geddy: 'geddyKey', secret: 'geddySecret'}); + assert.deepEqual(expected, result); + } + +, 'isEmpty, empty string (true)': function () { + assert.ok(core.isEmpty('')); + } + +, 'isEmpty, null (true)': function () { + assert.ok(core.isEmpty(null)); + } + +, 'isEmpty, undefined (true)': function () { + assert.ok(core.isEmpty(null)); + } + +, 'isEmpty, NaN (true)': function () { + assert.ok(core.isEmpty(NaN)); + } + +, 'isEmpty, invalid Date (true)': function () { + assert.ok(core.isEmpty(new Date(NaN))); + } + +, 'isEmpty, zero (false)': function () { + assert.ok(!core.isEmpty(0)); + } + +}; + +module.exports = tests; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/date.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/date.js b/blackberry10/node_modules/jake/node_modules/utilities/test/date.js new file mode 100644 index 0000000..535562f --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/date.js @@ -0,0 +1,75 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +var date = require('../lib/date') + , assert = require('assert') + , tests = {} + , _date = new Date(); + +tests = { + + 'test strftime for date': function () { + var data = date.strftime(_date, "%w") + , actual = _date.getDay(); + assert.equal(actual, data); + } + +, 'test calcCentury using current year for date': function () { + var data = date.calcCentury() + , actual = '21'; + assert.equal(actual, data); + } + +, 'test calcCentury using 20th century year for date': function () { + var data = date.calcCentury(2000) + , actual = '20'; + assert.equal(actual, data); + } + +, 'test calcCentury using 1st century year for date': function () { + var data = date.calcCentury(10) + , actual = '1'; + assert.equal(actual, data); + } + +, 'test getMeridiem for date': function () { + var data = date.getMeridiem(_date.getHours()) + , actual = (_date.getHours() > 11) ? 'PM' : 'AM'; + assert.equal(actual, data); + } + +, 'test relativeTime week/weeks switchover': function () { + var dtA = new Date() + , dtB + , res; + + dtB = date.add(dtA, 'day', 10); + dtB = date.add(dtB, 'hour', 23); + dtB = date.add(dtB, 'minute', 59); + dtB = date.add(dtB, 'second', 59); + dtB = date.add(dtB, 'millisecond', 999); + res = date.relativeTime(dtA, {now: dtB}); + assert.equal('one week ago', res); + + dtB = date.add(dtB, 'millisecond', 1); + res = date.relativeTime(dtA, {now: dtB}); + assert.equal('about 2 weeks ago', res); + } + +}; + +module.exports = tests; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/event_buffer.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/event_buffer.js b/blackberry10/node_modules/jake/node_modules/utilities/test/event_buffer.js new file mode 100644 index 0000000..61dcc30 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/event_buffer.js @@ -0,0 +1,45 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +var Stream = require('stream').Stream + , EventEmitter = require('events').EventEmitter + , EventBuffer = require('../lib/event_buffer.js').EventBuffer + , assert = require('assert') + , tests; + +tests = { + + 'test basic event buffer functionality': function () { + var source = new Stream() + , dest = new EventEmitter() + , buff = new EventBuffer(source) + , data = ''; + dest.on('data', function (d) { data += d; }); + source.writeable = true; + source.readable = true; + source.emit('data', 'abcdef'); + source.emit('data', '123456'); + buff.sync(dest); + assert.equal('abcdef123456', data); + source.emit('data', '---'); + assert.equal('abcdef123456---', data); + } + +}; + +module.exports = tests; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/file.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/file.js b/blackberry10/node_modules/jake/node_modules/utilities/test/file.js new file mode 100644 index 0000000..183373a --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/file.js @@ -0,0 +1,218 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +var assert = require('assert') + , fs = require('fs') + , path = require('path') + , file = require('../lib/file') + , existsSync = fs.existsSync || path.existsSync + , tests; + +tests = { + + 'before': function () { + process.chdir('./test'); + } + +, 'after': function () { + process.chdir('../'); + } + +, 'test mkdirP': function () { + var expected = [ + ['foo'] + , ['foo', 'bar'] + , ['foo', 'bar', 'baz'] + , ['foo', 'bar', 'baz', 'qux'] + ] + , res; + file.mkdirP('foo/bar/baz/qux'); + res = file.readdirR('foo'); + for (var i = 0, ii = res.length; i < ii; i++) { + assert.equal(path.join.apply(path, expected[i]), res[i]); + } + file.rmRf('foo', {silent: true}); + } + +, 'test rmRf': function () { + file.mkdirP('foo/bar/baz/qux', {silent: true}); + file.rmRf('foo/bar', {silent: true}); + res = file.readdirR('foo'); + assert.equal(1, res.length); + assert.equal('foo', res[0]); + fs.rmdirSync('foo'); + } + +, 'test cpR with same to and from will throw': function () { + assert.throws(function () { + file.cpR('foo.txt', 'foo.txt', {silent: true}); + }); + } + +, 'test cpR rename via copy in directory': function () { + file.mkdirP('foo', {silent: true}); + fs.writeFileSync('foo/bar.txt', 'w00t'); + file.cpR('foo/bar.txt', 'foo/baz.txt', {silent: true}); + assert.ok(existsSync('foo/baz.txt')); + file.rmRf('foo', {silent: true}); + } + +, 'test cpR rename via copy in base': function () { + fs.writeFileSync('bar.txt', 'w00t'); + file.cpR('bar.txt', 'baz.txt', {silent: true}); + assert.ok(existsSync('baz.txt')); + file.rmRf('bar.txt', {silent: true}); + file.rmRf('baz.txt', {silent: true}); + } + +, 'test readdirR': function () { + var expected = [ + ['foo'] + , ['foo', 'bar'] + , ['foo', 'bar', 'baz'] + , ['foo', 'bar', 'baz', 'qux'] + ] + , res; + + file.mkdirP('foo/bar/baz/qux', {silent: true}); + res = file.readdirR('foo'); + + for (var i = 0, ii = res.length; i < ii; i++) { + assert.equal(path.join.apply(path, expected[i]), res[i]); + } + file.rmRf('foo', {silent: true}); + } + +, 'test isAbsolute with Unix absolute path': function () { + var p = '/foo/bar/baz'; + assert.equal('/', file.isAbsolute(p)); + } + +, 'test isAbsolute with Unix relative path': function () { + var p = 'foo/bar/baz'; + assert.equal(false, file.isAbsolute(p)); + } + +, 'test isAbsolute with Win absolute path': function () { + var p = 'C:\\foo\\bar\\baz'; + assert.equal('C:\\', file.isAbsolute(p)); + } + +, 'test isAbsolute with Win relative path': function () { + var p = 'foo\\bar\\baz'; + assert.equal(false, file.isAbsolute(p)); + } + +, 'test absolutize with Unix absolute path': function () { + var expected = '/foo/bar/baz' + , actual = file.absolutize('/foo/bar/baz'); + assert.equal(expected, actual); + } + +, 'test absolutize with Win absolute path': function () { + var expected = 'C:\\foo\\bar\\baz' + , actual = file.absolutize('C:\\foo\\bar\\baz'); + assert.equal(expected, actual); + } + +, 'test absolutize with relative path': function () { + var expected = process.cwd() + , actual = ''; + + // We can't just create two different tests here + // because file.absolutize uses process.cwd() + // to get absolute path which is platform + // specific + if (process.platform === 'win32') { + expected += '\\foo\\bar\\baz' + actual = file.absolutize('foo\\bar\\baz') + } + else { + expected += '/foo/bar/baz' + actual = file.absolutize('foo/bar/baz'); + } + + assert.equal(expected, actual); + } + +, 'test basedir with Unix absolute path': function () { + var p = '/foo/bar/baz'; + assert.equal('/foo/bar', file.basedir(p)); + } + +, 'test basedir with Win absolute path': function () { + var p = 'C:\\foo\\bar\\baz'; + assert.equal('C:\\foo\\bar', file.basedir(p)); + } + +, 'test basedir with Unix root path': function () { + var p = '/'; + assert.equal('/', file.basedir(p)); + } + +, 'test basedir with Unix absolute path and double-asterisk': function () { + var p = '/**/foo/bar/baz'; + assert.equal('/', file.basedir(p)); + } + +, 'test basedir with leading double-asterisk': function () { + var p = '**/foo'; + assert.equal('.', file.basedir(p)); + } + +, 'test basedir with leading asterisk': function () { + var p = '*.js'; + assert.equal('.', file.basedir(p)); + } + +, 'test basedir with leading dot-slash and double-asterisk': function () { + var p = './**/foo'; + assert.equal('.', file.basedir(p)); + } + +, 'test basedir with leading dirname and double-asterisk': function () { + var p = 'a/**/*.js'; + assert.equal('a', file.basedir(p)); + } + +, 'test basedir with leading dot-dot-slash and double-asterisk': function () { + var p = '../../test/**/*.js'; + assert.equal('../../test', file.basedir(p)); + } + +, 'test basedir with single-asterisk in dirname': function () { + var p = 'a/test*/file'; + assert.equal('a', file.basedir(p)); + } + +, 'test basedir with single filename': function () { + var p = 'filename'; + assert.equal('.', file.basedir(p)); + } + +, 'test basedir with empty path': function () { + var p = ''; + assert.equal('.', file.basedir(p)); + assert.equal('.', file.basedir()); + } + +}; + +module.exports = tests; + + http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/i18n.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/i18n.js b/blackberry10/node_modules/jake/node_modules/utilities/test/i18n.js new file mode 100644 index 0000000..ba3e972 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/i18n.js @@ -0,0 +1,60 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +var i18n = require('../lib/i18n') + , assert = require('assert') + , tests + , inst = {}; + +tests = { + + 'before': function () { + i18n.loadLocale('en-us', {foo: 'FOO', bar: 'BAR', baz: 'BAZ'}); + i18n.loadLocale('ja-jp', {foo: 'フー', bar: 'バー'}); + inst.en = new i18n.I18n('en-us'); + inst.jp = new i18n.I18n('ja-jp'); + inst.de = new i18n.I18n('de-de'); + } + +, 'test default-locale fallback, defined strings': function () { + var expected = 'BAZ' + , actual = inst.jp.t('baz'); + assert.equal(expected, actual); + } + +, 'test default-locale fallback, no defined strings': function () { + var expected = 'BAZ' + , actual = inst.de.t('baz'); + assert.equal(expected, actual); + } + +, 'test key lookup, default-locale': function () { + var expected = 'FOO' + , actual = inst.en.t('foo'); + assert.equal(expected, actual); + } + +, 'test key lookup, non-default-locale': function () { + var expected = 'フー' + , actual = inst.jp.t('foo'); + assert.equal(expected, actual); + } + +}; + +module.exports = tests; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/inflection.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/inflection.js b/blackberry10/node_modules/jake/node_modules/utilities/test/inflection.js new file mode 100644 index 0000000..2a4cfe6 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/inflection.js @@ -0,0 +1,388 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +var inflection = require('../lib/inflection') + , assert = require('assert') + , esInflections + , sInflections + , iesInflections + , vesInflections + , icesInflections + , renInflections + , oesInflections + , iInflections + , genInflections + , irregularInflections + , noInflections + , tests; + +/** + * Most test inflections are from Ruby on Rails: + * https://github.com/rails/rails/blob/master/activesupport/test/inflector_test_cases.rb + * + * Ruby on Rails is MIT licensed: http://www.opensource.org/licenses/MIT +*/ +esInflections = [ + ["search", "searches"] + , ["switch", "switches"] + , ["fix", "fixes"] + , ["box", "boxes"] + , ["process", "processes"] + , ["address", "addresses"] + , ["wish", "wishes"] + , ["status", "statuses"] + , ["alias", "aliases"] + , ["basis", "bases"] + , ["diagnosis", "diagnoses"] + , ["bus", "buses"] +]; + +sInflections = [ + ["stack", "stacks"] + , ["shoe", "shoes"] + , ["status_code", "status_codes"] + , ["case", "cases"] + , ["edge", "edges"] + , ["archive", "archives"] + , ["experience", "experiences"] + , ["day", "days"] + , ["comment", "comments"] + , ["foobar", "foobars"] + , ["newsletter", "newsletters"] + , ["old_news", "old_news"] + , ["perspective", "perspectives"] + , ["diagnosis_a", "diagnosis_as"] + , ["horse", "horses"] + , ["prize", "prizes"] +]; + +iesInflections = [ + ["category", "categories"] + , ["query", "queries"] + , ["ability", "abilities"] + , ["agency", "agencies"] +]; + +vesInflections = [ + ["wife", "wives"] + , ["safe", "saves"] + , ["half", "halves"] + , ["elf", "elves"] + , ["dwarf", "dwarves"] +]; + +icesInflections = [ + ["index", "indices"] + , ["vertex", "vertices"] + , ["matrix", "matrices"] +]; + +renInflections = [ + ["node_child", "node_children"] + , ["child", "children"] +]; + +oesInflections = [ + ["buffalo", "buffaloes"] + , ["tomato", "tomatoes"] +]; + +iInflections = [ + ["octopus", "octopi"] + , ["virus", "viri"] +]; + +genInflections = [ + ["salesperson", "salespeople"] + , ["person", "people"] + , ["spokesman", "spokesmen"] + , ["man", "men"] + , ["woman", "women"] +]; + +irregularInflections = [ + ["datum", "data"] + , ["medium", "media"] + , ["ox", "oxen"] + , ["cow", "kine"] + , ["mouse", "mice"] + , ["louse", "lice"] + , ["axis", "axes"] + , ["testis", "testes"] + , ["crisis", "crises"] + , ["analysis", "analyses"] + , ["quiz", "quizzes"] +]; + +noInflections = [ + ["fish", "fish"] + , ["news", "news"] + , ["series", "series"] + , ["species", "species"] + , ["rice", "rice"] + , ["information", "information"] + , ["equipment", "equipment"] +]; + +tests = { + + 'test es plural words for inflection': function () { + var i = esInflections.length + , value; + + while (--i >= 0) { + value = esInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test es singular words for inflection': function () { + var i = esInflections.length + , value; + + while (--i >= 0) { + value = esInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test s plural words for inflection': function () { + var i = sInflections.length + , value; + + while (--i >= 0) { + value = sInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test s singular words for inflection': function () { + var i = sInflections.length + , value; + + while (--i >= 0) { + value = sInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test ies plural words for inflection': function () { + var i = iesInflections.length + , value; + + while (--i >= 0) { + value = iesInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test ies singular words for inflection': function () { + var i = iesInflections.length + , value; + + while (--i >= 0) { + value = iesInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test ves plural words for inflection': function () { + var i = vesInflections.length + , value; + + while (--i >= 0) { + value = vesInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test ves singular words for inflection': function () { + var i = vesInflections.length + , value; + + while (--i >= 0) { + value = vesInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test ices plural words for inflection': function () { + var i = icesInflections.length + , value; + + while (--i >= 0) { + value = icesInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test ices singular words for inflection': function () { + var i = icesInflections.length + , value; + + while (--i >= 0) { + value = icesInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test ren plural words for inflection': function () { + var i = renInflections.length + , value; + + while (--i >= 0) { + value = renInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test ren singular words for inflection': function () { + var i = renInflections.length + , value; + + while (--i >= 0) { + value = renInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test oes plural words for inflection': function () { + var i = oesInflections.length + , value; + + while (--i >= 0) { + value = oesInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test oes singular words for inflection': function () { + var i = oesInflections.length + , value; + + while (--i >= 0) { + value = oesInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test i plural words for inflection': function () { + var i = iInflections.length + , value; + + while (--i >= 0) { + value = iInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test i singular words for inflection': function () { + var i = iInflections.length + , value; + + while (--i >= 0) { + value = iInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test gender and people plural words for inflection': function () { + var i = genInflections.length + , value; + + while (--i >= 0) { + value = genInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test gender and people singular words for inflection': function () { + var i = genInflections.length + , value; + + while (--i >= 0) { + value = genInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test irregular plural words for inflection': function () { + var i = irregularInflections.length + , value; + + while (--i >= 0) { + value = irregularInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test irregular singular words for inflection': function () { + var i = irregularInflections.length + , value; + + while (--i >= 0) { + value = irregularInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +, 'test no change plural words for inflection': function () { + var i = noInflections.length + , value; + + while (--i >= 0) { + value = noInflections[i]; + + assert.equal(value[1], inflection.pluralize(value[0])) + } + } + +, 'test no change singular words for inflection': function () { + var i = noInflections.length + , value; + + while (--i >= 0) { + value = noInflections[i]; + + assert.equal(value[0], inflection.singularize(value[1])) + } + } + +}; + +module.exports = tests; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/network.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/network.js b/blackberry10/node_modules/jake/node_modules/utilities/test/network.js new file mode 100644 index 0000000..9619912 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/network.js @@ -0,0 +1,41 @@ +var assert = require('assert') + , sys = require('sys') + , net = require('net') + , network = require('../lib/network') + , tests; + +tests = { + + 'test a port is open': function (next) { + var expected = false + , port = 49152; + + network.isPortOpen(port, null, function (err, isOpen) { + assert.ifError(err); + assert.equal(expected, isOpen); + + next(); + }); + + } + +, 'test a port is closed': function (next) { + + var expected = true + , port = 49153 + , server = net.createServer(); + + server.listen(port, function () { + network.isPortOpen(port, null, function (err, isOpen) { + assert.ifError(err); + assert.equal(expected, isOpen); + + server.close(function () { + next(); + }); + }); + }); + } +} + +module.exports = tests; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/object.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/object.js b/blackberry10/node_modules/jake/node_modules/utilities/test/object.js new file mode 100644 index 0000000..ea2cea5 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/object.js @@ -0,0 +1,76 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +var object = require('../lib/object') + , array = require('../lib/array') + , assert = require('assert') + , tests = {} + , checkObjects; + +tests = { + + 'test merge in object': function () { + var expected = {user: 'geddy', key: 'key'} + , actual = object.merge({user: 'geddy'}, {key: 'key'}); + assert.deepEqual(actual, expected); + } + +, 'test merge with overwriting keys in object': function () { + var expected = {user: 'geddy', key: 'key'} + , actual = object.merge({user: 'geddy', key: 'geddyKey'}, {key: 'key'}); + assert.deepEqual(actual, expected); + } + +, 'test merge with objects as keys': function () { + var expected = {user: {name: 'geddy', password: 'random', key: 'key'}, key: 'key'} + , actual = object.merge({key: 'key'}, {user: {name: 'geddy', password: 'random', key: 'key'}}); + assert.deepEqual(actual, expected); + } + +, 'test reverseMerge in object': function () { + var expected = {user: 'geddy', key: 'key'} + , actual = object.reverseMerge({user: 'geddy'}, {key: 'key'}); + assert.deepEqual(actual, expected); + } + +, 'test reverseMerge with keys overwriting default in object': function () { + var expected = {user: 'geddy', key: 'geddyKey'} + , actual = object.reverseMerge({user: 'geddy', key: 'geddyKey'}, {key: 'key'}); + assert.deepEqual(actual, expected); + } + +, 'test reverseMerge with objects as keys': function () { + var expected = {user: {name: 'geddy', password: 'random', key: 'key'}, key: 'key'} + , actual = object.merge({user: {name: 'geddy', password: 'random', key: 'key'}}, {key: 'key'}); + assert.deepEqual(actual, expected); + } + +, 'test isEmpty with non empty object in object': function () { + var expected = false + , actual = object.isEmpty({user: 'geddy'}); + assert.equal(actual, expected); + } + +, 'test isEmpty with empty object in object': function () { + var expected = true + , actual = object.isEmpty({}); + assert.equal(actual, expected); + } + +}; + +module.exports = tests; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/sorted_collection.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/sorted_collection.js b/blackberry10/node_modules/jake/node_modules/utilities/test/sorted_collection.js new file mode 100644 index 0000000..2701a99 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/sorted_collection.js @@ -0,0 +1,115 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +var SortedCollection = require('../lib/sorted_collection').SortedCollection + , assert = require('assert') + , tests; + +tests = { + + 'test no default value': function () { + // Set up a collection, no default value for new items + var c = new SortedCollection(); + // Add some items + c.addItem('testA', 'AAAA'); + c.addItem('testB', 'BBBB'); + c.addItem('testC', 'CCCC'); + // Test count + assert.equal(3, c.count); + // Test getItem by string key + var item = c.getItem('testC'); + assert.equal('CCCC', item); + // Test getItem by index number + var item = c.getItem(1); + assert.equal('BBBB', item); + // Test setItem by string key + c.setItem('testA', 'aaaa'); + var item = c.getItem('testA'); + assert.equal('aaaa', item); + // Test setItem by index number + c.setItem(2, 'cccc'); + var item = c.getItem(2); + assert.equal('cccc', item); + } + +, 'test default value': function () { + // Set up a collection, default value for new items is 'foo' + var c = new SortedCollection('foo'); + // Add an item with no value -- should get + // default value + c.addItem('testA'); + // Add some items with empty/falsey values -- + // should be set to desired values + c.addItem('testB', null); + c.addItem('testC', false); + // Test getItem for default value + var item = c.getItem('testA'); + assert.equal('foo', item); + var item = c.getItem('testB'); + assert.equal(null, item); + var item = c.getItem('testC'); + assert.equal(false, item); + } + +, 'test each': function () { + var c = new SortedCollection() + , str = ''; + // Add an item with no value -- should get + // default value + c.addItem('a', 'A'); + c.addItem('b', 'B'); + c.addItem('c', 'C'); + c.addItem('d', 'D'); + c.each(function (val, key) { + str += val + key; + }); + assert.equal('AaBbCcDd', str); + } + +, 'test removing an item': function () { + var c = new SortedCollection() + , str = ''; + // Add an item with no value -- should get + // default value + c.addItem('a', 'A'); + c.addItem('b', 'B'); + c.addItem('c', 'C'); + c.addItem('d', 'D'); + assert.equal(4, c.count); + + omg = c.removeItem('c'); + assert.equal(3, c.count); + + c.each(function (val, key) { + str += val + key; + }); + assert.equal('AaBbDd', str); + } + +, 'test clone': function () { + var c = new SortedCollection() + , copy; + c.addItem('a', 'A'); + c.addItem('b', 'B'); + copy = c.clone(); + assert.equal(2, copy.count); + assert.equal('A', copy.getItem('a')); + } + +}; + +module.exports = tests; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/string.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/string.js b/blackberry10/node_modules/jake/node_modules/utilities/test/string.js new file mode 100644 index 0000000..a03027c --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/string.js @@ -0,0 +1,411 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +var assert = require('assert') + , string = require('../lib/string') + , tests; + +tests = { + + 'test basic escapeXML for string': function () { + var expected = '<html></html>' + , actual = string.escapeXML(''); + assert.equal(expected, actual); + } + +, 'test all escape characters for escapeXML': function () { + var expected = '<>&"'' + , actual = string.escapeXML('<>&"\''); + assert.equal(expected, actual); + } + +, 'test no escape characters with string for escapeXML': function () { + var expected = 'Geddy' + , actual = string.escapeXML('Geddy'); + assert.equal(expected, actual); + } + +, 'test no escape characters with numbers for escapeXML': function () { + var expected = 05 + , actual = string.escapeXML(05); + assert.equal(expected, actual); + } + +, 'test basic unescapeXML for string': function () { + var expected = '' + , actual = string.unescapeXML('<html></html>'); + assert.equal(expected, actual); + } + +, 'test all escape characters for unescapeXML': function () { + var expected = '<>&"\'' + , actual = string.unescapeXML('<>&"''); + assert.equal(expected, actual); + } + +, 'test no escape characters with string for unescapeXML': function () { + var expected = 'Geddy' + , actual = string.unescapeXML('Geddy'); + assert.equal(expected, actual); + } + +, 'test no escape characters with numbers for unescapeXML': function () { + var expected = 05 + , actual = string.unescapeXML(05); + assert.equal(expected, actual); + } + +, 'test basic needsEscape for string': function () { + var expected = true + , actual = string.needsEscape('Geddy>'); + assert.equal(expected, actual); + } + +, 'test basic needsEscape thats false for string': function () { + var expected = false + , actual = string.needsEscape('Geddy'); + assert.equal(expected, actual); + } + +, 'test basic needsUnescape for string': function () { + var expected = true + , actual = string.needsEscape('"Geddy"'); + assert.equal(expected, actual); + } + +, 'test basic needsUnescape thats false for string': function () { + var expected = false + , actual = string.needsEscape('Geddy'); + assert.equal(expected, actual); + } + +, 'test escapeRegExpCharacters': function () { + var expected = '\\^\\/\\.\\*\\+\\?\\|\\(\\)\\[\\]\\{\\}\\\\' + actual = string.escapeRegExpChars('^/.*+?|()[]{}\\'); + assert.equal(expected, actual); + } + +, 'test toArray for string': function () { + var data = string.toArray('geddy') + , expected = ['g', 'e', 'd', 'd', 'y']; + + // Loop through each item and check + // if not, then the arrays aren't _really_ the same + var i = expected.length; + while (--i >= 0) { + assert.equal(expected[i], data[i]); + } + } + +, 'test reverse for string': function () { + var data = string.reverse('yddeg') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test basic ltrim for string': function () { + var data = string.ltrim(' geddy') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test custom char ltrim for string': function () { + var data = string.ltrim('&&geddy', '&') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test basic rtrim for string': function () { + var data = string.rtrim('geddy ') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test custom char rtrim for string': function () { + var data = string.rtrim('geddy&&', '&') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test basic trim for string': function () { + var data = string.trim(' geddy ') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test custom char trim for string': function () { + var data = string.trim('&geddy&&', '&') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test chop special-case line-ending': function () { + var expected = 'geddy' + , actual = string.chop('geddy\r\n'); + assert.equal(expected, actual); + } + +, 'test chop not actual special-case line-ending': function () { + var expected = 'geddy\n' + , actual = string.chop('geddy\n\r'); + assert.equal(expected, actual); + } + +, 'test chop normal line-ending': function () { + var expected = 'geddy' + , actual = string.chop('geddy\n'); + assert.equal(expected, actual); + } + +, 'test chop whatever character': function () { + var expected = 'gedd' + , actual = string.chop('geddy'); + assert.equal(expected, actual); + } + +, 'test chop empty string': function () { + var expected = '' + , actual = string.chop(''); + assert.equal(expected, actual); + } + +, 'test basic lpad for string': function () { + var data = string.lpad('geddy', '&', 7) + , expected = '&&geddy'; + assert.equal(expected, data); + } + +, 'test lpad without width for string': function () { + var data = string.lpad('geddy', '&') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test lpad without width of char for string': function () { + var data = string.lpad('geddy') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test basic rpad for string': function () { + var data = string.rpad('geddy', '&', 7) + , expected = 'geddy&&'; + assert.equal(expected, data); + } + +, 'test rpad without width for string': function () { + var data = string.rpad('geddy', '&') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test rpad without width of char for string': function () { + var data = string.rpad('geddy') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test basic pad for string': function () { + var data = string.pad('geddy', '&', 7) + , expected = '&geddy&'; + assert.equal(expected, data); + } + +, 'test pad without width for string': function () { + var data = string.pad('geddy', '&') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test pad without width of char for string': function () { + var data = string.pad('geddy') + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test single tags in truncateHTML': function () { + var str = string.truncateHTML('

Once upon a time in a world

', { length: 10 }); + assert.equal(str, '

Once up...

'); + } + +, 'test multiple tags in truncateHTML': function () { + var str = string.truncateHTML('

Once upon a time in a world

', { length: 10 }); + assert.equal(str, '

Once up...in a wo...

'); + } + +, 'test multiple tags but only truncate once in truncateHTML': function () { + var str = string.truncateHTML('

Once upon a time in a world

', { length: 10, once: true }); + assert.equal(str, '

Once up...in a world

'); + } + +, 'test standard truncate': function () { + var str = string.truncate('Once upon a time in a world', { length: 10 }); + assert.equal(str, 'Once up...'); + } + +, 'test custom omission in truncate': function () { + var str = string.truncate('Once upon a time in a world', { length: 10, omission: '///' }); + assert.equal(str, 'Once up///'); + } + +, 'test regex seperator in truncate': function () { + var str = string.truncate('Once upon a time in a world', { length: 15, seperator: /\s/ }); + assert.equal(str, 'Once upon a...'); + } + +, 'test string seperator in truncate': function () { + var str = string.truncate('Once upon a time in a world', { length: 15, seperator: ' ' }); + assert.equal(str, 'Once upon a...'); + } + +, 'test unsafe html in truncate': function () { + var str = string.truncate('

Once upon a time in a world

', { length: 20 }); + assert.equal(str, '

Once upon a ti...'); + } + +, 'test nl2br for string': function () { + var data = string.nl2br("geddy\n") + , expected = 'geddy
'; + assert.equal(expected, data); + } + +, 'test snakeize for string': function () { + var data = string.snakeize("geddyJs") + , expected = 'geddy_js'; + assert.equal(expected, data); + } + +, 'test snakeize with beginning caps for string': function () { + var data = string.snakeize("GeddyJs") + , expected = 'geddy_js'; + assert.equal(expected, data); + } + +, 'test camelize for string': function () { + var data = string.camelize("geddy_js") + , expected = 'geddyJs'; + assert.equal(expected, data); + } + +, 'test camelize with initialCap for string': function () { + var data = string.camelize("geddy_js", {initialCap: true}) + , expected = 'GeddyJs'; + assert.equal(expected, data); + } + +, 'test camelize with leadingUnderscore with no underscore for string': function () { + var data = string.camelize("geddy_js", {leadingUnderscore: true}) + , expected = 'geddyJs'; + assert.equal(expected, data); + } + +, 'test camelize with leadingUnderscore with underscore for string': function () { + var data = string.camelize("_geddy_js", {leadingUnderscore: true}) + , expected = '_geddyJs'; + assert.equal(expected, data); + } + +, 'test decapitalize for string': function () { + var data = string.decapitalize("Geddy") + , expected = 'geddy'; + assert.equal(expected, data); + } + +, 'test capitalize for string': function () { + var data = string.capitalize("geddy") + , expected = 'Geddy'; + assert.equal(expected, data); + } + +, 'test dasherize for string': function () { + var data = string.dasherize("geddyJs") + , expected = 'geddy-js'; + assert.equal(expected, data); + } + +, 'test dasherize with custom replace char for string': function () { + var data = string.dasherize("geddyJs", "_") + , expected = 'geddy_js'; + assert.equal(expected, data); + } + +, 'test underscorize for string': function () { + var data = string.underscorize("geddyJs") + , expected = 'geddy_js'; + assert.equal(expected, data); + } + +, 'test include for string with included string': function () { + assert.ok(string.include('foobarbaz', 'foo')); + } + +, 'test include for string with not included string': function () { + assert.ok(!string.include('foobarbaz', 'qux')); + } + +, 'test getInflections for string': function () { + var actual = string.getInflections("string") + , expected = { + filename: { + singular: "string" + , plural: "strings" + }, + constructor: { + singular: "String" + , plural: "Strings" + }, + property: { + singular: "string" + , plural: "strings" + }, + }; + + assert.deepEqual(expected, actual); + } + +, 'test inflection with odd name for string': function () { + var actual = string.getInflections("snow_dog") + , expected = { + filename: { + singular: "snow_dog" + , plural: "snow_dogs" + }, + constructor: { + singular: "SnowDog" + , plural: "SnowDogs" + }, + property: { + singular: "snowDog" + , plural: "snowDogs" + }, + }; + + assert.deepEqual(expected, actual); + } + +, 'test uuid length for string': function () { + var data = string.uuid(5).length + , expected = 5; + assert.equal(expected, data); + } + +}; + +module.exports = tests; + + http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/jake/node_modules/utilities/test/uri.js ---------------------------------------------------------------------- diff --git a/blackberry10/node_modules/jake/node_modules/utilities/test/uri.js b/blackberry10/node_modules/jake/node_modules/utilities/test/uri.js new file mode 100644 index 0000000..8048493 --- /dev/null +++ b/blackberry10/node_modules/jake/node_modules/utilities/test/uri.js @@ -0,0 +1,99 @@ +/* + * Utilities: A classic collection of JavaScript utilities + * Copyright 2112 Matthew Eernisse (mde@fleegix.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +var uri = require('../lib/uri') + , array = require('../lib/array') + , assert = require('assert') + , tests = {}; + +tests = { + + 'test getFileExtension for uri': function () { + var data = uri.getFileExtension('users.json') + , actual = 'json'; + assert.equal(actual, data); + } + +, 'test paramify for uri': function () { + var data = uri.paramify({username: 'user', token: 'token', secret: 'secret'}) + , actual = 'username=user&token=token&secret=secret'; + assert.equal(actual, data); + } + +, 'test paramify with conslidate option for uri': function () { + var data = uri.paramify({username: 'user', auth: ['token', 'secret']}, {conslidate: true}) + , actual = 'username=user&auth=token&auth=secret'; + assert.equal(actual, data); + } + +, 'test paramify with includeEmpty option for uri': function () { + var data = uri.paramify({username: 'user', token: ''}, {includeEmpty: true}) + , actual = 'username=user&token='; + assert.equal(actual, data); + } + +, 'test paramify with includeEmpty as 0 option for uri': function () { + var data = uri.paramify({username: 'user', token: 0}, {includeEmpty: true}) + , actual = 'username=user&token=0'; + assert.equal(actual, data); + } + +, 'test paramify with includeEmpty as null option for uri': function () { + var data = uri.paramify({username: 'user', token: null}, {includeEmpty: true}) + , actual = 'username=user&token='; + assert.equal(actual, data); + } + +, 'test paramify with includeEmpty as undefined option for uri': function () { + var data = uri.paramify({username: 'user', token: undefined}, {includeEmpty: true}) + , actual = 'username=user&token='; + assert.equal(actual, data); + } + +, 'test paramify with snakeize option for uri': function () { + var data = uri.paramify({username: 'user', authToken: 'token'}, {snakeize: true}) + , actual = 'username=user&auth_token=token'; + assert.equal(actual, data); + } + +, 'test paramify with escapeVals option for uri': function () { + var data = uri.paramify({username: 'user', token: '