pike.git / lib / modules / ADT.pmod / testsuite.in

version» Context lines:

pike.git/lib/modules/ADT.pmod/testsuite.in:103:   test_eq(adth[-2],24)   test_do( adth->set_no_adjacent_duplicates(0), 0)   test_do( adth->push(26) )   test_do( adth->push(26) )   test_eq(adth[-2],26)   test_do( adth[-1]=27 )   test_equal(indices(adth),[[ ({9,10}) ]])   test_equal(values(adth),[[ ({26,27}) ]])   test_do(add_constant("adth"))    + dnl - ADT.LowLevelStack + cond_begin([[ ADT["LowLevelStack"] ]]) + test_any([[ +  object s = ADT.LowLevelStack(); +  s->push(1); +  return s->pop(); + ]], 1)    -  + test_eval_error(return ADT.LowLevelStack()->pop()) +  + test_any([[ +  object s = ADT.LowLevelStack(); +  for(int i; i<1000; i++) +  s->push(i); +  for(int i; i<1000; i++) +  s->pop(); +  for(int i; i<1000; i++) +  s->push(i); +  return s->pop(); + ]], 999) +  + test_equal_any([[ +  object s = ADT.LowLevelStack(); +  s->push(2); +  s->push(3); +  s->push(4); +  s->pop(); +  return s->pop(2); + ]], ({2,3}) ) +  + test_any([[ +  object s = ADT.LowLevelStack(); +  s->push(5); +  return s->top(); + ]], 5) +  + test_eval_error(return ADT.LowLevelStack()->top()) +  + test_any([[ +  object s = ADT.LowLevelStack(); +  for(int i; i<1000; i++) +  s->push(i); +  for(int i; i<1000; i++) +  s->quick_pop(); +  for(int i; i<1000; i++) +  s->push(i); +  return sizeof(s); + ]], 1000) +  + test_any([[ +  object s = ADT.LowLevelStack(); +  for(int i; i<1000; i++) +  s->push(i); +  return sizeof(s); + ]], 1000) +  + test_any([[ +  object s = ADT.LowLevelStack(); +  s->push(3); +  s->reset(); +  return sizeof(s); + ]], 0) +  + test_any([[ +  object s = ADT.LowLevelStack(); +  s->set_stack( "1234"/1 ); +  s->push("5"); +  return s->pop()+sizeof(s); + ]], "54") +  + test_any([[ +  object s = ADT.LowLevelStack(); +  s->push("a"); +  s->push("b"); +  return values(s)*","; + ]], [["a,b"]]) +  + test_any([[ +  object s = ADT.LowLevelStack(); +  s->set_stack( "1234"/1 ); +  object t = ADT.LowLevelStack(); +  t->push("5"); +  return values(s+t)*""; + ]], "12345") +  + cond_end // ADT.LowLevelStack +  +    dnl - ADT.Priority_queue      test_eval_error( ADT.Priority_queue()->pop(); )   test_any([[    object q=ADT.Priority_queue();    q->push(1,"a");    return q->pop();   ]], "a")   test_any([[    object q=ADT.Priority_queue();
pike.git/lib/modules/ADT.pmod/testsuite.in:125:    q->push(2,"b");    return q->pop();   ]], "a")   test_any([[    object q=ADT.Priority_queue();    q->push(2,"a");    q->push(1,"b");    return q->pop();   ]], "b")    + dnl - ADT.Scheduler      dnl - ADT.Stack      test_any([[    object s = ADT.Stack();    s->push(1);    return s->pop();   ]], 1)      test_eval_error(return ADT.Stack()->pop())
pike.git/lib/modules/ADT.pmod/testsuite.in:351:    Item z = Byte();    };    add_constant("Test", B);   ]])   test_eq( (string)Test("XXABZ"), "XXABZ" )   test_eq( Test("XXABZ")->y->a, 'A' )   test_do( add_constant("Test"); )      dnl - ADT.Table    - test_equal(ADT.Table.table( + test_equal((array)ADT.Table.table(    ({ ({ "a", "b", 42 }),    ({ "c", "b", 41 }),    ({ "a", "a", 76 }) }),    ({ "X", "Y", "z" }))->select("x", 2)->sum("Z")->distinct(0)->rsort("X") -  ->rename(0, "fOo")->sort("foO")->cast("array"), +  ->rename(0, "fOo")->sort("foO"),    ({ ({ "a", 118 }),    ({ "c", 41 }) }))    - test_equal(ADT.Table.table( + test_equal((array)ADT.Table.table(    ({ ({ "a", "5.3" }),    ({ "b", "5.1" }),    ({ "c", "4711" }) }), ({ "one", "two" }), -  ({ (["type":"text"]), (["type":"num"]) }))->sort("two")->cast("array"), +  ({ (["type":"text"]), (["type":"num"]) }))->sort("two"),    ({ ({ "b", "5.1" }),    ({ "a", "5.3" }),    ({ "c", "4711" }) }))    -  + dnl - ADT.TreeScheduler    -  + test_do( add_constant("Test", ([ +  "Consumers":({}), +  "Scheduler":ADT.TreeScheduler(), + ])); ) +  + dnl weight, label, [parent] + define(test_ts_add,[[ +  test_do([[ +  mapping m = all_constants()->Test; +  m->Consumers += ({ Test.Scheduler.add($1, $2, $3) }); +  ]]) + ]]) +  + test_ts_add(4, "4A") + test_ts_add(8, "8A") + test_ts_add(4, "4B", Test.Consumers[1]) + test_ts_add(8, "8B", Test.Consumers[1]) +  + test_eq(sizeof(Test.Consumers[1]->children), 2) + test_equal(Test.Consumers->weight, ({ 4, 8, 4, 8 })) + test_equal(Test.Consumers->pri, ({ 1.5, 0.75, 2.25, 1.125 })) + test_eq(Test.Scheduler.get()->value, "8A"); +  + test_do(Test.Scheduler.remove(Test.Consumers[1])) + test_eq(Test.Scheduler.get()->value, "8B"); +  + test_do(Test.Consumers[1]->reparent_siblings()) + test_eq(Test.Scheduler.get()->value, "8B"); + test_eq(sizeof(Test.Consumers[1]->children), 3) + test_equal(Test.Consumers->weight, ({ 6.0, 8, 4, 8 })) + test_equal(Test.Consumers->pri, ({ 1.5, 0.5, 2.25, 1.125 })) +  + test_do(destruct(Test.Scheduler);) + test_equal(Test.Consumers, ({ 0, 0, 0, 0 })) +  + test_do( add_constant("Test"); ) +    dnl - ADT.struct      define(test_put,[[   test_any([[ -  + #pragma no_deprecation_warnings    object s=ADT.struct();    s->$1;    return s->pop_data()+"\7777"+s->pop_data();   ]],$2"\7777")   test_any_equal([[ -  + #pragma no_deprecation_warnings    object s=ADT.struct($2);    return s->$3;   ]], $4)   ]])      test_put(add_data("hej"), "hej", get_fix_string(3), "hej")   test_put(put_uint(17,1), "\21", get_uint(1), 17)   test_put(put_uint(17,2), "\0\21", get_uint(2), 17)   test_put(put_var_string("hej",1), "\3hej", get_var_string(1), "hej") - cond([[ master()->resolv("Gmp")->mpz ]],[[ +    test_put(put_bignum(Gmp.mpz(123456789)), "\0\4\7[\315\25", get_bignum(),    Gmp.mpz(123456789)) - ]]) +    test_put(put_fix_string("hej"), "hej", get_fix_string(3), "hej")   test_put(put_fix_uint_array(({1,2,3,4}), 1), "\1\2\3\4", get_fix_uint_array(1,4),    ({1,2,3,4}))   test_put(put_var_uint_array(({1,2,3,4}),1,1), "\4\1\2\3\4", get_var_uint_array(1,1),    ({1,2,3,4}))      test_any([[ -  + #pragma no_deprecation_warnings    object s=ADT.struct("abcdefghijk");    return s->get_fix_string(3)+" "+s->contents()+" "+s->get_fix_string(3);   ]], "abc defghijk def")      test_any([[ -  + #pragma no_deprecation_warnings    object s=ADT.struct("abcdefghijk");    return s->get_fix_string(3)+" "+s->get_rest();   ]], "abc defghijk")      test_eval_error([[ -  + #pragma no_deprecation_warnings    object s=ADT.struct("abc");    s->get_rest();    s->get_fix_string(1);   ]])      test_any([[ -  + #pragma no_deprecation_warnings    object s=ADT.struct("hej");    string r = "x" + sizeof(s);    s->get_uint(3);    return r + ":" + sizeof(s);   ]], "x3:0")    -  + test_eq([[ + #pragma no_deprecation_warnings +  ADT.struct()->add_data("hej")->put_uint(1,2)->put_var_string("hi",1)->put_bignum(Gmp.mpz(1),1)->put_fix_string("x")->put_fix_uint_array(({6,7}),1)->put_var_uint_array(({6,7}),1,1)->pop_data() ]], "hej\0\1\2hi\1\1x\6\7\2\6\7") + test_eq([[ + #pragma no_deprecation_warnings +  ADT.struct()->put_var_uint_array(({6,7}),2,2)->pop_data() ]], "\0\4\0\6\0\7") + test_eq([[ + #pragma no_deprecation_warnings +  ADT.struct()->put_var_string_array(({"a","b"}),2,2)->pop_data() ]], "\0\6\0\1a\0\1b") +  + test_any([[ + #pragma no_deprecation_warnings +  object o = ADT.struct("abcd"); +  o->get_fix_string(1); +  return decode_value(encode_value(o))->get_fix_string(3); + ]], "bcd") +  +  + dnl ADT.Queue +  + test_any([[ +  object q=ADT.Queue(); +  if(sizeof(q)) return 1; +  if((array)q!=({})) return 2; +  if(!q->is_empty()) return 3; +  q->put(1,2); +  if(sizeof(q)!=2) return 4; +  if(!equal((array)q,({1,2}))) return 5; +  if(!equal(values(q),({1,2}))) return 6; +  if(q->peek()!=1) return 7; +  if(q->get()!=1) return 8; +  if(sizeof(q)!=1) return 9; +  q->flush(); +  if(sizeof(q)) return 10; +  if(!undefinedp(q->get())) return 11; +  return 0; + ]], 0) +    END_MARKER