Branch: Tag:

2019-04-11

2019-04-11 16:04:44 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Testsuite: Protect lots of lfuns.

724:    return sort((sprintf("%O", typeof(f[0])) - " ")/"|")*"|"; ]],    "int|string")    - test_any([[class Foo { string `[](mixed y) {return "";} }; + test_any([[class Foo { protected string `[](mixed y) {return "";} };    object(Foo) foo;    return sprintf("%O", typeof(foo[0])); ]],    "string")    - test_any([[class Foo { array(int) _indices() {return ({0});} }; + test_any([[class Foo { protected array(int) _indices() {return ({0});} };    object(Foo) foo;    return sprintf("%O", typeof(indices(foo))); ]],    "array(int)")    - test_any([[class Foo { array(string) _values() {return ({""});} }; + test_any([[class Foo { protected array(string) _values() {return ({""});} };    object(Foo) foo;    return sprintf("%O", typeof(values(foo))); ]],    "array(string)")
1336:       class B    { -  void create(int y) +  protected void create(int y)    {    }    }
1404:   {    inherit Stdio.File;    -  void create() { } +  protected void create() { }   };      class Bar
1417:    inherit Foo;       -  void create(Stdio.File f) +  protected void create(Stdio.File f)    {    assign(f);    }    }    -  void create() +  protected void create()    {    Gazonk(Stdio.stdin);    }
1595:    c = count++;    }    -  void _destruct() +  protected void _destruct()    {    count--;    if (count != c)
1710:   ]]);   test_program([[    inherit Thread.Mutex : monitor; -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int dummy;    int f (int x)    {
1745:   ]]);   test_program([[    inherit Thread.Mutex : monitor; -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int res = 0;    void f (int x)    {
1777:   ]]);   test_program([[    inherit Thread.Mutex : monitor; -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int f (int x)    {    if(monitor::trylock(1))
1943:   ]]);   test_program([[    inherit Thread.Mutex : monitor; -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int dummy;    int f (int x)    {
1981:   ]]);   test_program([[    inherit Thread.Mutex : monitor; -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int res = 0;    void f (int x)    {
2014:   ]]);   test_program([[    inherit Thread.Mutex : monitor; -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int f (int x)    {    if(monitor::trylock(1))
2171:    }   ]]);   test_program([[ -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int dummy;    int f (int x)    {
2199:    }   ]]);   test_program([[ -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int res = 0;    void f (int x)    {
2224:    }   ]]);   test_program([[ -  mixed `-> (string what) {return this[what];} +  protected mixed `-> (string what) {return this[what];}    int f (int x)    {    return x;
2411:   test_program([[    int i = 17, v;    this_program clone() {return this_program (i);} -  void create (int v_) {v = v_;} +  protected void create (int v_) {v = v_;}    int a() {return clone()->v == 17;}   ]])   test_program([[    this_program clone() {return this_program (i);}    int i = 17, v; -  void create (int v_) {v = v_;} +  protected void create (int v_) {v = v_;}    int a() {return clone()->v == 17;}   ]])   test_program([[
2537:   test_compile_error(""())   test_compile_error(([])())   test_compile_error(([])()) - test_any([[ class X { int y; class Z { void _destruct() { y++; } } }; X x=X(); destruct(x->Z()); return x->y;]],1) + test_any([[ class X { int y; class Z { protected void _destruct() { y++; } } }; X x=X(); destruct(x->Z()); return x->y;]],1)    - test_eval_error([[ class Z { int _destruct() { return 1/y; } }(); ]]) + test_eval_error([[ class Z { protected int _destruct() { return 1/y; } }(); ]])      test_any([[ class X { int y; class Z { protected void _destruct() { y++; } } }; X x=X(); destruct(x->Z()); return x->y;]],1)   test_any([[ class X { int y; class Z { protected void create() { y++; } } }; X x=X(); destruct(x->Z()); return x->y;]],1)
2634:       class X    { -  void create() {error ("foo\n");} // Line 8 +  protected void create() {error ("foo\n");} // Line 8    }       object rx = class {}();
3179:   test_compile_any([[Stdio.File foo(array(Stdio.FILE) f) { return f[0]; }]])   test_compile_any([[   class a { -  int `== (mixed x) { +  protected int `== (mixed x) {    return 0;    }   }
3383:    {    protected object foo;    -  mixed `-> (mixed what) +  protected mixed `-> (mixed what)    {    return foo;    }
3481:   test_compile_error([[object x = Gmp.mpz(17); constant y = x;]])   test_any([[object(Stdio.File) f; f=Stdio.File(); return 1]],1)   test_compile([[float t=gauge { string foo; foo; };]]) - test_compile_any([[class Foo { object(Stdio.FILE) f; void create() { f=Stdio.FILE(); }}]]) + test_compile_any([[class Foo { object(Stdio.FILE) f; protected void create() { f=Stdio.FILE(); }}]])   test_eq([[compile_string("#define A(X) (X)\nint x() { return A \n\t(1); }")()->x()]],1)      test_any([[class G { mapping t=([]);    class tO { void init(string name) { t[name]=this; }} -  class W { inherit tO; void create() { init("foo"); }} +  class W { inherit tO; protected void create() { init("foo"); }}   }; object x=G(); x->W(); return objectp(x->t->foo)]],1)      test_program([[class foo { program x() { return class {}; }}; class bar { inherit foo; program x() { return class {}; }} int a() { return foo()->x != bar()->x(); }]])
3501:    constant gurka = 1;    int bar;    -  void create() { bar = foo; } +  protected void create() { bar = foo; }    };    return B()->bar;   ]], 1)
3517:    int bar;    int baz = 3;    -  void create() { bar = baz + foo; } +  protected void create() { bar = baz + foo; }    };    return B()->bar;   ]], 4)
3539:    int bar;    int baz = 5;    -  void create() { bar = baz + A::foo + B::foo; } +  protected void create() { bar = baz + A::foo + B::foo; }    };    return C()->bar;   ]], 12)
3935:   ]],17)      test_any([[ - return class { int i=17; mixed `[](string foo) { return i; }}()[""] + return class { int i=17; protected mixed `[](string foo) { return i; }}()[""]   ]],17)      test_any([[ - return class { int i=17; mixed `[](string foo) { return ::`[]("i"); }}()[""] + return class { int i=17; protected mixed `[](string foo) { return ::`[]("i"); }}()[""]   ]],17)      test_any([[ - return class { int i=17; mixed `[](string foo) { return ::`[]; }}()[""]("i") + return class { int i=17; protected mixed `[](string foo) { return ::`[]; }}()[""]("i")   ]],17)      test_any([[ - return class { int i=17; mixed `[](string foo) { return ::`[]; }}()[""]("y") + return class { int i=17; protected mixed `[](string foo) { return ::`[]; }}()[""]("y")   ]],0)      test_any([[   object o=class {    int i=17; -  mixed `[](string foo) { return ::`[]=; } -  mixed `[]=(string ind, mixed foo) {} +  protected mixed `[](string foo) { return ::`[]=; } +  protected mixed `[]=(string ind, mixed foo) {}   }();      o[""]("i",99);
3967:    int bar=11;    int i=17;    int gazonk=12; -  mixed `[](string foo) { return ::`[]=; } -  mixed `[]=(string ind, mixed foo) {} +  protected mixed `[](string foo) { return ::`[]=; } +  protected mixed `[]=(string ind, mixed foo) {}   }();      o[""]("i",99);
3986:   object o=class   {    inherit Fonk; -  mixed `[](string foo) { return ::`[]=; } -  mixed `[]=(string ind, mixed foo) {} +  protected mixed `[](string foo) { return ::`[]=; } +  protected mixed `[]=(string ind, mixed foo) {}   }();      o[""]("i",99);
4005:   object o=class   {    inherit Fonk : zonk; -  mixed `[](string foo) { return zonk::`[]=; } -  mixed `[]=(string ind, mixed foo) {} +  protected mixed `[](string foo) { return zonk::`[]=; } +  protected mixed `[]=(string ind, mixed foo) {}   }();      o[""]("i",99);
4467:    class A(mapping foo) {    mapping _modified = ([]);    -  mixed `->=(string sym, mixed v) { +  protected mixed `->=(string sym, mixed v) {    return _modified[sym] = v;    }   
4514:    class A(array foo) {    int counter;    -  void `->=(string sym, mixed v) { +  protected void `->=(string sym, mixed v) {    counter += !!v;    ::`->=(sym, v);    }
4652:   test_any([[   class X {    protected string f() { return "p"; } -  protected class gazonk { void create() { f(); }}; +  protected class gazonk { protected void create() { f(); }};    protected class g { object e() { return gazonk(); }}; -  void create() { g()->e(); }}; return objectp(X()); ]],1) +  protected void create() { g()->e(); }}; return objectp(X()); ]],1)   test_any([[class A { int x=1; }; class B { protected inherit A; int foo() { return A::x; }}; return A()->x && !B()->x && B()->foo()==A()->x;]],1)   test_any([[class C { int q() { return p(); } int p() { return 17; }}; return C()->q();]],17)   test_any([[class C1 {
4662:    class Y { program YinD() { return D; }} };    class C2 { inherit C1; class D { string id() { return "bar"; } } };    return C2()->Y()->YinD()()->id()]],"bar") - test_any([[object o=class {int c;class bar{void create(){c++;};}}(); o->bar(); return o->c;]],1) - test_do([[add_constant("GURKA2",class { int c; class bar{void create() {c+=17;}}}()); ]]) + test_any([[object o=class {int c;class bar{protected void create(){c++;};}}(); o->bar(); return o->c;]],1) + test_do([[add_constant("GURKA2",class { int c; class bar{protected void create() {c+=17;}}}()); ]])   test_any([[class { inherit GURKA2.bar; }(); return GURKA2->c;]],17)   test_any([[class { inherit GURKA2.bar; }(); return GURKA2->c;]],34)    - test_do([[add_constant("GURKA2",class { int c; class bar{void create() { class { void create() {c+=17;}}(); }}}()); ]]) + test_do([[add_constant("GURKA2",class { int c; class bar{protected void create() { class { protected void create() {c+=17;}}(); }}}()); ]])   test_any([[class { inherit GURKA2.bar; }(); return GURKA2->c;]],17)   test_any([[class { inherit GURKA2.bar; }(); return GURKA2->c;]],34)   test_do([[add_constant("GURKA2");]]);
4870:    return my_lambda(); really_magic_var;   ]],"foo")    - test_eq([[class { int `()(){ return 4711; } }()(); ]],4711) + test_eq([[class { protected int `()(){ return 4711; } }()(); ]],4711)   teste_eval_error(mixed foo=({}); sort(@foo); )   test_compile_error([[int foo() { return 1} ; constant foo=(["foo":foo]); return foo->foo();]])   test_compile_error([[class T{void p(object e,object f){lambda::create(f);}}]])
5049:      test_compile_error(int foo() { LJjjjjJJJ ; })   test_true(class { constant i=1; }()->i) - test_true(class { constant i=0; mixed `->(string s) { if(s=="i") return 1; }}()->i) - test_true(class { constant i=1; mixed `->(string s) { return 0; }}()["i"]) - test_true(class { constant i=0; mixed `[](string s) { if(s=="i") return 1; }}()["i"]) - test_true(class { optional constant i=0; mixed `[](string s) { if(s=="i") return 1; }}()["i"]) - test_true(class { mixed `[]=(mixed a, mixed b) { if(a!=b) throw(1); }}()[1]=1) - test_true(class { mixed `->=(mixed a, mixed b) { if(a!=b) throw(1); }}()->i="i") + test_true(class { constant i=0; protected mixed `->(string s) { if(s=="i") return 1; }}()->i) + test_true(class { constant i=1; protected mixed `->(string s) { return 0; }}()["i"]) + test_true(class { constant i=0; protected mixed `[](string s) { if(s=="i") return 1; }}()["i"]) + test_true(class { optional constant i=0; protected mixed `[](string s) { if(s=="i") return 1; }}()["i"]) + test_true(class { protected mixed `[]=(mixed a, mixed b) { if(a!=b) throw(1); }}()[1]=1) + test_true(class { protected mixed `->=(mixed a, mixed b) { if(a!=b) throw(1); }}()->i="i")      test_do([[   #pragma strict_types
5247:    a coredump in a later test. */    class A {    array a = ({1}); -  void `->= (string var, mixed val) {::`->= (var, val);} +  protected void `->= (string var, mixed val) {::`->= (var, val);}    };    class B {    inherit A; -  void `->= (string var, mixed val) {if (var) ::`->= (var, val);} +  protected void `->= (string var, mixed val) {if (var) ::`->= (var, val);}    };    object o = B();    o->a += ({2});
5261:   test_any_equal([[    class A {    array a = ({1}); -  void `->= (string var, mixed val) {::`->= (var, val);} +  protected void `->= (string var, mixed val) {::`->= (var, val);}    };    class B {    inherit A;
5274:   test_any_equal([[    class A {    array a = ({1}); - // void `->= (string var, mixed val) {::`->= (var, val);} + // protected void `->= (string var, mixed val) {::`->= (var, val);}    };    class B {    int z;    inherit A; -  void `->= (string var, mixed val) { A::`->= (var, val);} +  protected void `->= (string var, mixed val) { A::`->= (var, val);}    };    object o = B();    o->a += ({2});
5298:    inherit FOO;    int b,c,d,e,f,g;    inherit A; -  void `->= (string var, mixed val) { A::`->= (var, val);} +  protected void `->= (string var, mixed val) { A::`->= (var, val);}    };    object o = B();    o->a += ({2});
5316:       class Q    { -  mixed `-> (string var) +  protected mixed `-> (string var)    {    return FNORD::`-> (var);    } -  void `->= (string var, mixed val) +  protected void `->= (string var, mixed val)    {    FNORD::`->= (var, val);    }
6131:      test_any([[    class X (int i) { -  int `< (mixed o) {return 0;} -  int `== (mixed o) {return 0;} +  protected int `< (mixed o) {return 0;} +  protected int `== (mixed o) {return 0;}    };    multiset m = (<X(2)>);    m[X(4)] = 1;
6290:      class Tomat   { -  int `==(mixed x) +  protected int `==(mixed x)    {    /* make hash bigger */    for(int e=sizeof(gurka);e<1000;e++) gurka[e]=e;    return 0;    }    -  int __hash() +  protected int __hash()    {    return 99999;    }
6305:      class Sallad   { -  int __hash() +  protected int __hash()    {    return 99999;    }   };    - void create() + protected void create()   {    for(int x=1;x<255;x++)    {
6329:   test_any([[    mapping m = ([ "foo" : 1 ]);    class A { -  int __hash() { return hash_value("foo"); } -  int `==(mixed o) { return o == "foo"; } +  protected int __hash() { return hash_value("foo"); } +  protected int `==(mixed o) { return o == "foo"; }    };    if( !m[A()] )    return (string)hash_value("foo");
6340:   test_any([[    mapping m = ([ "foo" : 1 ]);    class A { -  int __hash() { return hash_value("foo"); } -  int `==(mixed o) { return o == "foo"; } +  protected int __hash() { return hash_value("foo"); } +  protected int `==(mixed o) { return o == "foo"; }    };    if( sizeof(m - ([ A() : 1 ])) )    return (string)hash_value("foo");
6552:    mapping m = ([]);    class Refcounter()    { mapping state; -  void create(mapping m) { state = m; state->refs++;} -  void _destruct() {state->refs--;} +  protected void create(mapping m) { state = m; state->refs++;} +  protected void _destruct() {state->refs--;}    };    int final_res;    function foo()
6581:    {    object c;    class A {object b;} -  class B {object a; void _destruct() {c = class{}();}} +  class B {object a; protected void _destruct() {c = class{}();}}    mixed test()    {    object a = A(), b = B();
6611:    gc(); o = 0; return gc() > 0;    }]], 1)    test_any([[{ -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    object o = Live(); o->o = Live(); o->o->o = o;    gc(); o = 0; return gc() > 0;    }]], 1)    test_any([[{    class Dead {object o;}; -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    object o = Dead(); o->o = Live(); o->o->o = o;    gc(); o = 0; return gc() > 0;    }]], 1)    test_any([[{    class Dead {object o;}; -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    object o = Live(); o->o = Dead(); o->o->o = o;    gc(); o = 0; return gc() > 0;    }]], 1)       test_any_equal([[{ -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    array a = set_weak_flag(({Live()}), 1);    gc();    return set_weak_flag(a, 0);    }]], ({0}))    test_any_equal([[{ -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    multiset l = set_weak_flag((<Live()>), 1);    gc();    return set_weak_flag(l, 0);    }]], (<>))    test_any_equal([[{ -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    mapping m = set_weak_flag(([0: Live()]), 1);    gc();    return set_weak_flag(m, 0);    }]], ([]))    test_any_equal([[{ -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    mapping m = set_weak_flag(([Live(): 0]), 1);    gc();    return set_weak_flag(m, 0);
6662:    object o = class {    array g;    array a = ({17}); -  void create() {g = ({this});} -  void _destruct() {all_constants()->kablutt = a;} +  protected void create() {g = ({this});} +  protected void _destruct() {all_constants()->kablutt = a;}    }();    o = 0;    gc();
6673:    object o = class {    array g;    array a = set_weak_flag (({({17})}), 1); -  void create() {g = ({this});} -  void _destruct() { +  protected void create() {g = ({this});} +  protected void _destruct() {    if (!equal (a, ({({17})})))    error ("Contents in weak array zapped: %O.\n", a);    }
6686:    object o = class {    array g;    array a = set_weak_flag (({({17})}), 1); -  void create() {g = ({this});} -  void _destruct() {all_constants()->blatinka = a;} +  protected void create() {g = ({this});} +  protected void _destruct() {all_constants()->blatinka = a;}    }();    o = 0;    gc();
6728:    }]], 1)    test_any([[{    class Dead {object o;}; -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    object o = Live(); o->o = Dead();    array a = set_weak_flag(({o}), 1);    gc(); o = 0; return gc() > 0;    }]], 1)    test_any([[{    class Dead {object o;}; -  class Live {object o; void _destruct() {}}; +  class Live {object o; protected void _destruct() {}};    object o = Dead(); o->o = Live();    array a = set_weak_flag(({o}), 1);    gc(); o = 0; return gc() > 0;
6786:    class Foo {    array(Foo) f = ({this});    multiset(Foo) g = set_weak_flag((<this>), 1); -  void _destruct() {add_constant("beltbent_oblivion", 1);} +  protected void _destruct() {add_constant("beltbent_oblivion", 1);}    };    multiset(Foo) x = set_weak_flag ((<Foo()>), 1);    gc();
6826:    class Live {    array a;    array g = ({this}); -  void create() +  protected void create()    {    a = set_weak_flag (({0}), 1);    array b = set_weak_flag (({a}), 1);    a[0] = b;    } -  void _destruct() +  protected void _destruct()    {    if (!arrayp(a) || !arrayp(a[0]) || a[0][0] != a)    add_constant ("my_little_error", "GC garbed weak things too early.\n");
6851:    class Live    {    Foo f; -  void _destruct() +  protected void _destruct()    {    if (!f->l || !f->a || !f->a[0] || !f->a[1])    add_constant ("my_little_error", "GC garbed live things.\n");
6866:    array a = ({j});    }    Live l; -  void create (Live _l) +  protected void create (Live _l)    {    l = _l;    l->f = this;
7056:    object o = class {}();    array a = set_weak_flag (({o}), 1);    object this = this; -  void create() {destruct (o);} +  protected void create() {destruct (o);}    }();    f = 0;    gc();
7067:    object o = class {}();    mapping m = set_weak_flag (([1:o]), 1);    object this = this; -  void create() {destruct (o);} +  protected void create() {destruct (o);}    }();    f = 0;    gc();
7078:    object o = class {}();    mapping m = set_weak_flag (([o:1]), 1);    object this = this; -  void create() {destruct (o);} +  protected void create() {destruct (o);}    }();    f = 0;    gc();
7089:    object o = class {}();    multiset m = set_weak_flag ((<o>), 1);    object this = this; -  void create() {destruct (o);} +  protected void create() {destruct (o);}    }();    f = 0;    gc();
7099:       test_any([[mapping q=([ "t":class {} ()]); gc(); if(!objectp(q->t)) return -1; set_weak_flag(q,1); gc(); if(objectp(q->t)) return -2; return 0;]],0);    -  test_do([[class bar { object foo; void create(void|object tmp) { foo=tmp; } }; +  test_do([[class bar { object foo; protected void create(void|object tmp) { foo=tmp; } };    object o=bar(),o2=o;    for(int e=0;e<10000;e++) o=bar(o);    o2->foo=o;
7240:    {    object o = class {    mapping a = ([1: this]); -  void _destruct() {x = a;} +  protected void _destruct() {x = a;}    }();    o = 0;    gc();
7255:    {    object o = class {    multiset a = (<this>); -  void _destruct() {x = a;} +  protected void _destruct() {x = a;}    }();    o = 0;    gc();
7270:    {    object o = class {    array a = ({this}); -  void _destruct() {x = a;} +  protected void _destruct() {x = a;}    }();    o = 0;    gc();
7280:    ]], 1)    test_any([[    return class { -  class Obj (object o) {void _destruct() {}} +  class Obj (object o) {protected void _destruct() {}}    Obj x;    int test()    {    object o = class {    Obj a = Obj (this); -  void _destruct() {x = a;} +  protected void _destruct() {x = a;}    }();    o = 0;    gc();
7302:    {    object o = class {    Obj a = Obj (this); -  void _destruct() {x = a;} +  protected void _destruct() {x = a;}    }();    o = 0;    gc();
7728:    // PIKE-106: Mutex not unlocked properly on error in identify_cycle().    class Foo {    int cnt; -  int __hash() { return 0; } -  int `==(mixed x) { if (!cnt++) error("Comparison failure.\n"); } +  protected int __hash() { return 0; } +  protected int `==(mixed x) { if (!cnt++) error("Comparison failure.\n"); }    };    catch {    // This triggered an error.
8920:   test_equal( (<4,5,6>) | (<5,5,5>), (<4,5,5,5,6>) )   test_equal( ([-4:8,8:7]) | ([3:3,8:3]), ([-4:8,8:3,3:3]) )   test_any([[ -  class Foo {int `< (object o) {return 0;}}; +  class Foo {protected int `< (object o) {return 0;}};    return sizeof (({Foo()}) | ({Foo()}));   ]], 2)   
9027:   test_eq((<'f','o','o'>)[random(0)+'b'],0)   test_eq((<'f','o','o'>)[ [int](mixed)-1],0)    - test_eq([[class { mixed `->(mixed x) { return this[x]; } int foo() { return 1; }}()->foo()]],1) + test_eq([[class { protected mixed `->(mixed x) { return this[x]; } int foo() { return 1; }}()->foo()]],1)      // Test some indexing opcodes.   test_eval_error([[return ({1})[1];]])
9144:   define(test_new_style, [[    test_any_equal([[    object new_style = class { -  array(int) `[..] (int... args) {return args;} +  protected array(int) `[..] (int... args) {return args;}    }();    return new_style $1;    ]], $2)
9163:   define(test_old_style, [[    test_any_equal([[    object old_style = class { -  int _sizeof() {return 6;} -  array(int) `[] (int... args) {return args;} +  protected int _sizeof() {return 6;} +  protected array(int) `[] (int... args) {return args;}    }();    return old_style $1;    ]], $2)
9190:   test_eq([[(int)"0x1"]],[[0]])   test_eq([[(int)"010"]],[[10]])   test_eq((int)Gmp.mpz(5), 5) - test_eq((int)class { mixed cast(string x) { return x=="int" && 7; } }(), 7) - test_eval_error([[ return (int)class { mixed cast(string x) { + test_eq((int)class { protected mixed cast(string x) { return x=="int" && 7; } }(), 7) + test_eval_error([[ return (int)class { protected mixed cast(string x) {    return 1.0; } }(); ]]); - test_eval_error([[ return (int)class { mixed cast(string x) { + test_eval_error([[ return (int)class { protected mixed cast(string x) {    return ADT.Heap(); } }(); ]]); - test_any([[ return (int)class { mixed cast(string x) { + test_any([[ return (int)class { protected mixed cast(string x) {    return Gmp.mpz(7); } }(); ]], Gmp.mpz(7));   test_eq([[(float)"1"]],[[1.0]])   test_eq([[(float)"-1"]],[[-1.0]])
9210:   test_eq([[(string)1.0]],[["1.0"]])   test_eq([[(string)-1.0]],[["-1.0"]])   test_eq((string)Gmp.mpz(5), "5") - test_eq((string)class { mixed cast(string x) { + test_eq((string)class { protected mixed cast(string x) {    return x=="string" && "7"; } }(), "7") - test_eval_error((string)class { mixed cast(string x) { return 1.0; }}();) - test_eval_error((string)class { mixed cast(string x) { + test_eval_error((string)class { protected mixed cast(string x) { return 1.0; }}();) + test_eval_error((string)class { protected mixed cast(string x) {    return ADT.Heap(); }}();)   test_any([[ -  class A { int q=9; int _is_type(string x) { return x=="string"; } }; -  mixed o = (string)class { mixed cast(string x) { return A(); } }(); +  class A { int q=9; protected int _is_type(string x) { return x=="string"; } }; +  mixed o = (string)class { protected mixed cast(string x) { return A(); } }();    return o->q;]], 9)   // Note: 32-bit floats overflow at ~3.4e38.   test_true([[has_value ((string)1e38, ".") ||
9296:      test_any([[    object x = class { -  mixed cast (string t) {return t == "string" && "foo";} +  protected mixed cast (string t) {return t == "string" && "foo";}    }();    destruct (x);    return (string) x;
9312:   test_eval_error([[(string) ({0x80000000})]])   test_eq([[(string) ({'z', -0x80000000, '.'})]], "z\x80000000.")   test_eval_error([[(string) ({-0x80000001})]]) - test_eval_error([[(int)class { mixed cast() { return UNDEFINED; } }();]]) - test_eval_error([[(string)class { mixed cast() { return UNDEFINED; } }();]]) - test_eval_error([[(mapping)class { mixed cast() { return UNDEFINED; } }();]]) + test_eval_error([[(int)class { protected mixed cast() { return UNDEFINED; } }();]]) + test_eval_error([[(string)class { protected mixed cast() { return UNDEFINED; } }();]]) + test_eval_error([[(mapping)class { protected mixed cast() { return UNDEFINED; } }();]])      test_any([[    // Cast to subtyped object.
11190:   // - `%      test_do([[ -  class A (int x) { mixed `%(mixed y) { return this_program(x % (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed `%(mixed y) { return this_program(x % (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`%(A(13),A(5))->x, 3)
11201:   test_do(add_constant("A"));      test_do([[ -  class A (int x) { mixed ``%(mixed y) { return this_program((objectp(y)?y->x:y) % x); } }; +  class A (int x) { protected mixed ``%(mixed y) { return this_program((objectp(y)?y->x:y) % x); } };    add_constant("A",A);   ]])   test_eq(`%(A(13),A(5))->x, 3)
11215:   // - `&      test_do([[ -  class A (int x) { mixed `&(mixed y) { return this_program(x & (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed `&(mixed y) { return this_program(x & (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`&(A(7),A(5))->x, 5)
11229:   test_do(add_constant("A"));      test_do([[ -  class A (int x) { mixed ``&(mixed y) { return this_program(x & (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed ``&(mixed y) { return this_program(x & (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`&(A(7),A(5))->x, 5)
11247:   // - `*      test_do([[ -  class A (int x) { mixed `*(mixed y) { return this_program(x * (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed `*(mixed y) { return this_program(x * (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`*(A(3),A(2))->x, 6)
11261:   test_do(add_constant("A"));      test_do([[ -  class A (int x) { mixed ``*(mixed y) { return this_program(x * (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed ``*(mixed y) { return this_program(x * (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`*(A(3),A(2))->x, 6)
11306:   test_equal(`+(UNDEFINED,([1:2]),([3:4])), ([1:2,3:4]))   test_equal(`+(([1:2]),UNDEFINED,([3:4])), ([1:2,3:4]))    - test_equal(17+class{mixed ``+(mixed n){return (<n>);}}(),(<17>)) - test_equal(1700000000000000000000+class{mixed ``+(mixed n){return (<n>);}}(),(<1700000000000000000000>)) + test_equal(17+class{protected mixed ``+(mixed n){return (<n>);}}(),(<17>)) + test_equal(1700000000000000000000+class{protected mixed ``+(mixed n){return (<n>);}}(),(<1700000000000000000000>))    - test_eval_error(Gmp.mpz(1700000000000000000000)+class{mixed ``+(mixed n){return (<n>);}}()) + test_eval_error(Gmp.mpz(1700000000000000000000)+class{protected mixed ``+(mixed n){return (<n>);}}())      test_do([[ -  class A (int x) { mixed `+(mixed y) { return this_program(x + (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed `+(mixed y) { return this_program(x + (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`+(A(3),A(2))->x, 5)
11325:   test_do(add_constant("A"));      test_do([[ -  class A (int x) { mixed ``+(mixed y) { return this_program(x + (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed ``+(mixed y) { return this_program(x + (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`+(A(3),A(2))->x, 5)
11339:      test_do([[    class A { -  mixed `+(string s) { return "`+"+s; } -  mixed ``+(string s) { return s+"``+"; } -  mixed `+=(string s) { return "`+="+s; } +  protected mixed `+(string s) { return "`+"+s; } +  protected mixed ``+(string s) { return s+"``+"; } +  protected mixed `+=(string s) { return "`+="+s; }    };    add_constant("A",A);   ]])
11367:   test_do(add_constant("A"))      test_do([[ -  class A { mixed ``+(mixed x) { return sprintf("%O",x)-" "-"\n"; } }; +  class A { protected mixed ``+(mixed x) { return sprintf("%O",x)-" "-"\n"; } };    add_constant("A",A);   ]])   test_eq(`+(({1}),({2}),A()), "({/*2elements*/1,2})")
11377:      test_do([[    class A { -  mixed `+(mixed x) { return UNDEFINED; } -  mixed ``+(mixed x) { return UNDEFINED; } +  protected mixed `+(mixed x) { return UNDEFINED; } +  protected mixed ``+(mixed x) { return UNDEFINED; }    };    add_constant("A",A);   ]])
11390:      test_do([[    class A (int x) { -  mixed `-(mixed y) { return this_program(x - (objectp(y)?y->x:y)); } +  protected mixed `-(mixed y) { return this_program(x - (objectp(y)?y->x:y)); }    // Optimizer will modify the code which requires `+. -  mixed `+(int y) { return this_program(x+y); } +  protected mixed `+(int y) { return this_program(x+y); }    };    add_constant("A",A);   ]])
11408:      test_do([[    class A (int x) { -  mixed ``-(mixed y) { return this_program((objectp(y)?y->x:y) - x); } +  protected mixed ``-(mixed y) { return this_program((objectp(y)?y->x:y) - x); }    // Optimizer will modify the code which requires `+.    //mixed `+(int y) { return this_program(x+y); }    };
11421:   test_do(add_constant("A"));      test_do([[ -  class A (int x) { mixed `-(mixed y) { return this_program(-x); } }; +  class A (int x) { protected mixed `-(mixed y) { return this_program(-x); } };    add_constant("A",A);   ]])   test_eq(`-(A(5))->x, -5)
11439:   // - `/      test_do([[ -  class A (int x) { mixed `/(mixed y) { return this_program(x / (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed `/(mixed y) { return this_program(x / (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`/(A(8),A(2))->x, 4)
11453:   test_do(add_constant("A"));      test_do([[ -  class A (int x) { mixed ``/(mixed y) { return this_program((objectp(y)?y->x:y) / x); } }; +  class A (int x) { protected mixed ``/(mixed y) { return this_program((objectp(y)?y->x:y) / x); } };    add_constant("A",A);   ]])   test_eq(`/(A(8),A(2))->x, 4)
11477:   // - `^      test_do([[ -  class A (int x) { mixed `^(mixed y) { return this_program(x ^ (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed `^(mixed y) { return this_program(x ^ (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`^(A(7),A(1))->x, 6)
11491:   test_do(add_constant("A"));      test_do([[ -  class A (int x) { mixed ``^(mixed y) { return this_program(x ^ (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed ``^(mixed y) { return this_program(x ^ (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`^(A(7),A(1))->x, 6)
11503:   // - `|      test_do([[ -  class A (int x) { mixed `|(mixed y) { return this_program(x | (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed `|(mixed y) { return this_program(x | (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`|(A(3),A(6))->x, 7)
11517:   test_do(add_constant("A"));      test_do([[ -  class A (int x) { mixed ``|(mixed y) { return this_program(x | (objectp(y)?y->x:y)); } }; +  class A (int x) { protected mixed ``|(mixed y) { return this_program(x | (objectp(y)?y->x:y)); } };    add_constant("A",A);   ]])   test_eq(`|(A(3),A(6))->x, 7)
11529:   // - `~      test_do([[ -  class A (int x) { mixed `~() { return this_program(~x); } }; +  class A (int x) { protected mixed `~() { return this_program(~x); } };    add_constant("A",A);   ]])   test_eq(`~(A(5))->x, -6)
11649:      test_callablep(time, 1)   test_callablep(String.Buffer, 1) - test_callablep( class { void `()() { } }(), 1) + test_callablep( class { protected void `()() { } }(), 1)   test_callablep(String.Buffer(), 0)   test_callablep( ({}), 1 )   test_callablep( ({ 0,0 }), 0 )
11877:   ]], 1)      test_any([[ -  class X {int __hash() {return 17;}}; +  class X {protected int __hash() {return 17;}};    mixed c = copy_value (X());    return objectp (c) && object_program (c) == X;   ]], 1)
12199:   test_has_index([[ (< "a", "b", "c" >) ]],"b",1)   test_has_index([[ (< "a", "b", "c" >) ]],"B",0)   test_has_index([[ class {}() ]],"foo",0) - test_has_index([[ (class{array _indices(){return({"a","b"});}})() ]],"b",1) + test_has_index([[ (class{protected array _indices(){return({"a","b"});}})() ]],"b",1)      // - has_prefix   test_true(has_prefix("abc","a"))
12231:   test_has_value([[ ([ "a":"A", "b":"B", "c":"C" ]) ]],"B",1)   test_has_value([[ ([ "a":"A", "b":"B", "c":"C" ]) ]],"b",0)   test_has_value([[ class {}() ]],"foo",0) - test_has_value([[ (class{array _values(){return({"a","b"});}})() ]],"b",1) + test_has_value([[ (class{protected array _values(){return({"a","b"});}})() ]],"b",1)      // - hash   test_eq(hash("foo"),246314004)
12899:    {    mapping m;    -  int `==() +  protected int `==()    {    foreach(indices(m), mixed x)    m_delete(m, x);    return 0;    }    -  void create(mapping _m) +  protected void create(mapping _m)    {    m = _m;    }
13005:   test_eq(sizeof(({"fulbar","gazonk",7})),3)   test_eq(sizeof(([8:3,6:6,7:0])),3)   test_eq(sizeof((<8,7,6,5,4,7>)),6) - test_eq([[ sizeof( class { int _sizeof() { return 17; } }() ) ]], 17) + test_eq([[ sizeof( class { protected int _sizeof() { return 17; } }() ) ]], 17)      // - sleep   test_do(sleep(1))
13031:   test_equal(sort(({1.0,2.0,4.0,3.0})),({1.0,2.0,3.0,4.0}))   test_any_equal([[    // sort() on one arg should be stable. -  class C (int id) {int `< (mixed x) {return 0;}}; +  class C (int id) {protected int `< (mixed x) {return 0;}};    return sort (({C(2), C(6), C(1), C(4), C(3), C(5)}))->id;   ]], ({2, 6, 1, 4, 3, 5}))   test_any_equal([[
13049:   test_any([[    class foo {    int x=random(100); -  int `<(object o) {return x < o->x;} +  protected int `<(object o) {return x < o->x;}    };    array(object) o=allocate(100,foo)();    sort(o);
13308:   test_true([[typeof(this_program) == typeof(object_program(global::this))]])      test_program_eq([[ -  string _sprintf() {return "g";} +  protected string _sprintf() {return "g";}    class A { -  string _sprintf() {return "A";} +  protected string _sprintf() {return "A";}    class B { -  string _sprintf() {return "B";} +  protected string _sprintf() {return "B";}    mixed f() {    return sprintf ("%O%O%O%O%O%O",    global::this, A::this, B::this, this_program::this, this::this, this);
13323:   ]], "gABBBB")      test_program_eq([[ -  string _sprintf() {return "g";} +  protected string _sprintf() {return "g";}    class A { -  string _sprintf() {return "A";} +  protected string _sprintf() {return "A";}    class B { -  string _sprintf() {return "B";} +  protected string _sprintf() {return "B";}    mixed f() {    return sprintf ("%O%O%O%O%O",    this_object (2), this_object (1), this_object (0), this_object(), this);
13338:   ]], "gABBB")      test_program_eq([[ -  string _sprintf() {return "g";} +  protected string _sprintf() {return "g";}    class A { -  string _sprintf() {return "A";} +  protected string _sprintf() {return "A";}    class B { -  string _sprintf() {return "B";} +  protected string _sprintf() {return "B";}    mixed f() {    return map (({2, 1, 0}), lambda (int l) {    return sprintf ("%O", this_object (l));
13354:   ]], "gAB")      test_program_eq([[ -  string _sprintf() {return "g";} +  protected string _sprintf() {return "g";}    class A { -  string _sprintf() {return "A";} +  protected string _sprintf() {return "A";}    class B { -  string _sprintf() {return "B";} +  protected string _sprintf() {return "B";}    mixed f() {    return sprintf ("%O%O%O%O%O%O",    global::this, A::this, B::this, this_program::this, this::this, this);
13408:   ]], 2)      test_program_eq([[ -  string _sprintf() {return "g";} +  protected string _sprintf() {return "g";}    class A { -  string _sprintf() {return "A";} +  protected string _sprintf() {return "A";}    mixed f() {    return sprintf ("%O%O", global::this, A::this);    }    }    class B { -  string _sprintf() {return "B";} +  protected string _sprintf() {return "B";}    class C {    inherit A; -  string _sprintf() {return "C";} +  protected string _sprintf() {return "C";}    mixed f() {    return A::f() + sprintf ("%O%O%O%O",    global::this, B::this, this_program::this, this);
13430:   ]], "gCgBCC")      test_program_eq([[ -  string _sprintf() {return "g";} +  protected string _sprintf() {return "g";}    class A { -  string _sprintf() {return "A";} +  protected string _sprintf() {return "A";}    mixed f() {    return sprintf ("%O%O%O%O",    global::this, A::this, this_program::this, this);    }    }    class B { -  string _sprintf() {return "B";} +  protected string _sprintf() {return "B";}    class C {    inherit A; -  string _sprintf() {return "C";} +  protected string _sprintf() {return "C";}    mixed f() {    return A::f() + "|" +    sprintf ("%O%O%O%O%O",
14898:      dnl Make sure that _sprintf is called and that the argument list isn't screwed.   test_eq(sprintf("%d%c%s%t%o%d%u%x%X%e%f%g%E%G%O%d", 4711, -  @allocate(14, (class { string _sprintf(int t) +  @allocate(14, (class { protected string _sprintf(int t)    { mixed x = "not a number";    string s;    catch {
14952:    test_eq(sprintf("%"+$1+"%<"+$1, OBJ), $1 + $1);    test_eq(sprintf("%[1]"+$1+"%[0]"+$1, OBJ, OBJ), $1 + $1);    ]]); - test_do(add_constant("OBJ",class { string _sprintf(int t) { return sprintf("%c",t); } }() )) + test_do(add_constant("OBJ",class { protected string _sprintf(int t) { return sprintf("%c",t); } }() ))   test_object_sprintf("t")   test_object_sprintf("c")   test_object_sprintf("H")
14976:   test_any_equal([[    class A {    mapping m; -  string _sprintf(int t, mapping args) +  protected string _sprintf(int t, mapping args)    {    m = args;    return "";