75457f2002-10-19Martin Nilsson dnl $Id: testsuite.in,v 1.4 2002/10/19 13:43:05 nilsson Exp $
f0a91f2002-08-03Martin Nilsson 
75457f2002-10-19Martin Nilsson dnl - ADT.History test_eq(sizeof(ADT.History(2)),0) test_do(add_constant("adth", ADT.History(2))) test_eq(adth->get_maxsize(),2) test_any([[ adth->push(17); return sizeof(adth); ]], 1) test_any([[ adth->push(18); return sizeof(adth); ]], 2) test_any([[ adth->push(19); return sizeof(adth); ]], 2) test_eq(adth->get_latest_entry_num(),3) test_eq(adth->get_first_entry_num(),2) test_eval_error(return adth[0]) test_eval_error(return adth[1]) test_eq(adth[2],18) test_eq(adth[3],19) test_eq(adth[-1],19) test_eq(adth[-2],18) test_eval_error(return adth[-3]) test_do( adth->set_maxsize(4) ) test_eq(adth->get_maxsize(),4) test_eq(sizeof(adth),2) test_eq(adth[-1],19) test_eq(adth[-2],18) test_eval_error(return adth[-3]) test_do( adth->push(20); adth->push(21); adth->push(22); ) test_eq(adth[3],19) test_eq(adth[6],22) test_do( adth->flush() ) test_eq(adth->get_latest_entry_num(),6) test_eq(adth->get_first_entry_num(),0) test_do( adth->set_maxsize(0) ) test_do( adth->push(23) ) test_eq(sizeof(adth),0) test_do(add_constant("adth")) dnl - ADT.Stack
79f9532002-08-02Martin Nilsson  test_any([[ object s = ADT.Stack(); s->push(1); return s->pop(); ]], 1)
76719c2002-08-04Martin Nilsson test_eval_error(return ADT.Stack()->pop())
79f9532002-08-02Martin Nilsson test_any([[ object s = ADT.Stack();
76719c2002-08-04Martin Nilsson  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.Stack();
79f9532002-08-02Martin Nilsson  s->push(2); s->push(3); s->push(4);
76719c2002-08-04Martin Nilsson  s->pop(); return s->pop(2); ]], ({2,3}) )
79f9532002-08-02Martin Nilsson  test_any([[ object s = ADT.Stack(); s->push(5); return s->top(); ]], 5)
f0a91f2002-08-03Martin Nilsson 
76719c2002-08-04Martin Nilsson test_eval_error(return ADT.Stack()->top()) test_any([[ object s = ADT.Stack(); 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.Stack(); for(int i; i<1000; i++) s->push(i); return sizeof(s); ]], 1000) test_any([[ object s = ADT.Stack(); s->push(3); s->reset(); return sizeof(s); ]], 0) test_any([[ object s = ADT.Stack(); s->set_stack( "1234"/1 ); s->push("5"); return s->pop()+sizeof(s); ]], "54") test_any([[ object s = ADT.Stack(); s->push("a"); s->push("b"); return values(s)*","; ]], [["a,b"]]) test_any([[ object s = ADT.Stack(); s->set_stack( "1234"/1 ); object t = ADT.Stack(); t->push("5"); return values(s+t)*""; ]], "12345")
f0a91f2002-08-03Martin Nilsson 
75457f2002-10-19Martin Nilsson dnl - ADT.Table
f0a91f2002-08-03Martin Nilsson  test_true(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"), ({ ({ "a", 118 }), ({ "c", 41 }) }))