pike.git
/
src
/
testsuite.in
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/testsuite.in:1:
-
test_true([["$Id: testsuite.in,v 1.
588
2003/08/
05
12
:
59
:
21
mast Exp $"]]);
+
test_true([["$Id: testsuite.in,v 1.
589
2003/08/
18
15
:
11
:
38
mast 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:2165:
__signal_watchdog(); if(!quiet) werror("\r%s" FMT, status_prefix,maxdepth,tests); } string test=code*"\n"+"\n" "mixed Q() { return "+acc+"();}\n" "int main() { trace(9); werror(\"%O\\n\","+acc+"()); }\n" ;
-
mixed tmp;
+
mixed tmp
, x
;
mixed err=catch { tmp=compile_string(test)(); res=tmp->Q(); if(res != ans) throw("Test failed");
-
+
res = "None";
tmp = decode_value(encode_value(tmp, Codec()), Codec()); res=tmp->Q(); if(res != ans) throw("Test failed for encode/decode.");
-
+
x=Program.inherit_list(object_program(tmp));
};
-
mixed x=Program.inherit_list(object_program(tmp));
+
if(err) { errors++; werror("\nTest failed:\n----------------------------------\n%s\n---------------------------------\nexpected answer: %O\nAnswer received: %O\n",test,ans,res); if(!stringp(err) || !has_prefix(err, "Test failed")) { string tmp=master()->describe_backtrace(err); array s=tmp/"\n"; s=s[..20]; werror("%s\n",s*"\n");
pike.git/src/testsuite.in:8226:
test_eq(`+(1.0,-1.0),0.0) test_eq(`+(-1.0,-1.0),-2.0) test_equal(`+(({1,2,3}),({4,5,6})),({1,2,3,4,5,6})) test_equal(`+((<1,2,3,4>),(<4,5,6>)),(<1,2,3,4,4,5,6>)) test_equal(`+(([0:1,3:6]),([5:2,3:6])),([0:1,3:6,3:6,5:2])) test_any(return((1+2+3)-(1+2-3)), 6) // - this_object and this test_true(objectp(this_object()))
+
test_true(objectp(this))
+
test_true(objectp(global::this))
+
test_true(this_object() == this)
+
test_true([[typeof(this) == typeof(this_object())]])
+
test_true([[typeof(this) == typeof(global::this)]])
+
test_true([[typeof(this_program) == typeof(object_program(this_object()))]])
+
test_true([[typeof(this_program) == typeof(object_program(global::this))]])
-
test_program([[
+
test_program
_eq
([[
string _sprintf() {return "g";} class A { string _sprintf() {return "A";} class B { string _sprintf() {return "B";} mixed f() { return sprintf ("%O%O%O%O%O", global::this, A::this, B::this, this_program::this, this); } } }
-
int
a() {return A()->B()->f()
== "gABBB"
;}
-
]])
+
string
a() {return A()->B()->f();}
+
]]
, "gABBB"
)
-
test_program([[
+
test_program
_eq
([[
string _sprintf() {return "g";} class A { string _sprintf() {return "A";} class B { string _sprintf() {return "B";} mixed f() { return sprintf ("%O%O%O%O", this_object (2), this_object (1), this_object (0), this_object()); } } }
-
int
a() {return A()->B()->f()
== "gABB"
;}
-
]])
+
string
a() {return A()->B()->f();}
+
]]
, "gABB"
)
-
test_program([[
+
test_program
_eq
([[
string _sprintf() {return "g";} class A { string _sprintf() {return "A";} class B { string _sprintf() {return "B";} mixed f() { return map (({2, 1, 0}), lambda (int l) { return sprintf ("%O", this_object (l)); }) * ""; } } }
-
int
a() {return A()->B()->f()
== "gAB"
;}
-
]])
+
string
a() {return A()->B()->f();}
+
]]
, "gAB"
)
-
test_program([[
+
test_program
_eq
([[
string _sprintf() {return "g";} class A { string _sprintf() {return "A";} class B { string _sprintf() {return "B";} mixed f() { return sprintf ("%O%O%O%O%O", global::this, A::this, B::this, this_program::this, this); } } constant this = 7; }
-
int
a() {return A()->B()->f()
==
"g7BB7";
}
+
string
a() {return A()->B()->f()
;}
+
]],
"g7BB7"
)
+
+
test_compile_error([[
+
this = 17
;
]])
-
+
test_compile_error([[
+
class A {
+
class B {
+
void f() {A::this = 17;}
+
}
+
};
+
]])
+
+
test_any([[
+
class A {
+
class B {
+
A parent() {return A::this;}
+
}
+
};
+
A a = A();
+
A.B b = a->B();
+
destruct (a);
+
return zero_type (b->parent());
+
]], 2)
+
+
test_eval_error([[
+
class A {
+
class B {
+
class C {
+
A grandparent() {return A::this;}
+
}
+
}
+
};
+
A.B b = A()->B();
+
A.B.C c = b->C();
+
destruct (b);
+
b->grandparent();
+
]], 2)
+
+
test_program_eq([[
+
string _sprintf() {return "g";}
+
class A {
+
string _sprintf() {return "A";}
+
mixed f() {
+
return sprintf ("%O%O", global::this, A::this);
+
}
+
}
+
class B {
+
string _sprintf() {return "B";}
+
class C {
+
inherit A;
+
string _sprintf() {return "C";}
+
mixed f() {
+
return A::f() + sprintf ("%O%O%O%O",
+
global::this, B::this, this_program::this, this);
+
}
+
}
+
}
+
string a() {return B()->C()->f();}
+
]], "gCgBCC")
+
+
test_program_eq([[
+
string _sprintf() {return "g";}
+
class A {
+
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";}
+
class C {
+
inherit A;
+
string _sprintf() {return "C";}
+
mixed f() {
+
return A::f() + "|" +
+
sprintf ("%O%O%O%O%O",
+
global::this, B::this, C::this, this_program::this, this);
+
}
+
}
+
}
+
string a() {return B()->C()->f();}
+
]], "gCCC|gBCCC")
+
test_program([[ class A { class B { mixed f() { return typeof (A::this) != typeof (B::this); } } } int a() {return A()->B()->f();} ]])
pike.git/src/testsuite.in:8311:
class A { class B { mixed f() { return typeof (this_object (1)) != typeof (this_object (0)); } } } int a() {return A()->B()->f();} ]])
+
test_program([[
+
class A {
+
class B {
+
mixed f() {
+
return typeof (A::this_program) != typeof (B::this_program);
+
}
+
}
+
}
+
int a() {return A()->B()->f();}
+
]])
+
+
test_program_eq([[
+
object ao = compile_string(#"
+
string id() {return \"A\";}
+
class B {
+
string id() {return \"B\";}
+
string foo()
+
{
+
return this->id() + id() + local::id() + global::this->id() + global::id();
+
}
+
}")();
+
+
class Handler
+
{
+
mixed resolv (string id, void|string file, void|object handler)
+
{
+
if (id == "B") return ao->B;
+
return master()->resolv (id, file, handler);
+
}
+
}
+
+
string a()
+
{
+
object c = compile_string(#"
+
string id() {return \"C\";}
+
class D {
+
inherit B;
+
string id() {return \"D\";}
+
string foo()
+
{
+
return ::foo() + \"|\" +
+
this->id() + id() + B::id() + global::this->id() + global::id();
+
}
+
}", 0, Handler())();
+
+
return c->D()->foo();
+
}
+
]], "DDBAA|DDBCC")
+
+
test_program_eq([[
+
class X
+
{
+
object parent() {return global::this;}
+
}
+
+
class Handler
+
{
+
mixed resolv (string id, void|string file, void|object handler)
+
{
+
if (id == "X") return X;
+
return master()->resolv (id, file, handler);
+
}
+
}
+
+
object a()
+
{
+
object o = compile_string ("inherit X;", 0, Handler())();
+
return o->parent();
+
}
+
]], this_object())
+
+
// - throw test_eq(20,catch(throw(a()))) // - catch compile-errors test_any([[ master()->set_inhibit_compile_errors(lambda(){});mixed res = catch{compile_string("dfasfqw123");};master()->set_inhibit_compile_errors(0); return arrayp(res)||objectp(res); ]], 1) // catch test_false([[class X { string test(string foo) { catch { return lower_case(foo); }; return foo; }}()->test(0); ]]) // - time