<commit_before>import LazyResult from '../lib/lazy-result';
import Processor  from '../lib/processor';
import postcss    from '../lib/postcss';
import Result     from '../lib/result';
import parse      from '../lib/parse';
import Root       from '../lib/root';

import { expect } from 'chai';
import   sinon    from 'sinon';
import   path     from 'path';

describe('Processor', () => {

    describe('use()', () => {

        it('adds new plugins', () => {
            let a = () => 1;
            let processor = new Processor();
            processor.use(a);
            expect(processor.plugins).to.eql([a]);
        });

        it('adds new plugin by object', () => {
            let a = () => 1;
            let processor = new Processor();
            processor.use({ postcss: a });
            expect(processor.plugins).to.eql([a]);
        });

        it('adds new plugin by object-function', () => {
            let a   = () => 1;
            let obj = () => 2;
            obj.postcss = a;
            let processor = new Processor();
            processor.use(obj);
            expect(processor.plugins).to.eql([a]);
        });

        it('adds new processors of another postcss instance', () => {
            let a = () => 1;
            let processor = new Processor();
            let other     = new Processor([a]);
            processor.use(other);
            expect(processor.plugins).to.eql([a]);
        });

        it('returns itself', () => {
            let a = () => 1;
            let b = () => 2;
            let processor = new Processor();
            expect(processor.use(a).use(b).plugins).to.eql([a, b]);
        });

    });

    describe('process()', () => {
        beforeEach( () => {
            sinon.stub(console, 'warn');
        });

        afterEach( () => {
            console.warn.restore();
        });

        let beforeFix = new Processor([ (css) => {
            css.eachRule( (rule) => {
                if ( !rule.selector.match(/::(before|after)/) ) return;
                if ( !rule.some( i => i.prop === 'content' ) ) {
                    rule.prepend({ prop: 'content', value: '""' });
                }
            });
        }]);

        it('processes CSS', () => {
            let result = beforeFix.process('a::before{top:0}');
            expect(result.css).to.eql('a::before{content:"";top:0}');
        });

        it('processes parsed AST', () => {
            let root   = parse('a::before{top:0}');
            let result = beforeFix.process(root);
            expect(result.css).to.eql('a::before{content:"";top:0}');
        });

        it('processes previous result', () => {
            let result = (new Processor()).process('a::before{top:0}');
            result = beforeFix.process(result);
            expect(result.css).to.eql('a::before{content:"";top:0}');
        });

        it('takes maps from previous result', () => {
            let one = (new Processor()).process('a{}', {
                from: 'a.css',
                to:   'b.css',
                map: { inline: false }
            });
            let two = (new Processor()).process(one, {
                to:   'c.css',
                map: { inline: false }
            });
            expect(two.map.toJSON().sources).to.eql(['a.css']);
        });

        it('throws with file name', () => {
            let error;
            try {
                (new Processor()).process('a {', { from: 'a.css' }).css;
            } catch (e) {
                if ( e.name === 'CssSyntaxError' ) {
                    error = e;
                } else {
                    throw e;
                }
            }

            expect(error.file).to.eql(path.resolve('a.css'));
            expect(error.message).to.match(/a.css:1:1: Unclosed block$/);
        });

        it('allows to replace Root', () => {
            let processor = new Processor([ () => new Root() ]);
            expect(processor.process('a {}').css).to.eql('');
        });

        it('returns LazyResult object', () => {
            let result = (new Processor()).process('a{}');
            expect(result).to.be.an.instanceOf(LazyResult);
            expect(result.css).to.eql(       'a{}');
            expect(result.toString()).to.eql('a{}');
        });

        it('calls all plugins once', (done) => {
            let calls = '';
            let a = () => calls += 'a';
            let b = () => calls += 'b';

            let result = new Processor([a, b]).process('');
            result.css;
            result.map;
            result.root;
            result.then( () => {
                expect(calls).to.eql('ab');
                done();
            }).catch( (error) => done(error) );
        });

        it('parses, converts and stringifies CSS', () => {
            let a = (css) => expect(css).to.be.an.instanceof(Root);
            expect((new Processor([a])).process('a {}').css).to.be.a('string');
        });

        it('send result to plugins', () => {
            let processor = new Processor();
            let a = (css, result) => {
                expect(result).to.be.an.instanceof(Result);
                expect(result.processor).to.eql(processor);
                expect(result.opts).to.eql({ map: true });
                expect(result.root).to.eql(css);
            };
            processor.use(a).process('a {}', { map: true });
        });

        it('accepts source map from PostCSS', () => {
            let one = (new Processor()).process('a{}', {
                from: 'a.css',
                to:   'b.css',
                map:   { inline: false }
            });
            let two = (new Processor()).process(one.css, {
                from: 'b.css',
                to:   'c.css',
                map: { prev: one.map, inline: false }
            });
            expect(two.map.toJSON().sources).to.eql(['a.css']);
        });

        it('supports async plugins', (done) => {
            let starts = 0;
            let finish = 0;
            let async1 = (css) => {
                return new Promise( (resolve) => {
                    starts += 1;
                    setTimeout(() => {
                        expect(starts).to.eql(1);

                        css.append('a {}');
                        finish += 1;
                        resolve();
                    }, 1);
                });
            };
            let async2 = (css) => {
                return new Promise( (resolve) => {
                    expect(starts).to.eql(1);
                    expect(finish).to.eql(1);

                    starts += 1;
                    setTimeout(() => {
                        css.append('b {}');
                        finish += 1;
                        resolve();
                    }, 1);
                });
            };
            (new Processor([async1, async2])).process('').then( (result) => {
                expect(starts).to.eql(2);
                expect(finish).to.eql(2);
                expect(result.css).to.eql('a {}\nb {}');
                done();
            }).catch( (error) => done(error) );
        });

        it('works async without plugins', (done) => {
            (new Processor()).process('a {}').then( (result) => {
                expect(result.css).to.eql('a {}');
                done();
            }).catch( (error) => done(error) );
        });

        it('runs async plugin only once', (done) => {
            let calls = 0;
            let async = () => {
                return new Promise( (resolve) => {
                    setTimeout(() => {
                        calls += 1;
                        resolve();
                    }, 1);
                });
            };

            let result = (new Processor([async])).process('a {}');
            result.then( () => { });
            result.then( () => {
                result.then( () => {
                    expect(calls).to.eql(1);
                    done();
                });
            });
        });

        it('supports async errors', (done) => {
            let error = new Error('Async');
            let async = () => {
                return new Promise( (resolve, reject) => {
                    reject(error);
                });
            };
            let result = (new Processor([async])).process('');
            result.then( () => {
                done('should not run then callback');
            }).catch(function (err) {
                expect(err).to.eql(error);
                result.catch(function (err2) {
                    expect(err2).to.eql(error);
                    done();
                });
            }).catch( (err) => done(err) );
        });

        it('supports sync errors in async mode', (done) => {
            let error = new Error('Async');
            let async = () => {
                throw error;
            };
            (new Processor([async])).process('').then( () => {
                done('should not run then callback');
            }).catch(function (err) {
                expect(err).to.eql(error);
                done();
            });
        });

        it('throws parse error in async', (done) => {
            (new Processor()).process('a{').catch(function (err) {
                expect(err.message).to.eql('<css input>:1:1: Unclosed block');
                done();
            });
        });

        it('throws error on sync method to async plugin', () => {
            let async = () => {
                return new Promise( (resolve) => resolve() );
            };
            expect(() => {
                (new Processor([async])).process('a{}').css;
            }).to.throw(/async/);
        });

        it('checks plugin compatibility', () => {
            let plugin = postcss.plugin('test', function () {
                return function () {
                    throw 'Er';
                };
            });
            let func = plugin();
            func.postcssVersion = '2.1.5';

            let processBy = (version) => {
                let processor = new Processor([func]);
                processor.version = version;
                processor.process('a{}').css;
            };

            expect( () => processBy('1.0.0') ).to.throws('Er');
            expect(console.warn.callCount).to.eql(1);
            expect(console.warn.args[0][0]).to.eql(
                'test is based on PostCSS 2.1.5 but you use it with ' +
                'PostCSS 1.0.0. Maybe this is a source of error below.');

            expect( () => processBy('3.0.0') ).to.throws('Er');
            expect(console.warn.callCount).to.eql(2);

            expect( () => processBy('2.0.0') ).to.throws('Er');
            expect(console.warn.callCount).to.eql(3);

            expect( () => processBy('2.1.0') ).to.throws('Er');
            expect(console.warn.callCount).to.eql(3);
        });

        it('sets last plugin to result', (done) => {
            let plugin1 = function (css, result) {
                expect(result.lastPlugin).to.equal(plugin1);
            };
            let plugin2 = function (css, result) {
                expect(result.lastPlugin).to.equal(plugin2);
            };

            let processor = new Processor([plugin1, plugin2]);
            processor.process('a{}').then( (result) => {
                expect(result.lastPlugin).to.equal(plugin2);
                done();
            });
        });

    });

    describe('version', () => {

        it('contains PostCSS version', () => {
            expect((new Processor()).version).to.match(/\d+.\d+.\d+/);
        });

    });

});
<commit_msg>Update warning test.<commit_after>import LazyResult from '../lib/lazy-result';
import Processor  from '../lib/processor';
import postcss    from '../lib/postcss';
import Result     from '../lib/result';
import parse      from '../lib/parse';
import Root       from '../lib/root';

import { expect } from 'chai';
import   sinon    from 'sinon';
import   path     from 'path';

