| echo Testing select on lists... |
| eval x = { |
| [a = 3; b = "I see London"], |
| [a = 2; b = "I see France"], |
| [a = 1; b = "I see Alain's funky pants"] |
| } |
| same $x.a, {3, 2, 1} |
| same $x.b, {"I see London", "I see France", "I see Alain's funky pants"} |
| same $x.c, {undefined, undefined, undefined} |
| same {}.a, {} |
| |
| ///////////////////////////////// |
| echo Testing basic math... |
| eval x = (1 + 2) |
| same $x, 3 |
| eval x = (3 - 1) |
| same $x, 2 |
| eval x = (2 * 3) |
| same $x, 6 |
| eval x = (8 / 2) |
| same $x, 4 |
| |
| echo Testing extreme numbers... |
| same string(real("INF")), "real(\"INF\")" |
| same string(real("-INF")), "real(\"-INF\")" |
| same string(real("NaN")), "real(\"NaN\")" |
| diff real("NaN"), real("NaN") |
| same real("INF"), real("INF") |
| same real("-INF"), real("-INF") |
| diff real("INF"), real("-INF") |
| same 0.0, -(0.0) |
| same 0.0, real("-0.0") |
| same string(0.0), "0.0" |
| same string(-0.0), "-0.0" |
| |
| ///////////////////////////////// |
| echo Testing basic attributes in a ClassAd... |
| eval x = [ |
| a = 1; |
| b = 2.0; |
| c = "alain"; |
| d = true; |
| atime = absTime("2004-01-01"); |
| rtime = relTime("2+25:14:16.123"); |
| l = {1, 1, 2, 3, 5}; |
| e = error; |
| u = undefined; |
| ] |
| same $x.a, 1 |
| same $x.b, 2.0 |
| same $x.c, "alain" |
| same $x.d, true |
| same $x.atime, absTime("2004-01-01"); |
| same $x.rtime, relTime("2+25:14:16.123"); |
| same $x.l, {1, 1, 2, 3, 5} |
| same $x.l[4], 5 |
| same $x.e, error |
| same $x.u, undefined |
| same isinteger($x.a), true |
| same isinteger($x.b), false |
| same isreal($x.b), true |
| same isreal($x.c), false |
| same isstring($x.c), true |
| same isstring($x.d), false |
| same isboolean($x.d), true |
| same isboolean($x.c), false |
| same isabstime($x.atime), true |
| same isabstime($x.rtime), false |
| same isreltime($x.rtime), true |
| same isreltime($x.atime), false |
| same islist($x.l), true |
| same islist($x.a), false |
| same iserror($x.e), true |
| same iserror($x.u), false |
| same isundefined($x.u), true |
| same isundefined($x.e), false |
| |
| // Note that testing XML relies on the ClassAd from |
| // the above testing. |
| // echo Testing XML... |
| // eval y = [ a = 2; b = "Lisp rocks"; ] |
| // writexml tmp.xml {$x, $y} |
| // readxml z tmp.xml |
| // same $x, $z[0] |
| // same $y, $z[1] |
| |
| ///////////////////////////////// |
| |
| |
| ///////////////////////////////// |
| echo Testing subscripts |
| eval x = [ |
| a = 3; |
| b = "alain"; |
| ab = 4; |
| ] |
| same $x["a"], 3 |
| same $x["b"], "alain" |
| same $x["c"], error |
| eval d = $x["c"] |
| same $x[strcat("a", "b")], 4 |
| eval x = {"a", "b", "c"} |
| same $x[0], "a" |
| same $x[1], "b" |
| same $x[2], "c" |
| same $x[3], error |
| |
| ///////////////////////////////// |
| echo Testing multiple semicolons... |
| eval x = [ |
| ;; |
| a = 3;; |
| b = 4;; |
| ] |
| |
| ///////////////////////////////// |
| echo Testing functions... |
| same int(3), 3 |
| same int(3.9), 3 |
| same int("3.9"), 3 |
| same int(absTime("1970-01-01T:00:00:01Z")), 1 |
| same int(reltime("01:00:01")), 3601 |
| eval y = int(absTime("1970-01-01T:00:00:01Z")) |
| same $y, 1 |
| |
| same real(3), 3.0 |
| same real(3.9), 3.9 |
| same real("3.9"), 3.9 |
| same real(absTime("1970-01-01T:00:00:01Z")), 1.0 |
| same real(reltime("01:00:01")), 3601.0 |
| |
| same string("alain"), "alain" |
| same string(1), "1" |
| |
| same floor(3.9), 3 |
| same floor("3.9"), 3 |
| |
| same ceiling(3.9), 4 |
| same ceiling("3.9"), 4 |
| |
| same round(3.1), 3 |
| same round(3.9), 4 |
| |
| same strcat("", "roy"), "roy" |
| same strcat("alain", ""), "alain" |
| same strcat("alain", "roy"), "alainroy" |
| same strcat(14, " bottles of root beer"), "14 bottles of root beer" |
| |
| same substr("abcde", 1), "bcde" |
| same substr("abcde", 4), "e" |
| same substr("abcde", 5), "" |
| same substr("abcde", 1, 2), "bc" |
| same substr("abcde", 4, 2), "e" |
| |
| same strcmp("alain", "roy") < 0, true |
| same strcmp("roy", "alain") > 0, true |
| same strcmp("alain", "alain"), 0 |
| |
| same stricmp("alain", "ALAIN"), 0 |
| same stricmp("alain", "roy") < 0, true |
| |
| same tolower("ALAIN"), "alain") |
| same toupper("alain"), "ALAIN") |
| same tolower(true), "true") |
| same toupper(true), "TRUE") |
| |
| same member(1, {1, 2, 3}), true |
| same member(4, {1, 2, 3}), false |
| |
| same regexp("Alain.*Roy", "Alain Aslag Roy"), true |
| same regexp("alain.*roy", "Alain Aslag Roy"), false |
| same regexp("alain.*roy", "Alain Aslag Roy", "i"), true |
| |
| //same regexpMember("b.*", {}), false |
| //same regexpMember("b.*", {"aa"}), false |
| //same regexpMember("b.*", {"aa", "bb"}), true |
| //same regexpMember("b.*", {"bb", "aa"}), true |
| //same regexpMember("b.*", {1, "bb"} ), error |
| |
| |
| eval t = absTime("1970-01-02T:03:04:05Z") |
| same splitTime($t).year, 1970 |
| same splitTime($t).month, 1 |
| same splitTime($t).day, 2 |
| same splitTime($t).hours, 3 |
| same splitTime($t).minutes, 4 |
| same splitTime($t).seconds, 5 |
| same splitTime($t).offset, 0 |
| |
| |
| |
| eval t = absTime("1970-01-02T:03:04:05-06:00") |
| eval tt = splitTime($t) |
| same splitTime($t).year, 1970 |
| same splitTime($t).month, 1 |
| same splitTime($t).day, 2 |
| same splitTime($t).hours, 3 |
| same splitTime($t).minutes, 4 |
| same splitTime($t).seconds, 5 |
| same splitTime($t).offset, -21600 |
| |
| |
| |
| eval t = relTime("1d2h3m4.5s") |
| eval tt = splitTime($t) |
| same splitTime($t).days, 1 |
| same splitTime($t).hours, 2 |
| same splitTime($t).minutes, 3 |
| same splittime($t).seconds, 4.5 |
| eval tt = splitTime($t) |
| |
| |
| eval t = absTime("1997-08-30T16:04:05-0500") |
| eval f = formatTime($t, "%m %d %Y") |
| same $f, "08 30 1997" |
| eval f = formatTime($t, "%H %M %S") |
| same $f, "16 04 05" |
| eval f = formatTime($t, "%A %a") |
| same $f, "Saturday Sat" |
| eval f = formatTime($t, "%B %b") |
| same $f, "August Aug" |
| eval f = formatTime(splitTime($t), "%H:%M:%S") |
| same $f, "16:04:05" |
| eval f = formatTime($t) |
| same $f, "Sat Aug 30 16:04:05 1997" |
| |
| same size({}), 0 |
| same size({1}), 1 |
| same size({1, 2, 3, 4, 5}), 5 |
| same size([]), 0 |
| same size([a = 1;]), 1 |
| same size([a = 1; b = 2;]), 2 |
| same size(""), 0 |
| same size("a"), 1 |
| same size("ab"), 2 |
| same size(3), error |
| same size(3.4), error |
| |
| eval list0 = {} |
| eval list1 = {1} |
| eval list5 = {1, 2, 3, 4, 5} |
| |
| same sum($list0), undefined |
| same avg($list0), undefined |
| same min($list0), undefined |
| same max($list0), undefined |
| // #### Do we really want these to be false and true? |
| same anycompare("<", $list0, 3), false |
| same allcompare("<", $list0, 3), true |
| |
| same sum($list1), 1 |
| same avg($list1), 1.0 |
| same min($list1), 1 |
| same max($list1), 1 |
| same anycompare("<", $list1, 3), true |
| same allcompare("<", $list1, 3), true |
| |
| same sum($list5), 15 |
| same avg($list5), 3.0 |
| same min($list5), 1 |
| same max($list5), 5 |
| same anycompare("<", $list5, 3), true |
| same allcompare("<", $list5, 3), false |
| |
| same ifThenElse(1+1==2, 3, 4), 3 |
| same ifThenElse(1+1==3,3,4), 4 |
| same ifThenElse(ERROR,3,4), ERROR |
| same ifThenElse(UNDEFINED,3,4), UNDEFINED |
| |
| same interval(1), "1" |
| same interval(60*2 + 1), "2:01" |
| same interval(3600*3 + 60*2 + 1), "3:02:01" |
| same interval(3600*24*4 + 3600*3 + 60*2 + 1), "4+03:02:01" |
| |
| //same regexps("[abc]*([def]*)[ghi]*","aaaabbbbcccccdddeeefffggghhhiii","\\1"), "dddeeefff" |
| //same regexps("[abc]*([def]*)[ghi]*","abcdefghi","\\0"), "abcdefghi" |
| //same regexps("[abc]*([def]*)[ghi]*","abcdefghi","\\2"), error |
| //same regexps("[abc]*([def]*)[ghi]*","NO","\\0"), "" |
| |
| |
| echo Testing eval |
| same eval("1+1"), 2 |
| same eval(1+1), 2 |
| same eval("1+"), ERROR |
| eval x = [ A = 1; B = 2; C = eval("A+B"); ] |
| same $x.C, 3 |
| |
| echo Testing boolean expressions |
| echo Testing && operator |
| same false, false && false |
| same false, false && undefined |
| same false, false && true |
| same false, false && error |
| |
| same false, undefined && false |
| same undefined, undefined && undefined |
| same undefined, undefined && true |
| same error, undefined && error |
| |
| same false, true && false |
| same undefined, true && undefined |
| same true, true && true |
| same error, true && error |
| |
| same error, error && false |
| same error, error && undefined |
| same error, error && true |
| same error, error && error |
| |
| |
| echo Testing || operator |
| same false, false || false |
| same undefined, false || undefined |
| same true, false || true |
| same error, false || error |
| |
| same undefined, undefined || false |
| same undefined, undefined || undefined |
| same true, undefined || true |
| same error, undefined || error |
| |
| same true, true || false |
| same true, true || undefined |
| same true, true || true |
| same true, true || error |
| |
| same error, error || false |
| same error, error || undefined |
| same error, error || true |
| same error, error || error |
| |
| |
| echo Testing ! operator |
| same true, !false |
| same undefined, !undefined |
| same false, !true |
| same error, !error |
| |
| |
| echo Testing ? operator |
| same false, false ? true : false |
| same true, false ? false : true |
| same undefined, false ? true : undefined |
| same true, false ? undefined : true |
| |
| same true, true ? true : false |
| same false, true ? false : true |
| same true, true ? true : undefined |
| same undefined, true ? undefined : true |
| |
| echo Testing characters with negative ascii values |
| // # the following used to not even parse on some systems |
| same "–", "–" |
| |
| echo Testing stringListsIntersect() |
| same true, stringListsIntersect("one,two","two,three") |
| same false, stringListsIntersect("one,two","three,four") |
| same false, stringListsIntersect("one,two","three,four",";") |
| same true, stringListsIntersect("one,two","one") |
| same true, stringListsIntersect("one, two","two, three") |
| same true, stringListsIntersect("one,two","two,three",",") |
| same true, stringListsIntersect("one;two","two;three",";") |
| same undefined, stringListsIntersect("one,two",undefined) |
| same undefined, stringListsIntersect(undefined,"one,two" ) |