4bea98 | 2004-03-20 | Henrik Grubbström (Grubba) | | dnl $Id: testsuite.in,v 1.25 2004/03/20 16:30:11 grubba Exp $
|
3c87a1 | 2002-08-03 | Martin Nilsson | |
|
937007 | 2002-10-14 | Martin Nilsson | | dnl - Array
|
3c87a1 | 2002-08-03 | Martin Nilsson | |
|
ee66ab | 2003-01-15 | Martin 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"/"", ({ "/" }) }) }))
|
cccc64 | 2003-04-29 | Martin Nilsson | | dnl Array.diff_compare_table
|
ee66ab | 2003-01-15 | Martin Nilsson | | test_equal(Array.longest_ordered_sequence("dfgaokäpojghadjjioijrgxcvb"/""),
({ 0, 1, 2, 10, 11, 16, 18, 19, 20, 22 }));
|
937007 | 2002-10-14 | Martin Nilsson | | dnl Array.interleave_array
dnl Array.sort
|
e5a2cc | 2002-10-14 | Johan 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)
|
937007 | 2002-10-14 | Martin 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"}))
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal(Array.everynth(({})),({}))
|
3c87a1 | 2002-08-03 | Martin 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"}))
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal(Array.uniq( ({}) ), ({}))
|
3c87a1 | 2002-08-03 | Martin 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}))
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal([[ Array.filter( ({}), lambda(int i) { return 1; })]], ({}))
|
3c87a1 | 2002-08-03 | Martin Nilsson | |
test_equal(Array.permute( ({ 1,2 }), 0 ),
({ 1,2 }))
test_equal(Array.permute( ({ 1,2 }), 1 ),
({ 2,1 }))
|
cccc64 | 2003-04-29 | Martin Nilsson | | test_equal(Array.permute( ({ 1,2 }), 2 ),
({ 1,2 }))
|
3c87a1 | 2002-08-03 | Martin Nilsson | | 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 }))
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal(Array.permute( ({}), 1 ), ({}))
|
3c87a1 | 2002-08-03 | Martin Nilsson | |
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal(Array.enumerate(0), ({}))
test_equal(Array.enumerate(1), ({ 0 }))
|
3c87a1 | 2002-08-03 | Martin 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 }))
|
e5a2cc | 2002-10-14 | Johan 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)
|
937007 | 2002-10-14 | Martin Nilsson | |
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal(Array.shuffle(({})), ({}))
test_equal(Array.shuffle(({1})), ({1}))
|
3c87a1 | 2002-08-03 | Martin 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)))) )
|
937007 | 2002-10-14 | Martin Nilsson | | dnl Array.search_array
|
cccc64 | 2003-04-29 | Martin Nilsson | |
test_equal( Array.sum_arrays( `+, ({}) ), ({}) )
test_equal( Array.sum_arrays( `+, enumerate(5), enumerate(5)), ({0,2,4,6,8}) )
|
e5a2cc | 2002-10-14 | Johan Sundström | |
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal(Array.sort_array(({})), ({}))
|
e5a2cc | 2002-10-14 | Johan Sundström | | test_equal([[ Array.sort_array(enumerate(9), `<) ]], [[ enumerate(9,-1,8) ]])
|
937007 | 2002-10-14 | Martin Nilsson | | dnl Array.columns
dnl Array.transpose_old
|
ee66ab | 2003-01-15 | Martin 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"}),({ })})}))
|
937007 | 2002-10-14 | Martin Nilsson | | dnl Array.diff3_old
|
ee66ab | 2003-01-15 | Martin Nilsson | |
|
cccc64 | 2003-04-29 | Martin Nilsson | | define(test_sort,[[
test_eq(Array.$1($2,$3), -1)
test_eq(Array.$1($3,$2), 1)
]])
test_false(Array.dwim_sort_func("",""))
test_sort(dwim_sort_func,"1","a")
test_sort(dwim_sort_func,"1","1a")
test_sort(dwim_sort_func,"0a","1")
test_sort(dwim_sort_func,"1","2")
test_sort(dwim_sort_func,"2a","10")
|
ee66ab | 2003-01-15 | Martin Nilsson | | test_eq(Array.dwim_sort_func("1","1"), 0)
test_eq(Array.dwim_sort_func("1","01"), 0)
|
cccc64 | 2003-04-29 | Martin Nilsson | |
test_false(Array.lyskom_sort_func("",""))
test_sort(lyskom_sort_func,"a","b")
test_false(Array.lyskom_sort_func("a","a"))
test_false(Array.lyskom_sort_func("Foo (bar)","foo (really!)"))
|
ee66ab | 2003-01-15 | Martin Nilsson | |
|
937007 | 2002-10-14 | Martin Nilsson | | dnl Array.lyskom_sort_func
|
cccc64 | 2003-04-29 | Martin Nilsson | |
test_eq( Array.flatten( ({}) ), ({}) )
test_equal( Array.flatten( ({1,({2,({3,({4}),({}),5})}),({({}),({6})})})),
({1,2,3,4,5,6}) )
test_equal( Array.flatten( ({ 1,({2,3}),4,({2,3}),5 }) ), ({1,2,3,4,2,3,5}) )
test_any_equal([[
array a=({1,2,3});
a[1]=a;
return Array.flatten(a);
]], ({1,3}))
test_any_equal([[
array a=({1,({2,3}),({4,5}),({2,3})});
a[2][1]=a;
return Array.flatten(a);
]], ({1,2,3,4,2,3}))
|
e5a2cc | 2002-10-14 | Johan Sundström | |
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_eq(Array.sum(({})),0)
|
e5a2cc | 2002-10-14 | Johan Sundström | | test_eq(Array.sum((array(int))"157"), 157)
test_eq([[ Array.sum(enumerate(12345)) ]],
[[ Array.reduce(`+, enumerate(12345)) ]])
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_eq(Array.sum( "abcdefgh"/2.5 ), "abcdefgh")
test_equal([[ Array.sum( ({ ({ 1,2,3 }), ({ 4,5 }) }) )]],[[ ({ 1,2,3,4,5 }) ]])
|
e5a2cc | 2002-10-14 | Johan Sundström | |
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal(Array.uniq2(({})), ({}))
|
e5a2cc | 2002-10-14 | Johan Sundström | | test_equal([[ Array.uniq2("AAAAAAAAAAAHHHHAAA!!!!"/1)*"" ]], [[ "AHA!" ]])
|
937007 | 2002-10-14 | Martin 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 ) ]],[[ ({}) ]])
|
3c87a1 | 2002-08-03 | Martin Nilsson | |
|
937007 | 2002-10-14 | Martin Nilsson | | dnl Array.oid_sort_func
dnl Array.greedy_diff
|
e5a2cc | 2002-10-14 | Johan Sundström | |
|
f14a83 | 2002-10-16 | Martin Nilsson | | test_equal( Array.count(({})), ([]) )
|
e5a2cc | 2002-10-14 | Johan 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 ]) ]])
|
937007 | 2002-10-14 | Martin 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(({})), ({}))
|
e25444 | 2003-02-06 | Martin Nilsson | | dnl - Colors
define(test_rgb,[[
test_equal(Colors.$1($2),({$3}))
test_equal(Colors.$1(({$2})),({$3}))
]])
test_rgb(rgb_to_hsv,[[0,0,0]],[[0,0,0]])
test_rgb(rgb_to_hsv,[[255,255,255]],[[0,0,255]])
test_rgb(rgb_to_hsv,[[17,42,112]],[[159,216,112]])
test_rgb(hsv_to_rgb,[[0,0,0]],[[0,0,0]])
test_rgb(hsv_to_rgb,[[255,255,255]],[[255,0,0]])
test_rgb(hsv_to_rgb,[[17,42,112]],[[112,101,93]])
test_rgb(rgb_to_cmyk,[[0,0,0]],[[0,0,0,100]])
test_rgb(rgb_to_cmyk,[[255,255,255]],[[0,0,0,0]])
test_rgb(rgb_to_cmyk,[[17,41,112]],[[37,28,0,56]])
test_rgb(cmyk_to_rgb,[[0,0,0,0]],[[255,255,255]])
test_rgb(cmyk_to_rgb,[[100,100,100,100]],[[0,0,0]])
test_rgb(cmyk_to_rgb,[[17,42,100,2]],[[207,143,0]])
test_equal(Colors.parse_color(0),({0,0,0}))
test_equal(Colors.parse_color(""),({0,0,0}))
test_equal(Colors.parse_color("gazonk"),({0,0,0}))
test_equal(Colors.parse_color(0, ({1,2,3})),({1,2,3}))
test_equal(Colors.parse_color("", ({1,2,3})),({1,2,3}))
test_equal(Colors.parse_color("gazonk", ({1,2,3})),({1,2,3}))
test_equal(Colors.parse_color("red"),({255,0,0}))
test_equal(Colors.parse_color("red", ({1,2,3})),({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("dimgray"),({105,105,105}))
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_eq(Colors.color_name(0),"-")
test_eq(Colors.color_name( ({0,0}) ), "-")
test_eq(Colors.color_name( ({255,0,0}) ), "red")
test_eq(Colors.color_name( ({255,61,61}) ), "#ff3d3d")
test_eq(Colors.color_name( ({105,105,105}) ), "dimgrey")
|
937007 | 2002-10-14 | Martin Nilsson | |
|
26a195 | 2002-11-15 | Martin Nilsson | | dnl - Getopt
dnl setup
test_do( add_constant("getopt_env", master()->environment); )
test_do( master()->environment=([ "foo": ({ "foo", "bar" }) ]); )
|
631757 | 2002-11-17 | Martin Nilsson | | test_eq( Getopt.find_option( ({}), "a" ), 0 )
|
26a195 | 2002-11-15 | Martin 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")
|
631757 | 2002-11-17 | Martin 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) )
|
26a195 | 2002-11-15 | Martin 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")
|
631757 | 2002-11-17 | Martin Nilsson | | test_eval_error( Getopt.find_option( ",-a"/",", "a", 0, 0, "y", 1) )
|
26a195 | 2002-11-15 | Martin 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")
|
631757 | 2002-11-17 | Martin Nilsson | | test_equal( Getopt.get_args( ({}) ), ({}) )
|
26a195 | 2002-11-15 | Martin 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" }))
|
48f249 | 2003-01-02 | Martin Nilsson | | test_eval_error( Getopt.get_args(({ "x", 0, "-b" }), 1, 1))
|
26a195 | 2002-11-15 | Martin 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); }); )
|
631757 | 2002-11-17 | Martin Nilsson | | test_equal( Getopt.find_all_options( ({}), ({}) ), ({}) )
|
26a195 | 2002-11-15 | Martin 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 }) ]])
|
35c87a | 2003-02-26 | Martin Stjernholm | | test_any_equal([[
array x = ({"program", "-M", ".", "-e", "x"});
Getopt.find_all_options(
x, ({
({"M", Getopt.HAS_ARG, "-M", 0, 0}),
({"e", Getopt.HAS_ARG, "-e", 0, 0}),
}), 1);
return x;
]], ({"program", 0, 0, 0, 0}))
|
26a195 | 2002-11-15 | Martin Nilsson | |
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) )
|
4661b5 | 2002-11-16 | Henrik Grubbström (Grubba) | | test_equal( Getopt.get_args(({ "x", "a", "-b" }), 0, 1), ({ "x", "a", "-b" }))
|
48f249 | 2003-01-02 | Martin Nilsson | | test_eval_error( Getopt.get_args(({ "x", 0, "-b" }), 0, 1))
|
854a76 | 2002-11-17 | Henrik Grubbström (Grubba) | | test_eval_error( opt( ({"x","a","-b"}), ({"y",Getopt.HAS_ARG,"-b"}), -1, 1 ))
|
26a195 | 2002-11-15 | Martin Nilsson | | test_any_equal([[
array x = ({ "x", "a", "-b" });
|
4661b5 | 2002-11-16 | Henrik Grubbström (Grubba) | | opt(x, ({ "y", Getopt.HAS_ARG, "-b" }), 0, 1 );
|
26a195 | 2002-11-15 | Martin Nilsson | | return x;
]],[[ ({ "x", "a", "-b" }) ]])
test_any_equal([[
array x = ({ "x", "a", "-b" });
|
afd927 | 2002-11-15 | Henrik Grubbström (Grubba) | | opt(x, ({ "y", Getopt.HAS_ARG, "-b" }), 1, 1);
|
26a195 | 2002-11-15 | Martin 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"); )
|
cccc64 | 2003-04-29 | Martin Nilsson | | dnl - Int
test_eq( Int.parity(0), 0 )
test_eq( Int.parity(1), 1 )
test_eq( Int.parity(2), 1 )
test_eq( Int.parity(3), 0 )
test_eq( Int.parity(4), 1 )
test_eq( Int.parity(6), 0 )
test_eq( Int.parity(7), 1 )
|
f1fbf8 | 2004-03-15 | Martin Nilsson | | test_eq( Int.swap_word(array_sscanf("\1\2", "%2c")[0]),
array_sscanf("\2\1", "%2c")[0])
test_eq( Int.swap_long(array_sscanf("\1\2\3\4", "%4c")[0]),
array_sscanf("\4\3\2\1", "%4c")[0])
|
937007 | 2002-10-14 | Martin Nilsson | | dnl - Mapping
dnl Mapping.delete
dnl Mapping.Iterator
dnl - Multiset
dnl Multiset.Iterator
|
ee1317 | 2003-08-10 | Martin Nilsson | |
dnl - Process
test_equal([[Process.split_quoted_string("test ")]],[[({"test"})]])
test_equal([[Process.split_quoted_string("'test'")]],[[({"test"})]])
test_equal([[Process.split_quoted_string("foo 'test' bar")]],[[({"foo","test","bar"})]])
test_equal([[Process.split_quoted_string("pike -m master.pike 'write(\"test\");'")]],[[({"pike","-m","master.pike","write(\"test\");"})]])
test_false([[
#ifdef __NT__
Process.system(RUNPIKE +" -e exit(0)")
#else /* !__NT__ */
Process.system(RUNPIKE +" -e 'exit(0)'")
#endif /* __NT__ */
]])
test_true([[
#ifdef __NT__
Process.system(RUNPIKE+" -e exit(1)")
#else /* !__NT__ */
Process.system(RUNPIKE+" -e 'exit(1)'")
#endif /* __NT__ */
]])
test_any([[object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(2)"})); sleep(10); return p->wait()]],2)
test_eq([[
#ifdef __NT__
Process.popen(RUNPIKE+" -e \"write(\\\"test\\\");\"")
#else /* !__NT__ */
Process.popen(RUNPIKE+" -e 'write(\"test\");'")
#endif /* __NT__ */
]],"test")
test_any([[object o=Stdio.File(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(5)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.File(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.Fd(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.Fd(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.Fd(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); o2=0; return p->wait()]],1)
test_any([[object o=Stdio.Fd(); object o2=o->pipe(); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(5)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.Fd(); object o2=o->pipe(); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.Fd(); object o2=o->pipe(); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.File(\"stdin\")->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.File(); object o2=o->pipe(); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.File(\"stdin\")->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.File(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
test_any([[object o=Stdio.File(); object o2=o->pipe(Stdio.PROP_BIDIRECTIONAL); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o2])); o->write("hello"); destruct(o); destruct(o2); return p->wait()]],1)
cond([[ file_stat("/bin/cat") && file_stat("/dev/null") && (cpp("__NT__")/"\n")[1]=="__NT__" ]],
[[
test_false(Process.create_process(({"/bin/cat","/dev/null"}))->wait());
test_false(Process.create_process(({"/bin/cat","/dev/null"}))->wait());
test_false(Process.create_process(({"/bin/cat","/dev/null"}))->wait());
test_any([[
object o=Process.create_process(({"/bin/cat","/dev/null"}));
if(Process.create_process(({"/bin/cat","/dev/null"}))->wait()) return 99;
sleep(1);
return kill(o->pid(), 9);
]],0);
dnl Some OSs have a delay before PIDs are reused.
dnl Be nice, and let them reuse some.
test_do([[ sleep(2); ]]);
test_any([[ for(int x=0;x<10;x++) { for(int e=0;e<100;e++) if(Process.create_process(({"/bin/cat","/dev/null"}))->wait()) return e; __signal_watchdog(); } return -1;]],-1)
]])
cond([[ file_stat("/bin/cat") && file_stat("/dev/null") && all_constants()->thread_create && (cpp("__NT__")/"\n")[1]=="__NT__" ]],
[[
test_any([[
return allocate(10, thread_create) (
lambda() {
for (int x=0; x<10; x++) {
for (int e=0; e<50; e++)
if (Process.create_process(({"/bin/cat","/dev/null"}))->wait())
return e;
__signal_watchdog();
}
return -1;
}
)->wait() - ({-1})]],({}))
]])
cond([[ file_stat("/bin/cat") && file_stat("/dev/null") && all_constants()->thread_create && (cpp("__NT__")/"\n")[1]=="__NT__" ]],
[[
test_do([[
for(int q=0;q<100;q++)
{
array fnord=({});
Thread.Fifo fifo=Thread.Fifo();
for(int e=0;e<10;e++)
{
fnord+=({ thread_create(lambda() {
Process.create_process(({"/bin/cat","/dev/null"}));
fifo->read();
})
});
}
// for(int e=0;e<50;e++) Stdio.Port()->bind(0);
for(int e=0;e<10;e++) fifo->write(1);
fnord->wait();
__signal_watchdog();
}
]])
]])
cond([[ file_stat("/bin/sleep") && all_constants()->thread_create && (cpp("__NT__")/"\n")[1]=="__NT__" ]],
[[
test_any([[
class Fnord
{
int gnapp(int t)
{
int e;
for(e=0;e<7;e++)
{
for(int d=0;d<150;d++)
{
object o=Process.create_process(({"/bin/sleep","99999"}));
kill( o->pid(), 9 );
o->wait();
__signal_watchdog();
}
// werror("%d",t);
}
return -1;
}
array start()
{
array a=({});
for(int e=0;e<10;e++)
a+=({thread_create(gnapp,e)});
return a;
}
};
return Fnord()->start()->wait()-({ -1 });
]],[[ ({}) ]])
test_do([[
object proc = Process.create_process (({"/bin/sleep", "99999"}));
array threads = allocate (10, Thread.thread_create) (
lambda (object proc) {proc->wait();}, proc);
sleep (1);
proc->kill (9);
return threads->wait() - ({-1});
]], ({}))
]])
|
4bea98 | 2004-03-20 | Henrik Grubbström (Grubba) | | dnl - This test is disabled for now.
cond([[ 0 && __builtin->TraceProcess && (cpp("__NT__")/"\n")[1]=="__NT__" ]],
|
ee1317 | 2003-08-10 | Martin Nilsson | | [[
test_any([[
// Check that tracing works...
|
7c38af | 2003-10-16 | Henrik Grubbström (Grubba) | | // Spawn a /bin/dd that hangs on a read from a pipe connected to
|
72f767 | 2003-10-04 | Henrik Grubbström (Grubba) | | // this process, so that it will die of SIGPIPE if we die.
Stdio.File input_fd = Stdio.File();
|
ee1317 | 2003-08-10 | Martin Nilsson | | Process.TraceProcess proc =
|
87fbb0 | 2003-11-21 | Henrik Grubbström (Grubba) | | Process.TraceProcess(RUNPIKE_ARRAY + ({ "-e", "Stdio.stdin.read(1)" }), ([
|
05f38b | 2003-10-05 | Henrik Grubbström (Grubba) | | "stdin":input_fd->pipe(Stdio.PROP_IPC|Stdio.PROP_REVERSE),
|
72f767 | 2003-10-04 | Henrik Grubbström (Grubba) | | ]));
|
ee1317 | 2003-08-10 | Martin Nilsson | |
int initial_sleep = 5;
int count;
int state;
int code;
while (((code = proc->wait()) == -2) && (count++ < 20)) {
int sig = proc->last_signal();
switch(sig) {
case signum("TRAP"):
if (state) {
// NB: OSF/1 issues two SIGTRAPS before the program starts executing.
werror("Unexpected SIGTRAP in state %d.\n", state);
}
state = ((state <= 1) ? 1 : state);
proc->cont();
// Give it some time to settle down after initialization.
if (initial_sleep) {
sleep(initial_sleep);
initial_sleep=0;
}
// Check that we can block deadly signals.
proc->kill(signum("TERM"));
break;
case signum("TERM"):
if (state != 1) {
werror("Unexpected SIGTERM in state %d.\n", state);
}
state = ((state <= 2) ? 2 : state);
proc->cont(); // Ignore it...
// Check that we can make harmless signals deadly.
proc->kill(signum("CONT"));
break;
case signum("CONT"):
if (state != 2) {
werror("Unexpected SIGCONT in state %d.\n", state);
}
state = ((state <= 3) ? 3 : state);
proc->cont(signum("KILL")); // Make it a SIGKILL
sleep(5); // Give it some time to die and get reaped.
if (proc->kill(signum("KILL"))) {
return sprintf("Process didn't die of cont(%d).", signum("KILL"));
}
break;
default:
proc->kill(signum("KILL"));
return sprintf("Unexpected signal:%d in state %d.", sig, state);
}
}
if (code == -2) {
proc->kill(signum("KILL"));
return sprintf("Looping trace. (Looped %d times).", count-1);
}
if (code != -1) {
proc->kill(signum("KILL"));
return sprintf("Bad termination returncode from wait():%d (expected -1).",
code);
}
if (state != 3) {
return sprintf("Unexpected termination in state %d, signal %d.",
state, proc->last_signal());
}
int sig = proc->last_signal();
if (sig != signum("KILL")) {
proc->kill(signum("KILL"));
return sprintf("Unexpected termination signal:%d (expected %d).",
sig, signum("KILL"));
}
// Test ok.
return 0; ]], 0)
]])
test_do([[
string s;
for(s="foobar";strlen(s)<78;s+=s)
{
for(int e=0;e<strlen(s);e++)
{
s[e]++;
}
}
]])
|