describe('Processor', () => {

    describe('use()', () => {

        it('adds new plugins', () => {
            let a = () => 1;
            let processor = new Processor();
            processor.use(a);
            expect(processor.plugins).to.eql([a]);
        });

        it('adds new plugin by object', () => {
            let a = () => 1;
            let processor = new Processor();
            processor.use({ postcss: a });
            expect(processor.plugins).to.eql([a]);
        });

        it('adds new plugin by object-function', () => {
            let a   = () => 1;
            let obj = () => 2;
            obj.postcss = a;
            let processor = new Processor();
            processor.use(obj);
            expect(processor.plugins).to.eql([a]);
        });

        it('adds new processors of another postcss instance', () => {
            let a = () => 1;
            let processor = new Processor();
            let other     = new Processor([a]);
            processor.use(other);
            expect(processor.plugins).to.eql([a]);
        });

        it('returns itself', () => {
            let a = () => 1;
            let b = () => 2;
            let processor = new Processor();
            expect(processor.use(a).use(b).plugins).to.eql([a, b]);
        });

    });

    describe('process()', () => {
        beforeEach( () => {
            sinon.stub(console, 'warn');
        });

        afterEach( () => {
            console.warn.restore();
        });

        let beforeFix = new Processor([ (css) => {
            css.eachRule( (rule) => {
                if ( !rule.selector.match(/::(before|after)/) ) return;
                if ( !rule.some( i => i.prop === 'content' ) ) {
                    rule.prepend({ prop: 'content', value: '""' });
                }
            });
        }]);

        it('processes CSS', () => {
            let result = beforeFix.process('a::before{top:0}');
            expect(result.css).to.eql('a::before{content:"";top:0}');
        });

        it('processes parsed AST', () => {
            let root   = parse('a::before{top:0}');
            let result = beforeFix.process(root);
            expect(result.css).to.eql('a::before{content:"";top:0}');
        });

        it('processes previous result', () => {
            let result = (new Processor()).process('a::before{top:0}');
            result = beforeFix.process(result);
            expect(result.css).to.eql('a::before{content:"";top:0}');
        });

        it('takes maps from previous result', () => {
            let one = (new Processor()).process('a{}', {
                from: 'a.css',
                to:   'b.css',
                map: { inline: false }
            });
            let two = (new Processor()).process(one, {
                to:   'c.css',
                map: { inline: false }
            });
            expect(two.map.toJSON().sources).to.eql(['a.css']);
        });

        it('throws with file name', () => {
            let error;
            try {
                (new Processor()).process('a {', { from: 'a.css' }).css;
            } catch (e) {
                if ( e.name === 'CssSyntaxError' ) {
                    error = e;
                } else {
                    throw e;
                }
            }

            expect(error.file).to.eql(path.resolve('a.css'));
            expect(error.message).to.match(/a.css:1:1: Unclosed block$/);
        });

        it('allows to replace Root', () => {
            let processor = new Processor([ () => new Root() ]);
            expect(processor.process('a {}').css).to.eql('');
        });

        it('returns LazyResult object', () => {
            let result = (new Processor()).process('a{}');
            expect(result).to.be.an.instanceOf(LazyResult);
            expect(result.css).to.eql(       'a{}');
            expect(result.toString()).to.eql('a{}');
        });

        it('calls all plugins once', (done) => {
            let calls = '';
            let a = () => calls += 'a';
            let b = () => calls += 'b';

            let result = new Processor([a, b]).process('');
            result.css;
            result.map;
            result.root;
            result.then( () => {
                expect(calls).to.eql('ab');
                done();
            }).catch( (error) => done(error) );
        });

        it('parses, converts and stringifies CSS', () => {
            let a = (css) => expect(css).to.be.an.instanceof(Root);
            expect((new Processor([a])).process('a {}').css).to.be.a('string');
        });

        it('send result to plugins', () => {
            let processor = new Processor();
            let a = (css, result) => {
                expect(result).to.be.an.instanceof(Result);
                expect(result.processor).to.eql(processor);
                expect(result.opts).to.eql({ map: true });
                expect(result.root).to.eql(css);
            };
            processor.use(a).process('a {}', { map: true });
        });

        it('accepts source map from PostCSS', () => {
            let one = (new Processor()).process('a{}', {
                from: 'a.css',
                to:   'b.css',
                map:   { inline: false }
            });
            let two = (new Processor()).process(one.css, {
                from: 'b.css',
                to:   'c.css',
                map: { prev: one.map, inline: false }
            });
            expect(two.map.toJSON().sources).to.eql(['a.css']);
        });

        it('supports async plugins', (done) => {
            let starts = 0;
            let finish = 0;
            let async1 = (css) => {
                return new Promise( (resolve) => {
                    starts += 1;
                    setTimeout(() => {
                        expect(starts).to.eql(1);

                        css.append('a {}');
                        finish += 1;
                        resolve();
                    }, 1);
                });
            };
            let async2 = (css) => {
                return new Promise( (resolve) => {
                    expect(starts).to.eql(1);
                    expect(finish).to.eql(1);

                    starts += 1;
                    setTimeout(() => {
                        css.append('b {}');
                        finish += 1;
                        resolve();
                    }, 1);
                });
            };
            (new Processor([async1, async2])).process('').then( (result) => {
                expect(starts).to.eql(2);
                expect(finish).to.eql(2);
                expect(result.css).to.eql('a {}\nb {}');
                done();
            }).catch( (error) => done(error) );
        });

        it('works async without plugins', (done) => {
            (new Processor()).process('a {}').then( (result) => {
                expect(result.css).to.eql('a {}');
                done();
            }).catch( (error) => done(error) );
        });

        it('runs async plugin only once', (done) => {
            let calls = 0;
            let async = () => {
                return new Promise( (resolve) => {
                    setTimeout(() => {
                        calls += 1;
                        resolve();
                    }, 1);
                });
            };

            let result = (new Processor([async])).process('a {}');
            result.then( () => { });
            result.then( () => {
                result.then( () => {
                    expect(calls).to.eql(1);
                    done();
                });
            });
        });

        it('supports async errors', (done) => {
            let error = new Error('Async');
            let async = () => {
                return new Promise( (resolve, reject) => {
                    reject(error);
                });
            };
            let result = (new Processor([async])).process('');
            result.then( () => {
                done('should not run then callback');
            }).catch(function (err) {
                expect(err).to.eql(error);
                result.catch(function (err2) {
                    expect(err2).to.eql(error);
                    done();
                });
            }).catch( (err) => done(err) );
        });

        it('supports sync errors in async mode', (done) => {
            let error = new Error('Async');
            let async = () => {
                throw error;
            };
            (new Processor([async])).process('').then( () => {
                done('should not run then callback');
            }).catch(function (err) {
                expect(err).to.eql(error);
                done();
            });
        });

        it('throws parse error in async', (done) => {
            (new Processor()).process('a{').catch(function (err) {
                expect(err.message).to.eql('<css input>:1:1: Unclosed block');
                done();
            });
        });

        it('throws error on sync method to async plugin', () => {
            let async = () => {
                return new Promise( (resolve) => resolve() );
            };
            expect(() => {
                (new Processor([async])).process('a{}').css;
            }).to.throw(/async/);
        });

        it('checks plugin compatibility', () => {
            let plugin = postcss.plugin('test', function () {
                return function () {
                    throw 'Er';
                };
            });
            let func = plugin();
            func.postcssVersion = '2.1.5';

            let processBy = (version) => {
                let processor = new Processor([func]);
                processor.version = version;
                processor.process('a{}').css;
            };

            expect( () => processBy('1.0.0') ).to.throws('Er');
            expect(console.warn.callCount).to.eql(1);
            expect(console.warn.args[0][0]).to.eql(
                'Your current PostCSS version is 1.0.0, but test uses 2.1.5. ' +
                'Perhaps this is the source of the error below.');

            expect( () => processBy('3.0.0') ).to.throws('Er');
            expect(console.warn.callCount).to.eql(2);

            expect( () => processBy('2.0.0') ).to.throws('Er');
            expect(console.warn.callCount).to.eql(3);

            expect( () => processBy('2.1.0') ).to.throws('Er');
            expect(console.warn.callCount).to.eql(3);
        });

        it('sets last plugin to result', (done) => {
            let plugin1 = function (css, result) {
                expect(result.lastPlugin).to.equal(plugin1);
            };
            let plugin2 = function (css, result) {
                expect(result.lastPlugin).to.equal(plugin2);
            };

            let processor = new Processor([plugin1, plugin2]);
            processor.process('a{}').then( (result) => {
                expect(result.lastPlugin).to.equal(plugin2);
                done();
            });
        });

    });

    describe('version', () => {

        it('contains PostCSS version', () => {
            expect((new Processor()).version).to.match(/\d+.\d+.\d+/);
        });

    });

});
<|endoftext|>


<commit_before>var express = require('express');
var app = express();
var cool = require('cool-ascii-faces');
var pg = require('pg');

app.set('port', (process.env.PORT || 5000));

// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());

app.use(express.static(__dirname + '/public'));

/* ######## REST API ######## */

app.get('/', function(request, response) {
  response.send('Hello World!')
});

app.get('/poll', function(request, response) {
	pg.connect(process.env.DATABASE_URL, function(err, client, done) {
		client.query('SELECT * FROM poll;', function(err, result) {
			done();
			if (err) {
				console.error(err);
				response.send("Error " + err);
			} else {
				response.send(result.rows);
			}
		});
	});
});

app.get('/poll/:id', function(request, response) {
	pg.connect(process.env.DATABASE_URL, function(err, client, done) {
		client.query('SELECT * FROM poll WHERE poll_id='+request.params.id+';', function(err, result) {
			done();
			if (err) {
				console.error(err);
				response.send("Error " + err);
			} else {
				response.send(result.rows);
			}
		});
	});
});

app.post('/poll', function(req, response) {

	// response.send("HERE-- " + req.body);

	pg.connect(process.env.DATABASE_URL, function(err, client, done) {
		// console.error(req.body);

		client.query("INSERT INTO poll (creator_id, question) VALUES ('" + req.body.creator_id + "', '" + req.body.question + "'');", function(err, result) {
			done();
			if (err) {
				console.error(err);
				response.send("Error " + err);
			} else {
				response.send(result.rows);
			}
		});
	});
});

app.get('/test', function(request, response) {
  // var result = '';
  // var times = process.env.TIMES || 5;
  // for (i=0; i < times; i++) {
  // 	result += (cool() + "
");
  // }
  response.send("TEST 109");
});

app.get('/db', function(request, response) {
	pg.connect(process.env.DATABASE_URL, function(err, client, done) {
		client.query('SELECT * FROM test_table', function(err, result) {
			done();
			if (err) {
				console.error(err);
				response.send("Error " + err);
			} else {
				response.send(result.rows);
			}
		});
	});
});

app.listen(app.get('port'), function() {
  console.log("Node app is running at localhost:" + app.get('port'))
});
<commit_msg>POST /poll bug fix7 - body-parser corrected<commit_after>var express = require('express');
var app = express();
var cool = require('cool-ascii-faces');
var pg = require('pg');

app.set('port', (process.env.PORT || 5000));

// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());

app.use(express.static(__dirname + '/public'));

/* ######## REST API ######## */

app.get('/', function(request, response) {
  response.send('Hello World!')
});

app.get('/poll', function(request, response) {
	pg.connect(process.env.DATABASE_URL, function(err, client, done) {
		client.query('SELECT * FROM poll;', function(err, result) {
			done();
			if (err) {
				console.error(err);
				response.send("Error " + err);
			} else {
				response.send(result.rows);
			}
		});
	});
});

app.get('/poll/:id', function(request, response) {
	pg.connect(process.env.DATABASE_URL, function(err, client, done) {
		client.query('SELECT * FROM poll WHERE poll_id='+request.params.id+';', function(err, result) {
			done();
			if (err) {
				console.error(err);
				response.send("Error " + err);
			} else {
				response.send(result.rows);
			}
		});
	});
});

