http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/bound.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/bound.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/bound.js new file mode 100644 index 0000000..d398195 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/bound.js @@ -0,0 +1,10 @@ +var test = require('../'); + +test('bind works', function (t) { + t.plan(2); + var equal = t.equal; + var deepEqual = t.deepEqual; + equal(3, 3); + deepEqual([4], [4]); + t.end(); +});
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/browser/asserts.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/browser/asserts.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/browser/asserts.js new file mode 100644 index 0000000..a1b24f6 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/browser/asserts.js @@ -0,0 +1,9 @@ +var test = require('../../'); + +test(function (t) { + t.plan(4); + t.ok(true); + t.equal(3, 1+2); + t.deepEqual([1,2,[3,4]], [1,2,[3,4]]); + t.notDeepEqual([1,2,[3,4,5]], [1,2,[3,4]]); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/child_ordering.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/child_ordering.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/child_ordering.js new file mode 100644 index 0000000..12efafe --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/child_ordering.js @@ -0,0 +1,54 @@ +var test = require('../'); + +var childRan = false; + +test('parent', function(t) { + t.test('child', function(t) { + childRan = true; + t.pass('child ran'); + t.end(); + }); + t.end(); +}); + +test('uncle', function(t) { + t.ok(childRan, 'Child should run before next top-level test'); + t.end(); +}); + +var grandParentRan = false; +var parentRan = false; +var grandChildRan = false; +test('grandparent', function(t) { + t.ok(!grandParentRan, 'grand parent ran twice'); + grandParentRan = true; + t.test('parent', function(t) { + t.ok(!parentRan, 'parent ran twice'); + parentRan = true; + t.test('grandchild', function(t) { + t.ok(!grandChildRan, 'grand child ran twice'); + grandChildRan = true; + t.pass('grand child ran'); + t.end(); + }); + t.pass('parent ran'); + t.end(); + }); + t.test('other parent', function(t) { + t.ok(parentRan, 'first parent runs before second parent'); + t.ok(grandChildRan, 'grandchild runs before second parent'); + t.end(); + }); + t.pass('grandparent ran'); + t.end(); +}); + +test('second grandparent', function(t) { + t.ok(grandParentRan, 'grandparent ran'); + t.ok(parentRan, 'parent ran'); + t.ok(grandChildRan, 'grandchild ran'); + t.pass('other grandparent ran'); + t.end(); +}); + +// vim: set softtabstop=4 shiftwidth=4: http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/circular-things.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/circular-things.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/circular-things.js new file mode 100644 index 0000000..1a0368d --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/circular-things.js @@ -0,0 +1,43 @@ +var tape = require('../'); +var tap = require('tap'); + +tap.test('circular test', function (assert) { + var test = tape.createHarness({ exit : false }); + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + // console.log("rs", rows) + + // console.log("deepEqual?") + + assert.same(rows, [ + "TAP version 13" + , "circular" + , { id: 1 + , ok: false + , name: " should be equal" + , operator: "equal" + , expected: "{}" + , actual: '{ circular: [Circular] }' + } + , "tests 1" + , "pass 0" + , "fail 1" + ]) + assert.end() + }) + + // tt.equal(10, 10) + // tt.end() + + test.createStream().pipe(tc); + + test("circular", function (t) { + t.plan(1) + var circular = {} + circular.circular = circular + t.equal(circular, {}) + }) +}) http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/deep.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/deep.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/deep.js new file mode 100644 index 0000000..02f3681 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/deep.js @@ -0,0 +1,9 @@ +var test = require('../'); + +test('deep strict equal', function (t) { + t.notDeepEqual( + [ { a: '3' } ], + [ { a: 3 } ] + ); + t.end(); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/double_end.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/double_end.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/double_end.js new file mode 100644 index 0000000..c405d45 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/double_end.js @@ -0,0 +1,27 @@ +var test = require('tap').test; +var concat = require('concat-stream'); +var spawn = require('child_process').spawn; + +test(function (t) { + t.plan(2); + var ps = spawn(process.execPath, [ __dirname + '/double_end/double.js' ]); + ps.on('exit', function (code) { + t.equal(code, 1); + }); + ps.stdout.pipe(concat(function (body) { + t.equal(body.toString('utf8'), [ + 'TAP version 13', + '# double end', + 'ok 1 should be equal', + 'not ok 2 .end() called twice', + ' ---', + ' operator: fail', + ' ...', + '', + '1..2', + '# tests 2', + '# pass 1', + '# fail 1', + ].join('\n') + '\n\n'); + })); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/double_end/double.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/double_end/double.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/double_end/double.js new file mode 100644 index 0000000..4473482 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/double_end/double.js @@ -0,0 +1,9 @@ +var test = require('../../'); + +test('double end', function (t) { + t.equal(1 + 1, 2); + t.end(); + setTimeout(function () { + t.end(); + }, 5); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/end-as-callback.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/end-as-callback.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/end-as-callback.js new file mode 100644 index 0000000..6d24a0c --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/end-as-callback.js @@ -0,0 +1,66 @@ +var tap = require("tap"); +var tape = require("../"); + +tap.test("tape assert.end as callback", function (tt) { + var test = tape.createHarness({ exit: false }) + var tc = tap.createConsumer() + + var rows = [] + tc.on("data", function (r) { rows.push(r) }) + tc.on("end", function () { + var rs = rows.map(function (r) { + return r && typeof r === "object" ? + { id: r.id, ok: r.ok, name: r.name.trim() } : + r + }) + + tt.deepEqual(rs, [ + "TAP version 13", + "do a task and write", + { id: 1, ok: true, name: "null" }, + { id: 2, ok: true, name: "should be equal" }, + { id: 3, ok: true, name: "null" }, + "do a task and write fail", + { id: 4, ok: true, name: "null" }, + { id: 5, ok: true, name: "should be equal" }, + { id: 6, ok: false, name: "Error: fail" }, + "tests 6", + "pass 5", + "fail 1" + ]) + + tt.end() + }) + + test.createStream().pipe(tc) + + test("do a task and write", function (assert) { + fakeAsyncTask("foo", function (err, value) { + assert.ifError(err) + assert.equal(value, "taskfoo") + + fakeAsyncWrite("bar", assert.end) + }) + }) + + test("do a task and write fail", function (assert) { + fakeAsyncTask("bar", function (err, value) { + assert.ifError(err) + assert.equal(value, "taskbar") + + fakeAsyncWriteFail("baz", assert.end) + }) + }) +}) + +function fakeAsyncTask(name, cb) { + cb(null, "task" + name) +} + +function fakeAsyncWrite(name, cb) { + cb(null) +} + +function fakeAsyncWriteFail(name, cb) { + cb(new Error("fail")) +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit.js new file mode 100644 index 0000000..7f7c5d0 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit.js @@ -0,0 +1,142 @@ +var tap = require('tap'); +var spawn = require('child_process').spawn; + +tap.test('exit ok', function (t) { + t.plan(2); + + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + t.same(rs, [ + 'TAP version 13', + 'array', + { id: 1, ok: true, name: 'should be equivalent' }, + { id: 2, ok: true, name: 'should be equivalent' }, + { id: 3, ok: true, name: 'should be equivalent' }, + { id: 4, ok: true, name: 'should be equivalent' }, + { id: 5, ok: true, name: 'should be equivalent' }, + 'tests 5', + 'pass 5', + 'ok' + ]); + }); + + var ps = spawn(process.execPath, [ __dirname + '/exit/ok.js' ]); + ps.stdout.pipe(tc); + ps.on('exit', function (code) { + t.equal(code, 0); + }); +}); + +tap.test('exit fail', function (t) { + t.plan(2); + + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + t.same(rs, [ + 'TAP version 13', + 'array', + { id: 1, ok: true, name: 'should be equivalent' }, + { id: 2, ok: true, name: 'should be equivalent' }, + { id: 3, ok: true, name: 'should be equivalent' }, + { id: 4, ok: true, name: 'should be equivalent' }, + { id: 5, ok: false, name: 'should be equivalent' }, + 'tests 5', + 'pass 4', + 'fail 1' + ]); + }); + + var ps = spawn(process.execPath, [ __dirname + '/exit/fail.js' ]); + ps.stdout.pipe(tc); + ps.on('exit', function (code) { + t.notEqual(code, 0); + }); +}); + +tap.test('too few exit', function (t) { + t.plan(2); + + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + t.same(rs, [ + 'TAP version 13', + 'array', + { id: 1, ok: true, name: 'should be equivalent' }, + { id: 2, ok: true, name: 'should be equivalent' }, + { id: 3, ok: true, name: 'should be equivalent' }, + { id: 4, ok: true, name: 'should be equivalent' }, + { id: 5, ok: true, name: 'should be equivalent' }, + { id: 6, ok: false, name: 'plan != count' }, + 'tests 6', + 'pass 5', + 'fail 1' + ]); + }); + + var ps = spawn(process.execPath, [ __dirname + '/exit/too_few.js' ]); + ps.stdout.pipe(tc); + ps.on('exit', function (code) { + t.notEqual(code, 0); + }); +}); + +tap.test('more planned in a second test', function (t) { + t.plan(2); + + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + t.same(rs, [ + 'TAP version 13', + 'first', + { id: 1, ok: true, name: '(unnamed assert)' }, + 'second', + { id: 2, ok: true, name: '(unnamed assert)' }, + { id: 3, ok: false, name: 'plan != count' }, + 'tests 3', + 'pass 2', + 'fail 1' + ]); + }); + + var ps = spawn(process.execPath, [ __dirname + '/exit/second.js' ]); + ps.stdout.pipe(tc); + ps.on('exit', function (code) { + t.notEqual(code, 0); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/fail.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/fail.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/fail.js new file mode 100644 index 0000000..d7fd3ce --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/fail.js @@ -0,0 +1,35 @@ +var test = require('../../'); +var falafel = require('falafel'); + +test('array', function (t) { + t.plan(5); + + var src = '(' + function () { + var xs = [ 1, 2, [ 3, 4 ] ]; + var ys = [ 5, 6 ]; + g([ xs, ys ]); + } + ')()'; + + var output = falafel(src, function (node) { + if (node.type === 'ArrayExpression') { + node.update('fn(' + node.source() + ')'); + } + }); + + var arrays = [ + [ 3, 4 ], + [ 1, 2, [ 3, 4 ] ], + [ 5, 6 ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + ]; + + Function(['fn','g'], output)( + function (xs) { + t.same(arrays.shift(), xs); + return xs; + }, + function (xs) { + t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]); + } + ); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/ok.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/ok.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/ok.js new file mode 100644 index 0000000..a02c7b6 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/ok.js @@ -0,0 +1,35 @@ +var falafel = require('falafel'); +var test = require('../../'); + +test('array', function (t) { + t.plan(5); + + var src = '(' + function () { + var xs = [ 1, 2, [ 3, 4 ] ]; + var ys = [ 5, 6 ]; + g([ xs, ys ]); + } + ')()'; + + var output = falafel(src, function (node) { + if (node.type === 'ArrayExpression') { + node.update('fn(' + node.source() + ')'); + } + }); + + var arrays = [ + [ 3, 4 ], + [ 1, 2, [ 3, 4 ] ], + [ 5, 6 ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + ]; + + Function(['fn','g'], output)( + function (xs) { + t.same(arrays.shift(), xs); + return xs; + }, + function (xs) { + t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + } + ); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/second.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/second.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/second.js new file mode 100644 index 0000000..8a206bb --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/second.js @@ -0,0 +1,11 @@ +var test = require('../../'); + +test('first', function (t) { + t.plan(1); + t.ok(true); +}); + +test('second', function (t) { + t.plan(2); + t.ok(true); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/too_few.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/too_few.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/too_few.js new file mode 100644 index 0000000..8e60ce5 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/exit/too_few.js @@ -0,0 +1,35 @@ +var falafel = require('falafel'); +var test = require('../../'); + +test('array', function (t) { + t.plan(6); + + var src = '(' + function () { + var xs = [ 1, 2, [ 3, 4 ] ]; + var ys = [ 5, 6 ]; + g([ xs, ys ]); + } + ')()'; + + var output = falafel(src, function (node) { + if (node.type === 'ArrayExpression') { + node.update('fn(' + node.source() + ')'); + } + }); + + var arrays = [ + [ 3, 4 ], + [ 1, 2, [ 3, 4 ] ], + [ 5, 6 ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + ]; + + Function(['fn','g'], output)( + function (xs) { + t.same(arrays.shift(), xs); + return xs; + }, + function (xs) { + t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + } + ); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/fail.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/fail.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/fail.js new file mode 100644 index 0000000..d56045a --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/fail.js @@ -0,0 +1,68 @@ +var falafel = require('falafel'); +var tape = require('../'); +var tap = require('tap'); + +tap.test('array test', function (tt) { + tt.plan(1); + + var test = tape.createHarness({ exit : false }); + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + tt.same(rs, [ + 'TAP version 13', + 'array', + { id: 1, ok: true, name: 'should be equivalent' }, + { id: 2, ok: true, name: 'should be equivalent' }, + { id: 3, ok: true, name: 'should be equivalent' }, + { id: 4, ok: true, name: 'should be equivalent' }, + { id: 5, ok: false, name: 'should be equivalent' }, + 'tests 5', + 'pass 4', + 'fail 1' + ]); + }); + + test.createStream().pipe(tc); + + test('array', function (t) { + t.plan(5); + + var src = '(' + function () { + var xs = [ 1, 2, [ 3, 4 ] ]; + var ys = [ 5, 6 ]; + g([ xs, ys ]); + } + ')()'; + + var output = falafel(src, function (node) { + if (node.type === 'ArrayExpression') { + node.update('fn(' + node.source() + ')'); + } + }); + + var arrays = [ + [ 3, 4 ], + [ 1, 2, [ 3, 4 ] ], + [ 5, 6 ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + ]; + + Function(['fn','g'], output)( + function (xs) { + t.same(arrays.shift(), xs); + return xs; + }, + function (xs) { + t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]); + } + ); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/many.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/many.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/many.js new file mode 100644 index 0000000..10556e5 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/many.js @@ -0,0 +1,8 @@ +var test = require('../'); + +test('many tests', function (t) { + t.plan(100); + for (var i = 0; i < 100; i++) { + setTimeout(function () { t.pass() }, Math.random() * 50); + } +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/max_listeners.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/max_listeners.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/max_listeners.js new file mode 100644 index 0000000..5edfb15 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/max_listeners.js @@ -0,0 +1,7 @@ +var spawn = require('child_process').spawn; +var ps = spawn(process.execPath, [ __dirname + '/max_listeners/source.js' ]); +ps.stdout.pipe(process.stdout, { end : false }); + +ps.stderr.on('data', function (buf) { + console.log('not ok ' + buf); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/max_listeners/source.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/max_listeners/source.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/max_listeners/source.js new file mode 100644 index 0000000..839a327 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/max_listeners/source.js @@ -0,0 +1,5 @@ +var test = require('../../'); + +for (var i = 0; i < 11; i ++) { + test(function (t) { t.end() }); +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested-async-plan-noend.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested-async-plan-noend.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested-async-plan-noend.js new file mode 100644 index 0000000..6f8cfdd --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested-async-plan-noend.js @@ -0,0 +1,36 @@ +var test = require('../'); + +test('Harness async test support', function(t) { + t.plan(3); + + t.ok(true, 'sync child A'); + + t.test('sync child B', function(tt) { + tt.plan(2); + + setTimeout(function(){ + tt.test('async grandchild A', function(ttt) { + ttt.plan(1); + ttt.ok(true); + }); + }, 50); + + setTimeout(function() { + tt.test('async grandchild B', function(ttt) { + ttt.plan(1); + ttt.ok(true); + }); + }, 100); + }); + + setTimeout(function() { + t.test('async child', function(tt) { + tt.plan(2); + tt.ok(true, 'sync grandchild in async child A'); + tt.test('sync grandchild in async child B', function(ttt) { + ttt.plan(1); + ttt.ok(true); + }); + }); + }, 200); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested-sync-noplan-noend.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested-sync-noplan-noend.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested-sync-noplan-noend.js new file mode 100644 index 0000000..a206c50 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested-sync-noplan-noend.js @@ -0,0 +1,50 @@ +var tape = require('../'); +var tap = require('tap'); + +tap.test('nested sync test without plan or end', function (tt) { + tt.plan(1); + + var test = tape.createHarness(); + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + var expected = [ + 'TAP version 13', + 'nested without plan or end', + 'first', + { id: 1, ok: true, name: '(unnamed assert)' }, + 'second', + { id: 2, ok: true, name: '(unnamed assert)' }, + 'tests 2', + 'pass 2', + 'ok' + ] + tt.same(rs, expected); + }); + + test.createStream().pipe(tc); + + test('nested without plan or end', function(t) { + t.test('first', function(q) { + setTimeout(function first() { + q.ok(true); + q.end() + }, 10); + }); + t.test('second', function(q) { + setTimeout(function second() { + q.ok(true); + q.end() + }, 10); + }); + }); + +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested.js new file mode 100644 index 0000000..673465d --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested.js @@ -0,0 +1,89 @@ +var falafel = require('falafel'); +var tape = require('../'); +var tap = require('tap'); + +tap.test('array test', function (tt) { + tt.plan(1); + + var test = tape.createHarness(); + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + tt.same(rs, [ + 'TAP version 13', + 'nested array test', + { id: 1, ok: true, name: 'should be equivalent' }, + { id: 2, ok: true, name: 'should be equivalent' }, + { id: 3, ok: true, name: 'should be equivalent' }, + { id: 4, ok: true, name: 'should be equivalent' }, + { id: 5, ok: true, name: 'should be equivalent' }, + 'inside test', + { id: 6, ok: true, name: '(unnamed assert)' }, + { id: 7, ok: true, name: '(unnamed assert)' }, + 'another', + { id: 8, ok: true, name: '(unnamed assert)' }, + 'tests 8', + 'pass 8', + 'ok' + ]); + }); + + test.createStream().pipe(tc); + + test('nested array test', function (t) { + t.plan(6); + + var src = '(' + function () { + var xs = [ 1, 2, [ 3, 4 ] ]; + var ys = [ 5, 6 ]; + g([ xs, ys ]); + } + ')()'; + + var output = falafel(src, function (node) { + if (node.type === 'ArrayExpression') { + node.update('fn(' + node.source() + ')'); + } + }); + + t.test('inside test', function (q) { + q.plan(2); + q.ok(true); + + setTimeout(function () { + q.ok(true); + }, 100); + }); + + var arrays = [ + [ 3, 4 ], + [ 1, 2, [ 3, 4 ] ], + [ 5, 6 ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + ]; + + Function(['fn','g'], output)( + function (xs) { + t.same(arrays.shift(), xs); + return xs; + }, + function (xs) { + t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + } + ); + }); + + test('another', function (t) { + t.plan(1); + setTimeout(function () { + t.ok(true); + }, 50); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested2.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested2.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested2.js new file mode 100644 index 0000000..58ae8f3 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/nested2.js @@ -0,0 +1,19 @@ +var test = require('../'); + +test(function(t) { + var i = 0 + t.test('setup', function(t) { + process.nextTick(function() { + t.equal(i, 0, 'called once') + i++ + t.end() + }) + }) + + + t.test('teardown', function(t) { + t.end() + }) + + t.end() +}) http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/no_callback.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/no_callback.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/no_callback.js new file mode 100644 index 0000000..760ff26 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/no_callback.js @@ -0,0 +1,3 @@ +var test = require('../'); + +test('No callback.'); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only.js new file mode 100644 index 0000000..9e6bc26 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only.js @@ -0,0 +1,53 @@ +var tap = require('tap'); +var tape = require('../'); + +tap.test('tape only test', function (tt) { + var test = tape.createHarness({ exit: false }); + var tc = tap.createConsumer(); + var ran = []; + + var rows = [] + tc.on('data', function (r) { rows.push(r) }) + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id: r.id, ok: r.ok, name: r.name.trim() }; + } + else { + return r; + } + }) + + tt.deepEqual(rs, [ + 'TAP version 13', + 'run success', + { id: 1, ok: true, name: 'assert name'}, + 'tests 1', + 'pass 1', + 'ok' + ]) + tt.deepEqual(ran, [ 3 ]); + + tt.end() + }) + + test.createStream().pipe(tc) + + test("never run fail", function (t) { + ran.push(1); + t.equal(true, false) + t.end() + }) + + test("never run success", function (t) { + ran.push(2); + t.equal(true, true) + t.end() + }) + + test.only("run success", function (t) { + ran.push(3); + t.ok(true, "assert name") + t.end() + }) +}) http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only2.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only2.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only2.js new file mode 100644 index 0000000..fcf4f43 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only2.js @@ -0,0 +1,9 @@ +var test = require('../'); + +test('only2 test 1', function (t) { + t.end(); +}); + +test.only('only2 test 2', function (t) { + t.end(); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only3.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only3.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only3.js new file mode 100644 index 0000000..b192a4e --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/only3.js @@ -0,0 +1,15 @@ +var test = require('../'); + +test('only3 test 1', function (t) { + t.fail('not 1'); + t.end(); +}); + +test.only('only3 test 2', function (t) { + t.end(); +}); + +test('only3 test 3', function (t) { + t.fail('not 3'); + t.end(); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/order.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/order.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/order.js new file mode 100644 index 0000000..02aaa05 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/order.js @@ -0,0 +1,17 @@ +var test = require('../'); +var current = 0; + +test(function (t) { + t.equal(current++, 0); + t.end(); +}); +test(function (t) { + t.plan(1); + setTimeout(function () { + t.equal(current++, 1); + }, 100); +}); +test(function (t) { + t.equal(current++, 2); + t.end(); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/plan_optional.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/plan_optional.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/plan_optional.js new file mode 100644 index 0000000..a092eab --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/plan_optional.js @@ -0,0 +1,15 @@ +var test = require('../'); + +test('plan should be optional', function (t) { + t.pass('no plan here'); + t.end(); +}); + +test('no plan async', function (t) { + setTimeout(function() { + t.pass('ok'); + t.end(); + }, 100); +}); + +// vim: set softtabstop=4 shiftwidth=4: http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/skip.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/skip.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/skip.js new file mode 100644 index 0000000..216b600 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/skip.js @@ -0,0 +1,46 @@ +var test = require('../'); +var ran = 0; + +test('do not skip this', { skip: false }, function(t) { + t.pass('this should run'); + ran ++; + t.end(); +}); + +test('skip this', { skip: true }, function(t) { + t.fail('this should not even run'); + ran++; + t.end(); +}); + +test.skip('skip this too', function(t) { + t.fail('this should not even run'); + ran++; + t.end(); +}); + +test.skip('skip this too', function(t) { + t.fail('this should not even run'); + t.end(); +}); + +test('skip subtest', function(t) { + ran ++; + t.test('do not skip this', { skip: false }, function(t) { + ran ++; + t.pass('this should run'); + t.end(); + }); + t.test('skip this', { skip: true }, function(t) { + t.fail('this should not even run'); + t.end(); + }); + t.end(); +}); + +test('right number of tests ran', function(t) { + t.equal(ran, 3, 'ran the right number of tests'); + t.end(); +}); + +// vim: set softtabstop=4 shiftwidth=4: http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subcount.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subcount.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subcount.js new file mode 100644 index 0000000..3a5df3f --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subcount.js @@ -0,0 +1,14 @@ +var test = require('../'); + +test('parent test', function (t) { + t.plan(2); + t.test('first child', function (t) { + t.plan(1); + t.pass('pass first child'); + }) + + t.test(function (t) { + t.plan(1); + t.pass('pass second child'); + }) +}) http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subtest_and_async.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subtest_and_async.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subtest_and_async.js new file mode 100644 index 0000000..719dbf5 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subtest_and_async.js @@ -0,0 +1,23 @@ +var test = require('../'); + +var asyncFunction = function (callback) { + setTimeout(callback, Math.random * 50); +}; + +test('master test', function (t) { + t.test('subtest 1', function (t) { + t.pass('subtest 1 before async call'); + asyncFunction(function () { + t.pass('subtest 1 in async callback'); + t.end(); + }) + }); + + t.test('subtest 2', function (t) { + t.pass('subtest 2 before async call'); + asyncFunction(function () { + t.pass('subtest 2 in async callback'); + t.end(); + }) + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subtest_plan.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subtest_plan.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subtest_plan.js new file mode 100644 index 0000000..2b075ae --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/subtest_plan.js @@ -0,0 +1,21 @@ +var test = require('../'); + +test('parent', function (t) { + t.plan(3) + + var firstChildRan = false; + + t.pass('assertion in parent'); + + t.test('first child', function (t) { + t.plan(1); + t.pass('pass first child'); + firstChildRan = true; + }); + + t.test('second child', function (t) { + t.plan(2); + t.ok(firstChildRan, 'first child ran first'); + t.pass('pass second child'); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/throws.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/throws.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/throws.js new file mode 100644 index 0000000..ec91fb8 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/throws.js @@ -0,0 +1,20 @@ +var test = require('../'); + +function fn() { + throw new TypeError('RegExp'); +} + +test('throws', function (t) { + t.throws(fn); + t.end(); +}); + +test('throws (RegExp match)', function (t) { + t.throws(fn, /RegExp/); + t.end(); +}); + +test('throws (Function match)', function (t) { + t.throws(fn, TypeError); + t.end(); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/timeoutAfter.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/timeoutAfter.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/timeoutAfter.js new file mode 100644 index 0000000..bd2a4f1 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/timeoutAfter.js @@ -0,0 +1,35 @@ +var tape = require('../'); +var tap = require('tap'); + +tap.test('timeoutAfter test', function (tt) { + tt.plan(1); + + var test = tape.createHarness(); + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + tt.same(rs, [ + 'TAP version 13', + 'timeoutAfter', + { id: 1, ok: false, name: 'test timed out after 1ms' }, + 'tests 1', + 'pass 0', + 'fail 1' + ]); + }); + + test.createStream().pipe(tc); + + test('timeoutAfter', function (t) { + t.plan(1); + t.timeoutAfter(1); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/too_many.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/too_many.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/too_many.js new file mode 100644 index 0000000..b5c3881 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/too_many.js @@ -0,0 +1,69 @@ +var falafel = require('falafel'); +var tape = require('../'); +var tap = require('tap'); + +tap.test('array test', function (tt) { + tt.plan(1); + + var test = tape.createHarness({ exit : false }); + var tc = tap.createConsumer(); + + var rows = []; + tc.on('data', function (r) { rows.push(r) }); + tc.on('end', function () { + var rs = rows.map(function (r) { + if (r && typeof r === 'object') { + return { id : r.id, ok : r.ok, name : r.name.trim() }; + } + else return r; + }); + tt.same(rs, [ + 'TAP version 13', + 'array', + { id: 1, ok: true, name: 'should be equivalent' }, + { id: 2, ok: true, name: 'should be equivalent' }, + { id: 3, ok: true, name: 'should be equivalent' }, + { id: 4, ok: true, name: 'should be equivalent' }, + { id: 5, ok: false, name: 'plan != count' }, + { id: 6, ok: true, name: 'should be equivalent' }, + 'tests 6', + 'pass 5', + 'fail 1' + ]); + }); + + test.createStream().pipe(tc); + + test('array', function (t) { + t.plan(3); + + var src = '(' + function () { + var xs = [ 1, 2, [ 3, 4 ] ]; + var ys = [ 5, 6 ]; + g([ xs, ys ]); + } + ')()'; + + var output = falafel(src, function (node) { + if (node.type === 'ArrayExpression') { + node.update('fn(' + node.source() + ')'); + } + }); + + var arrays = [ + [ 3, 4 ], + [ 1, 2, [ 3, 4 ] ], + [ 5, 6 ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + ]; + + Function(['fn','g'], output)( + function (xs) { + t.same(arrays.shift(), xs); + return xs; + }, + function (xs) { + t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + } + ); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/undef.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/undef.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/undef.js new file mode 100644 index 0000000..e856a54 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/node_modules/tape/test/undef.js @@ -0,0 +1,32 @@ +var tape = require('../'); +var tap = require('tap'); +var concat = require('concat-stream'); + +tap.test('array test', function (tt) { + tt.plan(1); + + var test = tape.createHarness(); + test.createStream().pipe(concat(function (body) { + tt.equal( + body.toString('utf8'), + 'TAP version 13\n' + + '# undef\n' + + 'not ok 1 should be equivalent\n' + + ' ---\n' + + ' operator: deepEqual\n' + + ' expected: { beep: undefined }\n' + + ' actual: {}\n' + + ' ...\n' + + '\n' + + '1..1\n' + + '# tests 1\n' + + '# pass 0\n' + + '# fail 1\n' + ); + })); + + test('undef', function (t) { + t.plan(1); + t.deepEqual({}, { beep: undefined }); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/package.json ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/package.json b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/package.json new file mode 100644 index 0000000..9606ad2 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/package.json @@ -0,0 +1,51 @@ +{ + "name": "cordova-registry-mapper", + "version": "1.1.13", + "description": "Maps old plugin ids to new plugin names for fetching from npm", + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/stevengill/cordova-registry-mapper.git" + }, + "scripts": { + "test": "node tests/test.js" + }, + "keywords": [ + "cordova", + "plugins" + ], + "author": { + "name": "Steve Gill" + }, + "license": "Apache version 2.0", + "dependencies": { + "tape": "^3.5.0" + }, + "gitHead": "f9aedb702a876f1a4d53760bb31a39358e0f261e", + "bugs": { + "url": "https://github.com/stevengill/cordova-registry-mapper/issues" + }, + "homepage": "https://github.com/stevengill/cordova-registry-mapper#readme", + "_id": "[email protected]", + "_shasum": "08e74b13833abb4bda4b279a0d447590113c8c28", + "_from": "cordova-registry-mapper@^1.1.8", + "_npmVersion": "2.14.2", + "_nodeVersion": "0.10.36", + "_npmUser": { + "name": "stevegill", + "email": "[email protected]" + }, + "dist": { + "shasum": "08e74b13833abb4bda4b279a0d447590113c8c28", + "tarball": "http://registry.npmjs.org/cordova-registry-mapper/-/cordova-registry-mapper-1.1.13.tgz" + }, + "maintainers": [ + { + "name": "stevegill", + "email": "[email protected]" + } + ], + "directories": {}, + "_resolved": "https://registry.npmjs.org/cordova-registry-mapper/-/cordova-registry-mapper-1.1.13.tgz", + "readme": "ERROR: No README data found!" +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/tests/test.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/tests/test.js b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/tests/test.js new file mode 100644 index 0000000..35343be --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/cordova-registry-mapper/tests/test.js @@ -0,0 +1,11 @@ +var test = require('tape'); +var oldToNew = require('../index').oldToNew; +var newToOld = require('../index').newToOld; + +test('plugin mappings exist', function(t) { + t.plan(2); + + t.equal('cordova-plugin-device', oldToNew['org.apache.cordova.device']); + + t.equal('org.apache.cordova.device', newToOld['cordova-plugin-device']); +}) http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/.npmignore ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/.npmignore b/bin/node_modules/cordova-common/node_modules/elementtree/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/.npmignore @@ -0,0 +1 @@ +node_modules http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/.travis.yml ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/.travis.yml b/bin/node_modules/cordova-common/node_modules/elementtree/.travis.yml new file mode 100644 index 0000000..6f27c96 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/.travis.yml @@ -0,0 +1,10 @@ +language: node_js + +node_js: + - 0.6 + +script: make test + +notifications: + email: + - [email protected] http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/CHANGES.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/CHANGES.md b/bin/node_modules/cordova-common/node_modules/elementtree/CHANGES.md new file mode 100644 index 0000000..50d415d --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/CHANGES.md @@ -0,0 +1,39 @@ +elementtree v0.1.6 (in development) + +* Add support for CData elements. (#14) + [hermannpencole] + +elementtree v0.1.5 - 2012-11-14 + +* Fix a bug in the find() and findtext() method which could manifest itself + under some conditions. + [metagriffin] + +elementtree v0.1.4 - 2012-10-15 + +* Allow user to use namespaced attributes when using find* functions. + [Andrew Lunny] + +elementtree v0.1.3 - 2012-09-21 + +* Improve the output of text content in the tags (strip unnecessary line break + characters). + +[Darryl Pogue] + +elementtree v0.1.2 - 2012-09-04 + + * Allow user to pass 'indent' option to ElementTree.write method. If this + option is specified (e.g. {'indent': 4}). XML will be pretty printed. + [Darryl Pogue, Tomaz Muraus] + + * Bump sax dependency version. + +elementtree v0.1.1 - 2011-09-23 + + * Improve special character escaping. + [Ryan Phillips] + +elementtree v0.1.0 - 2011-09-05 + + * Initial release. http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/LICENSE.txt ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/LICENSE.txt b/bin/node_modules/cordova-common/node_modules/elementtree/LICENSE.txt new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/Makefile ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/Makefile b/bin/node_modules/cordova-common/node_modules/elementtree/Makefile new file mode 100644 index 0000000..ab7c4e0 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/Makefile @@ -0,0 +1,21 @@ +TESTS := \ + tests/test-simple.js + + + +PATH := ./node_modules/.bin:$(PATH) + +WHISKEY := $(shell bash -c 'PATH=$(PATH) type -p whiskey') + +default: test + +test: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --scope-leaks --sequential --real-time --tests "${TESTS}" + +tap: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --test-reporter tap --sequential --real-time --tests "${TESTS}" + +coverage: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --sequential --coverage --coverage-reporter html --coverage-dir coverage_html --tests "${TESTS}" + +.PHONY: default test coverage tap scope http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/NOTICE ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/NOTICE b/bin/node_modules/cordova-common/node_modules/elementtree/NOTICE new file mode 100644 index 0000000..28ad70a --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/NOTICE @@ -0,0 +1,5 @@ +node-elementtree +Copyright (c) 2011, Rackspace, Inc. + +The ElementTree toolkit is Copyright (c) 1999-2007 by Fredrik Lundh + http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/README.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/README.md b/bin/node_modules/cordova-common/node_modules/elementtree/README.md new file mode 100644 index 0000000..738420c --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/README.md @@ -0,0 +1,141 @@ +node-elementtree +==================== + +node-elementtree is a [Node.js](http://nodejs.org) XML parser and serializer based upon the [Python ElementTree v1.3](http://effbot.org/zone/element-index.htm) module. + +Installation +==================== + + $ npm install elementtree + +Using the library +==================== + +For the usage refer to the Python ElementTree library documentation - [http://effbot.org/zone/element-index.htm#usage](http://effbot.org/zone/element-index.htm#usage). + +Supported XPath expressions in `find`, `findall` and `findtext` methods are listed on [http://effbot.org/zone/element-xpath.htm](http://effbot.org/zone/element-xpath.htm). + +Example 1 â Creating An XML Document +==================== + +This example shows how to build a valid XML document that can be published to +Atom Hopper. Atom Hopper is used internally as a bridge from products all the +way to collecting revenue, called âUsage.â MaaS and other products send similar +events to it every time user performs an action on a resource +(e.g. creates,updates or deletes). Below is an example of leveraging the API +to create a new XML document. + +```javascript +var et = require('elementtree'); +var XML = et.XML; +var ElementTree = et.ElementTree; +var element = et.Element; +var subElement = et.SubElement; + +var date, root, tenantId, serviceName, eventType, usageId, dataCenter, region, +checks, resourceId, category, startTime, resourceName, etree, xml; + +date = new Date(); + +root = element('entry'); +root.set('xmlns', 'http://www.w3.org/2005/Atom'); + +tenantId = subElement(root, 'TenantId'); +tenantId.text = '12345'; + +serviceName = subElement(root, 'ServiceName'); +serviceName.text = 'MaaS'; + +resourceId = subElement(root, 'ResourceID'); +resourceId.text = 'enAAAA'; + +usageId = subElement(root, 'UsageID'); +usageId.text = '550e8400-e29b-41d4-a716-446655440000'; + +eventType = subElement(root, 'EventType'); +eventType.text = 'create'; + +category = subElement(root, 'category'); +category.set('term', 'monitoring.entity.create'); + +dataCenter = subElement(root, 'DataCenter'); +dataCenter.text = 'global'; + +region = subElement(root, 'Region'); +region.text = 'global'; + +startTime = subElement(root, 'StartTime'); +startTime.text = date; + +resourceName = subElement(root, 'ResourceName'); +resourceName.text = 'entity'; + +etree = new ElementTree(root); +xml = etree.write({'xml_declaration': false}); +console.log(xml); +``` + +As you can see, both et.Element and et.SubElement are factory methods which +return a new instance of Element and SubElement class, respectively. +When you create a new element (tag) you can use set method to set an attribute. +To set the tag value, assign a value to the .text attribute. + +This example would output a document that looks like this: + +```xml +<entry xmlns="http://www.w3.org/2005/Atom"> + <TenantId>12345</TenantId> + <ServiceName>MaaS</ServiceName> + <ResourceID>enAAAA</ResourceID> + <UsageID>550e8400-e29b-41d4-a716-446655440000</UsageID> + <EventType>create</EventType> + <category term="monitoring.entity.create"/> + <DataCenter>global</DataCenter> + <Region>global</Region> + <StartTime>Sun Apr 29 2012 16:37:32 GMT-0700 (PDT)</StartTime> + <ResourceName>entity</ResourceName> +</entry> +``` + +Example 2 â Parsing An XML Document +==================== + +This example shows how to parse an XML document and use simple XPath selectors. +For demonstration purposes, we will use the XML document located at +https://gist.github.com/2554343. + +Behind the scenes, node-elementtree uses Isaacâs sax library for parsing XML, +but the library has a concept of âparsers,â which means itâs pretty simple to +add support for a different parser. + +```javascript +var fs = require('fs'); + +var et = require('elementtree'); + +var XML = et.XML; +var ElementTree = et.ElementTree; +var element = et.Element; +var subElement = et.SubElement; + +var data, etree; + +data = fs.readFileSync('document.xml').toString(); +etree = et.parse(data); + +console.log(etree.findall('./entry/TenantId').length); // 2 +console.log(etree.findtext('./entry/ServiceName')); // MaaS +console.log(etree.findall('./entry/category')[0].get('term')); // monitoring.entity.create +console.log(etree.findall('*/category/[@term="monitoring.entity.update"]').length); // 1 +``` + +Build status +==================== + +[](http://travis-ci.org/racker/node-elementtree) + + +License +==================== + +node-elementtree is distributed under the [Apache license](http://www.apache.org/licenses/LICENSE-2.0.html). http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/lib/constants.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/lib/constants.js b/bin/node_modules/cordova-common/node_modules/elementtree/lib/constants.js new file mode 100644 index 0000000..b057faf --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/lib/constants.js @@ -0,0 +1,20 @@ +/* + * Copyright 2011 Rackspace + * + * 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 DEFAULT_PARSER = 'sax'; + +exports.DEFAULT_PARSER = DEFAULT_PARSER; http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/cordova-common/node_modules/elementtree/lib/elementpath.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/cordova-common/node_modules/elementtree/lib/elementpath.js b/bin/node_modules/cordova-common/node_modules/elementtree/lib/elementpath.js new file mode 100644 index 0000000..2e93f47 --- /dev/null +++ b/bin/node_modules/cordova-common/node_modules/elementtree/lib/elementpath.js @@ -0,0 +1,343 @@ +/** + * Copyright 2011 Rackspace + * + * 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 sprintf = require('./sprintf').sprintf; + +var utils = require('./utils'); +var SyntaxError = require('./errors').SyntaxError; + +var _cache = {}; + +var RE = new RegExp( + "(" + + "'[^']*'|\"[^\"]*\"|" + + "::|" + + "//?|" + + "\\.\\.|" + + "\\(\\)|" + + "[/.*:\\[\\]\\(\\)@=])|" + + "((?:\\{[^}]+\\})?[^/\\[\\]\\(\\)@=\\s]+)|" + + "\\s+", 'g' +); + +var xpath_tokenizer = utils.findall.bind(null, RE); + +function prepare_tag(next, token) { + var tag = token[0]; + + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem._children.forEach(function(e) { + if (e.tag === tag) { + rv.push(e); + } + }); + } + + return rv; + } + + return select; +} + +function prepare_star(next, token) { + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem._children.forEach(function(e) { + rv.push(e); + }); + } + + return rv; + } + + return select; +} + +function prepare_dot(next, token) { + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + rv.push(elem); + } + + return rv; + } + + return select; +} + +function prepare_iter(next, token) { + var tag; + token = next(); + + if (token[1] === '*') { + tag = '*'; + } + else if (!token[1]) { + tag = token[0] || ''; + } + else { + throw new SyntaxError(token); + } + + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem.iter(tag, function(e) { + if (e !== elem) { + rv.push(e); + } + }); + } + + return rv; + } + + return select; +} + +function prepare_dot_dot(next, token) { + function select(context, result) { + var i, len, elem, rv = [], parent_map = context.parent_map; + + if (!parent_map) { + context.parent_map = parent_map = {}; + + context.root.iter(null, function(p) { + p._children.forEach(function(e) { + parent_map[e] = p; + }); + }); + } + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (parent_map.hasOwnProperty(elem)) { + rv.push(parent_map[elem]); + } + } + + return rv; + } + + return select; +} + + +function prepare_predicate(next, token) { + var tag, key, value, select; + token = next(); + + if (token[1] === '@') { + // attribute + token = next(); + + if (token[1]) { + throw new SyntaxError(token, 'Invalid attribute predicate'); + } + + key = token[0]; + token = next(); + + if (token[1] === ']') { + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.get(key)) { + rv.push(elem); + } + } + + return rv; + }; + } + else if (token[1] === '=') { + value = next()[1]; + + if (value[0] === '"' || value[value.length - 1] === '\'') { + value = value.slice(1, value.length - 1); + } + else { + throw new SyntaxError(token, 'Ivalid comparison target'); + } + + token = next(); + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.get(key) === value) { + rv.push(elem); + } + } + + return rv; + }; + } + + if (token[1] !== ']') { + throw new SyntaxError(token, 'Invalid attribute predicate'); + } + } + else if (!token[1]) { + tag = token[0] || ''; + token = next(); + + if (token[1] !== ']') { + throw new SyntaxError(token, 'Invalid node predicate'); + } + + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.find(tag)) { + rv.push(elem); + } + } + + return rv; + }; + } + else { + throw new SyntaxError(null, 'Invalid predicate'); + } + + return select; +} + + + +var ops = { + "": prepare_tag, + "*": prepare_star, + ".": prepare_dot, + "..": prepare_dot_dot, + "//": prepare_iter, + "[": prepare_predicate, +}; + +function _SelectorContext(root) { + this.parent_map = null; + this.root = root; +} + +function findall(elem, path) { + var selector, result, i, len, token, value, select, context; + + if (_cache.hasOwnProperty(path)) { + selector = _cache[path]; + } + else { + // TODO: Use smarter cache purging approach + if (Object.keys(_cache).length > 100) { + _cache = {}; + } + + if (path.charAt(0) === '/') { + throw new SyntaxError(null, 'Cannot use absolute path on element'); + } + + result = xpath_tokenizer(path); + selector = []; + + function getToken() { + return result.shift(); + } + + token = getToken(); + while (true) { + var c = token[1] || ''; + value = ops[c](getToken, token); + + if (!value) { + throw new SyntaxError(null, sprintf('Invalid path: %s', path)); + } + + selector.push(value); + token = getToken(); + + if (!token) { + break; + } + else if (token[1] === '/') { + token = getToken(); + } + + if (!token) { + break; + } + } + + _cache[path] = selector; + } + + // Execute slector pattern + result = [elem]; + context = new _SelectorContext(elem); + + for (i = 0, len = selector.length; i < len; i++) { + select = selector[i]; + result = select(context, result); + } + + return result || []; +} + +function find(element, path) { + var resultElements = findall(element, path); + + if (resultElements && resultElements.length > 0) { + return resultElements[0]; + } + + return null; +} + +function findtext(element, path, defvalue) { + var resultElements = findall(element, path); + + if (resultElements && resultElements.length > 0) { + return resultElements[0].text; + } + + return defvalue; +} + + +exports.find = find; +exports.findall = findall; +exports.findtext = findtext; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
