pike.git / src / testsuite.in

version» Context lines:

pike.git/src/testsuite.in:1: - test_true([["$Id: testsuite.in,v 1.567 2002/11/25 12:09:30 grubba Exp $"]]); + test_true([["$Id: testsuite.in,v 1.568 2002/11/26 18:44:05 nilsson Exp $"]]);      // This triggered a bug only if run sufficiently early.   test_compile_any([[#pike 7.2]])      cond([[all_constants()->_verify_internals]],   [[    test_do(_verify_internals())   ]]);   test_eq(1e1,10.0);   test_eq(1E1,10.0);
pike.git/src/testsuite.in:2915:         test_any([[mixed s="foo"; return s++;]],"foo")   test_any([[mixed s="foo"; s++; return s;]],"foo1")   test_any([[mixed s="foo"; return ++s;]],"foo1")   test_any([[float p=2.0; return p--;]],2.0);   test_any([[float p=2.0; p--; return p;]],1.0)   test_any([[float p=2.0; return --p;]],1.0)      test_compile_error(int foo() { LJjjjjJJJ ; }) - test_true(clone(class c { constant i=1; })->i) - test_true(clone(class c { constant i=0; mixed `->(string s) { if(s=="i") return 1; }})->i) - test_true(clone(class c { constant i=1; mixed `->(string s) { return 0; }})["i"]) - test_true(clone(class c { constant i=0; mixed `[](string s) { if(s=="i") return 1; }})["i"]) - test_true(clone(class c { optional constant i=0; mixed `[](string s) { if(s=="i") return 1; }})["i"]) - test_true(clone(class c { mixed `[]=(mixed a, mixed b) { if(a!=b) throw(1); }})[1]=1) - test_true(clone(class c { mixed `->=(mixed a, mixed b) { if(a!=b) throw(1); }})->i="i") + test_true(class c { constant i=1; }()->i) + test_true(class c { constant i=0; mixed `->(string s) { if(s=="i") return 1; }}()->i) + test_true(class c { constant i=1; mixed `->(string s) { return 0; }}()["i"]) + test_true(class c { constant i=0; mixed `[](string s) { if(s=="i") return 1; }}()["i"]) + test_true(class c { optional constant i=0; mixed `[](string s) { if(s=="i") return 1; }}()["i"]) + test_true(class c { mixed `[]=(mixed a, mixed b) { if(a!=b) throw(1); }}()[1]=1) + test_true(class c { mixed `->=(mixed a, mixed b) { if(a!=b) throw(1); }}()->i="i")      test_eq((["static":42])->static,42)      test_compile_any(class A {}; class B { inherit A; })         // Automap tests      test_equal([[ ({10,20})[*] + 30 ]], [[ ({40, 50}) ]])   test_equal([[ 30 + ({10,20})[*] ]], [[ ({40, 50}) ]])
pike.git/src/testsuite.in:3222:    while(zero_type(o)) o=_prev(o); /* skip destructed */    catch { if(objectp(o) || object_program(o)) return 1; };    return 0;   ]],1)      test_any([[object(Stdio.File) o=Stdio.File(); return objectp(o);]],1)   test_any([[object o=Regexp("foo"); return objectp(o);]],1)   test_any([[object o=Regexp("foo"); return object_program(o);]],Regexp)   test_any([[class Test {}; object(Test) o=Test(); return object_program(o);]],Test)   test_define_program(test,[[constant foo = 1; int a() { return foo; }]]) - test_true(new(test)->a()) + test_true(test()->a())   test_program(inherit test;)   test_program(inherit test; int a() { return foo; } )   test_define_program(test,[[class TEST { int a() { return 1; } }]])   test_program(inherit test; inherit TEST; ) -  + test_do(add_constant("test");)    -  +    test_any([[    /* don't save parent */    class Foo { };    return function_object(object_program(Foo())) ==    object_program(this_object());   ]], 1)      test_any([[    class Foo { };    return function_name(object_program(Foo()));
pike.git/src/testsuite.in:3414:    object lock = Thread.Mutex()->lock();    gc();    return objectp (lock);    ]], 1)      // /precompiled/condition    test_true(Thread.Condition())    test_do(Thread.Condition()->signal())    test_do(Thread.Condition()->broadcast())    -  test_true(objectp(clone(Thread.Fifo))) -  test_true(objectp(clone(Thread.Queue))) +  test_true(objectp(Thread.Fifo())) +  test_true(objectp(Thread.Queue()))       test_any([[object o=Thread.Queue(); thread_create(lambda(object f) { for(int e=0;e<10000;e++) f->write(random(4711)); f->write(-1); },o); int tmp=0; while(o->read() != -1) tmp++; return tmp;]],10000)    test_any([[object o=Thread.Fifo(); thread_create(lambda(object f) { for(int e=0;e<10000;e++) f->write(random(4711)); f->write(-1); },o); int tmp=0; while(o->read() != -1) tmp++; return tmp;]],10000)      dnl this will crash pike on out-of-address-space-related errors   dnl test_any([[ catch { allocate(10000,thread_create)(lambda() { sleep(1); })->wait(); } ]])   ]])      cond([[all_constants()->thread_create]],   [[
pike.git/src/testsuite.in:4179:    o = 0;    gc();    if (!equal (all_constants()->blatinka, ({({17})})))    error ("Contents in saved weak array zapped: %O.\n",    all_constants()->blatinka);    gc();    return all_constants()->blatinka;    }]], ({0}));      ]]) + test_do(add_constant("kablutt");) + test_do(add_constant("blatinka");)      ifefun(gc,   [[       test_any([[{    class Dead {object o;};    object o = Dead(); o->o = Dead();    array a = set_weak_flag(({o}), 1);    gc(); o = 0; return gc() > 0;    }]], 1)
pike.git/src/testsuite.in:5788:    return sizeof( a-b )]],0);      ]])      cond([[all_constants()->_verify_internals]],   [[    test_do(_verify_internals())   ]])      test_eq("\377"[0],255) - test_do(add_constant("foo",clone(class c {int i;}))) + test_do(add_constant("foo",class c {int i;}()))   test_eq(foo->i,0)   test_do(foo->i=17)   test_eq(foo->i,17)   test_do(add_constant("foo")); - test_do(add_constant("foo",clone(class c {array(int) i=({0});}))) + test_do(add_constant("foo",class c {array(int) i=({0});}()))   test_eq(foo->i[0],0)   test_do(foo->i[0]=17)   test_eq(foo->i[0],17)   test_do(add_constant("foo"));      // signum, signame   test_true(intp(signum("SIGKILL")))      // kill, signal, getpid   test_true(intp(getpid()))
pike.git/src/testsuite.in:5833:   test_eq(sprintf("%O", _typeof(1)),"int(1..1)")   test_eq(sprintf("%O", _typeof("")),"string")   test_eq(sprintf("%O", _typeof("x"[0])),"int(120..120)")   test_eq(sprintf("%O", _typeof(0.0)),"float")   test_eq([[sscanf(sprintf("%Ox", _typeof(this_object))-" ",    "function(void|int(0..%*[0-9]):object)%*c")]], 2)         // class   test_true(programp(class c {})) - test_true(functionp(clone(class c { int foo() { return 1; }})->foo)) - test_true(clone(class c { int foo() { return 1; }})->foo()) - test_true(clone(class c { int i=1; })->i) - test_false(clone(class c { int foo() { return 1; }})->bar) - test_eq(clone(clone(class c { program foo=class c { int i=20; }; })->foo)->i,20) + test_true(functionp(class c { int foo() { return 1; }}()->foo)) + test_true(class c { int foo() { return 1; }}()->foo()) + test_true(class c { int i=1; }()->i) + test_false(class c { int foo() { return 1; }}()->bar) + test_eq(class c { program foo=class c { int i=20; }; }()->foo()->i,20)      // class()   test_true(programp(class c(){}))   test_equal(indices(class c(string a,static int b){}("foo",0)), ({"a"}))   test_equal(values(class c(string a,static int b){}("foo",0)), ({"foo"}))   test_true(programp(class c(string ... a){}))   test_equal(indices(class c(string a,static int ... b){}("foo",0)), ({"a"}))   test_equal(values(class c(static string a, int ... b){}("foo",0)), ({({0})}))      test_do([[
pike.git/src/testsuite.in:5905:   test_equal("abcd"/"" & indices("abcd"),({}))   test_eq(sizeof("abcd"/"" & "de"/""),1)   test_equal( ({0,0,0,0,0}), ({0,0,0,0,0}))   test_equal( ({"object","object","object","object","object"}), allocate(5,"object"))   test_equal(mkmapping("abcd"/"","jklm"/"") | mkmapping("jclm"/"","alcd"/""),    mkmapping("abcdjlm"/"","jklmacd"/""))   test_program(int foo() { return 17;} mixed a() { return foo() == 17; })   test_any([[mixed a; a=2; a=a*3; return a]],6)   test_any([[mixed a = ({1}); a=a+({2}); return equal(a,({1,2}))]],1)   test_define_program(test,[[int foo() { return 17; }]]) - test_any(function bar=clone(test)->foo; return bar(),17) + test_any(function bar=test()->foo; return bar(),17) + test_do(add_constant("test"))      // sscanf   test_any([[mixed a; return sscanf("11","%d",a)]],1)      test_any([[mixed a; sscanf("11","%d",a); return a]],11)   test_any([[mixed a; sscanf("11","%o",a); return a]],011)   test_any([[mixed a; sscanf("11","%x",a); return a]],0x11)   test_any([[mixed a; sscanf("11","%D",a); return a]],11)      
pike.git/src/testsuite.in:6464:   // index assigning   test_any(mixed a=({1}); a[0]=2; return equal(a,({2})),1)   test_any(mixed a=(<1>); a[1]=2; return equal(a,(<1>)),1)   test_any(mixed a=(<1>); a[0]=2; return equal(a,(<1,0>)),1)   test_any(mixed a=(<1>); a[1]=0; return equal(a,(<>)),1)   test_any(mixed a=(<1>); a[0]=0; return equal(a,(<1>)),1)   test_any(mixed a=([1:1]); a[0]=0; return equal(a,([1:1,0:0])),1)   test_any(mixed a=([1:1]); a[1]=0; return equal(a,([1:0])),1)      test_define_program(test,[[public int q,w,e,r; mixed t; mixed getw() { return w; } void setw(int _) { w=_; }]]) - test_eq(clone(test)->q,0) - test_eq(clone(test)->w,0) - test_eq(clone(test)->e,0) - test_eq(clone(test)->r,0) - test_eq(clone(test)->getw(),0) - test_any(object o=clone(test); o->setw(17); return o->w,17) - test_any(object o=clone(test); o->w=17; return o->getw(),17) + test_eq(test()->q,0) + test_eq(test()->w,0) + test_eq(test()->e,0) + test_eq(test()->r,0) + test_eq(test()->getw(),0) + test_any(object o=test(); o->setw(17); return o->w,17) + test_any(object o=test(); o->w=17; return o->getw(),17)    - test_eq(clone(test)["q"],0) - test_eq(clone(test)["w"],0) - test_eq(clone(test)["e"],0) - test_eq(clone(test)["r"],0) - test_eq(clone(test)["getw"](),0) - test_any(object o=clone(test); o["setw"](17); return o["w"],17) - test_any(object o=clone(test); o["w"]=17; return o["getw"](),17) + test_eq(test()["q"],0) + test_eq(test()["w"],0) + test_eq(test()["e"],0) + test_eq(test()["r"],0) + test_eq(test()["getw"](),0) + test_any(object o=test(); o["setw"](17); return o["w"],17) + test_any(object o=test(); o["w"]=17; return o["getw"](),17) + test_do(add_constant("test");)      // testing range   test_eq("foObar"[0..0],"f")   test_eq("foobargazonk"[3..5],"bar")   test_eq("foo"[1..10],"oo")   test_eq("foo"[-100..0],"f")   test_eq("foo"[-100..100],"foo")   test_eq("foo"[1..0],"")   test_eq("foo"[0..-100],"")   test_eq("foobargazonk"[0..],"foobargazonk")
pike.git/src/testsuite.in:7149:   ]]);   test_eval_error([[    class handler {mapping get_predefines() {return (["": 1]);}};    cpp ("x y z", "-", 0, handler());   ]]);   test_eval_error([[    class handler {mapping get_predefines() {return (["x": 1]);}};    cpp ("x y z", "-", 0, handler());   ]]);    - test_any(int e; object o=clone(Stdio.File); if(!o->open("conftest.h","wct")) return -1; e=o->write("return 17;\n"); if(!o->close()) return -1; return e,11) + test_any(int e; object o=Stdio.File(); if(!o->open("conftest.h","wct")) return -1; e=o->write("return 17;\n"); if(!o->close()) return -1; return e,11)      test_compile_any([[import Stdio.Readline; mapping x=([]);]]);      test_any([[   #include "conftest.h"   ]],17)   dnltest_any([[   dnl#include <conftest.h>   dnl]],17)   test_true(intp(__LINE__))
pike.git/src/testsuite.in:7784:   // - backtrace   test_true(arrayp(backtrace()))   test_eq(backtrace()[-1][2],a)      // - call_function   test_eq(1,call_function(a))   test_eq(1,call_function(lambda(int a){ return a; },1))   test_eq(1,call_function(intp,1))      // - clone - // clone is already tested a lot by this script +    test_true(objectp(clone(compile_string("int foo() { return 17; }"))))   test_eq(clone(compile_string("int foo() { return 17; }"))->foo(),17)      // - combine_path   test_eq([[combine_path("/foo/bar/gazonk/","..")]],"/foo/bar")   test_eq([[combine_path("/foo/bar/gazonk","..")]],"/foo/bar")   test_eq([[combine_path("/foo/bar/", "gazonk")]],"/foo/bar/gazonk")   test_eq([[combine_path("/foo/bar", "gazonk")]],"/foo/bar/gazonk")   test_eq([[combine_path("/.../","sune")]],"/.../sune")   test_eq([[combine_path("/",".")]],"/")
pike.git/src/testsuite.in:7919:   // - crypt   test_true(stringp(crypt("hej")))   test_true(crypt("hej",crypt("hej")))   test_false(crypt("hej","hej"))   test_false(crypt("h","hej"))      // - ctime   test_true(stringp(ctime(0)))      // - destruct - // FIXME put tests for destruct here. +    test_do(add_constant("PROG",compile_string("int foo() { return 1; }"))); - test_any([[object o=clone(PROG); destruct(o); return o]],0); - test_any([[object o=clone(PROG); destruct(o); return objectp(o)]],0); - test_any([[array(object) o=({clone(PROG)}); destruct(o[0]); return o-({0}) ]],({})); - test_any([[mapping o=(["foo":clone(PROG)]); destruct(o["foo"]); return o["foo"]; ]],0); - dnl test_any([[object t; mapping o=([t=clone(PROG):"foo"]); destruct(t); return sizeof(o)]],0); - test_do([[object t; array(object) o=({}); o+=({t=clone(PROG)}); destruct(t); o=({});]]); + test_any([[object o=PROG(); destruct(o); return o]],0); + test_any([[object o=PROG(); destruct(o); return objectp(o)]],0); + test_any([[array(object) o=({PROG()}); destruct(o[0]); return o-({0}) ]],({})); + test_any([[mapping o=(["foo":PROG()]); destruct(o["foo"]); return o["foo"]; ]],0); + dnl test_any([[object t; mapping o=([t=PROG():"foo"]); destruct(t); return sizeof(o)]],0); + test_do([[object t; array(object) o=({}); o+=({t=PROG()}); destruct(t); o=({});]]);   test_do(add_constant("PROG"))      // - Array.diff   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 }),
pike.git/src/testsuite.in:9056:   test_program(inherit test2; inherit test; mixed a() { return foo()==10 && bar()==11; })      test_define_program(test,[[int q,w,e,r; mixed t; mixed getw() { return w; } void setw(int _) { w=_; }]])   test_define_program(test2,[[int z,x,c,v,b; mixed getb() { return b; } void setb(int _) { b=_; }]])      test_program(inherit test; inherit test2; mixed a() { w=20; b=22; return getw()==20 && getb()==22; })   test_program(inherit test; inherit test2; mixed a() { setw(20); setb(22); return w==20 && b==22; })   test_program(inherit test2; inherit test; mixed a() { w=20; b=22; return getw()==20 && getb()==22; })   test_program(inherit test2; inherit test; mixed a() { setw(20); setb(22); return w==20 && b==22; })    - test_eval_error(return clone(class c{int i;void foo(){ destruct(this_object());i=0;return i;}})->foo()) + test_do(add_constant("test")) + test_do(add_constant("test2"))    -  + test_eval_error(return class c{int i;void foo(){ destruct(this_object());i=0;return i;}}()->foo()) +    // master defined functions      test_eq(dirname("/a/b/"),"/a/b")   test_eq(dirname("/a/b"),"/a")   test_eq(dirname("/a/"),"/a")   test_eq(dirname("/a"),"/")   test_eq(dirname("/"),"/")   test_eq(dirname(""),"")   test_eq(dirname("a/b/"),"a/b")   test_eq(dirname("a/b"),"a")