app.post('/poll', function(req, response) {

	response.send("HERE-- " + req.body);

	// pg.connect(process.env.DATABASE_URL, function(err, client, done) {

	// 	client.query("INSERT INTO poll (creator_id, question) VALUES ('" + req.body.creator_id + "', '" + req.body.question + "'');", function(err, result) {
	// 		done();
	// 		if (err) {
	// 			console.error(err);
	// 			response.send("Error " + err);
	// 		} else {
	// 			response.send(result.rows);
	// 		}
	// 	});
	// });
});

app.get('/test', function(request, response) {
  // var result = '';
  // var times = process.env.TIMES || 5;
  // for (i=0; i < times; i++) {
  // 	result += (cool() + "
");
  // }
  response.send("TEST 202");
});

app.get('/db', function(request, response) {
	pg.connect(process.env.DATABASE_URL, function(err, client, done) {
		client.query('SELECT * FROM test_table', function(err, result) {
			done();
			if (err) {
				console.error(err);
				response.send("Error " + err);
			} else {
				response.send(result.rows);
			}
		});
	});
});

app.listen(app.get('port'), function() {
  console.log("Node app is running at localhost:" + app.get('port'))
});
<|endoftext|>


<commit_before>'use strict';

var _ = Npm.require('lodash');
var path = Npm.require('path');
var fs = Npm.require('fs-extra');
var removeFile = Meteor._wrapAsync(fs.remove);
var copyFile = Meteor._wrapAsync(fs.copy);

/**
 * Worker that copies test files to the mirror reactively.
 *
 * @class FileCopier
 * @constructor
 * @param {object} options
 * @param {string} options.targetFramework The name of the target framework
 *                                         for which the tests should be copied
 *                                         to the mirror.
 * @param {function} [options.onFileAdded] Callback that is called after a
 *                                         file was added.
 * @param {function} [options.onFileChanged] Callback that is called after a
 *                                           file has changed.
 * @param {function} [options.onFileRemoved] Callback that is called after a
 *                                           file was removed.
 * @param {function} [options.shouldCopy] Control whether a file is copied.
 *                                        Passed the file object from the
 *                                        VelocityTestFiles collection which
 *                                        has a `absolutePath` field.
 *                                        Default: true
 * @param {function} [options.convertTestPathToMirrorPath] A function that converts
 *                                                         test file path to the mirror path.
 *
 * @example
 *     var fileCopier = new Velocity.FileCopier({
 *       targetFramework: TEST_FRAMEWORK_NAME
 *     });
 *     fileCopier.start();
 */
Velocity.FileCopier = function VelocityFileCopier(options) {
  check(options, {
    targetFramework: String,
    onFileAdded: Match.Optional(Function),
    onFileChanged: Match.Optional(Function),
    onFileRemoved: Match.Optional(Function),
    shouldCopy: Match.Optional(Function),
    convertTestPathToMirrorPath: Match.Optional(Function)
  });
  this.options = _.extend({
    onFileAdded: _.noop,
    onFileChanged: _.noop,
    onFileRemoved: _.noop,
    shouldCopy: function () { return true; },
    convertTestPathToMirrorPath: this._defaultConvertTestPathToMirrorPath
  }, options);
};

_.extend(Velocity.FileCopier.prototype, {

  /**
   * Starts copying files to the mirror.
   *
   * @method start
   * @memberof Velocity.FileCopier.prototype
   */
  start: function () {
    if (!this._observer) {
      var testFilesCursor = VelocityTestFiles.find({
        targetFramework: this.options.targetFramework
      });

      this._observer = testFilesCursor.observe({
        added: this._onFileAdded.bind(this),
        changed: this._onFileChanged.bind(this),
        removed: this._onFileRemoved.bind(this)
      });
    }
  },

  /**
   * Stops copying files to the mirror.
   * @memberof Velocity.FileCopier.prototype
   */
  stop: function () {
    this._observer.stop();
    this._observer = null;
  },

  _onFileAdded: function (newFile) {
    if (this.options.shouldCopy(newFile)) {
      this._replaceFileInMirror(newFile);
      this.options.onFileAdded(newFile);
    }
  },

  _onFileChanged: function (newFile, oldFile) {
    if (this.options.shouldCopy(oldFile)) {
      // Remove the oldFile in case the absolutePath has changed
      this._removeFileFromMirror(oldFile);
    }
    if (this.options.shouldCopy(newFile)) {
      this._replaceFileInMirror(newFile);
      this.options.onFileAdded(oldFile, newFile);
    }
  },

  _onFileRemoved: function (removedFile) {
    this._removeFileFromMirror(removedFile);
    this.options.onFileRemoved(removedFile);
  },

  _removeFileFromMirror: function (file) {
    var mirrorFilePath = this._convertTestPathToMirrorPath(file.absolutePath);
    DEBUG && console.log('[Velocity.FileCopier] Remove file from mirror', mirrorFilePath);
    removeFile(mirrorFilePath);
  },

  _replaceFileInMirror: function (file) {
    var self = this;

    var mirrorFilePath = self._convertTestPathToMirrorPath(file.absolutePath);
    DEBUG && console.log('[Velocity.FileCopier] Replace file in mirror', mirrorFilePath);
    copyFile(file.absolutePath, mirrorFilePath);
  },

  _isInTestsPath: function _isInTestsPath(filePath) {
    var testsPath = Velocity.getTestsPath();
    return filePath.substr(0, testsPath.length) === testsPath;
  },

  _convertTestPathToMirrorPath: function (filePath) {
    if (!this._isInTestsPath(filePath)) {
      throw new Error('[Velocity.FileCopier] Path "' + filePath + '" is not in the tests path.');
    }

    filePath = filePath.substr(Velocity.getTestsPath().length);
    filePath = this.options.convertTestPathToMirrorPath.call(this, filePath);

    return Velocity.getMirrorPath() + filePath;
  },

  _defaultConvertTestPathToMirrorPath: function (filePath) {
    var targetFramework = this.options.targetFramework;
    filePath = filePath.replace(targetFramework + '/client', 'client/' + targetFramework);
    filePath = filePath.replace(targetFramework + '/server', 'server/' + targetFramework);

    return filePath
  }
});
<commit_msg>Fixes typo in FileCopier documentation<commit_after>'use strict';

var _ = Npm.require('lodash');
var path = Npm.require('path');
var fs = Npm.require('fs-extra');
var removeFile = Meteor._wrapAsync(fs.remove);
var copyFile = Meteor._wrapAsync(fs.copy);

/**
 * Worker that copies test files to the mirror reactively.
 *
 * @class FileCopier
 * @constructor
 * @param {object} options
 * @param {string} options.targetFramework The name of the target framework
 *                                         for which the tests should be copied
 *                                         to the mirror.
 * @param {function} [options.onFileAdded] Callback that is called after a
 *                                         file was added.
 * @param {function} [options.onFileChanged] Callback that is called after a
 *                                           file has changed.
 * @param {function} [options.onFileRemoved] Callback that is called after a
 *                                           file was removed.
 * @param {function} [options.shouldCopy] Control whether a file is copied.
 *                                        Passed the file object from the
 *                                        VelocityTestFiles collection which
 *                                        has a `absolutePath` field.
 *                                        Default: true
 * @param {function} [options.convertTestPathToMirrorPath] A function that converts the
 *                                                         test file path to the mirror path.
 *
 * @example
 *     var fileCopier = new Velocity.FileCopier({
 *       targetFramework: TEST_FRAMEWORK_NAME
 *     });
 *     fileCopier.start();
 */
Velocity.FileCopier = function VelocityFileCopier(options) {
  check(options, {
    targetFramework: String,
    onFileAdded: Match.Optional(Function),
    onFileChanged: Match.Optional(Function),
    onFileRemoved: Match.Optional(Function),
    shouldCopy: Match.Optional(Function),
    convertTestPathToMirrorPath: Match.Optional(Function)
  });
  this.options = _.extend({
    onFileAdded: _.noop,
    onFileChanged: _.noop,
    onFileRemoved: _.noop,
    shouldCopy: function () { return true; },
    convertTestPathToMirrorPath: this._defaultConvertTestPathToMirrorPath
  }, options);
};

_.extend(Velocity.FileCopier.prototype, {

  /**
   * Starts copying files to the mirror.
   *
   * @method start
   * @memberof Velocity.FileCopier.prototype
   */
  start: function () {
    if (!this._observer) {
      var testFilesCursor = VelocityTestFiles.find({
        targetFramework: this.options.targetFramework
      });

      this._observer = testFilesCursor.observe({
        added: this._onFileAdded.bind(this),
        changed: this._onFileChanged.bind(this),
        removed: this._onFileRemoved.bind(this)
      });
    }
  },

  /**
   * Stops copying files to the mirror.
   * @memberof Velocity.FileCopier.prototype
   */
  stop: function () {
    this._observer.stop();
    this._observer = null;
  },

  _onFileAdded: function (newFile) {
    if (this.options.shouldCopy(newFile)) {
      this._replaceFileInMirror(newFile);
      this.options.onFileAdded(newFile);
    }
  },

  _onFileChanged: function (newFile, oldFile) {
    if (this.options.shouldCopy(oldFile)) {
      // Remove the oldFile in case the absolutePath has changed
      this._removeFileFromMirror(oldFile);
    }
    if (this.options.shouldCopy(newFile)) {
      this._replaceFileInMirror(newFile);
      this.options.onFileAdded(oldFile, newFile);
    }
  },

  _onFileRemoved: function (removedFile) {
    this._removeFileFromMirror(removedFile);
    this.options.onFileRemoved(removedFile);
  },

  _removeFileFromMirror: function (file) {
    var mirrorFilePath = this._convertTestPathToMirrorPath(file.absolutePath);
    DEBUG && console.log('[Velocity.FileCopier] Remove file from mirror', mirrorFilePath);
    removeFile(mirrorFilePath);
  },

  _replaceFileInMirror: function (file) {
    var self = this;

    var mirrorFilePath = self._convertTestPathToMirrorPath(file.absolutePath);
    DEBUG && console.log('[Velocity.FileCopier] Replace file in mirror', mirrorFilePath);
    copyFile(file.absolutePath, mirrorFilePath);
  },

  _isInTestsPath: function _isInTestsPath(filePath) {
    var testsPath = Velocity.getTestsPath();
    return filePath.substr(0, testsPath.length) === testsPath;
  },

  _convertTestPathToMirrorPath: function (filePath) {
    if (!this._isInTestsPath(filePath)) {
      throw new Error('[Velocity.FileCopier] Path "' + filePath + '" is not in the tests path.');
    }

    filePath = filePath.substr(Velocity.getTestsPath().length);
    filePath = this.options.convertTestPathToMirrorPath.call(this, filePath);

    return Velocity.getMirrorPath() + filePath;
  },

  _defaultConvertTestPathToMirrorPath: function (filePath) {
    var targetFramework = this.options.targetFramework;
    filePath = filePath.replace(targetFramework + '/client', 'client/' + targetFramework);
    filePath = filePath.replace(targetFramework + '/server', 'server/' + targetFramework);

    return filePath
  }
});
<|endoftext|>


