// Macro language regression tests // Requires the ImageJ 1.33q preview at http://rsb.info.nih.gov/ij/ij.jar requires("1.33q"); test = "null"; ifThenElse("IfThenElse"); functionCalls("FunctionCall"); images("Image"); setBatchMode(true); images("BatchImage"); setBatchMode(false); benchmarks("Benchmark"); exit(); function ifThenElse(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); } function functionCalls(thisTest) { test = thisTest; f1(123); f2("aString"); f3(1+2/3); v=1.5; f4(v); v = 'hello'; f5(v); if (f6()!=-1) fail(6); if (2-3!=f6()) fail(6); if ("return"!=f7()) fail(7); //** a = f8(); if (a.length!=3 || a[1]!=22) fail(8); a = newArray(1,2); b = newArray('one','two'); f9(a); f10(b); f11(a[0]); f12(b[1]); } function f1(a) {if (a!=123) fail(1);} function f2(a) {if (a!='aString') fail(2);} function f3(a) {if (a!=1+2/3) fail(3);} function f4(a) {if (a!=1.5) fail(4);} function f5(a) {if (a!='hello') fail(5);} function f6() {return -1;} function f7() {return 'return';} function f8() {a=newArray(11,22,33); return a;} function f9(b) {if (b.length!=2||b[1]!=2) fail(9);} function f10(b) {if (b.length!=2||b[0]!='one') fail(10);} function f11(a) {if (a!=1) fail(11);} function f12(a) {if (a!='two') fail(12);} function images(thisTest) { test = thisTest; n = 10; openAtStart = nImages; id = newArray(n); for (i=0; i