diff --git a/README b/README index 6a3d0a2..75ea326 100644 --- a/README +++ b/README @@ -1,11 +1,7 @@ -Extendables is an MIT-licensed developers' framework for Adobe ExtendScript. It is currently unmaintained and there are no guarantees it will continue to work with the latest versions of the Creative Suite and/or ExtendScript. +This is my fork of http://debrouwere.github.com/Extendables. See the source project for documentation and more info. -Extendables comes with three big blocks of functionality. +The difference with my fork is: -1. Additional methods on built-in objects like String and Array that give you the Javascript 1.8 features you're used to (think `forEach`), conveniences for functional programming (think `map`, `reduce`, `filter`), easy serialization to JSON or base64 and more. -2. Additional methods on InDesign DOM objects that make coding in InDesign less verbose. -3. Packages for logging, unit testing, http, user interface development, and a couple of other goodies. +* have issue tracker to track issues with Extendables framework, since the original source project has no issue tracker currently. -If you're writing heavy-duty automations for a Creative Suite app like InDesign, or anything more than just a throwaway script, this is for you. - -Read the documentation at http://debrouwere.github.com/Extendables/docs/ to learn more and get started. +* fix issues and offer enhancements as I get to them. See the issue tracker of open and closed issues for details. Some info might be put on the wiki as well. diff --git a/dependencies/jasmine.js b/dependencies/jasmine.js index 1adab61..707fb3e 100644 --- a/dependencies/jasmine.js +++ b/dependencies/jasmine.js @@ -1409,6 +1409,31 @@ jasmine.Matchers.prototype.toThrow = function(expected) { return result; }; +/** + * toBeCloseTo: compares that actual is close to the value of expected, based on given precision value for number of decimal places. + * + * @param expected + * @param precision + */ +jasmine.Matchers.prototype.toBeCloseTo = function() { + + function toBeCloseTo() { + return { + compare: function(actual, expected, precision) { + if (precision !== 0) { + precision = precision || 2; + } + + return { + pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2) + }; + } + }; + } + + return toBeCloseTo; +}; + jasmine.Matchers.Any = function(expectedClass) { this.expectedClass = expectedClass; }; diff --git a/test/jasmine.specs b/test/jasmine.specs new file mode 100644 index 0000000..1023a24 --- /dev/null +++ b/test/jasmine.specs @@ -0,0 +1,10 @@ +describe('Jasmine unit tests against Jasmine changes', function () { + it("The 'toBeCloseTo' matcher is for precision math comparison", function() { + var pi = 3.1415926, + e = 2.78; + + //expect(pi).not.toBeCloseTo(e, 2); + expect(pi).toBeCloseTo(e, 0); + expect(12.34).toBeCloseTo(12.3, 1); // success + }); +}); \ No newline at end of file