<commit_before>var midpoint = require('turf-midpoint');
var point = require('turf-point');
var distance = require('turf-distance');

/**
 * Takes a bounding box and calculates the minimum square bounding box that would contain the input.
 *
 * @module turf/square
 * @param {Array<number>} bbox
 * @return {Array<number>} A square surrounding that bounding box
 * @example
 * var bbox = [0,0,5,10];
 * var squared = turf.square(bbox)
 * var features = turf.featurecollection([
 *   turf.bboxPolygon(bbox),
 *   turf.bboxPolygon(squared)]);
 * //=features
 */
module.exports = function(bbox){
  var squareBbox = [0,0,0,0];
  var lowLeft = point(bbox[0], bbox[1]);
  var topLeft = point(bbox[0], bbox[3]);
  var topRight = point(bbox[2], bbox[3]);
  var lowRight = point(bbox[2], bbox[1]);

  var horizontalDistance = distance(lowLeft, lowRight, 'miles');
  var verticalDistance = distance(lowLeft, topLeft, 'miles');
  if(horizontalDistance >= verticalDistance){
    squareBbox[0] = bbox[0];
    squareBbox[2] = bbox[2];
    var verticalMidpoint = midpoint(lowLeft, topLeft);
    squareBbox[1] = verticalMidpoint.geometry.coordinates[1] - ((bbox[2] - bbox[0]) / 2);
    squareBbox[3] = verticalMidpoint.geometry.coordinates[1] + ((bbox[2] - bbox[0]) / 2);
    return squareBbox;
  }
  else {
    squareBbox[1] = bbox[1];
    squareBbox[3] = bbox[3];
    var horzontalMidpoint = midpoint(lowLeft, lowRight);
    squareBbox[0] = horzontalMidpoint.geometry.coordinates[0] - ((bbox[3] - bbox[1]) / 2);
    squareBbox[2] = horzontalMidpoint.geometry.coordinates[0] + ((bbox[3] - bbox[1]) / 2);
    return squareBbox;
  }
}

<commit_msg>Change style for params<commit_after>var midpoint = require('turf-midpoint');
var point = require('turf-point');
var distance = require('turf-distance');

/**
 * Takes a bounding box and calculates the minimum square bounding box that would contain the input.
 *
 * @module turf/square
 * @param {Array<number>} bbox a bounding box
 * @return {Array<number>} a square surrounding `bbox`
 * @example
 * var bbox = [0,0,5,10];
 * var squared = turf.square(bbox)
 * var features = turf.featurecollection([
 *   turf.bboxPolygon(bbox),
 *   turf.bboxPolygon(squared)]);
 * //=features
 */
module.exports = function(bbox){
  var squareBbox = [0,0,0,0];
  var lowLeft = point(bbox[0], bbox[1]);
  var topLeft = point(bbox[0], bbox[3]);
  var topRight = point(bbox[2], bbox[3]);
  var lowRight = point(bbox[2], bbox[1]);

  var horizontalDistance = distance(lowLeft, lowRight, 'miles');
  var verticalDistance = distance(lowLeft, topLeft, 'miles');
  if(horizontalDistance >= verticalDistance){
    squareBbox[0] = bbox[0];
    squareBbox[2] = bbox[2];
    var verticalMidpoint = midpoint(lowLeft, topLeft);
    squareBbox[1] = verticalMidpoint.geometry.coordinates[1] - ((bbox[2] - bbox[0]) / 2);
    squareBbox[3] = verticalMidpoint.geometry.coordinates[1] + ((bbox[2] - bbox[0]) / 2);
    return squareBbox;
  }
  else {
    squareBbox[1] = bbox[1];
    squareBbox[3] = bbox[3];
    var horzontalMidpoint = midpoint(lowLeft, lowRight);
    squareBbox[0] = horzontalMidpoint.geometry.coordinates[0] - ((bbox[3] - bbox[1]) / 2);
    squareBbox[2] = horzontalMidpoint.geometry.coordinates[0] + ((bbox[3] - bbox[1]) / 2);
    return squareBbox;
  }
}

<|endoftext|>


<commit_before>/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

(function () {
    'use strict';

    var deps = [
        'app/js/view/container', 'app/js/view/files', 'app/js/view/about', 'app/js/view/login',
        'app/js/model/files', 'app/js/model/file',
        'lib/underscore', 'lib/less', 'lib/backbone', 'lib/jquery', 'lib/bootstrap'
    ];
    define(deps, function (containerView, filesView, aboutView, loginView, filesList, FileModel, underscore) {
        $.ajaxSetup({ cache: false });

        function start() {
            function fetchFiles() {
                filesList.fetch();
            }

            //Starting the backbone router.
            var Router = Backbone.Router.extend({
                routes: {
                    '': 'showFiles',
                    'files': 'showFiles',
                    'about': 'showAbout'
                },

                showFiles: function () {
                    containerView.render();
                    containerView.showView(filesView);
                },

                showAbout: function () {
                    containerView.render();
                    containerView.showView(aboutView);
                }
            });
            var router = new Router();

            function setLoggedUser(userName) {
                if (!userName || userName === '') {
                    return;
                }
                containerView.setSignMode('signout');
                containerView.setUserName(userName);
                filesView.showDropZone();
                fetchFiles();
            }

            $.ajax({
                type: 'GET',
                'url': window.ux.ROOT_URL + 'rest/user/info',
                data: {},
                success: function (result, status, xhr) {
                    if (result && result.userInfo) {
                        setLoggedUser(result.userInfo.name);
                    }

                },
                error: function (xhr, status, err) {
                    // TODO
                }
            });

            loginView.on('login-action', function (data) {
                $.ajax({
                    type: 'POST',
                    'url': window.ux.ROOT_URL + 'rest/user/authenticate',
                    data: data,
                    success: function (result, status, xhr) {
                        setLoggedUser(data.j_username);
                    },
                    error: function (xhr, status, err) {
                        // TODO
                    }
                });
            });
            loginView.on('create-user-action', function (data) {
                $.ajax({
                    type: 'POST',
                    url: window.ux.ROOT_URL + 'rest/user/new',
                    data: data,
                    success: function (result, status, xhr) {
                        // TODO
                    }
                });
            });

            containerView.on('navigate', function (data) {
                router.navigate(data.href, {
                    trigger: true
                });
            });

            containerView.on('signout', function (data) {
                $.ajax({
                    type: 'POST',
                    url: window.ux.ROOT_URL + 'rest/user/signout',
                    data: data,
                    success: function (result, status, xhr) {
                        window.location.reload();
                    }
                });
            });

            filesView.on('delete-action', function (data) {
                filesList.remove(data.model);
                data.model.destroy();
            });

            function saveFile(file) {
                var newFile = new FileModel({
                    'name': file.name,
                    'contentType': file.contentType,
                    'content': file.content,
                    'publicData': false
                });
                filesList.add(newFile);
                newFile.save();
            }

            filesView.on('file-drop', function (data) {
                underscore.each(data.files, function (f) {
                    // Only process image files.
                    if (!f.type.match('image.*')) {
                        return;
                    }

                    var myFile = {
                        name: f.name,
                        contentType: f.type
                    };

                    var reader = new window.FileReader();
                    reader.addEventListener('load', function (evt) {
                        myFile.content = evt.target.result;
                        saveFile(myFile);
                    });

                    // Read in the image file as a data URL.
                    reader.readAsDataURL(f);
                });
            });

            filesView.on('show-photo-details', function (data) {
                data.model.fetch({});
            });

            //Starting the backbone history.
            Backbone.history.start({
                pushState: true,
                root: window.ux.ROOT_URL // This value is set by <c:url>
            });

            return {
                getRouter: function () {
                    return router;
                }
            };
        }

        return {
            start: start
        };
    });
}());<commit_msg>-simplifying the application<commit_after>/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

(function () {
    'use strict';

    var deps = [
        'app/js/view/container', 'app/js/view/files', 'app/js/view/about', 'app/js/view/login',
        'app/js/model/files', 'app/js/model/file',
        'lib/underscore', 'lib/less', 'lib/backbone', 'lib/jquery', 'lib/bootstrap'
    ];
    define(deps, function (containerView, filesView, aboutView, loginView, filesList, FileModel, underscore) {
        $.ajaxSetup({ cache: false });

        function start() {
            function fetchFiles() {
                filesList.fetch();
            }
            fetchFiles();

            //Starting the backbone router.
            var Router = Backbone.Router.extend({
                routes: {
                    '': 'showFiles',
                    'files': 'showFiles',
                    'about': 'showAbout'
                },

                showFiles: function () {
                    containerView.render();
                    containerView.showView(filesView);
                },

                showAbout: function () {
                    containerView.render();
                    containerView.showView(aboutView);
                }
            });
            var router = new Router();

            function setLoggedUser(userName) {
                if (!userName || userName === '') {
                    return;
                }
                containerView.setSignMode('signout');
                containerView.setUserName(userName);
                filesView.showDropZone();
                fetchFiles();
            }

            $.ajax({
                type: 'GET',
                'url': window.ux.ROOT_URL + 'rest/user/info',
                data: {},
                success: function (result, status, xhr) {
                    if (result && result.userInfo) {
                        setLoggedUser(result.userInfo.name);
                    }

                },
                error: function (xhr, status, err) {
                    // TODO
                }
            });

            loginView.on('login-action', function (data) {
                $.ajax({
                    type: 'POST',
                    'url': window.ux.ROOT_URL + 'rest/user/authenticate',
                    data: data,
                    success: function (result, status, xhr) {
                        setLoggedUser(data.j_username);
                    },
                    error: function (xhr, status, err) {
                        // TODO
                    }
                });
            });
            loginView.on('create-user-action', function (data) {
                $.ajax({
                    type: 'POST',
                    url: window.ux.ROOT_URL + 'rest/user/new',
                    data: data,
                    success: function (result, status, xhr) {
                        // TODO
                    }
                });
            });

            containerView.on('navigate', function (data) {
                router.navigate(data.href, {
                    trigger: true
                });
            });

            containerView.on('signout', function (data) {
                $.ajax({
                    type: 'POST',
                    url: window.ux.ROOT_URL + 'rest/user/signout',
                    data: data,
                    success: function (result, status, xhr) {
                        window.location.reload();
                    }
                });
            });

            filesView.on('delete-action', function (data) {
                filesList.remove(data.model);
                data.model.destroy();
            });

            function saveFile(file) {
                var newFile = new FileModel({
                    'name': file.name,
                    'contentType': file.contentType,
                    'content': file.content,
                    'publicData': false
                });
                filesList.add(newFile);
                newFile.save();
            }

            filesView.on('file-drop', function (data) {
                underscore.each(data.files, function (f) {
                    // Only process image files.
                    if (!f.type.match('image.*')) {
                        return;
                    }

                    var myFile = {
                        name: f.name,
                        contentType: f.type
                    };

                    var reader = new window.FileReader();
                    reader.addEventListener('load', function (evt) {
                        myFile.content = evt.target.result;
                        saveFile(myFile);
                    });

                    // Read in the image file as a data URL.
                    reader.readAsDataURL(f);
                });
            });

            filesView.on('show-photo-details', function (data) {
                data.model.fetch({});
            });

            //Starting the backbone history.
            Backbone.history.start({
                pushState: true,
                root: window.ux.ROOT_URL // This value is set by <c:url>
            });

            return {
                getRouter: function () {
                    return router;
                }
            };
        }

        return {
            start: start
        };
    });
}());<|endoftext|>


