From bed956fbe990d7926927c5ff5fee0d44fd8f5843 Mon Sep 17 00:00:00 2001 From: fabianmoronzirfas Date: Fri, 11 Nov 2016 15:32:55 +0100 Subject: [PATCH 1/9] docs(version): bump version to 1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d37714e..59f8da12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "basiljs", - "version": "1.0.10", + "version": "1.1.0", "description": "An attempt to port the spirit of the Processing visualization language to Adobe InDesign.", "main": "basil.js", "directories": { From 403bd59fe964cf83b07206b947022ad02c7c1e00 Mon Sep 17 00:00:00 2001 From: fabianmoronzirfas Date: Fri, 11 Nov 2016 15:33:52 +0100 Subject: [PATCH 2/9] docs(build release bundle): --- basil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basil.js b/basil.js index a8ca1b78..2c2950c9 100644 --- a/basil.js +++ b/basil.js @@ -1,4 +1,4 @@ -/* Basil.js v1.0.10 2016.11.08-04:13:40 */ +/* Basil.js v1.1.0 2016.11.11-15:33:03 */ /* ..- --.- ..- -.... -..-- .-..-. -.-..---.-.-....--.-- -....-.... -..-- .-.-..-.-.... .- .-- From 06888c499dbdd7b4fbf62f60957d57883aaddf71 Mon Sep 17 00:00:00 2001 From: trych Date: Fri, 11 Nov 2016 15:57:50 +0100 Subject: [PATCH 3/9] Replaced Github names by actual names --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 067232b1..a46451d0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -30,7 +30,7 @@ basil.js 1.1.0 - 11 November 2016 * Bugfix: b.words(), b.lines() etc. were broken * Bugfix: b.objectStyle(), b.characterStyle() and b.paragraphStyle() were broken -Shout outs to @trych @fabianmoronzirfas! +Shout outs to Timo Rychert and Fabian Morón Zirfas! This release is entirely based on your hard work! Many thanks for this massive contributions! From f34b8a3722dd635dc0dd7cc45edfc595865e1f58 Mon Sep 17 00:00:00 2001 From: ffd8 Date: Thu, 24 Nov 2016 00:36:17 +0100 Subject: [PATCH 4/9] updating version to 1.1.0 to appear correct in console --- src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 40596bda..535b6614 100644 --- a/src/main.js +++ b/src/main.js @@ -56,7 +56,7 @@ * @property VERSION {String} * @cat Environment */ - pub.VERSION = "1.0.10"; + pub.VERSION = "1.1.0"; #include "includes/constants.js"; #include "includes/public-vars.js"; From 5a11ac3443ea8efd05864cc197bbf8f38fe31fda Mon Sep 17 00:00:00 2001 From: fabianmoronzirfas Date: Wed, 21 Dec 2016 10:28:02 +0100 Subject: [PATCH 5/9] fix(encoding): fixed file encoding on and linted the hell out of it --- test/data-tests.jsx | 118 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) diff --git a/test/data-tests.jsx b/test/data-tests.jsx index 61235fbb..a3614125 100644 --- a/test/data-tests.jsx +++ b/test/data-tests.jsx @@ -1 +1,117 @@ -if (typeof b === 'undefined') { #include "../basil.js"; } if (typeof b.test === 'undefined') { #include "../lib/basil.test.js"; } b.test('DataTests', { testHashList: function(b) { var hash = new HashList(); assert(hash.length === 0); hash.set("one", 1); assert(hash.length === 1); assert(hash.get("one") === 1); assert(hash.hasKey("one")); assert(hash.hasValue(1)); hash.set("two", "zwei"); assert(hash.length === 2); assert(hash.get("two") === "zwei"); assert(hash.get('two') === 'zwei'); assert(hash.hasKey("two")); assert(hash.hasValue("zwei")); hash.set("three", true); assert(hash.length === 3); assert(hash.get('three') === true); assert(hash.hasKey("three")); assert(hash.hasValue(true)); hash.set("four", false); assert(hash.length === 4); assert(hash.hasKey("four")); assert(hash.get('four') === false); assert(hash.hasValue(false)); assert(typeof hash.get("bs") === 'undefined'); try { //hash.set("danger", new Function() ); } catch (exp) { assert(true); assert(hash.length === 4); // not added? assert(hash.hasValue( new Function()) === false); } hash.remove("one"); assert(hash.length === 3); hash.clear(); assert(hash.hasKey("four") === false); assert(hash.length === 0); }, "testHashList2" : function (b) { hash = new HashList(); // start over assert(hash.length === 0); var arr = hash.getSortedKeys(); assert(arr.length === 0); var arr = hash.getKeys(); assert(arr.length === 0); var arr = hash.getValues(); assert(arr.length === 0); var arr = hash.getKeysByValues(); assert(arr.length === 0); hash.set("eight", 8); hash.set("thousand", 1000); assert(typeof hash.get("watch") === "function"); // this is not nice hash.set("watch", 0); // it's a prototype function assert(hash.length === 3); assert(typeof hash.get("watch") === "number"); var arr = hash.getKeys(); assert(arr[0] === "eight"); assert(arr[1] === "thousand"); assert(arr[2] === "watch"); var arr = hash.getValues(); assert(arr[0] === 8); assert(arr[1] === 1000); assert(arr[2] === 0); var arr = hash.getSortedKeys(); assert(arr[0] === "eight"); assert(arr[1] === "thousand"); assert(arr[2] === "watch"); var arr = hash.getKeysByValues(); assert(arr[0] === "thousand"); assert(arr[1] === "eight"); assert(arr[2] === "watch"); // TODO: initial function removal in items? } }); // print collected test results b.test.result(); \ No newline at end of file +/* globals assert, HashList*/ +if (typeof b === "undefined") { + // @include "../basil.js"; +} +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; +} + +b.test("DataTests", { + + testHashList: function(b) { + + var hash = new HashList(); + + assert(hash.length === 0); + + hash.set("one", 1); + assert(hash.length === 1); + assert(hash.get("one") === 1); + assert(hash.hasKey("one")); + assert(hash.hasValue(1)); + + hash.set("two", "zwei"); + assert(hash.length === 2); + assert(hash.get("two") === "zwei"); + assert(hash.get("two") === "zwei"); + assert(hash.hasKey("two")); + assert(hash.hasValue("zwei")); + + hash.set("three", true); + assert(hash.length === 3); + assert(hash.get("three") === true); + assert(hash.hasKey("three")); + assert(hash.hasValue(true)); + + hash.set("four", false); + assert(hash.length === 4); + assert(hash.hasKey("four")); + assert(hash.get("four") === false); + assert(hash.hasValue(false)); + + assert(typeof hash.get("bs") === "undefined"); + + try { + // hash.set("danger", new Function() ); + } catch (exp) { + assert(true); + assert(hash.length === 4); // not added? + assert(hash.hasValue(new Function()) === false); // eslint-disable-line no-new-func + + } + + hash.remove("one"); + assert(hash.length === 3); + + hash.clear(); + assert(hash.hasKey("four") === false); + assert(hash.length === 0); + + }, + + testHashList2: function (b) { + + var hash = new HashList(); // start over + + assert(hash.length === 0); + + var arr = hash.getSortedKeys(); + assert(arr.length === 0); + + arr = hash.getKeys(); + assert(arr.length === 0); + + arr = hash.getValues(); + assert(arr.length === 0); + + arr = hash.getKeysByValues(); + assert(arr.length === 0); + + hash.set("eight", 8); + hash.set("thousand", 1000); + + assert(typeof hash.get("watch") === "function"); // this is not nice + hash.set("watch", 0); // it's a prototype function + assert(hash.length === 3); + assert(typeof hash.get("watch") === "number"); + + arr = hash.getKeys(); + assert(arr[0] === "eight"); + assert(arr[1] === "thousand"); + assert(arr[2] === "watch"); + + arr = hash.getValues(); + assert(arr[0] === 8); + assert(arr[1] === 1000); + assert(arr[2] === 0); + + arr = hash.getSortedKeys(); + assert(arr[0] === "eight"); + assert(arr[1] === "thousand"); + assert(arr[2] === "watch"); + + arr = hash.getKeysByValues(); + assert(arr[0] === "thousand"); + assert(arr[1] === "eight"); + assert(arr[2] === "watch"); + + // TODO: initial function removal in items? + + + } + +}); + +// print collected test results +b.test.result(); + From 872c0a4656f9726ebdf8da38fe71c6edc808a956 Mon Sep 17 00:00:00 2001 From: fabianmoronzirfas Date: Wed, 21 Dec 2016 10:34:49 +0100 Subject: [PATCH 6/9] style(linting): liniting the hell out of the test. All passing --- test/environment-tests.jsx | 215 +++++++++++++++++++------------------ 1 file changed, 113 insertions(+), 102 deletions(-) diff --git a/test/environment-tests.jsx b/test/environment-tests.jsx index 4ea04e07..deff22a4 100644 --- a/test/environment-tests.jsx +++ b/test/environment-tests.jsx @@ -20,24 +20,24 @@ b.test('EnvironmentTests', { b.close(SaveOptions.no); }, - testSizeAllArgs: function(b){ + testSizeAllArgs: function(b) { var doc = app.documents.add(); - b.size(100,200); + b.size(100, 200); assert(doc.documentPreferences.pageWidth === 100); assert(doc.documentPreferences.pageHeight === 200); }, - testSizeOneArg: function(b){ + testSizeOneArg: function(b) { var doc = app.documents.add(); b.size(100); assert(doc.documentPreferences.pageWidth === 100); assert(doc.documentPreferences.pageHeight === 100); }, - testSizeNoArg: function(b){ + testSizeNoArg: function(b) { var doc = app.documents.add(); var result = b.size(); assert(result instanceof Object); - assert(result.hasOwnProperty('height') === true); - assert(result.hasOwnProperty('width') === true); + assert(result.hasOwnProperty("height") === true); + assert(result.hasOwnProperty("width") === true); assert(result.height === b.height); assert(result.width === b.width); @@ -53,8 +53,8 @@ b.test('EnvironmentTests', { var doc = app.documents.add(); var currDoc = b.doc(doc); - - assert(doc == currDoc); + + assert(doc === currDoc); assert(app.documents.length === 1); }, @@ -63,7 +63,7 @@ b.test('EnvironmentTests', { var currDoc = b.doc({}); - assert(doc == currDoc); + assert(doc === currDoc); assert(app.documents.length === 1); }, @@ -74,7 +74,7 @@ b.test('EnvironmentTests', { try { b.doc(doc); assert(false); - } catch (expected) {} + } catch (expected) {} // eslint-disable-line no-empty }, testPageSetsPageByInstance: function(b) { @@ -84,9 +84,9 @@ b.test('EnvironmentTests', { b.doc(doc); var page = b.page(secondPage); - + assert(page instanceof Page); - assert(secondPage == page); + assert(secondPage === page); }, testPageSetsPageByIndex: function(b) { @@ -96,9 +96,9 @@ b.test('EnvironmentTests', { b.doc(doc); var page = b.page(3); - + assert(page instanceof Page); - assert(secondPage == page); + assert(secondPage === page); }, testPageWithNotExistingPageIndexThrowsError: function(b) { @@ -107,104 +107,104 @@ b.test('EnvironmentTests', { try { b.page(500); assert(false); - } catch (expected) {} + } catch (expected) {} // eslint-disable-line no-empty }, testPageManagement: function(b) { - + b.doc(); - + assert(b.pageNumber() === 1); assert(b.pageCount() === 1); b.addPage(); - assert(b.pageNumber() === 2); + assert(b.pageNumber() === 2); assert(b.pageCount() === 2); b.addPage(b.AT_BEGINNING); - assert(b.pageNumber() === 1); - assert(b.pageCount() === 3); + assert(b.pageNumber() === 1); + assert(b.pageCount() === 3); b.page(2); - assert(b.pageNumber() === 2); + assert(b.pageNumber() === 2); b.addPage(b.BEFORE); - assert(b.pageNumber() === 2); - assert(b.pageCount() === 4); + assert(b.pageNumber() === 2); + assert(b.pageCount() === 4); b.addPage(b.AFTER); - assert(b.pageNumber() === 3); - assert(b.pageCount() === 5); + assert(b.pageNumber() === 3); + assert(b.pageCount() === 5); b.removePage(); // this behaves differently according to the facing pages mode if(b.doc().documentPreferences.facingPages) { - assert(b.pageNumber() === 2); - } else { - assert(b.pageNumber() === 3); + assert(b.pageNumber() === 2); + } else { + assert(b.pageNumber() === 3); } - assert(b.pageCount() === 4); + assert(b.pageCount() === 4); b.removePage(1); assert(b.pageNumber() === 1); // new number 1 - assert(b.pageCount() === 3); - - b.removePage(b.pageCount()); - assert(b.pageNumber() === 2); - assert(b.pageCount() === 2); - + assert(b.pageCount() === 3); + + b.removePage(b.pageCount()); + assert(b.pageNumber() === 2); + assert(b.pageCount() === 2); + b.addPage(); - assert(b.pageNumber() === 3); - assert(b.pageCount() === 3); + assert(b.pageNumber() === 3); + assert(b.pageCount() === 3); }, testLayerSetsLayerByInstance: function(b) { var doc = app.documents.add(); - var addedLayer = doc.layers.add({name: 'foo'}); + var addedLayer = doc.layers.add({name: "foo"}); b.doc(doc); var layer = b.layer(addedLayer); - + assert(layer instanceof Layer); - assert(addedLayer == layer); + assert(addedLayer === layer); }, testLayerSetsLayerByName: function(b) { var doc = app.documents.add(); - var addedLayer = doc.layers.add({name: 'foo'}); + var addedLayer = doc.layers.add({name: "foo"}); b.doc(doc); - var layer = b.layer('foo'); - + var layer = b.layer("foo"); + assert(layer instanceof Layer); - assert(addedLayer == layer); + assert(addedLayer === layer); }, testLayerWithNotExistingLayerNameAddsLayer: function(b) { var doc = app.documents.add(); b.doc(doc); - var layer = b.layer('foo'); - + var layer = b.layer("foo"); + assert(layer instanceof Layer); - assert(doc.layers.item('foo') == layer); + assert(doc.layers.item("foo") === layer); }, testClear: function(b) { b.doc(); b.layer("fancy"); - b.ellipse(20,20,20,20); + b.ellipse(20, 20, 20, 20); + assert(b.doc().allPageItems.length === 1); + b.clear(b.layer("fancy")); + assert(b.doc().allPageItems.length === 0); + b.ellipse(20, 20, 20, 20); + assert(b.doc().allPageItems.length === 1); + b.clear(b.page()); + assert(b.doc().allPageItems.length === 0); + b.ellipse(20, 20, 20, 20); assert(b.doc().allPageItems.length === 1); - b.clear(b.layer("fancy")); - assert(b.doc().allPageItems.length === 0); - b.ellipse(20,20,20,20); - assert(b.doc().allPageItems.length === 1); - b.clear(b.page()); - assert(b.doc().allPageItems.length === 0); - b.ellipse(20,20,20,20); - assert(b.doc().allPageItems.length === 1); b.clear(b.doc()); - assert(b.doc().allPageItems.length === 0); + assert(b.doc().allPageItems.length === 0); // b.clearSwatches(); - + }, testRemove: function(b) { @@ -214,22 +214,22 @@ b.test('EnvironmentTests', { assert(obj.isValid); b.remove(obj); assert(!obj.isValid); - - var obj = b.color(255,255,255); + + obj = b.color(255, 255, 255); assert(obj.isValid); b.remove(obj); assert(!obj.isValid); - - var obj = b.layer("fancy"); + + obj = b.layer("fancy"); assert(obj.isValid); b.remove(obj); assert(!obj.isValid); - - var obj = b.addPage(); + + obj = b.addPage(); assert(obj.isValid); b.remove(obj); assert(!obj.isValid); - + }, testForEachItems: function(b) { @@ -238,69 +238,80 @@ b.test('EnvironmentTests', { b.page(); b.layer("fancy"); - b.ellipse(20,20,20,20); - b.ellipse(40,70,20,20); - + b.ellipse(20, 20, 20, 20); + b.ellipse(40, 70, 20, 20); + var result2, result3; + var result1 = result2 = result3 = 0; - + // process all items on a layer - b.items( b.layer("fancy"), function( item, n ) { - result1++; - } + b.items(b.layer("fancy"), function(item, n) { + result1++; + } ); - + // process all items on a page - b.items( b.page(), function( item, n ) { - result2++; - } + b.items(b.page(), function(item, n) { + result2++; + } ); - + // process all items in document - b.items( b.doc(), function( item, n ) { - result3++; - } + b.items(b.doc(), function(item, n) { + result3++; + } ); - - assert( result1 === 2 && result2 === 2 && result3 === 2 ); + + assert(result1 === 2 && result2 === 2 && result3 === 2); }, testCollectionGetters: function (b) { b.doc(); b.page(); - var obj = b.text("Hello Basil!", 0,0,100,100); + var obj = b.text("Hello Basil!", 0, 0, 100, 100); // process all items on a layer - var arr = b.characters( obj ); + var arr = b.characters(obj); assert(arr instanceof Characters); var counter = 0; - b.characters(obj, function(){counter++;}); + b.characters(obj, function() { + counter++; + }); assert(counter === 12); - - var arr = b.words( obj ); + + arr = b.words(obj); assert(arr instanceof Words); - counter = 0; - b.words(obj, function(){counter++;}); + counter = 0; + b.words(obj, function() { + counter++; + }); assert(counter === 2); - - var arr = b.lines( obj ); + + arr = b.lines(obj); assert(arr instanceof Lines); - counter = 0; - b.lines(obj, function(){counter++;}); + counter = 0; + b.lines(obj, function() { + counter++; + }); assert(counter === 1); - - var arr = b.paragraphs( obj ); + + arr = b.paragraphs(obj); assert(arr instanceof Paragraphs); - counter = 0; - b.paragraphs(obj, function(){counter++;}); + counter = 0; + b.paragraphs(obj, function() { + counter++; + }); assert(counter === 1); - - var arr = b.stories( b.doc() ); + + arr = b.stories(b.doc()); assert(arr instanceof Stories); - counter = 0; - b.stories(b.doc(), function(){counter++;}); + counter = 0; + b.stories(b.doc(), function() { + counter++; + }); assert(counter === 1); - + } }); From 88ec629f26b00a91630568a7cbbcddbf5e7a102c Mon Sep 17 00:00:00 2001 From: fabianmoronzirfas Date: Wed, 21 Dec 2016 10:35:25 +0100 Subject: [PATCH 7/9] style(linting): whitespace only --- test/arc-tests.jsx | 2 +- test/benchmarks/line_over_word.jsx | 6 +++--- test/color-tests.jsx | 2 +- test/conversion-tests.jsx | 6 +++--- test/environment-tests.jsx | 11 +++++----- test/group-tests.jsx | 12 +++++------ test/input-tests.jsx | 2 +- test/math-tests.jsx | 32 +++++++++++++++--------------- test/string-tests.jsx | 2 +- test/transform-tests.jsx | 2 +- 10 files changed, 39 insertions(+), 38 deletions(-) diff --git a/test/arc-tests.jsx b/test/arc-tests.jsx index d2cd7baf..9c416da7 100644 --- a/test/arc-tests.jsx +++ b/test/arc-tests.jsx @@ -44,7 +44,7 @@ b.test('ArcTests', { lastAngle += b.radians(angles[i]); } } - + } }); diff --git a/test/benchmarks/line_over_word.jsx b/test/benchmarks/line_over_word.jsx index 07045445..071d103e 100644 --- a/test/benchmarks/line_over_word.jsx +++ b/test/benchmarks/line_over_word.jsx @@ -24,16 +24,16 @@ function draw() { } function textLines(){ - // build textframe with lorem text to margin, + // build textframe with lorem text to margin, b.canvasMode(b.MARGIN); b.layer(textLayer); b.textSize(textSize); var myTextFrame = b.text(" ",0,0,b.width,b.height); - app.documents[0].stories.everyItem().hyphenation = false; + app.documents[0].stories.everyItem().hyphenation = false; myTextFrame.contents = TextFrameContents.placeholderText; // run function with fullpage mode - b.canvasMode(b.PAGE); + b.canvasMode(b.PAGE); b.layer(lineLayer); b.paragraphs(myTextFrame, function(p,n){ p.hyphenation = false; diff --git a/test/color-tests.jsx b/test/color-tests.jsx index ef60bc87..e08f82cf 100644 --- a/test/color-tests.jsx +++ b/test/color-tests.jsx @@ -16,7 +16,7 @@ b.test('ColorTests', { }, tearDown: function(b) { - b.close(SaveOptions.no); + b.close(SaveOptions.no); }, testDefaultColors: function(b) { diff --git a/test/conversion-tests.jsx b/test/conversion-tests.jsx index f45ed172..1e64fdfe 100644 --- a/test/conversion-tests.jsx +++ b/test/conversion-tests.jsx @@ -25,10 +25,10 @@ b.test('ConversionTests', { var i = 1234; var j = 762387452; var k = -2034856; - + assert( b.unhex(b.hex(i)) == i - && b.unhex(b.hex(j)) == j - && b.unhex(b.hex(k)) == k); + && b.unhex(b.hex(j)) == j + && b.unhex(b.hex(k)) == k); } diff --git a/test/environment-tests.jsx b/test/environment-tests.jsx index deff22a4..a5ae655f 100644 --- a/test/environment-tests.jsx +++ b/test/environment-tests.jsx @@ -1,11 +1,12 @@ -if (typeof b === 'undefined') { - //@include "../basil.js"; +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; } -if (typeof b.test === 'undefined') { - //@include "../lib/basil.test.js"; +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; } -b.test('EnvironmentTests', { +b.test("EnvironmentTests", { setUpTest: function(b) { }, diff --git a/test/group-tests.jsx b/test/group-tests.jsx index 7364e797..6dab3b20 100644 --- a/test/group-tests.jsx +++ b/test/group-tests.jsx @@ -16,26 +16,26 @@ b.test('GroupTests', { }, tearDown: function(b) { - b.close(SaveOptions.no); + b.close(SaveOptions.no); }, - + testCreateGroup: function(b) { - + b.doc(); // create array of objects var arr = []; arr.push(b.ellipse( 20, 20, 20, 20 )); - arr.push(b.rect( 60, 20, 20, 20 )); - arr.push(b.rect( 100, 20, 20, 20 )); + arr.push(b.rect( 60, 20, 20, 20 )); + arr.push(b.rect( 100, 20, 20, 20 )); // group them and modify group var circles = b.group(arr, 'rects'); assert( circles instanceof Group ); assert( circles.pageItems.length === 3 ); - + // get the bounds of our Group // ungroup our selected items diff --git a/test/input-tests.jsx b/test/input-tests.jsx index a11de2c0..56c9c450 100644 --- a/test/input-tests.jsx +++ b/test/input-tests.jsx @@ -26,7 +26,7 @@ b.test('InputTests', { textFrame1.label = label; var found = b.labels(label); - + assert(found.length === 1); assert(found[0] instanceof TextFrame); }, diff --git a/test/math-tests.jsx b/test/math-tests.jsx index 91c79988..669a7a47 100644 --- a/test/math-tests.jsx +++ b/test/math-tests.jsx @@ -1,47 +1,47 @@ if (typeof b === 'undefined') { - #include "../basil.js"; + //@include "../basil.js"; } if (typeof b.test === 'undefined') { - #include "../lib/basil.test.js"; + //@include "../lib/basil.test.js"; } b.test('MathTests', { testRandomWithNoArgs: function(b) { var rand = b.random(); - + assert(rand > 0 && rand < 1); }, testRandomWithOneArg: function(b) { var rand = b.random(5); - + assert(rand > 0 && rand < 5); }, testRandomWithTwoArgs: function(b) { var rand = b.random(-5, 10.2); - + assert(rand > -5 && rand < 10.2); }, testRandomWithMoreThanTwoArgsIgnoresLastArgs: function(b) { var rand = b.random(-5, 10.2, 2, 54, 34.5, 324); - + assert(rand > -5 && rand < 10.2); }, testConstrain: function(b) { - + assert(b.constrain(100, 0, 200) === 100); - assert(b.constrain(200, 0, 200) === 200); - assert(b.constrain(0, 0, 200) === 0); - assert(b.constrain(201, 0, 200) === 200); - assert(b.constrain(2000000000000000000000, 0, 200) === 200); - assert(b.constrain(-1, 0, 200) === 0); - assert(b.constrain(-100000000000000000000, 0, 200) === 0); - assert(b.constrain(-0.12387918263, 0, 200) === 0); - assert(b.constrain(200234.123123123123, 0, 200) === 200); - + assert(b.constrain(200, 0, 200) === 200); + assert(b.constrain(0, 0, 200) === 0); + assert(b.constrain(201, 0, 200) === 200); + assert(b.constrain(2000000000000000000000, 0, 200) === 200); + assert(b.constrain(-1, 0, 200) === 0); + assert(b.constrain(-100000000000000000000, 0, 200) === 0); + assert(b.constrain(-0.12387918263, 0, 200) === 0); + assert(b.constrain(200234.123123123123, 0, 200) === 200); + } }); diff --git a/test/string-tests.jsx b/test/string-tests.jsx index 22ea1200..cad190ee 100644 --- a/test/string-tests.jsx +++ b/test/string-tests.jsx @@ -23,7 +23,7 @@ b.test('EnvironmentTests', { testSplitJoin: function(b) { var doc = b.doc(); var str = "hello world how are you, my dear?"; - assert( b.join(b.split(str, " "), " ") === str ); + assert( b.join(b.split(str, " "), " ") === str ); } diff --git a/test/transform-tests.jsx b/test/transform-tests.jsx index d6913d63..fad4d6a5 100644 --- a/test/transform-tests.jsx +++ b/test/transform-tests.jsx @@ -1 +1 @@ -if (typeof b === 'undefined') { #include "../basil.js"; } if (typeof b.test === 'undefined') { #include "../lib/basil.test.js"; } b.test('TransformTests', { setUpTest: function(b) { }, tearDownTest: function(b) { }, setUp: function(b) { }, tearDown: function(b) { b.close(SaveOptions.no); }, testMoveX: function(b) { b.rectMode(b.CORNER); var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemX(rect) === 0); // move to 50,0 b.itemX(rect, 50); // check new x coordinate assert( b.itemX(rect) === 50); rect.remove(); //~ b.rectMode(b.CENTER); //~ // create box at 0,0 //~ var rect = b.rect(0,0,100,100); //~ //~ assert( b.itemX(rect) === 0); //~ // move to 50,0 //~ b.itemX(rect, 50); //~ // check new x coordinate //~ assert( b.itemX(rect) === 50); //~ rect.remove(); }, testMoveY: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemY(rect) === 0); // move to 50,0 b.itemY(rect, 50); // check new x coordinate assert( b.itemY(rect) === 50); }, testPosition: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemPosition(rect).x === 0 && b.itemPosition(rect).y === 0); // move to 50,0 b.itemPosition(rect, 50, 50); // check new x coordinate assert( b.itemPosition(rect).x === 50 && b.itemPosition(rect).y === 50); }, testWidth: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemWidth(rect) === 100 ); // move to 50,0 b.itemWidth(rect, 50); // check new x coordinate assert( b.itemWidth(rect) === 50 ); }, testHeight: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemHeight(rect) === 100 ); // move to 50,0 b.itemHeight(rect, 50); // check new x coordinate assert( b.itemHeight(rect) === 50 ); }, testSize: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemSize(rect).width === 100 && b.itemSize(rect).height === 100 ); // move to 50,0 b.itemSize(rect, 50, 50); // check new x coordinate assert( b.itemSize(rect).width === 50 && b.itemSize(rect).height === 50 ); } // todo: add matrix transformation tests here ... }); // print collected test results b.test.result(); \ No newline at end of file +if (typeof b === 'undefined') { //@include "../basil.js"; } if (typeof b.test === 'undefined') { //@include "../lib/basil.test.js"; } b.test('TransformTests', { setUpTest: function(b) { }, tearDownTest: function(b) { }, setUp: function(b) { }, tearDown: function(b) { b.close(SaveOptions.no); }, testMoveX: function(b) { b.rectMode(b.CORNER); var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemX(rect) === 0); // move to 50,0 b.itemX(rect, 50); // check new x coordinate assert( b.itemX(rect) === 50); rect.remove(); //~ b.rectMode(b.CENTER); //~ // create box at 0,0 //~ var rect = b.rect(0,0,100,100); //~ //~ assert( b.itemX(rect) === 0); //~ // move to 50,0 //~ b.itemX(rect, 50); //~ // check new x coordinate //~ assert( b.itemX(rect) === 50); //~ rect.remove(); }, testMoveY: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemY(rect) === 0); // move to 50,0 b.itemY(rect, 50); // check new x coordinate assert( b.itemY(rect) === 50); }, testPosition: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemPosition(rect).x === 0 && b.itemPosition(rect).y === 0); // move to 50,0 b.itemPosition(rect, 50, 50); // check new x coordinate assert( b.itemPosition(rect).x === 50 && b.itemPosition(rect).y === 50); }, testWidth: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemWidth(rect) === 100 ); // move to 50,0 b.itemWidth(rect, 50); // check new x coordinate assert( b.itemWidth(rect) === 50 ); }, testHeight: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemHeight(rect) === 100 ); // move to 50,0 b.itemHeight(rect, 50); // check new x coordinate assert( b.itemHeight(rect) === 50 ); }, testSize: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemSize(rect).width === 100 && b.itemSize(rect).height === 100 ); // move to 50,0 b.itemSize(rect, 50, 50); // check new x coordinate assert( b.itemSize(rect).width === 50 && b.itemSize(rect).height === 50 ); } // todo: add matrix transformation tests here ... }); // print collected test results b.test.result(); \ No newline at end of file From 02f0279271f6750783b064800f2804edffcdaf99 Mon Sep 17 00:00:00 2001 From: fabianmoronzirfas Date: Wed, 21 Dec 2016 10:53:04 +0100 Subject: [PATCH 8/9] style(linting): linted the hell out of it all test passing --- test/all-tests.jsx | 26 ++--- test/arc-tests.jsx | 23 ++-- test/benchmarks/clearItems.jsx | 28 ++--- test/benchmarks/line_over_word.jsx | 70 ++++++------ test/benchmarks/pages with text + lines.jsx | 24 +++-- test/color-tests.jsx | 47 +++++---- test/conversion-tests.jsx | 20 ++-- test/group-tests.jsx | 29 ++--- test/input-tests.jsx | 23 ++-- test/loop/loop.jsx | 4 +- test/math-tests.jsx | 11 +- test/string-tests.jsx | 16 ++- test/transform-tests.jsx | 2 +- test/typography-tests.jsx | 111 ++++++++++---------- test/visual/canvasModes.jsx | 4 - 15 files changed, 218 insertions(+), 220 deletions(-) diff --git a/test/all-tests.jsx b/test/all-tests.jsx index 68eb987e..1a8477ce 100644 --- a/test/all-tests.jsx +++ b/test/all-tests.jsx @@ -1,14 +1,14 @@ -//@include "../basil.js"; -//@include "../lib/basil.test.js"; +// @include "../basil.js"; +// @include "../lib/basil.test.js"; -//@include "typography-tests.jsx"; -//@include "transform-tests.jsx"; -//@include "conversion-tests.jsx"; -//@include "data-tests.jsx"; -//@include "environment-tests.jsx"; -//@include "input-tests.jsx"; -//@include "math-tests.jsx"; -//@include "string-tests.jsx"; -//@include "color-tests.jsx"; -//@include "vertex-tests.jsx"; -//@include "group-tests.jsx"; \ No newline at end of file +// @include "typography-tests.jsx"; +// @include "transform-tests.jsx"; +// @include "conversion-tests.jsx"; +// @include "data-tests.jsx"; +// @include "environment-tests.jsx"; +// @include "input-tests.jsx"; +// @include "math-tests.jsx"; +// @include "string-tests.jsx"; +// @include "color-tests.jsx"; +// @include "vertex-tests.jsx"; +// @include "group-tests.jsx"; diff --git a/test/arc-tests.jsx b/test/arc-tests.jsx index 9c416da7..ca78b501 100644 --- a/test/arc-tests.jsx +++ b/test/arc-tests.jsx @@ -1,11 +1,11 @@ -if (typeof b === 'undefined') { - //@include "../basil.js"; +if (typeof b === "undefined") { + // @include "../basil.js"; } -if (typeof b.test === 'undefined') { - //@include "../lib/basil.test.js"; +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; } -b.test('ArcTests', { +b.test("ArcTests", { setUpTest: function(b) { }, @@ -25,26 +25,23 @@ b.test('ArcTests', { b.arc(50, 55, 50, 50, 0, b.HALF_PI); b.noFill(); b.arc(50, 55, 60, 60, b.HALF_PI, b.PI); - b.arc(50, 55, 70, 70, b.PI, b.PI+b.QUARTER_PI); - b.arc(50, 55, 80, 80, b.PI+b.QUARTER_PI, b.TWO_PI); + b.arc(50, 55, 70, 70, b.PI, b.PI + b.QUARTER_PI); + b.arc(50, 55, 80, 80, b.PI + b.QUARTER_PI, b.TWO_PI); }, testPieChart: function(b) { // http://processing.org/examples/piechart.html - var angles = [ 30, 10, 45, 35, 60, 38, 75, 67 ]; - - pieChart(300, angles); - + var angles = [30, 10, 45, 35, 60, 38, 75, 67]; function pieChart(diameter, data) { var lastAngle = 0; for (var i = 0; i < data.length; i++) { var gray = b.map(i, 0, data.length, 0, 255); b.fill(gray); - b.arc(b.width/2, b.height/2, diameter, diameter, lastAngle, lastAngle+b.radians(angles[i])); + b.arc(b.width / 2, b.height / 2, diameter, diameter, lastAngle, lastAngle + b.radians(angles[i])); lastAngle += b.radians(angles[i]); } } - + pieChart(300, angles); } }); diff --git a/test/benchmarks/clearItems.jsx b/test/benchmarks/clearItems.jsx index 9d0c69f3..70a06b60 100644 --- a/test/benchmarks/clearItems.jsx +++ b/test/benchmarks/clearItems.jsx @@ -1,4 +1,4 @@ -//@include "../../basil.js"; +// @include "../../basil.js"; function draw() { @@ -10,43 +10,43 @@ function draw() { var x, y; var count = 500; - + var layer = null; for (var i = 0; i < count * 2; i += 1) { x = b.random(b.width); y = b.random(b.height); b.ellipse(x, y, 50, 50); if(i === count - 1) { - var layer = b.layer("Layer 2"); + layer = b.layer("Layer 2"); } - }; - + } + var group = null; var page = b.addPage(); - for (var i = 0; i < count * 2; i += 1) { + for (var j = 0; j < count * 2; j += 1) { x = b.random(b.width); y = b.random(b.height); b.ellipse(x, y, 50, 50); - if(i === count - 1) { - var group = b.group(b.items(b.page())); + if(j === count - 1) { + group = b.group(b.items(b.page())); } - }; + } var time = b.millis(); b.clear(group); - b.println("Clearing " + count + " grouped items: " + ((b.millis() - time)/1000) + " seconds."); + b.println("Clearing " + count + " grouped items: " + ((b.millis() - time) / 1000) + " seconds."); time = b.millis(); b.clear(page); - b.println("Clearing " + count + " items on page: " + ((b.millis() - time)/1000) + " seconds."); + b.println("Clearing " + count + " items on page: " + ((b.millis() - time) / 1000) + " seconds."); b.page(1); time = b.millis(); b.clear(layer); - b.println("Clearing " + count + " items on layer: " + ((b.millis() - time)/1000) + " seconds."); + b.println("Clearing " + count + " items on layer: " + ((b.millis() - time) / 1000) + " seconds."); time = b.millis(); b.clear(doc); - b.println("Clearing " + count + " items in document: " + ((b.millis() - time)/1000) + " seconds."); + b.println("Clearing " + count + " items in document: " + ((b.millis() - time) / 1000) + " seconds."); } -b.go(); \ No newline at end of file +b.go(); diff --git a/test/benchmarks/line_over_word.jsx b/test/benchmarks/line_over_word.jsx index 071d103e..c082a109 100644 --- a/test/benchmarks/line_over_word.jsx +++ b/test/benchmarks/line_over_word.jsx @@ -1,61 +1,63 @@ -//@include "../../basil.js"; +/* eslint-disable no-undefined */ +// @include "../../basil.js"; var numPages = 2; var textSize = 30; var textLayer = null; var lineLayer = null; -function setup() { - textLayer = b.layer("text"); - lineLayer = b.layer("lines"); -} - -function draw() { - var pageTime = 0; - for(var i = 0; i < numPages; i++){ - textLines(); - if(i < numPages-1){ - b.addPage(); - } - b.println("page " + (i + 1) + " took " + ((b.millis() - pageTime)/1000) + " seconds to process"); - pageTime = b.millis(); - } - textLayer.visible = false; -} - -function textLines(){ +function textLines() { // build textframe with lorem text to margin, b.canvasMode(b.MARGIN); b.layer(textLayer); b.textSize(textSize); - var myTextFrame = b.text(" ",0,0,b.width,b.height); + var myTextFrame = b.text(" ", 0, 0, b.width, b.height); app.documents[0].stories.everyItem().hyphenation = false; myTextFrame.contents = TextFrameContents.placeholderText; // run function with fullpage mode b.canvasMode(b.PAGE); b.layer(lineLayer); - b.paragraphs(myTextFrame, function(p,n){ + b.paragraphs(myTextFrame, function(p, n) { p.hyphenation = false; - b.lines(p, function(l,m){ + b.lines(p, function(l, m) { var wbp; // temp bounds - b.words(l, function(w,o){ + b.words(l, function(w, o) { var wb = b.bounds(w); - if(wbp == undefined){ - b.line(0,wb.bottom,wb.left,wb.bottom); + if(wbp === undefined) { + b.line(0, wb.bottom, wb.left, wb.bottom); }else{ - b.line(wbp.right,wb.bottom,wb.left,wb.bottom); + b.line(wbp.right, wb.bottom, wb.left, wb.bottom); } - b.line(wb.left,wb.bottom,wb.left,wb.top); - b.line(wb.left,wb.top,wb.right,wb.top); - b.line(wb.right,wb.top,wb.right,wb.bottom); + b.line(wb.left, wb.bottom, wb.left, wb.top); + b.line(wb.left, wb.top, wb.right, wb.top); + b.line(wb.right, wb.top, wb.right, wb.bottom); wbp = wb; }); - b.line(wbp.right,wbp.bottom,b.width,wbp.bottom); // last to right edge + b.line(wbp.right, wbp.bottom, b.width, wbp.bottom); // last to right edge }); }); } -//b.go(b.MODEHIDDEN); -//b.go(b.MODESILENT); -b.go(); \ No newline at end of file +function setup() { + textLayer = b.layer("text"); + lineLayer = b.layer("lines"); +} + +function draw() { + var pageTime = 0; + for(var i = 0; i < numPages; i++) { + textLines(); + if(i < numPages - 1) { + b.addPage(); + } + b.println("page " + (i + 1) + " took " + ((b.millis() - pageTime) / 1000) + " seconds to process"); + pageTime = b.millis(); + } + textLayer.visible = false; +} + + +// b.go(b.MODEHIDDEN); +// b.go(b.MODESILENT); +b.go(); diff --git a/test/benchmarks/pages with text + lines.jsx b/test/benchmarks/pages with text + lines.jsx index fb6efce5..920546db 100644 --- a/test/benchmarks/pages with text + lines.jsx +++ b/test/benchmarks/pages with text + lines.jsx @@ -1,30 +1,32 @@ -//@include "../../basil.js"; +// @include "../../basil.js"; var pageCount = 5; function draw() { // create long lorem ipsum string - var lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. '; + var lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "; for (var i = 0; i < 10; i++) { lorem += lorem; - }; + } b.strokeWeight(1); - b.stroke(255,255,0); + b.stroke(255, 255, 0); b.textSize(40); - for (var i = 0; i < pageCount; i++) { - var textFrame = b.text(lorem, 0,0, b.width, b.height); - b.words(textFrame, function(word,wi){ + for (var j = 0; j < pageCount; j++) { + var textFrame = b.text(lorem, 0, 0, b.width, b.height); + b.words(textFrame, function(word, wi) { var bounds = b.bounds(word); if (wi % 7 === 0) { - b.rect(bounds.left,bounds.top,bounds.width,bounds.height); + b.rect(bounds.left, bounds.top, bounds.width, bounds.height); } else { - b.line(0,0,bounds.left,bounds.bottom); + b.line(0, 0, bounds.left, bounds.bottom); } }); - if (i !== pageCount-1) b.addPage(); - }; + if (j !== pageCount - 1) { + b.addPage(); + } + } } b.go(); diff --git a/test/color-tests.jsx b/test/color-tests.jsx index e08f82cf..5742041d 100644 --- a/test/color-tests.jsx +++ b/test/color-tests.jsx @@ -1,11 +1,12 @@ -if (typeof b === 'undefined') { - //@include "../basil.js"; +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; } -if (typeof b.test === 'undefined') { - //@include "../lib/basil.test.js"; +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; } -b.test('ColorTests', { +b.test("ColorTests", { setUpTest: function(b) { }, @@ -21,8 +22,8 @@ b.test('ColorTests', { testDefaultColors: function(b) { var doc = b.doc(); - var rect = b.rect(0,0,100,100); - var black = b.color('Black'); + var rect = b.rect(0, 0, 100, 100); + var black = b.color("Black"); assert(black instanceof Color); assert(rect.fillColor.colorValue.toString() === black.colorValue.toString()); @@ -32,8 +33,8 @@ b.test('ColorTests', { testCreateRGBColor: function(b) { var doc = b.doc(); b.colorMode(b.RGB); - var red = b.color(255,2,3); - var green = b.color(0,255,0,"green"); + var red = b.color(255, 2, 3); + var green = b.color(0, 255, 0, "green"); var rgbGrey = b.color(128); assert(red instanceof Color); @@ -55,9 +56,9 @@ b.test('ColorTests', { testCreateCMYKColor: function(b) { var doc = b.doc(); b.colorMode(b.CMYK); - var magenta = b.color(1,100,3,4); - var yellow = b.color(0,0,100,0,"yellow"); - var cmykGrey = b.color(80,"light grey"); + var magenta = b.color(1, 100, 3, 4); + var yellow = b.color(0, 0, 100, 0, "yellow"); + var cmykGrey = b.color(80, "light grey"); assert(magenta instanceof Color); assert(yellow instanceof Color); @@ -80,20 +81,20 @@ b.test('ColorTests', { var doc = b.doc(); b.colorMode(b.RGB); var swatchCountStart = doc.swatches.length; - var red = b.color(56,2,3); - var green = b.color(0,255,0,"a color with a name"); + var red = b.color(56, 2, 3); + var green = b.color(0, 255, 0, "a color with a name"); var rgbGrey = b.color(50); var swatchCountEnd = doc.swatches.length; - assert((swatchCountStart+3) === swatchCountEnd); + assert((swatchCountStart + 3) === swatchCountEnd); }, testAddColorToSwatchesAndGetIt: function(b) { var doc = b.doc(); b.colorMode(b.RGB); - var red = b.color(56,2,3,"red"); - var green = b.color(1,255,3,"green"); - var grey = b.color(50,"grey"); + var red = b.color(56, 2, 3, "red"); + var green = b.color(1, 255, 3, "green"); + var grey = b.color(50, "grey"); var greenSwatch = doc.swatches.item("green"); assert(b.color("green") === green); @@ -107,9 +108,9 @@ b.test('ColorTests', { testCreateGradient: function(b) { var doc = b.doc(); - var red = b.color(255,0,0); - var green = b.color(0,255,0); - var blue = b.color(0,0,255); + var red = b.color(255, 0, 0); + var green = b.color(0, 255, 0); + var blue = b.color(0, 0, 255); var redBlue = b.gradient(red, blue); var multiStop = b.gradient([red, green, blue, red, green]); @@ -162,8 +163,8 @@ b.test('ColorTests', { var bwb = b.gradient([black, white, black]); var swatchCountEnd = doc.swatches.length; - assert((swatchCountStart+3) === swatchCountEnd); + assert((swatchCountStart + 3) === swatchCountEnd); } }); -b.test.result(); \ No newline at end of file +b.test.result(); diff --git a/test/conversion-tests.jsx b/test/conversion-tests.jsx index 1e64fdfe..03a7446f 100644 --- a/test/conversion-tests.jsx +++ b/test/conversion-tests.jsx @@ -1,11 +1,12 @@ -if (typeof b === 'undefined') { - //@include "../basil.js"; +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; } -if (typeof b.test === 'undefined') { - //@include "../lib/basil.test.js"; +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; } -b.test('ConversionTests', { +b.test("ConversionTests", { setUpTest: function(b) { }, @@ -26,13 +27,10 @@ b.test('ConversionTests', { var j = 762387452; var k = -2034856; - assert( b.unhex(b.hex(i)) == i - && b.unhex(b.hex(j)) == j - && b.unhex(b.hex(k)) == k); + assert(b.unhex(b.hex(i)) === i + && b.unhex(b.hex(j)) === j + && b.unhex(b.hex(k)) === k); } - - - }); // print collected test results diff --git a/test/group-tests.jsx b/test/group-tests.jsx index 6dab3b20..db92caeb 100644 --- a/test/group-tests.jsx +++ b/test/group-tests.jsx @@ -1,11 +1,12 @@ -if (typeof b === 'undefined') { - //@include "../basil.js"; +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; } -if (typeof b.test === 'undefined') { - //@include "../lib/basil.test.js"; +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; } -b.test('GroupTests', { +b.test("GroupTests", { setUpTest: function(b) { }, @@ -26,25 +27,25 @@ b.test('GroupTests', { // create array of objects var arr = []; - arr.push(b.ellipse( 20, 20, 20, 20 )); - arr.push(b.rect( 60, 20, 20, 20 )); - arr.push(b.rect( 100, 20, 20, 20 )); + arr.push(b.ellipse(20, 20, 20, 20)); + arr.push(b.rect(60, 20, 20, 20)); + arr.push(b.rect(100, 20, 20, 20)); // group them and modify group - var circles = b.group(arr, 'rects'); + var circles = b.group(arr, "rects"); - assert( circles instanceof Group ); - assert( circles.pageItems.length === 3 ); + assert(circles instanceof Group); + assert(circles.pageItems.length === 3); // get the bounds of our Group // ungroup our selected items - var items = b.ungroup( 'rects' ); - assert( items.length === 3 ); + var items = b.ungroup("rects"); + assert(items.length === 3); } - }); +}); // print collected test results b.test.result(); diff --git a/test/input-tests.jsx b/test/input-tests.jsx index 56c9c450..3bcc9646 100644 --- a/test/input-tests.jsx +++ b/test/input-tests.jsx @@ -1,11 +1,12 @@ -if (typeof b === 'undefined') { - //@include "../basil.js"; +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; } -if (typeof b.test === 'undefined') { - //@include "../lib/basil.test.js"; +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; } -b.test('InputTests', { +b.test("InputTests", { setUpTest: function(b) { }, @@ -21,8 +22,8 @@ b.test('InputTests', { }, testFindByLabel: function(b) { - var label = 'foo'; - var textFrame1 = b.text('foo', 0, 0, 300, 300); + var label = "foo"; + var textFrame1 = b.text("foo", 0, 0, 300, 300); textFrame1.label = label; var found = b.labels(label); @@ -32,10 +33,10 @@ b.test('InputTests', { }, testFindByLabelWithMultipleItemsWithSameLabel: function(b) { - var label = 'foo'; - var textFrame1 = b.text('foo', 0, 0, 300, 300); + var label = "foo"; + var textFrame1 = b.text("foo", 0, 0, 300, 300); textFrame1.label = label; - var textFrame2 = b.text('bar', 0, 0, 300, 300); + var textFrame2 = b.text("bar", 0, 0, 300, 300); textFrame2.label = label; var found = b.labels(label); @@ -45,7 +46,7 @@ b.test('InputTests', { testFindByLabelWithNotExistingLabel: function(b) { try{ - var found = b.labels('bar'); + var found = b.labels("bar"); } catch (e) { assert(true); } diff --git a/test/loop/loop.jsx b/test/loop/loop.jsx index 45a66b9c..2e216caa 100644 --- a/test/loop/loop.jsx +++ b/test/loop/loop.jsx @@ -1,5 +1,5 @@ -//@targetengine "loop"; -//@include "./basil.js"; +// @targetengine "loop"; +// @include "./basil.js"; var x = 0; var y = 0; function setup() { diff --git a/test/math-tests.jsx b/test/math-tests.jsx index 669a7a47..6d4d9f82 100644 --- a/test/math-tests.jsx +++ b/test/math-tests.jsx @@ -1,11 +1,12 @@ -if (typeof b === 'undefined') { - //@include "../basil.js"; +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; } -if (typeof b.test === 'undefined') { - //@include "../lib/basil.test.js"; +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; } -b.test('MathTests', { +b.test("MathTests", { testRandomWithNoArgs: function(b) { var rand = b.random(); diff --git a/test/string-tests.jsx b/test/string-tests.jsx index cad190ee..b538dae0 100644 --- a/test/string-tests.jsx +++ b/test/string-tests.jsx @@ -1,11 +1,12 @@ -if (typeof b === 'undefined') { - //@include "../basil.js"; +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; } -if (typeof b.test === 'undefined') { - //@include "../lib/basil.test.js"; +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; } -b.test('EnvironmentTests', { +b.test("EnvironmentTests", { setUpTest: function(b) { }, @@ -23,11 +24,8 @@ b.test('EnvironmentTests', { testSplitJoin: function(b) { var doc = b.doc(); var str = "hello world how are you, my dear?"; - assert( b.join(b.split(str, " "), " ") === str ); + assert(b.join(b.split(str, " "), " ") === str); } - - - }); // print collected test results diff --git a/test/transform-tests.jsx b/test/transform-tests.jsx index fad4d6a5..990cd7ef 100644 --- a/test/transform-tests.jsx +++ b/test/transform-tests.jsx @@ -1 +1 @@ -if (typeof b === 'undefined') { //@include "../basil.js"; } if (typeof b.test === 'undefined') { //@include "../lib/basil.test.js"; } b.test('TransformTests', { setUpTest: function(b) { }, tearDownTest: function(b) { }, setUp: function(b) { }, tearDown: function(b) { b.close(SaveOptions.no); }, testMoveX: function(b) { b.rectMode(b.CORNER); var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemX(rect) === 0); // move to 50,0 b.itemX(rect, 50); // check new x coordinate assert( b.itemX(rect) === 50); rect.remove(); //~ b.rectMode(b.CENTER); //~ // create box at 0,0 //~ var rect = b.rect(0,0,100,100); //~ //~ assert( b.itemX(rect) === 0); //~ // move to 50,0 //~ b.itemX(rect, 50); //~ // check new x coordinate //~ assert( b.itemX(rect) === 50); //~ rect.remove(); }, testMoveY: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemY(rect) === 0); // move to 50,0 b.itemY(rect, 50); // check new x coordinate assert( b.itemY(rect) === 50); }, testPosition: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemPosition(rect).x === 0 && b.itemPosition(rect).y === 0); // move to 50,0 b.itemPosition(rect, 50, 50); // check new x coordinate assert( b.itemPosition(rect).x === 50 && b.itemPosition(rect).y === 50); }, testWidth: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemWidth(rect) === 100 ); // move to 50,0 b.itemWidth(rect, 50); // check new x coordinate assert( b.itemWidth(rect) === 50 ); }, testHeight: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemHeight(rect) === 100 ); // move to 50,0 b.itemHeight(rect, 50); // check new x coordinate assert( b.itemHeight(rect) === 50 ); }, testSize: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0,0,100,100); assert( b.itemSize(rect).width === 100 && b.itemSize(rect).height === 100 ); // move to 50,0 b.itemSize(rect, 50, 50); // check new x coordinate assert( b.itemSize(rect).width === 50 && b.itemSize(rect).height === 50 ); } // todo: add matrix transformation tests here ... }); // print collected test results b.test.result(); \ No newline at end of file +/* globals assert */ if (typeof b === "undefined") { // @include "../basil.js"; } if (typeof b.test === "undefined") { // @include "../lib/basil.test.js"; } b.test("TransformTests", { setUpTest: function(b) { }, tearDownTest: function(b) { }, setUp: function(b) { }, tearDown: function(b) { b.close(SaveOptions.no); }, testMoveX: function(b) { b.rectMode(b.CORNER); var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemX(rect) === 0); // move to 50,0 b.itemX(rect, 50); // check new x coordinate assert(b.itemX(rect) === 50); rect.remove(); // ~ b.rectMode(b.CENTER); // ~ // create box at 0,0 // ~ var rect = b.rect(0,0,100,100); // ~ // ~ assert( b.itemX(rect) === 0); // ~ // move to 50,0 // ~ b.itemX(rect, 50); // ~ // check new x coordinate // ~ assert( b.itemX(rect) === 50); // ~ rect.remove(); }, testMoveY: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemY(rect) === 0); // move to 50,0 b.itemY(rect, 50); // check new x coordinate assert(b.itemY(rect) === 50); }, testPosition: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemPosition(rect).x === 0 && b.itemPosition(rect).y === 0); // move to 50,0 b.itemPosition(rect, 50, 50); // check new x coordinate assert(b.itemPosition(rect).x === 50 && b.itemPosition(rect).y === 50); }, testWidth: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemWidth(rect) === 100); // move to 50,0 b.itemWidth(rect, 50); // check new x coordinate assert(b.itemWidth(rect) === 50); }, testHeight: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemHeight(rect) === 100); // move to 50,0 b.itemHeight(rect, 50); // check new x coordinate assert(b.itemHeight(rect) === 50); }, testSize: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemSize(rect).width === 100 && b.itemSize(rect).height === 100); // move to 50,0 b.itemSize(rect, 50, 50); // check new x coordinate assert(b.itemSize(rect).width === 50 && b.itemSize(rect).height === 50); } // todo: add matrix transformation tests here ... }); // print collected test results b.test.result(); diff --git a/test/typography-tests.jsx b/test/typography-tests.jsx index 4b599ee1..26fdb923 100644 --- a/test/typography-tests.jsx +++ b/test/typography-tests.jsx @@ -1,8 +1,9 @@ -if (typeof b === "undefined") { - //@include "../basil.js"; +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; } if (typeof b.test === "undefined") { - //@include "../lib/basil.test.js"; + // @include "../lib/basil.test.js"; } b.test("TypographyTests", { @@ -10,7 +11,7 @@ b.test("TypographyTests", { layer: null, setUpTest: function(b) { - doc = app.documents.add(); + this.doc = app.documents.add(); }, tearDownTest: function(b) { @@ -18,8 +19,8 @@ b.test("TypographyTests", { }, setUp: function(b) { - doc = b.doc(); - layer = doc.layers.add({name: "test layer"}); + this.doc = b.doc(); + this.layer = this.doc.layers.add({name: "test layer"}); }, tearDown: function(b) { @@ -29,58 +30,58 @@ b.test("TypographyTests", { testWriteText: function(b) { var contents = "foo bar"; - b.doc(doc); + b.doc(this.doc); b.page(0); - b.layer(layer); + b.layer(this.layer); b.text(contents, 0, 0, 300, 300); - assert(layer.textFrames.length === 1); - assert(layer.textFrames[0].contents === contents); + assert(this.layer.textFrames.length === 1); + assert(this.layer.textFrames[0].contents === contents); }, testCreateMultipleTextFrames: function(b) { var contents1 = "foo bar", contents2 = "bar foo"; - b.doc(doc); + b.doc(this.doc); b.page(0); - b.layer(layer); + b.layer(this.layer); b.text(contents1, 0, 0, 300, 300); b.text(contents2, 50, 50, 300, 300); - assert(layer.textFrames.length === 2); - assert(layer.textFrames[0].contents !== layer.textFrames[1].contents); - assert(layer.textFrames[0].contents === contents1 || contents2); - assert(layer.textFrames[1].contents === contents1 || contents2); + assert(this.layer.textFrames.length === 2); + assert(this.layer.textFrames[0].contents !== this.layer.textFrames[1].contents); + assert(this.layer.textFrames[0].contents === contents1 || contents2); + assert(this.layer.textFrames[1].contents === contents1 || contents2); }, testWriteTextWithSpecialCharacters: function(b) { var contents = "Copyright: ©, Euro: €"; - b.doc(doc); + b.doc(this.doc); b.page(0); - b.layer(layer); + b.layer(this.layer); b.text(contents, 0, 0, 300, 300); - assert(layer.textFrames.length === 1); - assert(layer.textFrames[0].contents === contents); + assert(this.layer.textFrames.length === 1); + assert(this.layer.textFrames[0].contents === contents); }, testWriteTextWithCarriageReturns: function(b) { var contents = "foo\rbar\rfoobar"; - b.doc(doc); + b.doc(this.doc); b.page(0); - b.layer(layer); + b.layer(this.layer); b.text(contents, 0, 0, 300, 300); - assert(layer.textFrames.length === 1); - assert(layer.textFrames[0].contents === contents); - assert(layer.textFrames[0].contents.split("\r").length === 3); + assert(this.layer.textFrames.length === 1); + assert(this.layer.textFrames[0].contents === contents); + assert(this.layer.textFrames[0].contents.split("\r").length === 3); }, testGetAppliedFontFromTextFrame: function(b) { - b.doc(doc); + b.doc(this.doc); var textFrame = b.text("foo", 0, 0, 100, 100); var font = b.typo(textFrame, "appliedFont"); @@ -90,9 +91,9 @@ b.test("TypographyTests", { }, testSetPointSizeInTextFrame: function(b) { - b.doc(doc); - var textFrame = b.text("foo", 0, 0, 100, 100), - size = 36; + b.doc(this.doc); + var textFrame = b.text("foo", 0, 0, 100, 100); + var size = 36; b.typo(textFrame, "pointSize", size); @@ -102,9 +103,9 @@ b.test("TypographyTests", { }, testSetPointSizeInOverlownPara: function(b) { - b.doc(doc); - var textFrame = b.text("lorem ipsum dolor sit amet\rlorem ipsum dolor sit amet", 0, 0, 100, 30), - size = 30; + b.doc(this.doc); + var textFrame = b.text("lorem ipsum dolor sit amet\rlorem ipsum dolor sit amet", 0, 0, 100, 30); + var size = 30; b.typo(textFrame, "pointSize", size); @@ -115,31 +116,31 @@ b.test("TypographyTests", { }, testCreateEmptyStyles: function(b) { - b.doc(doc); + b.doc(this.doc); - var paraStyleCount = doc.paragraphStyles.length; - var charStyleCount = doc.characterStyles.length; - var objStyleCount = doc.objectStyles.length; + var paraStyleCount = this.doc.paragraphStyles.length; + var charStyleCount = this.doc.characterStyles.length; + var objStyleCount = this.doc.objectStyles.length; var paragraphStyle = b.paragraphStyle("emptyParagraphStyle"); var characterStyle = b.characterStyle("emptyCharacterStyle"); var objectStyle = b.objectStyle("emptyObjectStyle"); - assert(paraStyleCount + 1 === doc.paragraphStyles.length); - assert(charStyleCount + 1 === doc.characterStyles.length); - assert(objStyleCount + 1 === doc.objectStyles.length); + assert(paraStyleCount + 1 === this.doc.paragraphStyles.length); + assert(charStyleCount + 1 === this.doc.characterStyles.length); + assert(objStyleCount + 1 === this.doc.objectStyles.length); assert(paragraphStyle instanceof ParagraphStyle); assert(characterStyle instanceof CharacterStyle); assert(objectStyle instanceof ObjectStyle); - assert(doc.paragraphStyles.itemByName("emptyParagraphStyle").isValid); - assert(doc.characterStyles.itemByName("emptyCharacterStyle").isValid); - assert(doc.objectStyles.itemByName("emptyObjectStyle").isValid); + assert(this.doc.paragraphStyles.itemByName("emptyParagraphStyle").isValid); + assert(this.doc.characterStyles.itemByName("emptyCharacterStyle").isValid); + assert(this.doc.objectStyles.itemByName("emptyObjectStyle").isValid); }, testReturnExistingStyles: function(b) { - b.doc(doc); + b.doc(this.doc); // create empty styles on top level b.paragraphStyle("topParagraphStyle"); @@ -147,9 +148,9 @@ b.test("TypographyTests", { b.objectStyle("topObjectStyle"); // create styles nested in groups - doc.paragraphStyleGroups.add({name: "paraGroup"}).paragraphStyles.add({name: "nestedParagraphStyle"}); - doc.characterStyleGroups.add({name: "charGroup"}).characterStyles.add({name: "nestedCharacterStyle"}); - doc.objectStyleGroups.add({name: "objGroup"}).objectStyles.add({name: "nestedObjectStyle"}); + this.doc.paragraphStyleGroups.add({name: "paraGroup"}).paragraphStyles.add({name: "nestedParagraphStyle"}); + this.doc.characterStyleGroups.add({name: "charGroup"}).characterStyles.add({name: "nestedCharacterStyle"}); + this.doc.objectStyleGroups.add({name: "objGroup"}).objectStyles.add({name: "nestedObjectStyle"}); // get styles var topPara = b.paragraphStyle("topParagraphStyle"); @@ -175,7 +176,7 @@ b.test("TypographyTests", { }, testCreateStylesWithProps: function(b) { - b.doc(doc); + b.doc(this.doc); var paraCharProps = { baselineShift: 5, @@ -203,7 +204,7 @@ b.test("TypographyTests", { }, testUpdatePropsOfExistingStyles: function(b) { - b.doc(doc); + b.doc(this.doc); var paraCharProps = { baselineShift: 5, @@ -243,17 +244,17 @@ b.test("TypographyTests", { assert(charStyle.baselineShift === 20 && charStyle.strikeThru === false && charStyle.capitalization === Capitalization.SMALL_CAPS); assert(objStyle.strokeWeight === 20 && objStyle.nonprinting === false && objStyle.topLeftCornerOption === CornerOptions.FANCY_CORNER); - assert(doc.paragraphStyles.item("newStyle").isValid); - assert(doc.characterStyles.item("newStyle").isValid); - assert(doc.objectStyles.item("newStyle").isValid); + assert(this.doc.paragraphStyles.item("newStyle").isValid); + assert(this.doc.characterStyles.item("newStyle").isValid); + assert(this.doc.objectStyles.item("newStyle").isValid); - assert(doc.paragraphStyles.item("paragraphStyle").isValid === false); - assert(doc.characterStyles.item("characterStyle").isValid === false); - assert(doc.objectStyles.item("objectStyle").isValid === false); + assert(this.doc.paragraphStyles.item("paragraphStyle").isValid === false); + assert(this.doc.characterStyles.item("characterStyle").isValid === false); + assert(this.doc.objectStyles.item("objectStyle").isValid === false); }, testApplyStyles: function(b) { - b.doc(doc); + b.doc(this.doc); // create linked text frames var textFrame1 = b.text(b.LOREM + "\r" + b.LOREM, 0, 0, 300, 300); diff --git a/test/visual/canvasModes.jsx b/test/visual/canvasModes.jsx index f0917478..022d574d 100644 --- a/test/visual/canvasModes.jsx +++ b/test/visual/canvasModes.jsx @@ -88,10 +88,6 @@ function draw() { b.canvasMode(b.FACING_BLEEDS); // only left page b.rect(0, 0, b.width, b.height); - - - - } b.go(); From 6f32155d12f7d01dbe8c7f18578d99d844655549 Mon Sep 17 00:00:00 2001 From: fabianmoronzirfas Date: Wed, 21 Dec 2016 10:55:31 +0100 Subject: [PATCH 9/9] fix(linebreaks): fixing linebreaks --- test/transform-tests.jsx | 110 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/test/transform-tests.jsx b/test/transform-tests.jsx index 990cd7ef..c3569314 100644 --- a/test/transform-tests.jsx +++ b/test/transform-tests.jsx @@ -1 +1,109 @@ -/* globals assert */ if (typeof b === "undefined") { // @include "../basil.js"; } if (typeof b.test === "undefined") { // @include "../lib/basil.test.js"; } b.test("TransformTests", { setUpTest: function(b) { }, tearDownTest: function(b) { }, setUp: function(b) { }, tearDown: function(b) { b.close(SaveOptions.no); }, testMoveX: function(b) { b.rectMode(b.CORNER); var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemX(rect) === 0); // move to 50,0 b.itemX(rect, 50); // check new x coordinate assert(b.itemX(rect) === 50); rect.remove(); // ~ b.rectMode(b.CENTER); // ~ // create box at 0,0 // ~ var rect = b.rect(0,0,100,100); // ~ // ~ assert( b.itemX(rect) === 0); // ~ // move to 50,0 // ~ b.itemX(rect, 50); // ~ // check new x coordinate // ~ assert( b.itemX(rect) === 50); // ~ rect.remove(); }, testMoveY: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemY(rect) === 0); // move to 50,0 b.itemY(rect, 50); // check new x coordinate assert(b.itemY(rect) === 50); }, testPosition: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemPosition(rect).x === 0 && b.itemPosition(rect).y === 0); // move to 50,0 b.itemPosition(rect, 50, 50); // check new x coordinate assert(b.itemPosition(rect).x === 50 && b.itemPosition(rect).y === 50); }, testWidth: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemWidth(rect) === 100); // move to 50,0 b.itemWidth(rect, 50); // check new x coordinate assert(b.itemWidth(rect) === 50); }, testHeight: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemHeight(rect) === 100); // move to 50,0 b.itemHeight(rect, 50); // check new x coordinate assert(b.itemHeight(rect) === 50); }, testSize: function(b) { var doc = b.doc(); // create box at 0,0 var rect = b.rect(0, 0, 100, 100); assert(b.itemSize(rect).width === 100 && b.itemSize(rect).height === 100); // move to 50,0 b.itemSize(rect, 50, 50); // check new x coordinate assert(b.itemSize(rect).width === 50 && b.itemSize(rect).height === 50); } // todo: add matrix transformation tests here ... }); // print collected test results b.test.result(); +/* globals assert */ +if (typeof b === "undefined") { + // @include "../basil.js"; +} +if (typeof b.test === "undefined") { + // @include "../lib/basil.test.js"; +} + +b.test("TransformTests", { + + setUpTest: function(b) { + }, + + tearDownTest: function(b) { + }, + + setUp: function(b) { + }, + + tearDown: function(b) { + b.close(SaveOptions.no); + }, + + testMoveX: function(b) { + b.rectMode(b.CORNER); + var doc = b.doc(); + // create box at 0,0 + var rect = b.rect(0, 0, 100, 100); + assert(b.itemX(rect) === 0); + // move to 50,0 + b.itemX(rect, 50); + // check new x coordinate + assert(b.itemX(rect) === 50); + rect.remove(); + +// ~ b.rectMode(b.CENTER); +// ~ // create box at 0,0 +// ~ var rect = b.rect(0,0,100,100); +// ~ +// ~ assert( b.itemX(rect) === 0); +// ~ // move to 50,0 +// ~ b.itemX(rect, 50); +// ~ // check new x coordinate +// ~ assert( b.itemX(rect) === 50); +// ~ rect.remove(); + }, + + testMoveY: function(b) { + var doc = b.doc(); + // create box at 0,0 + var rect = b.rect(0, 0, 100, 100); + assert(b.itemY(rect) === 0); + // move to 50,0 + b.itemY(rect, 50); + // check new x coordinate + assert(b.itemY(rect) === 50); + }, + + testPosition: function(b) { + var doc = b.doc(); + // create box at 0,0 + var rect = b.rect(0, 0, 100, 100); + assert(b.itemPosition(rect).x === 0 && b.itemPosition(rect).y === 0); + // move to 50,0 + b.itemPosition(rect, 50, 50); + // check new x coordinate + assert(b.itemPosition(rect).x === 50 && b.itemPosition(rect).y === 50); + }, + + testWidth: function(b) { + var doc = b.doc(); + // create box at 0,0 + var rect = b.rect(0, 0, 100, 100); + assert(b.itemWidth(rect) === 100); + // move to 50,0 + b.itemWidth(rect, 50); + // check new x coordinate + assert(b.itemWidth(rect) === 50); + }, + + testHeight: function(b) { + var doc = b.doc(); + // create box at 0,0 + var rect = b.rect(0, 0, 100, 100); + assert(b.itemHeight(rect) === 100); + // move to 50,0 + b.itemHeight(rect, 50); + // check new x coordinate + assert(b.itemHeight(rect) === 50); + }, + + testSize: function(b) { + var doc = b.doc(); + // create box at 0,0 + var rect = b.rect(0, 0, 100, 100); + assert(b.itemSize(rect).width === 100 && b.itemSize(rect).height === 100); + // move to 50,0 + b.itemSize(rect, 50, 50); + // check new x coordinate + assert(b.itemSize(rect).width === 50 && b.itemSize(rect).height === 50); + } + + // todo: add matrix transformation tests here ... + +}); + +// print collected test results +b.test.result(); +