ee66ab2003-01-15Martin Nilsson dnl $Id: testsuite.in,v 1.12 2003/01/15 14:47:47 nilsson Exp $
3c87a12002-08-03Martin Nilsson 
9370072002-10-14Martin Nilsson dnl - Array
3c87a12002-08-03Martin Nilsson 
ee66ab2003-01-15Martin Nilsson test_equal(Array.diff(({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }), ({ 6, 7, 8, 9, 3, 4, 5, 1, 2, 0 })), ({ ({ ({ 0, 1, 2, 3, 4, 5 }), ({ 6, 7, 8, 9 }), ({}) }), ({ ({}), ({ 6, 7, 8, 9 }), ({ 3, 4, 5, 1, 2, 0 }) }) })) test_equal(Array.diff(({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }), ({ 9, 7, 8, 4, 5, 6, 0, 1, 2, 3 })), ({ ({ ({}), ({ 0, 1, 2, 3 }), ({ 4, 5, 6, 7, 8, 9 }) }), ({ ({ 9, 7, 8, 4, 5, 6 }), ({ 0, 1, 2, 3 }), ({}) }) })) test_equal(Array.diff("qadfgoksdfäojerjgöohjgdgkm"/"", "xadfgokälojeorjgöoyjgdgkmzzz"/""), ({ ({ ({ "q" }), "adfgok"/"", "sdf"/"", ({ "ä" }), ({}), "oje"/"", ({}), "rjgöo"/"", ({ "h" }), "jgdgkm"/"", ({}) }), ({ ({ "x" }), "adfgok"/"", ({}), ({ "ä" }), ({ "l" }), "oje"/"", ({ "o" }), "rjgöo"/"", ({ "y" }), "jgdgkm"/"", "zzz"/"" }) })) test_equal(Array.diff("123.org"/"","http://123.org/"/""), ({ ({ ({}), "123.org"/"", ({}) }), ({ "http://"/"", "123.org"/"", ({ "/" }) }) })) test_equal(Array.longest_ordered_sequence("dfgaokäpojghadjjioijrgxcvb"/""), ({ 0, 1, 2, 10, 11, 16, 18, 19, 20, 22 }));
9370072002-10-14Martin Nilsson dnl Array.diff_compare_table dnl Array.longest_ordered_sequence dnl Array.interleave_array dnl Array.sort
e5a2cc2002-10-14Johan Sundström test_equal([[ Array.diff(enumerate(4),enumerate(4,1,2)) ]], [[ ({ ({ ({0,1}), ({2,3}), ({ }) }), ({ ({ }), ({2,3}), ({4,5}) }) }) ]]) test_any_equal([[ array x, y; [x, y] = Array.diff(enumerate(4),enumerate(4,1,2)); return x[1] == y[1]; ]], 1)
9370072002-10-14Martin Nilsson test_equal(Array.everynth("0123456789"/""), ({ "0", "2", "4", "6", "8"})) test_equal(Array.everynth("0123456789"/"",3), ({ "0", "3", "6", "9"})) test_equal(Array.everynth("0123456789"/"",3,4), ({ "4", "7"}))
f14a832002-10-16Martin Nilsson test_equal(Array.everynth(({})),({}))
3c87a12002-08-03Martin Nilsson  test_equal(Array.splice(({7,8,99}),({"h","h",99})), ({7,"h",8,"h",99,99})) test_equal(Array.splice(({7,8}),({"h","h",99})), ({7,"h",8,"h"})) test_equal(Array.splice(({7,8,99}),({"h","h",99}),({"g",({"fg"}),97})), ({7,"h","g",8,"h",({"fg"}),99,99,97})) test_equal(Array.splice(({7,"foo"})), ({7,"foo"})) test_equal(Array.splice(), ({})) test_equal(Array.splice(({})), ({})) test_equal(Array.transpose( ({ ({ 1,2,3}), ({4,5,6}) }) ), ({ ({1,4}), ({2,5}), ({3,6}) })) test_equal([[Array.transpose(({catch{throw(({""}));},({1,2})[1..]}))]], [[ ({ ({ "", 2 }) }) ]]) test_equal(Array.uniq( ({ 1,1,2,2,3,3,4,1,2,3,3,2,1,2,1 }) ), ({1,2,3,4})) test_equal(Array.uniq( ({ "a",5,1.0,5,"b","a" }) ), ({"a",5,1.0,"b"}))
f14a832002-10-16Martin Nilsson test_equal(Array.uniq( ({}) ), ({}))
3c87a12002-08-03Martin Nilsson  test_equal(Array.filter( ({ 1,2,3,4,5,6, }), lambda(int i) { return 0; } ), ({})) test_equal(Array.filter( ({ 1,2,3,4,5,6, }), lambda(int i) { return 1; } ), ({1,2,3,4,5,6})) test_equal(Array.filter( ({ 1,2,3,4,5,6, }), lambda(int i) { return i%2; } ), ({1,3,5}))
f14a832002-10-16Martin Nilsson test_equal([[ Array.filter( ({}), lambda(int i) { return 1; })]], ({}))
3c87a12002-08-03Martin Nilsson  test_equal(Array.permute( ({ 1,2 }), 0 ), ({ 1,2 })) test_equal(Array.permute( ({ 1,2 }), 1 ), ({ 2,1 })) test_equal(Array.permute( ({ 1,2,3,4,5,6,7,8,9,10 }), 3628800), ({ 1,2,3,4,5,6,7,8,9,10 }))
f14a832002-10-16Martin Nilsson test_equal(Array.permute( ({}), 1 ), ({}))
3c87a12002-08-03Martin Nilsson 
f14a832002-10-16Martin Nilsson test_equal(Array.enumerate(0), ({})) test_equal(Array.enumerate(1), ({ 0 }))
3c87a12002-08-03Martin Nilsson test_equal(Array.enumerate(5), ({ 0,1,2,3,4 })) test_equal(Array.enumerate(5,2), ({ 0,2,4,6,8 })) test_equal(Array.enumerate(5,2,7), ({ 7,9,11,13,15 })) test_equal(Array.enumerate(5,2,7,`-), ({ 7,5,3,1,-1 }))
e5a2cc2002-10-14Johan Sundström test_eq([[ Array.reduce(`>>, ({})) ]], 0) test_eq([[ Array.reduce(`==, ({}), 1) ]], 1) test_eq([[ Array.reduce(`<<, ({1,2,3,4,5})) ]], 1<<14) test_eq([[ Array.rreduce(`>>, ({})) ]], 0) test_eq([[ Array.rreduce(`==, ({}), 1) ]], 1) test_eq([[ Array.rreduce(`<<, ({4,3,2,1})) ]], 1125899906842624)
9370072002-10-14Martin Nilsson 
f14a832002-10-16Martin Nilsson test_equal(Array.shuffle(({})), ({})) test_equal(Array.shuffle(({1})), ({1}))
3c87a12002-08-03Martin Nilsson test_any([[ random_seed(4711); array b = Array.shuffle(Array.enumerate(1000)); random_seed(4711); // There is a chance in 1000! (aprox. 4E2568) that this fails of // natural causes. return equal(b, Array.shuffle(Array.enumerate(1000))) && !equal(Array.enumerate(1000),b); ]], 1); test_true( equal(Array.enumerate(1000),sort(Array.shuffle(Array.enumerate(1000)))) )
9370072002-10-14Martin Nilsson dnl Array.search_array dnl Array.sum_arrays
e5a2cc2002-10-14Johan Sundström 
f14a832002-10-16Martin Nilsson test_equal(Array.sort_array(({})), ({}))
e5a2cc2002-10-14Johan Sundström test_equal([[ Array.sort_array(enumerate(9), `<) ]], [[ enumerate(9,-1,8) ]])
9370072002-10-14Martin Nilsson dnl Array.columns dnl Array.transpose_old
ee66ab2003-01-15Martin Nilsson  dnl (note that the results would be different for a really optimal diff3) test_equal(Array.diff3(({}),({"a","c"}),({"b","y"})), ({({({ })}), ({({"a","c"})}), ({({"b","y"})})})) test_equal(Array.diff3(({"a"}),({"a","b"}),({"b"})), ({({({"a"}),({ })}), ({({"a"}),({"b"})}), ({({ }),({"b"})})})) test_equal(Array.diff3(({"a"}),({"a","c"}),({"b"})), ({({({"a"}),({ })}), ({({"a"}),({"c"})}), ({({ }),({"b"})})})) test_equal(Array.diff3(({"a","d"}),({"a","d"}),({"a","b"})), ({({({"a"}),({"d"})}), ({({"a"}),({"d"})}), ({({"a"}),({"b"})})})) test_equal(Array.diff3(({"a","b"}),({"b"}),({"c","b"})), ({({({"a"}),({"b"})}), ({({ }),({"b"})}), ({({"c"}),({"b"})})})) dnl The following is not optimal. test_equal(Array.diff3(({"a","b"}),({"b"}),({"b","b"})), ({({({"a"}),({"b"}),({ })}), ({({ }),({"b"}),({ })}), ({({ }),({"b"}),({"b"})})})) test_equal(Array.diff3(({"a","c","d"}),({"a","d","d"}),({"a","b"})), ({({({"a"}),({"c"}),({"d"}),({ })}), ({({"a"}),({ }),({"d"}),({"d"})}), ({({"a"}),({"b"}),({ }),({ })})})) test_equal(Array.diff3(({"a","b","c"}),({"b","e","c"}),({"b","e","c"})), ({({({"a"}),({"b"}),({ }),({"c"})}), ({({ }),({"b"}),({"e"}),({"c"})}), ({({ }),({"b"}),({"e"}),({"c"})})})) test_equal(Array.diff3(({"a","b","x"}),({"y","b","c","x"}),({"y","c","a"})), ({({({"a"}),({"b"}),({ }),({"x"})}), ({({"y"}),({"b"}),({"c"}),({"x"})}), ({({"y"}),({ }),({"c"}),({"a"})})})) test_equal(Array.diff3(({"y","b","c","x"}),({"y","c","a"}),({"a","b","x"})), ({({({"y"}),({"b"}),({"c"}),({"x"})}), ({({"y"}),({ }),({"c"}),({"a"})}), ({({"a"}),({"b"}),({ }),({"x"})})})) test_equal(Array.diff3(({"y","b","c","x"}),({"a","b","x"}),({"y","c","a"})), ({({({"y"}),({"b"}),({"c"}),({"x"})}), ({({"a"}),({"b"}),({ }),({"x"})}), ({({"y"}),({ }),({"c"}),({"a"})})})) test_equal(Array.diff3(({"a","a","b","b"}),({"b","b","c","c"}),({"c","c","a","a"})), ({({({"a","a"}),({"b","b"}),({ }),({ })}), ({({ }),({"b","b"}),({"c","c"}),({ })}), ({({ }),({ }),({"c","c"}),({"a","a"})})})) dnl The following is not optimal. test_equal(Array.diff3(({"a","x","b","c"}),({"b","x","c"}),({"b","x","c"})), ({({({"a","x"}),({"b"}),({ }),({"c"})}), ({({ }),({"b"}),({"x"}),({"c"})}), ({({ }),({"b"}),({"x"}),({"c"})})})) test_equal(Array.diff3(({"x","x","a","x"}),({"a","x","b","x"}),({"a","x","b","x"})), ({({({"x","x"}),({"a","x"}),({ })}), ({({ }),({"a","x"}),({"b","x"})}), ({({ }),({"a","x"}),({"b","x"})})})) test_equal(Array.diff3(({"a","a","b"}),({"b","c"}),({"c","a","a"})), ({({({ }),({ }),({"a","a"}),({"b"})}), ({({"b"}),({"c"}),({ }),({ })}), ({({ }),({"c"}),({"a","a"}),({ })})})) test_equal(Array.diff3(({"x","x","x","a"}),({"y","b"}),({"x","x","x","c"})), ({({({"x","x","x"}),({"a" })}), ({({ }),({"y","b"})}), ({({"x","x","x"}),({"c" })})})) test_equal(Array.diff3(({"a","x","x","x","a"}),({"b","y","y","b"}),({"c","x","x","x","c"})), ({({({"a" }),({"x","x","x"}),({"a"})}), ({({"b","y","y","b"}),({ }),({ })}), ({({"c" }),({"x","x","x"}),({"c"})})})) test_equal(Array.diff3(({"a","b","c","d"}),({"x","x","x","d"}),({"a","y","y","y"})), ({({({"a"}),({"b","c" }),({"d"})}), ({({ }),({"x","x","x"}),({"d"})}), ({({"a"}),({"y","y","y"}),({ })})})) test_equal(Array.diff3(({"a","b","c","d"}),({"a","x","x","d"}),({"a","y","y","y"})), ({({({"a"}),({"b","c" }),({"d"})}), ({({"a"}),({"x","x" }),({"d"})}), ({({"a"}),({"y","y","y"}),({ })})})) test_equal(Array.diff3(({"a","b","c","d"}),({"x","x","x","b"}),({"a","y","y","y"})), ({({({"a" }),({"b"}),({"c","d" })}), ({({"x","x","x"}),({"b"}),({ })}), ({({"a" }),({ }),({"y","y","y"})})})) test_equal(Array.diff3(({"a","b","c","d"}),({"x","x","x","c"}),({"a","y","y","y"})), ({({({"a"}),({"b" }),({"c"}),({"d"})}), ({({ }),({"x","x","x"}),({"c"}),({ })}), ({({"a"}),({"y","y","y"}),({ }),({ })})})) test_equal(Array.diff3(({"a","b","b","c","d"}),({"z","a","b","b","x"}),({"z","b","c","x"})), ({({({ }),({"a"}),({"b"}),({"b"}),({"c"}),({"d"})}), ({({"z"}),({"a"}),({"b"}),({"b"}),({ }),({"x"})}), ({({"z"}),({ }),({"b"}),({ }),({"c"}),({"x"})})})) test_equal(Array.diff3(({"a","b","c","d"}),({"b","a","c","c"}),({"b","b","d","d","a"})), ({({({"a"}),({"b"}),({"c"}),({"d"}),({ }),({ }),({ })}), ({({ }),({"b"}),({ }),({ }),({ }),({"a"}),({"c","c"})}), ({({ }),({"b"}),({"b"}),({"d"}),({"d"}),({"a"}),({ })})})) dnl The following is not optimal. test_equal(Array.diff3(({"a"}),({"b","a"}),({"a","b","a"})), ({({({ }),({"a"}),({ })}), ({({"b"}),({"a"}),({ })}), ({({ }),({"a"}),({"b","a"})})})) dnl The following is not optimal. test_equal(Array.diff3(({"a","c"}),({"b","a","c"}),({"a","c","b","a","c"})), ({({({ }),({"a","c"}),({ })}), ({({"b"}),({"a","c"}),({ })}), ({({ }),({"a","c"}),({"b","a","c"})})})) dnl The following is not optimal. test_equal(Array.diff3(({"a","d"}),({"b","a","c"}),({"a","c","b","a","c"})), ({({({ }),({"a"}),({"d" }),({ })}), ({({"b"}),({"a"}),({ }),({"c"})}), ({({ }),({"a"}),({"c","b","a"}),({"c"})})})) dnl The following is not optimal. test_equal(Array.diff3(({"a","a"}),({"b","a","d","a"}),({"a","a","b","a","a"})), ({({({ }),({"a"}),({ }),({"a"}),({ })}), ({({"b"}),({"a"}),({"d"}),({"a"}),({ })}), ({({ }),({"a"}),({ }),({"a"}),({"b","a","a"})})})) test_equal(Array.diff3(({"a"}),({"a","b"}),({"b","a"})), ({({({ }),({"a"}),({ })}), ({({ }),({"a"}),({"b"})}), ({({"b"}),({"a"}),({ })})})) test_equal(Array.diff3(({"a","b"}),({"b","a"}),({"a"})), ({({({ }),({"a"}),({"b"})}), ({({"b"}),({"a"}),({ })}), ({({ }),({"a"}),({ })})})) test_equal(Array.diff3(({"b","a"}),({"a"}),({"a","b"})), ({({({"b"}),({"a"}),({ })}), ({({ }),({"a"}),({ })}), ({({ }),({"a"}),({"b"})})})) test_equal(Array.diff3(({"a","b"}),({"a"}),({"b","a"})), ({({({ }),({"a"}),({"b"})}), ({({ }),({"a"}),({ })}), ({({"b"}),({"a"}),({ })})})) test_equal(Array.diff3(({"a","c"}),({"a","c","b","a"}),({"b","a","c"})), ({({({ }),({"a","c"}),({ })}), ({({ }),({"a","c"}),({"b","a"})}), ({({"b"}),({"a","c"}),({ })})})) test_equal(Array.diff3(({"a","c","b","a"}),({"a","c"}),({"b","a","c"})), ({({({ }),({"a","c"}),({"b","a"})}), ({({ }),({"a","c"}),({ })}), ({({"b"}),({"a","c"}),({ })})}))
9370072002-10-14Martin Nilsson dnl Array.diff3_old
ee66ab2003-01-15Martin Nilsson  test_eq(Array.dwim_sort_func("1","a"), -1) test_eq(Array.dwim_sort_func("1","1a"), -1) test_eq(Array.dwim_sort_func("1","0a"), 1) test_eq(Array.dwim_sort_func("1","1"), 0) test_eq(Array.dwim_sort_func("1","01"), 0) test_eq(Array.dwim_sort_func("1","2"), -1) test_eq(Array.dwim_sort_func("10","2a"), 1)
9370072002-10-14Martin Nilsson dnl Array.lyskom_sort_func dnl Array.flatten
e5a2cc2002-10-14Johan Sundström 
f14a832002-10-16Martin Nilsson test_eq(Array.sum(({})),0)
e5a2cc2002-10-14Johan Sundström test_eq(Array.sum((array(int))"157"), 157) test_eq([[ Array.sum(enumerate(12345)) ]], [[ Array.reduce(`+, enumerate(12345)) ]])
f14a832002-10-16Martin Nilsson test_eq(Array.sum( "abcdefgh"/2.5 ), "abcdefgh") test_equal([[ Array.sum( ({ ({ 1,2,3 }), ({ 4,5 }) }) )]],[[ ({ 1,2,3,4,5 }) ]])
e5a2cc2002-10-14Johan Sundström 
f14a832002-10-16Martin Nilsson test_equal(Array.uniq2(({})), ({}))
e5a2cc2002-10-14Johan Sundström test_equal([[ Array.uniq2("AAAAAAAAAAAHHHHAAA!!!!"/1)*"" ]], [[ "AHA!" ]])
9370072002-10-14Martin Nilsson  test_equal([[ Array.arrayify( ({1,2,3}) ) ]],[[ ({1,2,3}) ]]) test_equal([[ Array.arrayify( 1 ) ]],[[ ({1}) ]]) test_equal([[ Array.arrayify( 0 ) ]],[[ ({0}) ]]) test_equal([[ Array.arrayify( UNDEFINED ) ]],[[ ({}) ]])
3c87a12002-08-03Martin Nilsson 
9370072002-10-14Martin Nilsson dnl Array.oid_sort_func dnl Array.greedy_diff
e5a2cc2002-10-14Johan Sundström 
f14a832002-10-16Martin Nilsson test_equal( Array.count(({})), ([]) )
e5a2cc2002-10-14Johan Sundström test_eq( Array.count((multiset)("All your Pike are belong to us!"/1), " "), 6 ) test_eq( Array.count("...and there was much rejoicing."/1, "."), 4 ) test_eq([[Array.count((["An":"eye", "for":4, "an":"eye"]), "eye")]], 2 ) test_equal([[ Array.count((["An":"eye", "for":4, "an":"eye"])) ]], [[ ([ "eye":2, 4:1 ]) ]])
9370072002-10-14Martin Nilsson  test_equal(Array.common_prefix(({ "soliloquise"/1 })), "soliloquise"/1) test_equal(Array.common_prefix(({ "muzzle"/1, "muzzy"/1 })), "muzz"/1) test_equal(Array.common_prefix(({ "labyrinth"/1, "diatom"/1 })), ({})) test_equal(Array.common_prefix(({ "abc"/1, "abc"/1, "abc"/1 })), "abc"/1) test_equal(Array.common_prefix(({})), ({}))
26a1952002-11-15Martin Nilsson dnl - Getopt dnl setup test_do( add_constant("getopt_env", master()->environment); ) test_do( master()->environment=([ "foo": ({ "foo", "bar" }) ]); )
6317572002-11-17Martin Nilsson test_eq( Getopt.find_option( ({}), "a" ), 0 )
26a1952002-11-15Martin Nilsson test_eq( Getopt.find_option( "-a,-b"/",", "a" ), 0 ) test_eq( Getopt.find_option( "-a,--b"/",", "a" ), 0 ) test_eq( Getopt.find_option( "-a,-b"/",", "b" ), 1 ) test_eq( Getopt.find_option( "-a,-ab"/",", "b" ), 1 ) test_eq( Getopt.find_option( ",-a,-b"/",", "bc"/1 ), 1) test_eq( Getopt.find_option( ",-,-a"/",", "a" ), 1) test_eq( Getopt.find_option( ",--,-a"/",", "a" ), 0) test_eq( Getopt.find_option( ",--a,-b"/",", "a"), 0) test_eq( Getopt.find_option( ",--a,-b"/",", "b"), 1) test_eq( Getopt.find_option( ",--a=b"/",", "x", "a"), "b") test_eq( Getopt.find_option( ",--a=b"/",", "x", "a", 0, "y"), "b") test_eq( Getopt.find_option( ",--a,-b"/",", "b", "a", 0, "y"), "-b")
6317572002-11-17Martin Nilsson test_eq( Getopt.find_option( ",--a,-b"/",", "b", "a", 0, UNDEFINED), 1) test_eval_error( Getopt.find_option( ",--a"/",", "x", "a", 0, "y", 1) )
26a1952002-11-15Martin Nilsson  test_eq( Getopt.find_option( ",-ab"/",", "a"), 1) test_eq( Getopt.find_option( ",-ab"/",", "b"), 1) test_eq( Getopt.find_option( ",-ab"/",", "a", 0, 0, "y"), "b") test_eq( Getopt.find_option( ",-a,-b"/",", "ab"/1, 0, 0, "y"), "-b")
6317572002-11-17Martin Nilsson test_eval_error( Getopt.find_option( ",-a"/",", "a", 0, 0, "y", 1) )
26a1952002-11-15Martin Nilsson  test_any_equal([[ array x = ({ "", "--a" }); Getopt.find_option( x, "x", "a" ); return x; ]],[[ ({ "", 0 }) ]]) test_any_equal([[ array x = ({ "", "--a" }); Getopt.find_option( x, "x", "b" ); return x; ]],[[ ({ "", "--a" }) ]]) test_any_equal([[ array x = ({ "", "--a", "hej" }); Getopt.find_option( x, "x", "a", 0, "b" ); return x; ]],[[ ({ "", 0, 0 }) ]]) test_any_equal([[ array x = ({ "", "-ab" }); Getopt.find_option( x, "a" ); return x; ]],[[ ({ "", "-b" }) ]]) test_any_equal([[ array x = ({ "", "-ab" }); Getopt.find_option( x, "b" ); return x; ]],[[ ({ "", "-a" }) ]]) test_any_equal([[ array x = ({ "", "-ab" }); Getopt.find_option( x, "a", 0, 0, "y" ); return x; ]],[[ ({ "", 0 }) ]]) test_any_equal([[ array x = ({ "", "-", "-abc" }); Getopt.find_option( x, "b" ); return x; ]],[[ ({ "", "-", "-ac" }) ]]) test_any_equal([[ array x = ({ "", "-ab", "c" }); Getopt.find_option( x, "b", 0, 0, "y" ); return x; ]],[[ ({ "", "-a", 0 }) ]]) test_eq( Getopt.find_option(({}),({"a","b"}),({"c","d"}), 0, "e" ), "e") test_eq( Getopt.find_option(({}),({"a","b"}),({"c","d"}), "foo", "e" ), "bar") test_eq( Getopt.find_option(({}),({"a","b"}),({"c","d"}), "foo" ), "bar") test_eq( Getopt.find_option(({}),({"a","b"}),({"c","d"}), ({"x","foo"}) ), "bar") test_eq( Getopt.find_option(({}),({"a","b"}),({"c","d"}), "x", "e" ), "e")
6317572002-11-17Martin Nilsson test_equal( Getopt.get_args( ({}) ), ({}) )
26a1952002-11-15Martin Nilsson test_equal( Getopt.get_args(({ "x",0,0,1,"y",0,"z" })), "xyz"/1 ) test_eval_error( Getopt.get_args(({ "x", "-a" }), 0, 1) ) test_equal( Getopt.get_args(({ "-a", 0, "a"})), ({ "-a", "a" }) ) test_eval_error( Getopt.get_args(({ "x", "--a" }), 0, 1) ) test_equal( Getopt.get_args(({ "x", "--", "--a" })), ({ "x", "--a" }) ) test_equal( Getopt.get_args(({ "x", "-" })), ({ "x", "-" }) ) test_eval_error( Getop.get_args(({ "x", "a", "-b" }), 0, 1) ) test_equal( Getopt.get_args(({ "x", "a", "-b" }), 1, 1), ({ "x", "a", "-b" })) test_equal( Getopt.get_args(({ "x", "ab", "-b" }), 1, 1), ({ "x", "ab", "-b" }))
48f2492003-01-02Martin Nilsson test_eval_error( Getopt.get_args(({ "x", 0, "-b" }), 1, 1))
26a1952002-11-15Martin Nilsson test_eval_error( Getopt.get_args(({ "x", "-a" }), 1, 1)) test_do( add_constant("opt", lambda(array x, array y, mixed ... z) { return Getopt.find_all_options(x, ({ y }), @z); }); )
6317572002-11-17Martin Nilsson test_equal( Getopt.find_all_options( ({}), ({}) ), ({}) )
26a1952002-11-15Martin Nilsson test_equal( opt( "-a,-b"/",", ({ "a", Getopt.NO_ARG, "-a" }) ), ({}) ) test_equal( opt( "-a,--b"/",", ({ "a", Getopt.NO_ARG, "-b" }) ), ({}) ) test_equal( opt( "-a,-b"/",", ({ "b", Getopt.NO_ARG, "-b" }) ), ({ ({ "b", 1 }) }) ) test_equal( opt( "-a,-ab"/",", ({ "b", Getopt.NO_ARG, "-b" }) ), ({ ({ "b", 1 }) }) ) test_equal( opt( ",-,-a"/",", ({ "a", Getopt.NO_ARG, "-a" }) ), ({ ({ "a", 1 }) }) ) ) test_equal( opt( ",--,-a"/",", ({ "a", Getopt.NO_ARG, "-a" }) ), ({}) ) test_equal( opt( ",-b,-A"/",", ({ "a", Getopt.NO_ARG, "-a-A"/2 }) ), ({ ({ "a", 1 }) }) ) test_equal( Getopt.find_all_options( ",-a,-b"/",", ({ ({ "a", Getopt.NO_ARG, "-a" }), ({ "b", Getopt.NO_ARG, "-b" }) })), ({ ({ "a", 1 }), ({ "b", 1 }) }) ) test_equal( opt( "--a,--b"/",", ({ "a", Getopt.NO_ARG, "--a" }) ), ({}) ) test_equal( opt( "--a,--b"/",", ({ "b", Getopt.NO_ARG, "--b" }) ), ({ ({ "b", 1 }) }) ) test_equal( opt( "--a,--b=c"/",", ({ "b", Getopt.NO_ARG, "--b" }) ), ({ ({ "b", "c" }) }) ) test_equal( opt( ",-,--a"/",", ({ "a", Getopt.NO_ARG, "--a" }) ), ({ ({ "a", 1 }) }) ) ) test_equal( opt( ",--,--a"/",", ({ "a", Getopt.NO_ARG, "--a" }) ), ({}) ) test_equal( opt( ",--b,--A"/",", ({ "a", Getopt.NO_ARG, "--a--A"/3 }) ), ({ ({ "a", 1 }) }) ) test_equal( Getopt.find_all_options( ",--a,--b"/",", ({ ({ "a", Getopt.NO_ARG, "--a" }), ({ "b", Getopt.NO_ARG, "--b" }) })), ({ ({ "a", 1 }), ({ "b", 1 }) }) ) test_equal( opt( "-a,-b"/",", ({ "a", Getopt.MAY_HAVE_ARG, "-a" }) ), ({}) ) test_equal( opt( "-a,-b"/",", ({ "b", Getopt.MAY_HAVE_ARG, "-b" }) ), ({ ({ "b", 1 }) }) ) test_equal( opt( "-a,-b,c"/",", ({ "b", Getopt.MAY_HAVE_ARG, "-b" }) ), ({ ({ "b", 1 }) }) ) test_equal( opt( "-a,-bc"/",", ({ "b", Getopt.MAY_HAVE_ARG, "-b" }) ), ({ ({ "b", "c" }) }) ) test_equal( opt( "--a,--b"/",", ({ "a", Getopt.MAY_HAVE_ARG, "--a" }) ), ({}) ) test_equal( opt( "--a,--b,d"/",", ({ "b", Getopt.MAY_HAVE_ARG, "--b" }) ), ({ ({ "b", 1 }) }) ) test_equal( opt( "--a,--b=c,d"/",", ({ "b", Getopt.MAY_HAVE_ARG, "--b" }) ), ({ ({ "b", "c" }) }) ) test_equal( opt( "-a,-b"/",", ({ "a", Getopt.HAS_ARG, "-a" }) ), ({}) ) test_eval_error( opt( "-a,-b"/",", ({ "b", Getopt.HAS_ARG, "-b" }), 0, 1 ) ) test_equal( opt( "-a,-b,c"/",", ({ "b", Getopt.HAS_ARG, "-b" }) ), ({ ({ "b", "c" }) }) ) test_equal( opt( "-a,-bc,d"/",", ({ "b", Getopt.HAS_ARG, "-b" }) ), ({ ({ "b", "c" }) }) ) test_equal( opt( "--a,--b"/",", ({ "a", Getopt.HAS_ARG, "--a" }) ), ({}) ) test_eval_error( opt( "--a,--b"/",", ({ "b", Getopt.HAS_ARG, "--b" }), 0, 1 ) ) test_equal( opt( "--a,--b,d"/",", ({ "b", Getopt.HAS_ARG, "--b" }) ), ({ ({ "b", "d" }) }) ) test_equal( opt( "--a,--b=c,d"/",", ({ "b", Getopt.HAS_ARG, "--b" }) ), ({ ({ "b", "c" }) }) ) test_any_equal([[ array x = ({ "", "--a" }); opt( x, ({ "x", Getopt.NO_ARG, "--a" }) ); return x; ]],[[ ({ "", 0 }) ]]) test_any_equal([[ array x = ({ "", "--a" }); opt( x, ({ "x", Getopt.NO_ARG, "--b" }) ); return x; ]],[[ ({ "", "--a" }) ]]) test_any_equal([[ array x = ({ "", "--a", "hej" }); opt( x, ({ "x", Getopt.HAS_ARG, "--a" }) ); return x; ]],[[ ({ "", 0, 0 }) ]]) test_any_equal([[ array x = ({ "", "--a", "hej" }); opt( x, ({ "x", Getopt.MAY_HAVE_ARG, "--a" }) ); return x; ]],[[ ({ "", 0, "hej" }) ]]) test_any_equal([[ array x = ({ "", "-ab" }); opt( x, ({ "x", Getopt.NO_ARG, "-a" }) ); return x; ]],[[ ({ "", "-b" }) ]]) test_any_equal([[ array x = ({ "", "-ab" }); opt( x, ({ "x", Getopt.MAY_HAVE_ARG, "-a" }) ); return x; ]],[[ ({ "", 0 }) ]]) test_any_equal([[ array x = ({ "", "-ab" }); opt( x, ({ "x", Getopt.NO_ARG, "-b" }) ); return x; ]],[[ ({ "", "-a" }) ]]) test_any_equal([[ array x = ({ "", "-ab" }); opt( x, ({ "x", Getopt.HAS_ARG, "-a" }) ); return x; ]],[[ ({ "", 0 }) ]]) test_any_equal([[ array x = ({ "", "-", "-abc" }); opt( x, ({ "x", Getopt.NO_ARG, "-b" }) ); return x; ]],[[ ({ "", "-", "-ac" }) ]]) test_any_equal([[ array x = ({ "", "-ab", "c" }); opt( x, ({ "x", Getopt.HAS_ARG, "-b" }) ); return x; ]],[[ ({ "", "-a", 0 }) ]]) test_any_equal([[ array x = ({ "", "-ab", "c", "--x", "x" }); Getopt.find_all_options( x, ({ ({ "x", Getopt.HAS_ARG, "-b" }), ({ "y", Getopt.NO_ARG, "-a" }), ({ "z", Getopt.HAS_ARG, "--x" }) }) ); return x; ]],[[ ({ "", 0, 0, 0, 0 }) ]]) test_equal( opt( ({}), ({ "a", Getopt.MAY_HAVE_ARG, "-a", 0, "e" }) ), ({ }) ) test_equal( opt( ({"","-a"}), ({ "a", Getopt.MAY_HAVE_ARG, "-a", 0, "e" }) ), ({ ({ "a", "e" }) }) ) test_equal( opt( ({"","--a"}), ({ "a", Getopt.MAY_HAVE_ARG, "--a", 0, "e" }) ), ({ ({ "a", "e" }) }) ) test_equal( opt( ({}), ({ "a", Getopt.HAS_ARG, "-a", "foo" }) ), ({ ({ "a", "bar" }) }) ) test_equal( opt( ({}), ({ "a", Getopt.HAS_ARG, "-a", ({ "x", "foo" }) }) ), ({ ({ "a", "bar" }) }) ) test_equal( Getopt.get_args(({ "x", "a", "-b" }), 1, 1), ({ "x", "a", "-b" })) test_any_equal([[ array x = ({ "x", "a", "-b" }); opt(x, ({ "y", Getopt.HAS_ARG, "-b" }), 1 ); return x; ]],[[ ({ "x", "a", "-b" }) ]]) test_do( putenv("POSIX_ME_HARDER", "1"); ) test_eval_error( Getop.get_args(({ "x", "a", "-b" }), -1, 1) )
4661b52002-11-16Henrik Grubbström (Grubba) test_equal( Getopt.get_args(({ "x", "a", "-b" }), 0, 1), ({ "x", "a", "-b" }))
48f2492003-01-02Martin Nilsson test_eval_error( Getopt.get_args(({ "x", 0, "-b" }), 0, 1))
854a762002-11-17Henrik Grubbström (Grubba) test_eval_error( opt( ({"x","a","-b"}), ({"y",Getopt.HAS_ARG,"-b"}), -1, 1 ))
26a1952002-11-15Martin Nilsson test_any_equal([[ array x = ({ "x", "a", "-b" });
4661b52002-11-16Henrik Grubbström (Grubba)  opt(x, ({ "y", Getopt.HAS_ARG, "-b" }), 0, 1 );
26a1952002-11-15Martin Nilsson  return x; ]],[[ ({ "x", "a", "-b" }) ]]) test_any_equal([[ array x = ({ "x", "a", "-b" });
afd9272002-11-15Henrik Grubbström (Grubba)  opt(x, ({ "y", Getopt.HAS_ARG, "-b" }), 1, 1);
26a1952002-11-15Martin Nilsson  return x; ]],[[ ({ "x", "a", "-b" }) ]]) dnl cleanup test_do( master()->environment=getopt_env; ) test_do( add_constant("getopt_env"); ) test_do( add_constant("opt"); )
9370072002-10-14Martin Nilsson dnl - Colors test_equal(Colors.parse_color(""),({0,0,0}))
3c87a12002-08-03Martin Nilsson test_equal(Colors.parse_color("red"),({255,0,0})) test_equal(Colors.parse_color("RED"),({255,0,0})) test_equal(Colors.parse_color("lightred"),({255,61,61})) test_equal(Colors.parse_color("LIGHT RED"),({255,61,61})) test_equal(Colors.parse_color("#ff0000"),({255,0,0})) test_equal(Colors.parse_color("ff0000"),({255,0,0})) test_equal(Colors.parse_color("@0,255,255"),({255,0,0})) test_equal(Colors.parse_color("%0,100,100,0"),({255,0,0})) test_equal(Colors.rgb_to_hsv(255,0,0),({0,255,255})) test_equal(Colors.hsv_to_rgb(0,255,255),({255,0,0})) test_equal(Colors.rgb_to_cmyk(255,0,0),({0,100,100,0})) test_equal(Colors.cmyk_to_rgb(0,100,100,0),({255,0,0}))
9370072002-10-14Martin Nilsson  dnl - Mapping dnl Mapping.delete dnl Mapping.Iterator dnl - Multiset dnl Multiset.Iterator