<commit_before>/*
 * @license
 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 */
(function(context){
  "use strict"
  var importParse = require('./lib/importParse');
  var jsParse = require('./lib/jsParse');
  var hydrolyze = require('./lib/hydrolyze');

  context.exports = {
    hydrolyze: hydrolyze,
    importParse: importParse,
    jsParse: jsParse
  };
}(module))<commit_msg>remove hydrolize reference.<commit_after>/*
 * @license
 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 */
(function(context){
  "use strict"
  var importParse = require('./lib/importParse');
  var jsParse = require('./lib/jsParse');

  context.exports = {
    importParse: importParse,
    jsParse: jsParse
  };
}(module))<|endoftext|>


<commit_before>const test = require('ava')
const read = require('../lib/read')

test('reads files correctly', async t => {
  const res = await read('test/sample')

  const file = res.find(f => f.path === 'test.md')
  t.true(file.contents.trim() === 'Hello!')
})

test('reads binary files as buffers', async t => {
  const res = await read('test/sample')
  const file = res.find(f => f.path === 'picture.png')
  t.true(Buffer.isBuffer(file.contents))
  t.true(Buffer.byteLength(file.contents) === 1119)
})

test('throws on nonexistent path', async t => {
  try {
    await read('test/fakepath')
  } catch (err) {
    t.truthy(err[0])
    t.is(err[0].code, 'ENOENT')
  }
})
<commit_msg>add exclusion test<commit_after>const test = require('ava')
const read = require('../lib/read')

test('reads files correctly', async t => {
  const res = await read('test/sample')

  const file = res.find(f => f.path === 'test.md')
  t.true(file.contents.trim() === 'Hello!')
})

test('reads binary files as buffers', async t => {
  const res = await read('test/sample')
  const file = res.find(f => f.path === 'picture.png')
  t.true(Buffer.isBuffer(file.contents))
  t.true(Buffer.byteLength(file.contents) === 1119)
})

test('throws on nonexistent path', async t => {
  try {
    await read('test/fakepath')
  } catch (err) {
    t.truthy(err[0])
    t.is(err[0].code, 'ENOENT')
  }
})

test('excludes files', async t => {
  const res = await read('test/sample', ['subdir/'])

  const basenames = res.map(f => f.basename)
  t.false(basenames.includes('another.md'))
})
<|endoftext|>


<commit_before>module.exports = '';
<commit_msg>`configMergeLoader` returns a function<commit_after>module.exports = () => {
};
<|endoftext|>


<commit_before>try {
  var deep = require('deep-get-set');
  deep.p = true;
} catch (err) {
  if (!deep) {
    var deep = function (obj, path, value) {
      if (arguments.length === 3) obj[path] = value;
      return obj[path];
    };
  }
}

var bind = function (object) {
  if (typeof this !== 'function')
    throw new TypeError('What is trying to be bound is not callable');

  var self = this;
  var args = [].slice.call(arguments, 1);
  var bound = function () {
    return self.apply(object || null, args.concat([].slice.call(arguments)));
  };

  bound.prototype = this.prototype;
  return bound;
};

var defaults = {
  idKey: 'id',
  name: 'empty',
  delimiter: ':',
  events: null,
  map: {
    emit: 'emit'
  },
  methods: {},
  native: [
    'filter',
    'map',
    'push',
    'pop',
    'reverse',
    'shift',
    'sort',
    'splice',
    'unshift',
  ]
};

try { module.exports = Empty; }
catch (err) { if (typeof window !== 'undefined') window.Empty = Empty; }

function Empty () {
  if (!(this instanceof Empty)) return new Empty();

  if (!Empty.config.events)
    throw new Error('You need to call Empty.configure before using Empty');

  // Call EventEmitter's constructor.
  if (typeof Empty.config.events === 'function')
    Empty.config.events.call(this);
}

Empty.configure = function (options) {
  if (typeof options !== 'object')
    throw new Error('Empty.configure requires an options object as first argument');

  var Events = options.events;

  if (Events) {
    mixin(Empty, Events);
    Empty.config.events = Events;
  }

  Empty.config = extend({}, defaults, options);

  // Add methods (custom and native) to Empty.prototype
  augment();
};

Empty.wrap = function (object, id) {
  var args, instance;

  object = object || {};
  if (!object[Empty.config.name]) initialize(object, id);

  if (typeof object === 'function') {
    args = [].slice.call(arguments, 1);
    instance = Object.create(object.prototype);
    object.apply(instance, args);
    return (new Empty()).bind(instance);
  }

  return (new Empty()).bind(object);
};

Empty.initialize = initialize;
Empty.mixin = mixin;
Empty.extend = extend;

Empty.config = defaults;
Empty.VERSION = '0.2.0';

// Proxy method to map to external library API.

Empty.prototype._emit = function () {
  this[Empty.config.map.emit].apply(this, arguments);
};

// Curry-esque method that returns an Empty instance with an object bound to it.

Empty.prototype.bind = function (object) {
  this.origin = object;
  return this;
};

// Id getter/setter.

Empty.prototype.id = apply(function (object, value) {
  ensureId.call(this, object, value);

  if (!value) return object[Empty.config.name].id;
});

Empty.prototype.state = apply(function (object, key, value) {
  if (!object[Empty.config.name]) initialize(object);

  if (typeof value === 'undefined')
    return object[Empty.config.name].state[key];

  object[Empty.config.name].state[key] = value;
});

Empty.prototype.set = apply(function (object, key, value, op) {
  var previous, action, id, _object, _key;
  var d = Empty.config.delimiter;

  if (!object[Empty.config.name]) initialize(object);

  // Handle 'key' argument as object.
  if (typeof key === 'object' && !value) {
    _object = key;
    id = ensureId.call(this, object, key[Empty.config.idKey]);

    for (_key in _object) {
      value = _object[_key];
      previous = object[_key];
      action = value ? set : unset;
      action(object, _key, value);

      if (previous !== _object[_key]) {
        set(object[Empty.config.name].previous, _key, previous);

        this._emit(['change', _key, id].join(d), object);
        this._emit(['change', _key].join(d), object);
      }
    }

    this._emit('change', object);
    return object;
  }

  // Handle normal key, value arguments.
  previous = get(object, key);
  id = ensureId.call(this, object, key, value);

  if (typeof op === 'string') {
    set[op](object, key, value);
  } else {
    action = value ? set : unset;
    action(object, key, value);
  }

  if (previous !== value) {
    set(object[Empty.config.name].previous, key + '', previous);

    this._emit(['change', key, id].join(d), object);
    this._emit(['change', key].join(d), object);
    this._emit('change', object);
  }

  return object;
});

// Convenience methods.

Empty.prototype.unset = apply(function (object, key) {
  return this.set(object, key, void 0);
});

Empty.prototype.get = apply(function (object, key) {
  return get(object, key);
});

// For bound objects.

Empty.prototype.toJSON = function () {
  return this.origin;
};

function apply (fn) {
  return function () {;
    var args = [].slice.call(arguments);
    if (typeof this.origin === 'object') args.unshift(this.origin);

    return fn.apply(this, args);
  };
}

function set (object, key, value) {
  // Support array bracket notation e.g. array[1] = 'foo'
  // with Empty#set(array, 1, 'foo');
  if (Array.isArray(object) && typeof key === 'number') {
    object[key] = value;
    return value;
  }

  return deep(object, key, value);
}

// Perform array operations directly on object properties.
// e.g. `__.set(object, 'foo', 1, 'push');`
// is the same as `object.foo.push(1)`.
// `object.foo` being an array.

set.push = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    target.push(value);
    return target;
  }

  return update.apply(null, args);
};

set.pop = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    target.pop(value);
    return target;
  }

  return update.apply(null, args);
};

set.concat = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    return target.concat(value);
  }

  return update.apply(null, args);
};

set.inc = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    return value ? target + value : target + 1;
  }

  return update.apply(null, args);
};

set.toggle = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    return !target;
  }

  return update.apply(null, args);
};

function update (fn, object, key, value) {
  var target;
  var result;

  target = deep(object, key);
  result = fn(target, value);

  return deep(object, key, result);
}

function unset (object, key) {
  return deep(object, key, void 0);
}

function get (object, key) {
  if (Array.isArray(object) && typeof key === 'number') return object[key];
  return deep(object, key);
}

function extend (target) {
  var sources = [].slice.call(arguments, 1);

  sources.forEach(function (source) {
    var key;
    for (key in source) if (source.hasOwnProperty(key)) target[key] = source[key];
  });

  return target;
}

function mixin (target, source) {
  var methods;

  if (typeof source === 'function') {
    // Save a copy of own prototype methods.
    methods = extend({}, target.prototype);

    // Set prototype for correct inheritance.
    target.prototype = Object.create(source.prototype);

    // Restore original methods.
    extend(target.prototype, methods);
  } else {
    extend(target.prototype, source);
  }

  return target;
}

function initialize (object, id) {
  object = object || {};

  if (!object[Empty.config.name]) {
    Object.defineProperty(object, Empty.config.name, {
      enumerable: false,
      configurable: false,
      writable: true,
      value: empty(id || object[Empty.config.idKey])
    });
  }

  return object;
}

function empty (id) {
  return {
    id: id || generateId(),
    state: {},
    previous: {}
  };
}

