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

version» Context lines:

pike.git/lib/modules/ADT.pmod/testsuite.in:1:   START_MARKER - dnl $Id$ +       dnl - ADT.BitBuffer      test_do( add_constant( "B", ADT.BitBuffer() ) )   test_eq( B->drain(), "" )   test_eq( B->feed(""), B )   test_eval_error( B->feed("\400") )   test_eq( B->drain(), "" )   test_eq( sizeof(B), 0 )   
pike.git/lib/modules/ADT.pmod/testsuite.in:126:    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:312:    return (string)Test();   ]], "\1\0\0klm")   test_any([[    class Test {    inherit ADT.Struct;    Item a = Word(0x1234);    Item b = Drow(0x1234);    Item c = Long(0x12345678);    Item d = Gnol(0x12345678);    Item e = uint64(); +  Item f = int32();    };    return (string)Test(); - ]], "\22""44\22\22""4VxxV4\22\0\0\0\0\0\0\0\0"); + ]], "\22""44\22\22""4VxxV4\22\0\0\0\0\0\0\0\0\0\0\0\0");   test_do([[    class Test {    inherit ADT.Struct;    Item a = Varchars();    Item b = Varchars(1,3);    Item c = Chars(1);    };    add_constant("Test",Test);   ]])   test_eq( (string)Test("a\0b\0c"), "a\0b\0c" )
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