// Macro language regression tests startTime = getTime; runMacro("RegressionTests.js"); // run JavaScript regression tests runMacro("FilterTester"); // run Michael Schmid's filter tests test = "null"; roiManagerSelect(); measure(); binary(); logic("Logic"); math("Math"); functionCalls("FunctionCall"); images("Image"); setBatchMode(true); images("BatchImage"); setBatchMode(false); benchmarks("Benchmark"); analyzeParticles(); duplication(false); duplication(true); showStatus("Regression tests done ("+d2s((getTime-startTime)/1000,2)+" seconds)"); beep; wait(4000); exit(); // Logic tests function logic(thisTest) { test = thisTest; if (1>2) fail(1); if (2>1) ; else fail(2); if (1+2*3!=7||2/3+1!=1+(2/3)) fail(3); s = "ImageJ has a very nice macro language"; if (s=="ImageJ has a very nice macro language2") fail(4); if ("ImageJ has a very nice macro language "==s) fail(5); a = newArray(1, 2, 3); if (a[0]+a[0]!=a[1]) fail(6); s = newArray('one', 'two'); if (s[0]+s[1] != 'onetwo') fail(7); if (s[0]>=s[1]) fail(8); } // Math tests // Requires ImageJ 1.34b or later function math(thisTest) { test = thisTest; n = 10; if (n++!=10) fail(1); if (++n!=12) fail(2); if (n--!=12) fail(3); if (--n!=10) fail(4); a=newArray(0,1,2,3,4,5,6); for (i=0; i1) fail(2); if (abs(circularity-0.9997)>0.0001) fail(3); if (abs(minor-219.0134)>0.0001) fail(4); run("Duplicate...", "title=temp"); run("Restore Selection"); setAutoThreshold(); run("Convert to Mask"); run("Restore Selection"); getHistogram(values, counts, 256); if (counts[255]!=2115) fail(5); close; selectImage(id); close; selectWindow("Results"); run("Close"); } function binary() { test = "Binary"; binary2(); setBatchMode(true); test = "Binary (batch)"; binary2(); setBatchMode(false); } function binary2() { run("Options...", "iterations=1 count=1 "); run("Blobs (25K)"); run("Convert to Mask"); getHistogram(0, counts, 256); if (counts[255]!= 22243) fail(1); run("Erode"); getHistogram(0, counts, 256); if (counts[255]!= 17256) fail(2); run("Undo"); run("Close-"); getHistogram(0, counts, 256); if (counts[255]!= 21900) fail(3); run("Undo"); run("Open"); getHistogram(0, counts, 256); if (counts[255]!= 22148) fail(4); run("Undo"); run("Skeletonize"); getHistogram(0, counts, 256); if (counts[255]!= 686) fail(5); run("Undo"); run("Options...", "iterations=4 count=4"); run("Open"); getHistogram(0, counts, 256); if (counts[255]!= 19196) fail(6); run("Options...", "iterations=1 count=1 "); close; } function roiManagerSelect() { test = "Roi Manager"; setBatchMode(true); newImage("Untitled", "8-bit", 2000, 2000, 1); width = getWidth(); height = getHeight(); if (roiManager("count")>0) roiManager("reset"); n = 250; x = newArray(n); y = newArray(n); w = newArray(n); h = newArray(n); for (i=0; i