function augment () {
  var methods = Empty.config.methods;
  var keys = Object.keys(methods);
  var d = Empty.config.delimiter;

  // Add extra methods to Empty prototype.

  keys.forEach(function (key) {

    Empty.prototype[key] = apply(function (object) {
      if (!object[Empty.config.name]) initialize(object);

      var result = methods[key].apply(null, arguments);
      var id = object[Empty.config.name].id;

      this._emit(key, object, result);
      this._emit([key, id].join(d), object, result);
      this._emit(['change', id].join(d), object, result, key);

      return result;
    });

  });

  // Add Array native methods to Empty prototype.

  Empty.config.native.forEach(function (method) {

    Empty.prototype[method] = apply(function (array) {
      if (!array[Empty.config.name]) initialize(array);

      var args = [].slice.call(arguments, 1);
      var result = Array.prototype[method].apply(array, args);
      var id = array[Empty.config.name].id;

      this._emit(method, array, result);
      this._emit([method, id].join(d), array, result);
      this._emit(['change', id].join(d), array, result, method);

      return result;
    });

  });
}

function generateId () {
  // https://github.com/mkuklis/depot.js/blob/master/depot.js#L207
  return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}

// Make sure empty.id is synced to the objects idKey property.
// So if the property being set is the id itself, the change:key:id event uses the latest id.

function ensureId (object, key, value) {
  if (!object[Empty.config.name]) initialize(object);

  var oldId = object[Empty.config.name].id;
  var ownId = object[Empty.config.idKey];

  // Case: Empty#id.
  if (typeof key === 'undefined'
      && typeof value === 'undefined'
      && typeof ownId !== 'undefined') {

    object[Empty.config.name].id = ownId;

    return object[Empty.config.name].id;
  }

  // Case: Empty#set.
  if (typeof key === 'string'
      && key === 'id'
      && typeof value === 'string') {

    object[Empty.config.name].id = value;

    return object[Empty.config.name].id;
  }

  // Case: Empty#set with object as key.
  if (typeof key === 'string'
      && key !== oldId
      && typeof value === 'undefined') {

    object[Empty.config.name].id = key;
  }

  return object[Empty.config.name].id;
}<commit_msg>Function#bind plus polyfill removed<commit_after>try {
  var deep = require('deep-get-set');
  deep.p = true;
} catch (err) {
  if (!deep) {
    var deep = function (obj, path, value) {
      if (arguments.length === 3) obj[path] = value;
      return obj[path];
    };
  }
}

var defaults = {
  idKey: 'id',
  name: 'empty',
  delimiter: ':',
  events: null,
  map: {
    emit: 'emit'
  },
  methods: {},
  native: [
    'filter',
    'map',
    'push',
    'pop',
    'reverse',
    'shift',
    'sort',
    'splice',
    'unshift',
  ]
};

try { module.exports = Empty; }
catch (err) { if (typeof window !== 'undefined') window.Empty = Empty; }

function Empty () {
  if (!(this instanceof Empty)) return new Empty();

  if (!Empty.config.events)
    throw new Error('You need to call Empty.configure before using Empty');

  // Call EventEmitter's constructor.
  if (typeof Empty.config.events === 'function')
    Empty.config.events.call(this);
}

Empty.configure = function (options) {
  if (typeof options !== 'object')
    throw new Error('Empty.configure requires an options object as first argument');

  var Events = options.events;

  if (Events) {
    mixin(Empty, Events);
    Empty.config.events = Events;
  }

  Empty.config = extend({}, defaults, options);

  // Add methods (custom and native) to Empty.prototype
  augment();
};

Empty.wrap = function (object, id) {
  var args, instance;

  object = object || {};
  if (!object[Empty.config.name]) initialize(object, id);

  if (typeof object === 'function') {
    args = [].slice.call(arguments, 1);
    instance = Object.create(object.prototype);
    object.apply(instance, args);
    return (new Empty()).bind(instance);
  }

  return (new Empty()).bind(object);
};

Empty.initialize = initialize;
Empty.mixin = mixin;
Empty.extend = extend;

Empty.config = defaults;
Empty.VERSION = '0.2.0';

// Proxy method to map to external library API.

Empty.prototype._emit = function () {
  this[Empty.config.map.emit].apply(this, arguments);
};

// Curry-esque method that returns an Empty instance with an object bound to it.

Empty.prototype.bind = function (object) {
  this.origin = object;
  return this;
};

// Id getter/setter.

Empty.prototype.id = apply(function (object, value) {
  ensureId.call(this, object, value);

  if (!value) return object[Empty.config.name].id;
});

Empty.prototype.state = apply(function (object, key, value) {
  if (!object[Empty.config.name]) initialize(object);

  if (typeof value === 'undefined')
    return object[Empty.config.name].state[key];

  object[Empty.config.name].state[key] = value;
});

Empty.prototype.set = apply(function (object, key, value, op) {
  var previous, action, id, _object, _key;
  var d = Empty.config.delimiter;

  if (!object[Empty.config.name]) initialize(object);

  // Handle 'key' argument as object.
  if (typeof key === 'object' && !value) {
    _object = key;
    id = ensureId.call(this, object, key[Empty.config.idKey]);

    for (_key in _object) {
      value = _object[_key];
      previous = object[_key];
      action = value ? set : unset;
      action(object, _key, value);

      if (previous !== _object[_key]) {
        set(object[Empty.config.name].previous, _key, previous);

        this._emit(['change', _key, id].join(d), object);
        this._emit(['change', _key].join(d), object);
      }
    }

    this._emit('change', object);
    return object;
  }

  // Handle normal key, value arguments.
  previous = get(object, key);
  id = ensureId.call(this, object, key, value);

  if (typeof op === 'string') {
    set[op](object, key, value);
  } else {
    action = value ? set : unset;
    action(object, key, value);
  }

  if (previous !== value) {
    set(object[Empty.config.name].previous, key + '', previous);

    this._emit(['change', key, id].join(d), object);
    this._emit(['change', key].join(d), object);
    this._emit('change', object);
  }

  return object;
});

// Convenience methods.

Empty.prototype.unset = apply(function (object, key) {
  return this.set(object, key, void 0);
});

Empty.prototype.get = apply(function (object, key) {
  return get(object, key);
});

// For bound objects.

Empty.prototype.toJSON = function () {
  return this.origin;
};

function apply (fn) {
  return function () {;
    var args = [].slice.call(arguments);
    if (typeof this.origin === 'object') args.unshift(this.origin);

    return fn.apply(this, args);
  };
}

function set (object, key, value) {
  // Support array bracket notation e.g. array[1] = 'foo'
  // with Empty#set(array, 1, 'foo');
  if (Array.isArray(object) && typeof key === 'number') {
    object[key] = value;
    return value;
  }

  return deep(object, key, value);
}

// Perform array operations directly on object properties.
// e.g. `__.set(object, 'foo', 1, 'push');`
// is the same as `object.foo.push(1)`.
// `object.foo` being an array.

set.push = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    target.push(value);
    return target;
  }

  return update.apply(null, args);
};

set.pop = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    target.pop(value);
    return target;
  }

  return update.apply(null, args);
};

set.concat = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    return target.concat(value);
  }

  return update.apply(null, args);
};

set.inc = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    return value ? target + value : target + 1;
  }

  return update.apply(null, args);
};

set.toggle = function () {
  var args = [].slice.call(arguments);
  args.unshift(operation);

  function operation (target, value) {
    return !target;
  }

  return update.apply(null, args);
};

function update (fn, object, key, value) {
  var target;
  var result;

  target = deep(object, key);
  result = fn(target, value);

  return deep(object, key, result);
}

function unset (object, key) {
  return deep(object, key, void 0);
}

function get (object, key) {
  if (Array.isArray(object) && typeof key === 'number') return object[key];
  return deep(object, key);
}

function extend (target) {
  var sources = [].slice.call(arguments, 1);

  sources.forEach(function (source) {
    var key;
    for (key in source) if (source.hasOwnProperty(key)) target[key] = source[key];
  });

  return target;
}

function mixin (target, source) {
  var methods;

  if (typeof source === 'function') {
    // Save a copy of own prototype methods.
    methods = extend({}, target.prototype);

    // Set prototype for correct inheritance.
    target.prototype = Object.create(source.prototype);

    // Restore original methods.
    extend(target.prototype, methods);
  } else {
    extend(target.prototype, source);
  }

  return target;
}

function initialize (object, id) {
  object = object || {};

  if (!object[Empty.config.name]) {
    Object.defineProperty(object, Empty.config.name, {
      enumerable: false,
      configurable: false,
      writable: true,
      value: empty(id || object[Empty.config.idKey])
    });
  }

  return object;
}

function empty (id) {
  return {
    id: id || generateId(),
    state: {},
    previous: {}
  };
}

function augment () {
  var methods = Empty.config.methods;
  var keys = Object.keys(methods);
  var d = Empty.config.delimiter;

  // Add extra methods to Empty prototype.

  keys.forEach(function (key) {

    Empty.prototype[key] = apply(function (object) {
      if (!object[Empty.config.name]) initialize(object);

      var result = methods[key].apply(null, arguments);
      var id = object[Empty.config.name].id;

      this._emit(key, object, result);
      this._emit([key, id].join(d), object, result);
      this._emit(['change', id].join(d), object, result, key);

      return result;
    });

  });

  // Add Array native methods to Empty prototype.

  Empty.config.native.forEach(function (method) {

    Empty.prototype[method] = apply(function (array) {
      if (!array[Empty.config.name]) initialize(array);

      var args = [].slice.call(arguments, 1);
      var result = Array.prototype[method].apply(array, args);
      var id = array[Empty.config.name].id;

      this._emit(method, array, result);
      this._emit([method, id].join(d), array, result);
      this._emit(['change', id].join(d), array, result, method);

      return result;
    });

  });
}

function generateId () {
  // https://github.com/mkuklis/depot.js/blob/master/depot.js#L207
  return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}

// Make sure empty.id is synced to the objects idKey property.
// So if the property being set is the id itself, the change:key:id event uses the latest id.

function ensureId (object, key, value) {
  if (!object[Empty.config.name]) initialize(object);

  var oldId = object[Empty.config.name].id;
  var ownId = object[Empty.config.idKey];

  // Case: Empty#id.
  if (typeof key === 'undefined'
      && typeof value === 'undefined'
      && typeof ownId !== 'undefined') {

    object[Empty.config.name].id = ownId;

    return object[Empty.config.name].id;
  }

  // Case: Empty#set.
  if (typeof key === 'string'
      && key === 'id'
      && typeof value === 'string') {

    object[Empty.config.name].id = value;

    return object[Empty.config.name].id;
  }

  // Case: Empty#set with object as key.
  if (typeof key === 'string'
      && key !== oldId
      && typeof value === 'undefined') {

    object[Empty.config.name].id = key;
  }

  return object[Empty.config.name].id;
}<|endoftext|>


<commit_before>// These are the test files in this dir to be run.
var tests = [
  { path: "blur.pde", tags: ["2D","Convolution"] },
  { path: "edgedetect.pde", tags: ["2D","Convolution"] },
  { path: "defaults-background_and_size.pde", tags: ["2D"] },
  { path: "background-gray.pde", tags: ["2D"] },
  { path: "background-gray-alpha.pde", tags: ["2D"] },
  { path: "background-3-arg.pde", tags: ["2D"] },
  { path: "background-3-arg-alpha.pde", tags: ["2D"] },
  { path: "background-color.pde", tags: ["2D"] },
  { path: "background-color-alpha.pde", tags: ["2D"] },
  { path: "background-hex.pde", tags: ["2D"] },
  { path: "background-hex2.pde", tags: ["2D"] },
  { path: "background-hex-alpha.pde", tags: ["2D"] },
  { path: "background-image.pde", tags: ["2D"], knownFailureTicket: "1285" },
  { path: "background-before-size.pde", tags: ["2D"] },
  { path: "background-color-1arg-2d.pde", tags: ["2D"] },
  { path: "background-color-1arg-alpha-2d.pde", tags: ["2D"] },
  { path: "background-hex-3RGB-alpha.pde", tags: ["2D"], knownFailureTicket: "1346" },
  { path: "background-gray-3d.pde", tags: ["3D"] },
  { path: "background-gray-alpha-3d.pde", tags: ["3D"] },
  { path: "background-3-arg-3d.pde", tags: ["3D"] },
  { path: "background-3-arg-alpha-3d.pde", tags: ["3D"] },
  { path: "background-color-3d.pde", tags: ["3D"] },
  { path: "background-color-alpha-3d.pde", tags: ["3D"] },
  { path: "background-hex-3d.pde", tags: ["3D"] },
  { path: "background-hex2-3d.pde", tags: ["3D"] },
  { path: "background-hex-alpha-3d.pde", tags: ["3D"] },
  { path: "background-color-1arg-3d.pde", tags: ["3D"] },
  { path: "background-color-1arg-alpha-3d.pde", tags: ["3D"] },
  { path: "background-hex-3RGB-alpha-3d.pde", tags: ["3D"], knownFailureTicket: "1346" },
  { path: "background-image-3d.pde", tags: ["3D"], knownFailureTicket: "1323" },
  { path: "circles.pde", tags: ["2D"] },
  { path: "circles2.pde", tags: ["2D"] },
  { path: "conditionals1.pde", tags: ["2D"] },
  { path: "conditionals2.pde", tags: ["2D"] },
  { path: "datatype-conversion.pde", tags: ["2D"] },
  { path: "distance-2d.pde", tags: ["2D"] },
  { path: "embedded-iteration.pde", tags: ["2D"] },
  { path: "iteration.pde", tags: ["2D"] },
  { path: "letters.pde", tags: ["2D"], epsilonOverride: 0.45 }, /* See ticket #1172 */
  { path: "logical-operators.pde", tags: ["2D"] },
  { path: "point-line-rect.pde", tags: ["2D"] },
  { path: "sine-wave.pde", tags: ["2D"] },
  { path: "target.pde", tags: ["2D"] },
  { path: "triangle-strip.pde", tags: ["2D"], epsilonOverride: 0.08 },
  { path: "true-false.pde", tags: ["2D"] },
  { path: "variable-scope.pde", tags: ["2D"] },
  { path: "variables.pde", tags: ["2D"] },
  { path: "words.pde", tags: ["2D"], epsilonOverride: 0.25 }, /* See ticket #1172 */
  { path: "defaults-text.pde", tags: ["2D"], epsilonOverride: 0.10 }, /* See ticket #1172 */
  { path: "simple.pde", tags: ["2D"] },
  { path: "arc-tangent.pde",  tags: ["2D"] },
  { path: "arc_ref1.pde",  tags: ["2D"], epsilonOverride: 0.06 },
  { path: "arc_ref2.pde",  tags: ["2D"], epsilonOverride: 0.08 },
  { path: "arc_ref3.pde",  tags: ["2D"], epsilonOverride: 0.08 },
  { path: "bezier.pde", tags: ["2D"], epsilonOverride: 0.08 },
  { path: "ellipse.pde", tags: ["2D"] },
  { path: "piechart.pde", tags: ["2D"] },
  { path: "point-stroke-array-2d.pde", tags: ["2D"] },
  { path: "bezier-ellipse.pde", tags: ["2D"] },
  { path: "curves.pde", tags: ["2D"], epsilonOverride: 0.07 },
  { path: "curve.pde", tags: ["2D"], epsilonOverride: 0.09 },
  { path: "continuous-curve.pde", tags: ["2D"], epsilonOverride: 0.09 },
  { path: "points-lines.pde", tags: ["2D"] },
  { path: "rect-quad.pde", tags: ["2D"] },
  { path: "size-fill-rect.pde", tags: ["2D"] },
  { path: "triangle.pde", tags: ["2D"] },
  { path: "svg_font_biotyp.pde", tags: ["2D"] },
  { path: "3d-arc-4-combo.pde", tags: ["3D"], epsilonOverride: 0.13 },
  { path: "text-leading.pde", tags: ["2D"], epsilonOverride: 0.20 },
  { path: "point_3D_stroke.pde", tags: ["3D"] },
  { path: "point_3D_strokeWeight.pde", tags: ["3D"], epsilonOverride: 0.22 },
  { path: "box.pde", tags: ["3D"], epsilonOverride: 0.18 },
  { path: "ambientLight_1.pde", tags: ["3D"] },
  { path: "ambientLight_p5test_1.pde", tags: ["3D"] },
  { path: "ambientLight_p5test_2.pde", tags: ["3D"], epsilonOverride: 0.10 },
  { path: "ambient_p5test.pde", tags: ["3D"] },
  { path: "directionalLight_p5test_1.pde", tags: ["3D"] },
  { path: "directionalLight_p5test_2.pde", tags: ["3D"] },
  { path: "directionalLight_scale.pde", tags: ["3D"] },
  { path: "emissive_p5test.pde", tags: ["3D"] },
  { path: "lightSpecular_p5test.pde", tags: ["3D"], epsilonOverride: 0.07 },
  { path: "pointLight_p5test.pde", tags: ["3D"] },
  { path: "shininess_p5test.pde", tags: ["3D"] },
  { path: "specular_p5test.pde", tags: ["3D"]},
  { path: "spotLight_p5test.pde", tags: ["3D"], knownFailureTicket: "1239" }, /* See ticket #1202 */
  { path: "3d-ellipse-fill-noFill-stoke-noStroke.pde", tags: ["3D"], epsilonOverride: 0.15 },
  { path: "createGraphics.pde", tags: ["3D"], epsilonOverride: 0.07 }, /* See ticket #1075 */
  { path: "rect-directional-light.pde", tags: ["3D"] },
  { path: "createimage.pde", tags: ["2D"] },
  { path: "array.pde", tags: ["2D"] },
  { path: "brightness-2.pde", tags: ["2D"] },
  { path: "create-image.pde", tags: ["2D"] },
  { path: "creating.pde", tags: ["2D"] },
  { path: "displaying.pde", tags: ["2D"], knownFailureTicket: "1285" },
  { path: "graphing-2d.pde", tags: ["2D"] },
  { path: "histogram.pde", tags: ["2D"], knownFailureTicket: "1174" },
  { path: "linear-gradient.pde", tags: ["2D"] },
  { path: "mandelbrot.pde", tags: ["2D"], knownFailureTicket: "1174" },
  { path: "modulo.pde", tags: ["2D"] },
  { path: "multiple-constructors.pde", tags: ["2D"], epsilonOverride: 0.06 },
  { path: "neighborhood.pde", tags: ["2D"], epsilonOverride: 0.08 },
  { path: "no-loop.pde", tags: ["2D"] },
  { path: "reading.pde", tags: ["2D"], knownFailureTicket: "1285" },
  { path: "relativity.pde", tags: ["2D"] },
  { path: "triangle-flower.pde", tags: ["2D"] },
  { path: "self-1-success.pde", tags: ["Calibration"] },
  { path: "self-2-fail.pde", tags: ["Calibration"] },
  { path: "self-3-fail.pde", tags: ["Calibration"] },
  { path: "self-4-fail.pde", tags: ["Calibration"] },
  { path: "self-5-success.pde", tags: ["Calibration"] },
  { path: "beginEndShape-2dlines.pde", tags:["endShape2D", "2D"] },
  { path: "beginEndShape-2dnocloseline.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.06  },
  { path: "beginEndShape-2dnoclosetriangle.pde", tags:["endShape2D", "2D"] },
  { path: "beginEndShape-2dnocloserectangle.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dnofilltriangle.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dnofillrectangle.pde", tags:["endShape2D", "2D"] },
  { path: "beginEndShape-2dpoints.pde", tags:["endShape2D", "2D"], knownFailureTicket: "1245" },
  { path: "beginEndShape-2dpolygon.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dquads.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dquadstrip1.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dquadstrip2.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.10 },
  { path: "beginEndShape-2dtrianglefan1.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.14 },
  { path: "beginEndShape-2dtrianglefan2.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.17 },
  { path: "beginEndShape-2dtriangles1.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.12 },
  { path: "beginEndShape-2dtriangles2.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.12 },
  { path: "beginEndShape-2dtrianglestrip1.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.15 },
  { path: "beginEndShape-2dtrianglestrip2.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.12 },
  { path: "beginEndShape-3dlines.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "beginEndShape-3dnocloseline.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.15 },
  { path: "beginEndShape-3dnoclosetriangle.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.18 },
  { path: "beginEndShape-3dnocloserectangle.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.18 },
  { path: "beginEndShape-3dnofilltriangle.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.15 },
  { path: "beginEndShape-3dnofillrectangle.pde", tags:["endShape3D", "3D"], knownFailureTicket: "1271" },
  { path: "beginEndShape-3dpoints.pde", tags:["endShape3D", "3D"], knownFailureTicket: "1268" },
  { path: "beginEndShape-3dpolygon.pde", tags:["endShape3D", "3D"], knownFailureTicket: "1286" },
  { path: "beginEndShape-3dquads.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.12, knownFailureTicket: "1271" },
  { path: "beginEndShape-3dquadstrip1.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.25 },
  { path: "beginEndShape-3dquadstrip2.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "beginEndShape-3dtrianglefan1.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.27 },
  { path: "beginEndShape-3dtrianglefan2.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "beginEndShape-3dtriangles1.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.18 },
  { path: "beginEndShape-3dtriangles2.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.15 },
  { path: "beginEndShape-3dtrianglestrip1.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "beginEndShape-3dtrianglestrip2.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "textWidth_comic.pde", tags:["2D"], epsilonOverride: 0.35} /* See ticket #1172 */
];
<commit_msg>marked edge detect as known fail<commit_after>// These are the test files in this dir to be run.
var tests = [
  { path: "blur.pde", tags: ["2D","Convolution"] },
  { path: "edgedetect.pde", tags: ["2D","Convolution"], knownFailureTicket: "1399" },
  { path: "defaults-background_and_size.pde", tags: ["2D"] },
  { path: "background-gray.pde", tags: ["2D"] },
  { path: "background-gray-alpha.pde", tags: ["2D"] },
  { path: "background-3-arg.pde", tags: ["2D"] },
  { path: "background-3-arg-alpha.pde", tags: ["2D"] },
  { path: "background-color.pde", tags: ["2D"] },
  { path: "background-color-alpha.pde", tags: ["2D"] },
  { path: "background-hex.pde", tags: ["2D"] },
  { path: "background-hex2.pde", tags: ["2D"] },
  { path: "background-hex-alpha.pde", tags: ["2D"] },
  { path: "background-image.pde", tags: ["2D"], knownFailureTicket: "1285" },
  { path: "background-before-size.pde", tags: ["2D"] },
  { path: "background-color-1arg-2d.pde", tags: ["2D"] },
  { path: "background-color-1arg-alpha-2d.pde", tags: ["2D"] },
  { path: "background-hex-3RGB-alpha.pde", tags: ["2D"], knownFailureTicket: "1346" },
  { path: "background-gray-3d.pde", tags: ["3D"] },
  { path: "background-gray-alpha-3d.pde", tags: ["3D"] },
  { path: "background-3-arg-3d.pde", tags: ["3D"] },
  { path: "background-3-arg-alpha-3d.pde", tags: ["3D"] },
  { path: "background-color-3d.pde", tags: ["3D"] },
  { path: "background-color-alpha-3d.pde", tags: ["3D"] },
  { path: "background-hex-3d.pde", tags: ["3D"] },
  { path: "background-hex2-3d.pde", tags: ["3D"] },
  { path: "background-hex-alpha-3d.pde", tags: ["3D"] },
  { path: "background-color-1arg-3d.pde", tags: ["3D"] },
  { path: "background-color-1arg-alpha-3d.pde", tags: ["3D"] },
  { path: "background-hex-3RGB-alpha-3d.pde", tags: ["3D"], knownFailureTicket: "1346" },
  { path: "background-image-3d.pde", tags: ["3D"], knownFailureTicket: "1323" },
  { path: "circles.pde", tags: ["2D"] },
  { path: "circles2.pde", tags: ["2D"] },
  { path: "conditionals1.pde", tags: ["2D"] },
  { path: "conditionals2.pde", tags: ["2D"] },
  { path: "datatype-conversion.pde", tags: ["2D"] },
  { path: "distance-2d.pde", tags: ["2D"] },
  { path: "embedded-iteration.pde", tags: ["2D"] },
  { path: "iteration.pde", tags: ["2D"] },
  { path: "letters.pde", tags: ["2D"], epsilonOverride: 0.45 }, /* See ticket #1172 */
  { path: "logical-operators.pde", tags: ["2D"] },
  { path: "point-line-rect.pde", tags: ["2D"] },
  { path: "sine-wave.pde", tags: ["2D"] },
  { path: "target.pde", tags: ["2D"] },
  { path: "triangle-strip.pde", tags: ["2D"], epsilonOverride: 0.08 },
  { path: "true-false.pde", tags: ["2D"] },
  { path: "variable-scope.pde", tags: ["2D"] },
  { path: "variables.pde", tags: ["2D"] },
  { path: "words.pde", tags: ["2D"], epsilonOverride: 0.25 }, /* See ticket #1172 */
  { path: "defaults-text.pde", tags: ["2D"], epsilonOverride: 0.10 }, /* See ticket #1172 */
  { path: "simple.pde", tags: ["2D"] },
  { path: "arc-tangent.pde",  tags: ["2D"] },
  { path: "arc_ref1.pde",  tags: ["2D"], epsilonOverride: 0.06 },
  { path: "arc_ref2.pde",  tags: ["2D"], epsilonOverride: 0.08 },
  { path: "arc_ref3.pde",  tags: ["2D"], epsilonOverride: 0.08 },
  { path: "bezier.pde", tags: ["2D"], epsilonOverride: 0.08 },
  { path: "ellipse.pde", tags: ["2D"] },
  { path: "piechart.pde", tags: ["2D"] },
  { path: "point-stroke-array-2d.pde", tags: ["2D"] },
  { path: "bezier-ellipse.pde", tags: ["2D"] },
  { path: "curves.pde", tags: ["2D"], epsilonOverride: 0.07 },
  { path: "curve.pde", tags: ["2D"], epsilonOverride: 0.09 },
  { path: "continuous-curve.pde", tags: ["2D"], epsilonOverride: 0.09 },
  { path: "points-lines.pde", tags: ["2D"] },
  { path: "rect-quad.pde", tags: ["2D"] },
  { path: "size-fill-rect.pde", tags: ["2D"] },
  { path: "triangle.pde", tags: ["2D"] },
  { path: "svg_font_biotyp.pde", tags: ["2D"] },
  { path: "3d-arc-4-combo.pde", tags: ["3D"], epsilonOverride: 0.13 },
  { path: "text-leading.pde", tags: ["2D"], epsilonOverride: 0.20 },
  { path: "point_3D_stroke.pde", tags: ["3D"] },
  { path: "point_3D_strokeWeight.pde", tags: ["3D"], epsilonOverride: 0.22 },
  { path: "box.pde", tags: ["3D"], epsilonOverride: 0.18 },
  { path: "ambientLight_1.pde", tags: ["3D"] },
  { path: "ambientLight_p5test_1.pde", tags: ["3D"] },
  { path: "ambientLight_p5test_2.pde", tags: ["3D"], epsilonOverride: 0.10 },
  { path: "ambient_p5test.pde", tags: ["3D"] },
  { path: "directionalLight_p5test_1.pde", tags: ["3D"] },
  { path: "directionalLight_p5test_2.pde", tags: ["3D"] },
  { path: "directionalLight_scale.pde", tags: ["3D"] },
  { path: "emissive_p5test.pde", tags: ["3D"] },
  { path: "lightSpecular_p5test.pde", tags: ["3D"], epsilonOverride: 0.07 },
  { path: "pointLight_p5test.pde", tags: ["3D"] },
  { path: "shininess_p5test.pde", tags: ["3D"] },
  { path: "specular_p5test.pde", tags: ["3D"]},
  { path: "spotLight_p5test.pde", tags: ["3D"], knownFailureTicket: "1239" }, /* See ticket #1202 */
  { path: "3d-ellipse-fill-noFill-stoke-noStroke.pde", tags: ["3D"], epsilonOverride: 0.15 },
  { path: "createGraphics.pde", tags: ["3D"], epsilonOverride: 0.07 }, /* See ticket #1075 */
  { path: "rect-directional-light.pde", tags: ["3D"] },
  { path: "createimage.pde", tags: ["2D"] },
  { path: "array.pde", tags: ["2D"] },
  { path: "brightness-2.pde", tags: ["2D"] },
  { path: "create-image.pde", tags: ["2D"] },
  { path: "creating.pde", tags: ["2D"] },
  { path: "displaying.pde", tags: ["2D"], knownFailureTicket: "1285" },
  { path: "graphing-2d.pde", tags: ["2D"] },
  { path: "histogram.pde", tags: ["2D"], knownFailureTicket: "1174" },
  { path: "linear-gradient.pde", tags: ["2D"] },
  { path: "mandelbrot.pde", tags: ["2D"], knownFailureTicket: "1174" },
  { path: "modulo.pde", tags: ["2D"] },
  { path: "multiple-constructors.pde", tags: ["2D"], epsilonOverride: 0.06 },
  { path: "neighborhood.pde", tags: ["2D"], epsilonOverride: 0.08 },
  { path: "no-loop.pde", tags: ["2D"] },
  { path: "reading.pde", tags: ["2D"], knownFailureTicket: "1285" },
  { path: "relativity.pde", tags: ["2D"] },
  { path: "triangle-flower.pde", tags: ["2D"] },
  { path: "self-1-success.pde", tags: ["Calibration"] },
  { path: "self-2-fail.pde", tags: ["Calibration"] },
  { path: "self-3-fail.pde", tags: ["Calibration"] },
  { path: "self-4-fail.pde", tags: ["Calibration"] },
  { path: "self-5-success.pde", tags: ["Calibration"] },
  { path: "beginEndShape-2dlines.pde", tags:["endShape2D", "2D"] },
  { path: "beginEndShape-2dnocloseline.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.06  },
  { path: "beginEndShape-2dnoclosetriangle.pde", tags:["endShape2D", "2D"] },
  { path: "beginEndShape-2dnocloserectangle.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dnofilltriangle.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dnofillrectangle.pde", tags:["endShape2D", "2D"] },
  { path: "beginEndShape-2dpoints.pde", tags:["endShape2D", "2D"], knownFailureTicket: "1245" },
  { path: "beginEndShape-2dpolygon.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dquads.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dquadstrip1.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.07 },
  { path: "beginEndShape-2dquadstrip2.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.10 },
  { path: "beginEndShape-2dtrianglefan1.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.14 },
  { path: "beginEndShape-2dtrianglefan2.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.17 },
  { path: "beginEndShape-2dtriangles1.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.12 },
  { path: "beginEndShape-2dtriangles2.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.12 },
  { path: "beginEndShape-2dtrianglestrip1.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.15 },
  { path: "beginEndShape-2dtrianglestrip2.pde", tags:["endShape2D", "2D"], epsilonOverride: 0.12 },
  { path: "beginEndShape-3dlines.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "beginEndShape-3dnocloseline.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.15 },
  { path: "beginEndShape-3dnoclosetriangle.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.18 },
  { path: "beginEndShape-3dnocloserectangle.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.18 },
  { path: "beginEndShape-3dnofilltriangle.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.15 },
  { path: "beginEndShape-3dnofillrectangle.pde", tags:["endShape3D", "3D"], knownFailureTicket: "1271" },
  { path: "beginEndShape-3dpoints.pde", tags:["endShape3D", "3D"], knownFailureTicket: "1268" },
  { path: "beginEndShape-3dpolygon.pde", tags:["endShape3D", "3D"], knownFailureTicket: "1286" },
  { path: "beginEndShape-3dquads.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.12, knownFailureTicket: "1271" },
  { path: "beginEndShape-3dquadstrip1.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.25 },
  { path: "beginEndShape-3dquadstrip2.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "beginEndShape-3dtrianglefan1.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.27 },
  { path: "beginEndShape-3dtrianglefan2.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "beginEndShape-3dtriangles1.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.18 },
  { path: "beginEndShape-3dtriangles2.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.15 },
  { path: "beginEndShape-3dtrianglestrip1.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "beginEndShape-3dtrianglestrip2.pde", tags:["endShape3D", "3D"], epsilonOverride: 0.20 },
  { path: "textWidth_comic.pde", tags:["2D"], epsilonOverride: 0.35} /* See ticket #1172 */
];
<|endoftext|>