1169d9 | 2004-05-02 | Martin Nilsson | | START_MARKER
|
4f9a0a | 2002-09-21 | Martin Stjernholm | |
// This triggered a bug only if run sufficiently early.
|
e70eb2 | 2015-11-30 | Martin Nilsson | | test_compile_any([[#pike 7.6]])
|
3daf98 | 2014-02-17 | Martin Nilsson | | test_compile_any([[#pike 7.8]])
|
b8ce9d | 2014-08-24 | Martin Nilsson | | test_compile_any([[#pike 8.0]])
|
63c1a6 | 2014-10-05 | Martin Nilsson | | test_compile_any([[#pike 8.1]])
|
2144ac | 2014-11-24 | Martin Nilsson | | test_compile_any([[#pike 8.2]])
|
ab01ea | 1999-09-21 | Fredrik Hübinette (Hubbe) | |
|
323682 | 2015-11-15 | Martin Nilsson | | ifefun(_verify_internals,
|
c0988f | 1998-04-17 | Fredrik Hübinette (Hubbe) | | [[
test_do(_verify_internals())
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | ]]);
test_eq(1e1,10.0);
test_eq(1E1,10.0);
test_eq(1e+1,10.0);
test_eq(1.1e1,11.0);
test_eq(1e-1,0.1);
test_eq('\x20',32);
test_eq("\x20","\040");
test_eq("\d32","\x20");
test_eq('Å',"Å"[0]);
test_eq('\7777',"\7777"[0]);
test_eq('\77777777',"\77777777"[0]);
test_eq("\x10000","\x10000");
test_eq(0x80000000-0x80000000, 0);
test_eq(0xf0000000-0xf0000000, 0);
test_eq(0x80000001-0x80000000, 1);
test_eq(0x80000000-0x80000001,-1);
test_eq(-2147483648*-1, -2147483648/-1);
|
3e5021 | 2014-08-18 | Martin Nilsson | | test_eq(0x8000000000000000-0x8000000000000000, 0);
test_eq(0xf000000000000000-0xf000000000000000, 0);
test_eq(0x8000000000000001-0x8000000000000000, 1);
test_eq(0x8000000000000000-0x8000000000000001,-1);
test_eq(-9223372036854775808*-1, -9223372036854775808/-1);
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | test_true([[1.0e-40]]);
|
a83f8c | 1998-03-20 | Fredrik Hübinette (Hubbe) | | test_eq([[#"foo
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | bar"]],[["foo\nbar"]]);
|
170d58 | 2015-08-23 | Martin Nilsson | | test_eq([[# "foo
bar"]],[["foo\nbar"]]);
|
b62bf6 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | test_eq([[#"foo\
bar"]],[["foobar"]]);
|
e9e53e | 2015-07-07 | Henrik Grubbström (Grubba) | | test_eq([[#(foo
|
606f27 | 2015-07-26 | Henrik Grubbström (Grubba) | | bar#) - "\r"]],[["foo\nbar"]]);
|
170d58 | 2015-08-23 | Martin Nilsson | | test_eq([[# (foo
bar#) - "\r"]],[["foo\nbar"]]);
|
e9e53e | 2015-07-07 | Henrik Grubbström (Grubba) | | test_eq([[#(foo\
|
606f27 | 2015-07-26 | Henrik Grubbström (Grubba) | | bar#) - "\r"]],[["foo\\\nbar"]]);
|
e9e53e | 2015-07-07 | Henrik Grubbström (Grubba) | | test_eq([[#[foo
|
606f27 | 2015-07-26 | Henrik Grubbström (Grubba) | | bar#] - "\r"]],[["foo\nbar"]]);
|
170d58 | 2015-08-23 | Martin Nilsson | | test_eq([[# [foo
bar#] - "\r"]],[["foo\nbar"]]);
|
e9e53e | 2015-07-07 | Henrik Grubbström (Grubba) | | test_eq([[#[foo\
|
606f27 | 2015-07-26 | Henrik Grubbström (Grubba) | | bar#] - "\r"]],[["foo\\\nbar"]]);
|
e9e53e | 2015-07-07 | Henrik Grubbström (Grubba) | | test_eq([[#{foo
|
606f27 | 2015-07-26 | Henrik Grubbström (Grubba) | | bar#} - "\r"]],[["foo\nbar"]]);
|
170d58 | 2015-08-23 | Martin Nilsson | | test_eq([[# {foo
bar#} - "\r"]],[["foo\nbar"]]);
|
e9e53e | 2015-07-07 | Henrik Grubbström (Grubba) | | test_eq([[#{foo\
|
606f27 | 2015-07-26 | Henrik Grubbström (Grubba) | | bar#} - "\r"]],[["foo\\\nbar"]]);
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | test_true([[stringp(#string "Makefile")]]);
|
3488ef | 2000-04-17 | Henrik Grubbström (Grubba) | | test_any([[class Bar { array(int) foo = ({}); };
class Foo { inherit Bar; array(int) foo = ({1}); };
return sizeof(Foo()->foo);]],1);
|
87c9d2 | 1998-04-09 | Fredrik Hübinette (Hubbe) | |
|
649dce | 2008-05-21 | Martin Stjernholm | | test_eq([["(" + 0x7fffffff + ")"]], "(2147483647)")
test_eq([["(" + -0x80000000 + ")"]], "(-2147483648)")
|
3e5021 | 2014-08-18 | Martin Nilsson | | test_eq([["(" + 0x7fffffffffffffff + ")"]], "(9223372036854775807)")
test_eq([["(" + -0x8000000000000000 + ")"]], "(-9223372036854775808)")
|
649dce | 2008-05-21 | Martin Stjernholm | | test_eq([["(" + Int.NATIVE_MAX + ")"]], [[sprintf ("(%d)", Int.NATIVE_MAX)]])
test_eq([["(" + Int.NATIVE_MIN + ")"]], [[sprintf ("(%d)", Int.NATIVE_MIN)]])
|
3362ea | 2012-07-06 | Martin Stjernholm | | test_eq([[Int.NATIVE_MAX]], [[(int) (Int.NATIVE_MAX + "")]])
test_eq([[Int.NATIVE_MIN]], [[(int) (Int.NATIVE_MIN + "")]])
test_eq([[(string) Int.NATIVE_MAX]], [[Int.NATIVE_MAX + ""]])
test_eq([[(string) Int.NATIVE_MIN]], [[Int.NATIVE_MIN + ""]])
test_eq([[(string) Int.NATIVE_MAX]], [[sprintf ("%d", Int.NATIVE_MAX)]])
test_eq([[(string) Int.NATIVE_MIN]], [[sprintf ("%d", Int.NATIVE_MIN)]])
|
649dce | 2008-05-21 | Martin Stjernholm | |
|
137eab | 2014-08-19 | Martin Nilsson | | test_any_equal([[
array res = ({});
array ops = ({ `+, `-, `*, `/, `%, `<<, `>>, `&, `|, `^ });
array nums_a = ({ 0, 1, -1, 0xffffffff, 0xffffffffffffffff });
array nums_b = ({ 0, 1, -1 });
foreach(ops;; function op)
foreach(nums_a;; int a)
foreach(nums_b;; int b)
{
mixed err = catch {
res += ({ op(a,b) });
};
if( err ) res += ({ "E" });
}
return res;
]],[[ ({
// +
0, 1, -1, 1, 2, 0, -1, 0, -2, 0xffffffff, 0x100000000, 0xfffffffe, 0xffffffffffffffff, 0x10000000000000000, 0xfffffffffffffffe,
// -
0, -1, 1, 1, 0, 2, -1, -2, 0, 0xffffffff, 0xfffffffe, 0x100000000, 0xffffffffffffffff, 0xfffffffffffffffe, 0x10000000000000000,
// *
0, 0, 0, 0, 1, -1, 0, -1, 1, 0, 0xffffffff, -0xffffffff, 0, 0xffffffffffffffff, -0xffffffffffffffff,
// /
"E", 0, 0, "E", 1, -1, "E", -1, 1, "E", 0xffffffff, -0xffffffff, "E", 0xffffffffffffffff, -0xffffffffffffffff,
// %
"E", 0, 0, "E", 0, 0, "E", 0, 0, "E", 0, 0, "E", 0, 0,
// <<
0, 0, "E", 1, 2, "E", -1, -2, "E", 0xffffffff, 0x1fffffffe, "E", 0xffffffffffffffff, 0x1fffffffffffffffe, "E",
// >>
0, 0, "E", 1, 0, "E", -1, -1, "E", 0xffffffff, 0x7fffffff, "E", 0xffffffffffffffff, 0x7fffffffffffffff, "E",
// &
0, 0, 0, 0, 1, 1, 0, 1, -1, 0, 1, 0xffffffff, 0, 1, 0xffffffffffffffff,
// |
0, 1, -1, 1, 1, -1, -1, -1, -1, 0xffffffff, 0xffffffff, -1, 0xffffffffffffffff, 0xffffffffffffffff, -1,
// ^
0, 1, -1, 1, 0, -2, -1, -2, 0, 0xffffffff, 0xfffffffe, -0x100000000, 0xffffffffffffffff, 0xfffffffffffffffe, -0x10000000000000000,
}) ]])
|
2166c0 | 2008-05-06 | Henrik Grubbström (Grubba) | | # __func__
test_eq(__func__, "a")
test_eq("b", __func__)
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | test_eq(8, 0b1000);
test_eq(-8, -0b1000);
test_eq(16, 0b10000);
test_eq(-16, -0b10000);
|
565645 | 1999-10-26 | Fredrik Noring | |
|
926208 | 2003-02-26 | Martin Stjernholm | | test_true(1e-100000000000000000000000000000000000000000000000000000000000<=1e-10000)
|
6f3577 | 2003-02-26 | Mirar (Pontus Hagland) | | test_true(1e-10000<=1e-1000)
test_true(1e-1000<=1e-100)
test_true(1e-100<=1e-10)
test_true(1e-10<=1e-1)
test_true(1e-1<=1e1)
test_true(1e1<=1e10)
test_true(1e10<=1e100)
test_true(1e100<=1e1000)
test_true(1e1000<=1e10000)
|
926208 | 2003-02-26 | Martin Stjernholm | | test_true(1e10000<=1e100000000000000000000000000000000000000000000000000000000000)
|
6f3577 | 2003-02-26 | Mirar (Pontus Hagland) | |
|
0346dc | 2014-05-10 | Martin Nilsson | | test_compile_error('\3434523423423523423423423423')
test_compile_error("\3434523423423523423423423423")
test_compile_error("\d109827346981234561823743412654")
|
9a90b3 | 2014-10-22 | Per Hedbor | | test_compile_error('\d109827346981234561823743412654')
|
0346dc | 2014-05-10 | Martin Nilsson | | test_compile_error("\x109a27bc69e256c83deaa34c26b4")
|
9a90b3 | 2014-10-22 | Per Hedbor | | test_compile_error('\x109a27bc69e256c83deaa34c26b4')
|
b168bb | 2004-11-01 | Martin Stjernholm | | test_compile_error('\u17fo')
|
0346dc | 2014-05-10 | Martin Nilsson | | test_compile_error("\u17fo")
|
9a90b3 | 2014-10-22 | Per Hedbor | |
test_eq('012456789abcdefghijklmnopqrstuvwxyz'->digits(256),
"012456789abcdefghijklmnopqrstuvwxyz")
test_eq('\uu117f', 0x5c7531313766)
|
aee0b5 | 2004-11-16 | Martin Stjernholm | | test_eq("\uuuu17fo", "\\uuu17fo")
|
b168bb | 2004-11-01 | Martin Stjernholm | | test_eq('\u117f', 0x117f)
test_eq("\u117foo", "\10577oo")
test_eq("\u1117foo", "\10427foo")
test_eq("\uuuu117foo", "\\uuu117foo")
test_compile_error('\U117f')
|
0346dc | 2014-05-10 | Martin Nilsson | | test_compile_error("\U117f")
test_compile_error("\UdEaDbEaT")
|
aee0b5 | 2004-11-16 | Martin Stjernholm | | test_eq("\UUdEaDbEaT", "\\UdEaDbEaT")
|
b168bb | 2004-11-01 | Martin Stjernholm | | test_eq('\UDeaDBeEF', -559038737)
test_eq("\UDeaDBeEFFF", "\33653337357FF")
test_eq("\UUDeaDBeEFFF", "\\UDeaDBeEFFF")
|
e80a29 | 2002-02-28 | Martin Stjernholm | | test_do([[
|
bcc7d6 | 2002-04-12 | Martin Nilsson | | // bug 2677
|
e80a29 | 2002-02-28 | Martin Stjernholm | | int x;
if (time())
x = 1;
else
foo: break foo;
]])
|
14dd02 | 2002-06-11 | Henrik Grubbström (Grubba) | | test_any([[
// bug 2690
array(function) foo(void|int b)
{
int add() { return b++; };
return ({ add, add });
};
array(function) bar = foo();
return equal(({`==(@bar),@bar()}), ({ 1, 0, 1 }));
]], 1)
|
805ea6 | 2002-02-26 | Martin Stjernholm | | test_any([[
int f (int i) {i = 0; return i;};
return f (1);
]],0)
|
fa7892 | 2001-07-28 | Fredrik Hübinette (Hubbe) | | test_any([[
|
c20941 | 2002-11-13 | Henrik Grubbström (Grubba) | | // Test that F_TAIL_RECUR and RECUR work properly.
class X
{
int Ack(int M, int N) {
if (M == 0) return( N + 1 );
if (N == 0) return( Ack(M - 1, 1) );
return( Ack(M - 1, Ack(M, (N - 1))) );
}
};
return X()->Ack(3,5);
]],253)
test_any([[
// Test that F_COND_RECUR works properly.
|
daf649 | 2002-11-14 | Henrik Grubbström (Grubba) | | // This test forces F_COND_RECUR to fail.
|
c20941 | 2002-11-13 | Henrik Grubbström (Grubba) | | class X
{
int Ack(int M, int N) {
if (M == 0) return( N + 1 );
if (N == 0) return( Ack(M - 1, 1) );
return( Ack(M - 1, Ack(M, (N - 1))) );
}
};
|
fa7892 | 2001-07-28 | Fredrik Hübinette (Hubbe) | |
|
daf649 | 2002-11-14 | Henrik Grubbström (Grubba) | | class Y { inherit X;
int Ack(int M, int N) { return ::Ack(M, N); }
};
|
fa7892 | 2001-07-28 | Fredrik Hübinette (Hubbe) | |
|
c20941 | 2002-11-13 | Henrik Grubbström (Grubba) | | return Y()->Ack(2,2);
|
fa7892 | 2001-07-28 | Fredrik Hübinette (Hubbe) | | ]],7)
|
20043f | 2008-07-17 | Henrik Grubbström (Grubba) | | test_any([[
// Test that F_RECUR et al are not used for inlined functions
// where the scope is in use.
class X {
inline function(int:int) foo(int x, int y)
{
if (y) return foo(x+y, y-1);
return lambda(int z) { return x+z; };
}
};
return X()->foo(10, 3)(5);
]], 21)
|
ce9bfb | 2002-12-20 | Henrik Grubbström (Grubba) | | test_any([[
// Test that loop optimizer isn't too aggressive.
// Thanks to Alexander Demenshin <aldem-pike@aldem.net>
int x,y,a;
for(;x<10000;x++) {
y += (x - a++);
}
return a;
]], 10000)
test_any([[
// Test that loop optimizer isn't too aggressive.
// Thanks to Alexander Demenshin <aldem-pike@aldem.net>
mapping m = ([]);
for(;m->x<10000;m->x++) {
m->y += (m->x - m->a++);
}
return m->a;
]], 10000)
|
4ce36d | 2003-01-29 | Marcus Comstedt | | test_any([[
// Test that loop optimizer isn't too aggressive.
// Thanks to me. / Marcus
for(int i=0; i<3.0; i++)
if(i>4.0)
return -1;
return 0;
]], 0)
|
f88fda | 2003-03-21 | Johan Sundström | | test_any([[
// Test that optimizer notes side effects in arguments to `!=
// Thanks to Marcus Agehall
int j = 20, i;
string end = "17";
for( ; i < j ; i++)
if(sscanf(end, "%d%s", j, end) != 2)
cd(".");
return i;
]], 17)
|
07b70d | 2014-10-27 | Martin Nilsson | | test_any([[
for(int i; i<10; i++) ;
return 1;
]], 1)
|
9002ef | 2004-04-29 | Martin Nilsson | | test_any([[
// Another over-optimization test.
string x(string i) { return i; };
return x("")+1+1;
]], "11")
|
df23b9 | 2009-11-20 | Henrik Grubbström (Grubba) | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
df23b9 | 2009-11-20 | Henrik Grubbström (Grubba) | | // Check that parent pointers aren't added unnecessarily [bug 2672].
class I {};
class X
{
// Neither the inherit nor the variable type should add
// a parent pointer requirement.
inherit I;
I i;
};
X x = ((program) X)(); // Error: Parent lost, cannot clone program.
return 0;
]], 0)
|
204536 | 2011-03-28 | Henrik Grubbström (Grubba) | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
df23b9 | 2009-11-20 | Henrik Grubbström (Grubba) | | // Check that parent pointers aren't added unnecessarily [bug 2672].
class I {};
class X
{
|
204536 | 2011-03-28 | Henrik Grubbström (Grubba) | | // The cloning of I makes X need its parent usually,
// but note that since we're nested in a function
// scope by the testsuite, I will not be overloadable,
// and thus we won't need the parent.
|
df23b9 | 2009-11-20 | Henrik Grubbström (Grubba) | | inherit I;
I i = I();
};
X x = ((program) X)(); // Error: Parent lost, cannot clone program.
return 0;
]], 0)
|
204536 | 2011-03-28 | Henrik Grubbström (Grubba) | | test_eval_error([[
class Wrapper {
// Check that parent pointers aren't added unnecessarily [bug 2672].
class I {}
class X
{
// The cloning of I makes X need its parent.
inherit I;
I i = I();
}
};
object x = ((program) (Wrapper()->X))(); // Error: Parent lost, cannot clone program.
return 0;
]], 0)
test_any([[
// Check that parent pointers aren't added unnecessarily [LysLysKOM 18781511].
class Foo {
|
e68090 | 2015-03-22 | Henrik Grubbström (Grubba) | | final constant const_val = 1;
|
204536 | 2011-03-28 | Henrik Grubbström (Grubba) | | class Bar
{
int func()
{
|
e68090 | 2015-03-22 | Henrik Grubbström (Grubba) | | // parent-pointer not needed, since const_val is final.
return const_val;
|
204536 | 2011-03-28 | Henrik Grubbström (Grubba) | | };
}
};
return !Foo.Bar;
]], 0)
|
f53802 | 2003-02-25 | Marcus Comstedt | | test_compile_any([[
|
13670c | 2015-05-25 | Martin Nilsson | | mixed foo()
|
f53802 | 2003-02-25 | Marcus Comstedt | | {
Stdio.File bar(int x, int y)
|
13670c | 2015-05-25 | Martin Nilsson | | {
|
f53802 | 2003-02-25 | Marcus Comstedt | | return 0;
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | };
return bar;
|
13670c | 2015-05-25 | Martin Nilsson | | }
|
f53802 | 2003-02-25 | Marcus Comstedt | | ]])
|
7a8442 | 2003-10-10 | Martin Stjernholm | | test_compile_any([[
string foo (string a, string b, string c, string d, string e, string f, string g)
{
string out;
if (a)
out = "foo";
else
out = "bar";
return out;
}
]])
|
c69116 | 2016-04-25 | Henrik Grubbström (Grubba) | | test_compile_any([[
mixed foo()
{
array a;
array b = a->f("b")?->b;
return b;
}
]])
|
127316 | 2014-07-02 | Arne Goedeke | | define(test_string_range,[[
test_any([[
string s = (string) ({ $1, $1 });
if (!arrayp(String.range(s))) return "huh?"; // dont optimize this, it forces string range check
return search(s, $1);
]], 0)
]])
test_string_range(254);
test_string_range(255);
test_string_range((1<<16)-1);
test_string_range((1<<16)+1);
test_string_range((1<<29)-1);
test_string_range((1<<29)+1);
test_string_range((1<<31)-1);
test_string_range(-(1<<31));
|
2fa122 | 2006-03-01 | Henrik Grubbström (Grubba) | | dnl number of variables/scope, number of scopes, expect_compiler_error
define(test_scopes,[[
|
887c59 | 2006-03-01 | Henrik Grubbström (Grubba) | | test_any([[
|
50ab1c | 2010-07-12 | Martin Stjernholm | | log_status("Testing scoped variables $1:$2%s...",
$3?" expecting a compilation error":"");
|
887c59 | 2006-03-01 | Henrik Grubbström (Grubba) | | string line = sprintf("#line %d %O\n", __LINE__, __FILE__);
|
2fa122 | 2006-03-01 | Henrik Grubbström (Grubba) | | string s = "{\n" +
(map(indices(allocate($1)), lambda(int no) {
no++;
return sprintf(" int var_%d;\n"
" if (var_%d)\n"
" error(\"Variable var_%d not \"\n"
" \"initialized to zero: \"\n"
" \"%%O\\n\",\n"
" var_%d);\n"
" var_%d = %d;\n",
no, no, no, no, no, no);
}) +
map(indices(allocate($1)), lambda(int no) {
no++;
return sprintf(" if (var_%d != %d)\n"
" error(\"Variable var_%d was \"\n"
" \"clobbered with %%O.\\n\",\n"
" var_%d);\n",
no, no, no, no);
})) * "" +
"}\n";
program p;
|
d55352 | 2007-06-18 | Martin Stjernholm | | if ($3) master()->set_inhibit_compile_errors (1);
|
2fa122 | 2006-03-01 | Henrik Grubbström (Grubba) | | mixed err = catch {
p = compile_string("int a() {\n" + line + (s * $2) +
" return 0;\n"
"}\n");
};
if ($3) {
|
d55352 | 2007-06-18 | Martin Stjernholm | | master()->set_inhibit_compile_errors (0);
|
2fa122 | 2006-03-01 | Henrik Grubbström (Grubba) | | if (err) return 0;
error("Expected a compilation error for $1 variables in $2 scope%s.\n",
($2>1)?"s":"");
}
if (err) throw(err);
|
887c59 | 2006-03-01 | Henrik Grubbström (Grubba) | | return p()->a();
]], 0)
]])
|
2fa122 | 2006-03-01 | Henrik Grubbström (Grubba) | | test_scopes(255, 1, 0)
test_scopes(256, 1, 1)
test_scopes(16, 17, 0)
test_scopes(17, 16, 0)
|
4ce36d | 2003-01-29 | Marcus Comstedt | |
|
078c60 | 2006-03-02 | Henrik Grubbström (Grubba) | | test_any([[
// LysLysKOM 14180500
if (1) {
string var = "Reinitialization error.";
}
sscanf("", "%d", int zero);
return zero;
]], 0);
|
414ab9 | 2006-03-04 | Henrik Grubbström (Grubba) | | test_any([[
// LysLysKOM 14189033
int i;
for (i = 0; i < 4; i++) {
sscanf("", "%d", int test);
if (test) return test;
test = i+1;
}
return 0;
]], 0)
|
ae0ac1 | 2002-11-14 | Henrik Grubbström (Grubba) | | dnl FIXME: Add test that local and local:: in combination
dnl with recursion works correctly.
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | test_eval_error([[mixed x; return mkmapping(x,x)]]);
|
97431e | 1999-03-19 | Fredrik Hübinette (Hubbe) | |
|
3488ef | 2000-04-17 | Henrik Grubbström (Grubba) | | test_eval_error([[class Foo {
void bar() {}
|
f960bd | 2015-07-31 | Martin Nilsson | | void foo() {destruct(this);bar();}
|
3488ef | 2000-04-17 | Henrik Grubbström (Grubba) | | };
Foo()->foo();
]])
|
7ddaa3 | 2000-08-22 | Martin Stjernholm | | test_do([[
void foo (int i) {
multiset res = (<>);
if (i) res = res;
};
foo (1);
]])
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | | test_any([[
array tmp=({});
tmp=({([])})+tmp;
tmp->foo=7;
tmp=({([])})+tmp;
return sizeof(tmp[0]);
]], 0)
|
52032c | 2008-05-12 | Henrik Grubbström (Grubba) | | test_any([[
// Bug 4537.
void fiddle(array(int) a)
{
a += ({ 2 });
};
array(int) a = ({ 1 });
fiddle(a);
return sizeof(a);
]], 1)
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | |
|
774f9a | 2011-03-21 | Martin Stjernholm | | test_eval_error([[
// [Bug 5911]
class X {
string s;
};
X()->s = (mixed) X();
]])
|
b0dfbb | 2011-09-04 | Martin Nilsson | | test_any([[
// Bug 6062
class C { mapping options = ([ 1:1 ]); };
C c = C();
c->options[3] = 3;
c = C();
return sizeof(c->options) == 1;
]], 1)
|
6c98ca | 2011-09-05 | Henrik Grubbström (Grubba) | | test_any([[
// Bug 6063
class A { extern string s; string q() { return s; } };
class B { inherit A; string s = "s"; };
class C { inherit B; };
class D { inherit C; };
return ({ B(), C(), D() })->q() * "";
]], "sss")
|
6bf0fa | 2011-09-12 | Henrik Grubbström (Grubba) | | test_any([[
// bug 6065
class A(string s) {};
class B(string s) { inherit A; };
return B("foo")->s;
]], "foo")
|
49a00f | 2018-02-02 | Henrik Grubbström (Grubba) | | test_any_equal([[
class A{ constant sym = 1; }
class B{ constant sym = 2; inherit A; }
return indices(B);
]], ({ "sym" }))
test_any_equal([[
class A{ constant sym = 1; }
class B{ inherit A; constant sym = 2; }
return indices(B);
]], ({ "sym" }))
test_any_equal([[
class A{ constant sym = 1; }
class B{ constant sym = 2; inherit A; }
return values(B);
]], ({ 2 }))
test_any_equal([[
class A{ constant sym = 1; }
class B{ inherit A; constant sym = 2; }
return values(B);
]], ({ 2 }))
test_any_equal([[
class A{ constant sym = 1; }
class B{ constant sym = 2; inherit A; }
return indices(B());
]], ({ "sym" }))
test_any_equal([[
class A{ constant sym = 1; }
class B{ inherit A; constant sym = 2; }
return indices(B());
]], ({ "sym" }))
test_any_equal([[
class A{ constant sym = 1; }
class B{ constant sym = 2; inherit A; }
return values(B());
]], ({ 2 }))
test_any_equal([[
class A{ constant sym = 1; }
class B{ inherit A; constant sym = 2; }
return values(B());
]], ({ 2 }))
|
65e0e1 | 2019-03-28 | Henrik Grubbström (Grubba) | | test_any_equal([[
// Test constant expression in inherit.
class A { constant sym = 1; }
class B { constant sym = 2; }
class C { inherit ([ "A":A, "B":B ])["A"]; }
class D { inherit ([ "A":A, "B":B ])["B"]; }
return ({ A, B, C, D })->sym;
]], ({ 1, 2, 1, 2 }))
|
fdd6a8 | 2008-10-13 | Mirar (Pontus Hagland) | | dnl bug in for loop optimization in combination with +=
test_any([[
|
13670c | 2015-05-25 | Martin Nilsson | | array v=({1,2,3});
for (int i=0; i<sizeof(v); i++)
for (int j=0; j<i; j++)
{
v+=({1+i});
if (i==17) { i=10000; break; }
}
|
fdd6a8 | 2008-10-13 | Mirar (Pontus Hagland) | | return sizeof(v); // if buggy, will be 6 and not 140
]], 140);
test_any([[
|
13670c | 2015-05-25 | Martin Nilsson | | array v=({1,2,3});
for (int i=0; i<sizeof(v); i++)
for (int j=0; j<i; j++)
{
v=v+({1+i});
if (i==17) { i=10000; break; }
}
|
fdd6a8 | 2008-10-13 | Mirar (Pontus Hagland) | | return sizeof(v); // not buggy, will be 140
]], 140);
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | test_any([[int a=0xffffffff; return a+17]], 0x100000010);
test_any([[int a=0xffffffff; return a-17]], 0xffffffee);
test_any([[int a=0xffffffff; return a*17]], 0x10ffffffef);
test_any([[int a=0xffffffff; return a^17]], 0xffffffee);
test_any([[int a=0xffffffff; return a&17]], 17);
test_any([[int a=0xffffffff; return a|17]], 0xffffffff);
test_any([[int a=0xffffffff; return a<<17]], 0x1fffffffe0000);
|
2b2df2 | 1999-11-01 | Henrik Grubbström (Grubba) | |
test_any([[ int a=0xffffffff; return a/17 ]],
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | [[ (0xffffffff == -1)?-1:0x0f0f0f0f ]]);
|
2b2df2 | 1999-11-01 | Henrik Grubbström (Grubba) | | test_any([[ int a=0xffffffff; return a%17 ]],
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | [[ (0xffffffff == -1)?16:0 ]]);
|
2b2df2 | 1999-11-01 | Henrik Grubbström (Grubba) | | test_any([[ int a=0xffffffff; return a>>17 ]],
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | [[ (0xffffffff == -1)?-1:0x7fff ]]);
|
f61d77 | 2013-12-12 | Henrik Grubbström (Grubba) | | dnl Check the derived return type of sprintf().
test_any([[return sprintf("%O", typeof(sprintf("%1H", "foo"))); ]],
|
a2f242 | 2014-01-05 | Henrik Grubbström (Grubba) | | "string(8bit)");
|
f61d77 | 2013-12-12 | Henrik Grubbström (Grubba) | | test_any([[return sprintf("%O", typeof(sprintf("foo"))); ]],
"string(102..111)");
test_any([[return sprintf("%O", typeof(sprintf("foo%c", 17))); ]],
"string(17..17 | 102..111)");
test_any([[return sprintf("%O", typeof(sprintf("%2c\n", 'a'))); ]],
|
a2f242 | 2014-01-05 | Henrik Grubbström (Grubba) | | "string(8bit)");
|
8b2dd4 | 2014-08-31 | Henrik Grubbström (Grubba) | | dnl Note the following tests the return type of int2char().
|
f61d77 | 2013-12-12 | Henrik Grubbström (Grubba) | | test_any([[return sprintf("%O", typeof(sprintf("%c", 1023))); ]],
"string(1023..1023)");
test_any([[return sprintf("%O", typeof(sprintf("%c\n", 1023))); ]],
"string(10..10 | 1023..1023)");
|
8b2dd4 | 2014-08-31 | Henrik Grubbström (Grubba) | | dnl The following is due to (string & sprintf_result) == sprintf_result.
|
f61d77 | 2013-12-12 | Henrik Grubbström (Grubba) | | test_any([[return sprintf("%O", typeof(sprintf("%c\n", Stdio))); ]],
|
8b2dd4 | 2014-08-31 | Henrik Grubbström (Grubba) | | sprintf("%O", sprintf_result));
|
f61d77 | 2013-12-12 | Henrik Grubbström (Grubba) | | test_any([[return sprintf("%O", typeof(sprintf("%4[1]c", 17))); ]],
|
a2f242 | 2014-01-05 | Henrik Grubbström (Grubba) | | "string(8bit)");
|
f61d77 | 2013-12-12 | Henrik Grubbström (Grubba) | | test_any([[return sprintf("%O", typeof(sprintf("%[1]n", 17))); ]],
"string(zero)");
|
b34726 | 2013-06-03 | Martin Nilsson | | test_any([[return sprintf("%O", typeof(aggregate("foo")));]], "array(string(102..111))");
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_any([[int a; return sprintf("%O", typeof(aggregate(a)));]], "array(int)");
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | | test_any([[int|string a;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | string s = sprintf("%O", typeof(aggregate(a)));
|
3b30c9 | 2007-04-03 | Henrik Grubbström (Grubba) | | return (< "array(string) | array(int)", "array(string | int)", "array(int | string)" >)[s];]], 1);
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_any([[return sprintf("%O", typeof(aggregate()));]], "array(zero)");
|
1954be | 1999-12-10 | Henrik Grubbström (Grubba) | | test_any([[int i; return (< "int", "int | zero", "zero | int" >)
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | [sprintf("%O", typeof(max(i,0)))];]], 1)
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | |
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_any([[array(string) a; return sprintf("%O", typeof(a[0])); ]], "string")
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | |
test_any([[class foo { string a; };
object(foo) bar;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(bar->a));]], "string");
|
3b7464 | 1999-11-24 | Henrik Grubbström (Grubba) | |
test_any([[class foo { string a; };
array(object(foo)) bar;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(bar[0]->a));]], "string");
|
94b524 | 1999-11-01 | Mirar (Pontus Hagland) | |
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_any([[function(:string)|function(int:int) f;
return sprintf("%O", typeof(f())); ]],
|
f2e6a4 | 1999-11-24 | Henrik Grubbström (Grubba) | | "string")
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_any([[function(:string)|function(int:int) f;
return sprintf("%O", typeof(f(1))); ]],
|
f2e6a4 | 1999-11-24 | Henrik Grubbström (Grubba) | | "int")
|
dc19e7 | 1999-11-24 | Henrik Grubbström (Grubba) | | test_any([[function(:string)|function(mixed, mixed...:int) f;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(f())); ]],
|
dc19e7 | 1999-11-24 | Henrik Grubbström (Grubba) | | "string")
test_any([[function(:string)|function(mixed, mixed ...:int) f;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(f(1))); ]],
|
dc19e7 | 1999-11-24 | Henrik Grubbström (Grubba) | | "int")
|
00091b | 1999-12-05 | Martin Stjernholm | | test_any([[mapping(object:string)|mapping(string:int) f;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(f[class{}()])); ]],
|
00091b | 1999-12-05 | Martin Stjernholm | | "string")
test_any([[mapping(object:string)|mapping(string:int) f;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(f[""])); ]],
|
00091b | 1999-12-05 | Martin Stjernholm | | "int")
test_any([[mapping(object:string)|mapping(string:int) f;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sort((sprintf("%O", typeof(f[0])) - " ")/"|")*"|"; ]],
|
00091b | 1999-12-05 | Martin Stjernholm | | "int|string")
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_any([[class Foo { protected string `[](mixed y) {return "";} };
|
b6733a | 1999-12-05 | Henrik Grubbström (Grubba) | | object(Foo) foo;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(foo[0])); ]],
|
b6733a | 1999-12-05 | Henrik Grubbström (Grubba) | | "string")
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_any([[class Foo { protected array(int) _indices() {return ({0});} };
|
b6733a | 1999-12-05 | Henrik Grubbström (Grubba) | | object(Foo) foo;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(indices(foo))); ]],
|
f60091 | 1999-12-05 | Henrik Grubbström (Grubba) | | "array(int)")
|
b6733a | 1999-12-05 | Henrik Grubbström (Grubba) | |
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_any([[class Foo { protected array(string) _values() {return ({""});} };
|
b6733a | 1999-12-05 | Henrik Grubbström (Grubba) | | object(Foo) foo;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(values(foo))); ]],
|
b6733a | 1999-12-05 | Henrik Grubbström (Grubba) | | "array(string)")
|
ffb7fe | 1999-12-08 | Henrik Grubbström (Grubba) | | test_any([[mapping(string:int) foo;
array(string) bar;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | return sprintf("%O", typeof(rows(foo, bar))); ]],
|
ffb7fe | 1999-12-08 | Henrik Grubbström (Grubba) | | "array(int)")
|
c49442 | 2016-01-04 | Per Hedbor | | // basic auto tests.
test_any([[
class Toplevel {
class Foo {
auto a = 10;
auto b = typeof(a);
};
string test() {
|
300d02 | 2016-11-05 | Martin Nilsson | | return sprintf("a%Ob%O", typeof(Foo()->a),typeof(Foo()->b));
|
c49442 | 2016-01-04 | Per Hedbor | | };
};
return Toplevel()->test();
]], "aint(10..10)btype(int(10..10))");
test_any([[{
class Toplevel {
class Foo {
auto test(){ return 10;return 20;return 30; };
};
string test() {
|
300d02 | 2016-11-05 | Martin Nilsson | | return sprintf("%O", typeof(Foo()->test));
|
c49442 | 2016-01-04 | Per Hedbor | | }
};
return Toplevel()->test()-" ";
}]], "function(:int(10..10)|int(20..20)|int(30..30))");
|
85ff73 | 2001-07-03 | Martin Stjernholm | | test_any([[{
class Foo
{
mixed m;
|
537f1e | 2001-07-03 | Henrik Grubbström (Grubba) | | };
|
85ff73 | 2001-07-03 | Martin Stjernholm | | class Bar
{
inherit Foo;
string m;
Foo b;
|
537f1e | 2001-07-03 | Henrik Grubbström (Grubba) | | mixed f() {
return typeof(b->m);
}
};
|
f704a2 | 2001-07-03 | Henrik Grubbström (Grubba) | | Foo c;
Bar d;
|
537f1e | 2001-07-03 | Henrik Grubbström (Grubba) | | return sprintf("%O$%O$%O$%O",
Bar()->f(), typeof(c->m), typeof(d->m), typeof(d->b->m));
|
f704a2 | 2001-07-03 | Henrik Grubbström (Grubba) | | }]], "mixed$mixed$string$mixed")
|
85ff73 | 2001-07-03 | Martin Stjernholm | |
|
32efc9 | 2003-03-07 | Henrik Grubbström (Grubba) | | // las.c:find_return_type() checks.
test_eq([[
// Test case from Robert J. Budzynski <Robert.Budzynski@fuw.edu.pl>.
// When broken the return type will be mixed.
sprintf("%O", typeof(lambda(string s){
|
0b8d2f | 2013-06-17 | Martin Nilsson | | return Charset.decoder("utf-8")->feed(s)->drain();
|
32efc9 | 2003-03-07 | Henrik Grubbström (Grubba) | | }))
]], [[ "function(string : string)" ]])
|
9d3a7a | 2005-02-18 | Henrik Grubbström (Grubba) | | // Test implicit lambda.
test_eq([[
`()(){ return 1; }
]], 1)
|
cc8b3b | 2017-11-02 | Henrik Grubbström (Grubba) | | test_equal([[
lambda(array a, function f) { return f(@a); }
(({ 0, 1, 2, 3 })){ return __ARGS__; }
]], ({ 0, 1, 2, 3}))
|
d96720 | 2004-02-28 | Martin Stjernholm | | // Argument checking
|
bed458 | 2012-07-12 | Henrik Grubbström (Grubba) | | // Test new_check_call.
|
c287ef | 2012-07-18 | Henrik Grubbström (Grubba) | | test_any([[
|
bed458 | 2012-07-12 | Henrik Grubbström (Grubba) | | constant foo = 5;
// Test that it survives a F_ARG_LIST with CAR == CDR.
return foo%foo;
]], 0)
|
d96720 | 2004-02-28 | Martin Stjernholm | | // Test get_all_args.
test_eval_error([[
// A trick to get some svalues to freed refcounted stuff on the stack.
lambda (mixed a, mixed b, mixed c) {} (({time()}), ({time()}), ({time()}));
// set_weak_flag is chosen since it calls get_all_args with an
// argument spec that contains two arguments of different types.
([function] set_weak_flag)();
]])
test_eval_error([[
lambda (mixed a, mixed b, mixed c) {} (({time()}), ({time()}), ({time()}));
([function] set_weak_flag) (17);
]])
test_eval_error([[
lambda (mixed a, mixed b, mixed c) {} (({time()}), ({time()}), ({time()}));
([function] set_weak_flag) ("foo");
]])
test_eval_error([[
lambda (mixed a, mixed b, mixed c) {} (({time()}), ({time()}), ({time()}));
([function] set_weak_flag) (17, "foo");
]])
|
ac1e89 | 2009-03-11 | Marcus Comstedt | | // Check that write() and error() with one argument are not
// incorrectly subjected to sprintf() argument
test_compile([[write("%\u2323");]])
test_compile([[error("%\u2323");]])
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | | // type checks
define(test_type_error, [[
test_compile_error([[ $1 x; x=$3; ]])
|
6b3f5c | 2002-04-11 | Martin Nilsson | | test_compile_error_any([[ class ErrBa { $1 x() { return $3; } } ]])
test_compile_error_any([[ class ErrBa { $1 x() { $2 a=$3; return a; } } ]])
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | | ]])
test_type_error(int,float,17.23)
test_type_error(int,array,({1,2,3}))
test_type_error(int,mapping,([1:2,3:4]))
test_type_error(int,multiset,(<1,2,3>))
test_type_error(int,function,lambda() { return 17; })
|
f960bd | 2015-07-31 | Martin Nilsson | | test_type_error(int,program,this_program)
test_type_error(int,object,this)
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | |
test_type_error(float,int,17)
test_type_error(float,array,({1,2,3}))
test_type_error(float,mapping,([1:2,3:4]))
test_type_error(float,multiset,(<1,2,3>))
test_type_error(float,function,lambda() { return 17; })
|
f960bd | 2015-07-31 | Martin Nilsson | | test_type_error(float,program,this_program)
test_type_error(float,object,this)
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | |
test_type_error(array,int,17)
test_type_error(array,float,17.23)
test_type_error(array,mapping,([1:2,3:4]))
test_type_error(array,multiset,(<1,2,3>))
test_type_error(array,function,lambda() { return 17; })
|
f960bd | 2015-07-31 | Martin Nilsson | | test_type_error(array,program,this_program)
test_type_error(array,object,this)
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | |
test_type_error(mapping,int,17)
test_type_error(mapping,float,17.23)
test_type_error(mapping,array,({1,2,3}))
test_type_error(mapping,multiset,(<1,2,3>))
test_type_error(mapping,function,lambda() { return 17; })
|
f960bd | 2015-07-31 | Martin Nilsson | | test_type_error(mapping,program,this_program)
test_type_error(mapping,object,this)
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | |
test_type_error(multiset,int,17)
test_type_error(multiset,float,17.23)
test_type_error(multiset,array,({1,2,3}))
test_type_error(multiset,mapping,([1:2,3:4]))
test_type_error(multiset,function,lambda() { return 17; })
|
f960bd | 2015-07-31 | Martin Nilsson | | test_type_error(multiset,program,this_program)
test_type_error(multiset,object,this)
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | |
test_type_error(function,int,17)
test_type_error(function,float,17.23)
test_type_error(function,array,({1,2,3}))
test_type_error(function,mapping,([1:2,3:4]))
test_type_error(function,multiset,(<1,2,3>))
test_type_error(program,int,17)
test_type_error(program,float,17.23)
test_type_error(program,array,({1,2,3}))
test_type_error(program,mapping,([1:2,3:4]))
test_type_error(program,multiset,(<1,2,3>))
test_type_error(object,int,17)
test_type_error(object,float,17.23)
test_type_error(object,array,({1,2,3}))
test_type_error(object,mapping,([1:2,3:4]))
test_type_error(object,multiset,(<1,2,3>))
|
b5ca84 | 2009-06-22 | Henrik Grubbström (Grubba) | | test_any_equal([[
// This code caused a NULL dereference in Pike 7.8.306 and earlier.
indices foo;
return typeof(foo);
]], typeof(indices((mixed)0)))
|
b8efef | 2008-09-12 | Henrik Grubbström (Grubba) | | // Check that complex function types survive soft casting to function.
|
a4cf89 | 2008-09-12 | Henrik Grubbström (Grubba) | | ignore_warning("Soft cast of scope(0,function(*)) to function is a noop.", [[
|
b8efef | 2008-09-12 | Henrik Grubbström (Grubba) | | test_eq(typeof([function]`+), typeof(`+))
]])
|
aba09a | 2011-12-28 | Henrik Grubbström (Grubba) | | test_compile_error([[ static_assert(0, "Fail."); ]])
test_any([[ static_assert(1, "Ok."); ]], 0)
|
f900a9 | 2005-01-17 | Henrik Grubbström (Grubba) | | test_any([[
/* Detect bug in modify_shared_string().
*
* Note: For proper operation this test depends on HASH_PREFIX being
* <= 128, and the initial string in test having a single ref.
*/
string prefix = "A"*128;
string suffix = "B"*128;
string test = prefix + "C" + suffix;
string match = prefix + "D" + suffix;
if (test == match) return("Early match!");
test[128] = 'D';
if (test != match) return("Late mismatch!");
]], 0)
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | | test_compile_error([[ string a="abcb"; a=a/"b"; ]])
test_compile_error([[ string a="abcb"; a/="b"; ]])
test_compile_error([[ string a="abcb"; string b="b"; a=a/b; ]])
test_compile_error([[ string a="abcb"; string b="b"; a/=b; ]])
test_compile_error([[ string a="x"; int b; b="x"*17; ]])
test_compile_error([[ string a="x"; array b; b="x"*17; ]])
test_compile_error([[ int b=17; string a; a=b*42; ]])
test_compile_error([[ int b=17; float c=42.0; b=b/c; ]])
test_compile_error([[ int b=17; float c=42.0; b/=c; ]])
test_compile_error([[ int b=17; float c=42.0; b=b*c; ]])
test_compile_error([[ int b=17; float c=42.0; b*=c; ]])
|
2d190e | 2001-02-21 | Mirar (Pontus Hagland) | | test_compile_error([[ int b=17; float c=42.0; b=b+c; ]])
test_compile_error([[ int b=17; float c=42.0; b+=c; ]])
test_compile_error([[ int b=17; float c=42.0; b=b-c; ]])
test_compile_error([[ int b=17; float c=42.0; b-=c; ]])
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | | test_compile_error([[ float b=17.0; string a; a=b*42; ]])
test_compile_error([[ float b=17.0; string a; a=b*42.0; ]])
|
9692ed | 2001-12-20 | Martin Stjernholm | | test_compile_error([[class F {inherit master()->dirnode;};]]);
|
eea216 | 2008-07-11 | Martin Stjernholm | | test_any([[
class A {
constant i = -1;
string f() {
return ([1: "foo"])[i] || "bar"; // No warning here. C.f. lyslys 16630665.
}
};
class B {
inherit A;
constant i = 1;
};
return B()->f();
]], "foo")
|
18cfc1 | 2002-05-24 | Martin Nilsson | | // Warnings
test_compile_warning([[ [mixed]1 ]])
|
90bf26 | 2004-01-15 | Martin Nilsson | | test_compile_warning([[
class A { int a = 6; };
class B {
constant a = 5;
inherit A;
};
]])
|
18cfc1 | 2002-05-24 | Martin Nilsson | |
|
25702d | 2015-10-18 | Henrik Grubbström (Grubba) | | test_compile_warning([[
class A {
int foo;
protected void create(int foo)
{
// Intentional common typo below.
this:foo = foo;
}
};
]])
|
5bcd22 | 2001-02-21 | Mirar (Pontus Hagland) | | //
|
7241dd | 2017-11-12 | Henrik Grubbström (Grubba) | | test_compile_warning([[
// Warning: Compat: Substituting destroy() for _destruct().
class A {
protected void destroy() {}
}
]])
test_compile_any([[
#pragma no_deprecation_warnings
class A {
protected void destroy() {}
}
]])
test_compile_any([[
class A {
protected void _destruct() {}
protected void destroy() {}
}
]])
test_compile_any([[
class A {
protected void destroy() {}
protected void _destruct() {}
}
]])
|
8aae36 | 2019-04-06 | Henrik Grubbström (Grubba) | | test_any([[
// Test Pike.InhibitDestruct.
class Foo {
inherit Pike.InhibitDestruct;
/* Make the symbols visible outside. */
void inhibit_destruct() { ::inhibit_destruct(); }
void permit_destruct() { ::permit_destruct(); }
}
object o = Foo();
destruct(o);
if (o) return 1;
o = Foo();
o->inhibit_destruct();
o->permit_destruct();
if (!o) return 2;
destruct(o);
if (o) return 3;
o = Foo();
o->inhibit_destruct();
destruct(o);
if (!o) return 4;
o->inhibit_destruct();
if (!o) return 5;
o->permit_destruct();
if (!o) return 6;
o->permit_destruct();
if (o) return 7;
return 0;
]], 0)
|
644730 | 2000-03-10 | Henrik Grubbström (Grubba) | | test_any([[
class Foo {
constant zero = 0;
mapping(string:array(int)) m;
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | string foo() { return sprintf("%O", typeof(m[""][zero])); }
|
644730 | 2000-03-10 | Henrik Grubbström (Grubba) | | };
return Foo()->foo();
]], "int")
|
a91588 | 2000-09-20 | Fredrik Noring | | test_compile_any([[
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | class Foo { ; }
|
a91588 | 2000-09-20 | Fredrik Noring | | ]])
test_compile_any([[
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | class Foo { ; ; }
|
a91588 | 2000-09-20 | Fredrik Noring | | ]])
test_compile_any([[
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | class Foo { ; constant c = 0; }
|
a91588 | 2000-09-20 | Fredrik Noring | | ]])
|
107a0a | 2001-01-16 | Fredrik Hübinette (Hubbe) | | test_compile_any([[
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | class Foo { mixed a() { constant c = 17; return c; }
mixed b() { constant c = 17; return c; } }
|
107a0a | 2001-01-16 | Fredrik Hübinette (Hubbe) | | ]])
|
9847f1 | 1999-11-27 | Martin Stjernholm | | test_compile_any([[
constant FOO = 0;
mapping(int:string) foo = ([FOO: "foo"]);
]])
|
761233 | 2000-03-30 | Henrik Grubbström (Grubba) | | test_compile_error([[
|
099be6 | 2000-03-30 | Henrik Grubbström (Grubba) | | function(...:int) foo;
]]);
|
761233 | 2000-03-30 | Henrik Grubbström (Grubba) | | test_compile_error([[
|
099be6 | 2000-03-30 | Henrik Grubbström (Grubba) | | function(,...:int) foo;
]]);
|
761233 | 2000-03-30 | Henrik Grubbström (Grubba) | | test_compile_error([[
|
099be6 | 2000-03-30 | Henrik Grubbström (Grubba) | | function(string,...:int) foo;
]]);
|
f0a765 | 2008-06-24 | Martin Stjernholm | | test_compile_any([[
|
d5a1ec | 2013-11-03 | Henrik Grubbström (Grubba) | | // #pragma strict_types
|
f0a765 | 2008-06-24 | Martin Stjernholm | | void x (void|mapping(string:string) args)
{
if (args)
foreach (indices (args), string a)
werror ("%O\n", a);
}
]])
// For some reason, the test above doesn't generate the warning (about
// the type from indices (args)) if it comes after the one below.
// Also, if it is repeated it doesn't generate the warning the second
// time. Not very reassuring.. /mast
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | test_any([[return class {
|
d0cd2f | 1998-11-08 | Fredrik Hübinette (Hubbe) | | string bonk() { return "oiff"; }
class A
{
string bonk_me() { return bonk(); }
}
class B { inherit A; }
class C
{
string oiff() { return "bonk"; }
class D { inherit B; }
}
}()->C()->D()->bonk_me()]],"oiff")
|
1cc068 | 2008-09-14 | Henrik Grubbström (Grubba) | | test_any_equal([[
// Test hiding of inherited symbols with protected.
class A {
local mixed a() {}
mixed b();
mixed c;
local mixed d;
extern mixed e;
local mixed f;
|
9ead32 | 2009-08-18 | Henrik Grubbström (Grubba) | | local mixed g() {}
mixed h();
|
1cc068 | 2008-09-14 | Henrik Grubbström (Grubba) | | this_program get_a() { return this_program::this; }
};
class B {
inherit A;
protected mixed a() {}
protected mixed b() {}
protected mixed c = a();
protected mixed d = b();
protected mixed e = a();
protected local mixed f = b();
|
9ead32 | 2009-08-18 | Henrik Grubbström (Grubba) | | protected mixed g();
protected mixed h();
|
1cc068 | 2008-09-14 | Henrik Grubbström (Grubba) | | this_program get_b() { return this_program::this; }
};
class C {
inherit B;
this_program get_c() { return this_program::this; }
};
class D {
inherit C;
this_program get_d() { return this_program::this; }
};
object(D) d = D();
return ({ "A", sort(indices(d->get_a())),
"B", sort(indices(d->get_b())),
"C", sort(indices(d->get_c())),
"D", sort(indices(d->get_d())) });
|
10e23f | 2009-08-18 | Henrik Grubbström (Grubba) | | ]], ({ "A", ({ "a", "b", "c", "d", "e", "f", "g", "get_a", "h" }),
|
1cc068 | 2008-09-14 | Henrik Grubbström (Grubba) | | "B", ({ "get_a", "get_b" }),
"C", ({ "get_a", "get_b", "get_c" }),
"D", ({ "get_a", "get_b", "get_c", "get_d" }) }))
test_any_equal([[
// Test hiding of inherited symbols with private.
class A {
local mixed a() {}
mixed b();
mixed c;
local mixed d;
extern mixed e;
local mixed f;
this_program get_a() { return this_program::this; }
};
class B {
inherit A;
private mixed a() {}
private mixed b() {}
private mixed c = a();
private mixed d = b();
private mixed e = a();
private local mixed f = b();
this_program get_b() { return this_program::this; }
};
class C {
inherit B;
this_program get_c() { return this_program::this; }
};
class D {
inherit C;
|
8e06a3 | 2014-09-30 | Martin Nilsson | | this_program get_d() { return this::this; }
|
1cc068 | 2008-09-14 | Henrik Grubbström (Grubba) | | };
object(D) d = D();
return ({ "A", sort(indices(d->get_a())),
"B", sort(indices(d->get_b())),
"C", sort(indices(d->get_c())),
"D", sort(indices(d->get_d())) });
]], ({ "A", ({ "a", "b", "c", "d", "e", "f", "get_a" }),
"B", ({ "get_a", "get_b" }),
"C", ({ "get_a", "get_b", "get_c" }),
"D", ({ "get_a", "get_b", "get_c", "get_d" }) }))
|
c92b8e | 2016-05-06 | Henrik Grubbström (Grubba) | | test_any([[
class O {
string foo() { return "O"; };
class A { string foo() { return "A"; } };
class B { string foo() { return "B"; } };
class C {
inherit A;
inherit B;
string foo() {
return "C" + ::this_function() * ":" +
"C" + A::this_function() +
"C" + B::this_function() +
"C" + O::this_function() + "C"; }
};
};
return O()->C()->foo();
]], "CA:BCACBCOC")
|
d1e8d1 | 2009-06-24 | Henrik Grubbström (Grubba) | | test_any([[
// Test that backtraces with prototypes are rendered correctly by
// describe_backtrace() et al. These backtraces have caused both
// "Bad offset" and "Identifier reference index out of range".
|
76ed45 | 2009-06-24 | Henrik Grubbström (Grubba) | | class A { void foo(); };
class B { int gazonk; inherit A; void bar() { foo(); } };
|
d1e8d1 | 2009-06-24 | Henrik Grubbström (Grubba) | | return sizeof(describe_backtrace(catch { B()->bar(); })) > 0;
]], 1)
|
42d5b3 | 2012-01-09 | Henrik Grubbström (Grubba) | | test_any([[
// Test that backtraces with event handlers are rendered correctly.
// These backtraces have caused SEGV's due to function pointers
// out of bounds. cf [bug 6156].
return sizeof(describe_backtrace(catch {
|
f5005c | 2012-02-17 | Henrik Grubbström (Grubba) | | Builtin.__Backtrace_Tester__();
|
42d5b3 | 2012-01-09 | Henrik Grubbström (Grubba) | | })) > 0;
]], 1)
test_any([[
// Test that backtraces with event handlers are rendered correctly.
// These backtraces have caused SEGV's due to function pointers
// out of bounds. cf [bug 6156].
|
f5005c | 2012-02-17 | Henrik Grubbström (Grubba) | | return catch { Builtin.__Backtrace_Tester__(); }[1][-1][2];
]], Builtin.__Backtrace_Tester__)
|
42d5b3 | 2012-01-09 | Henrik Grubbström (Grubba) | |
|
075e83 | 2018-11-21 | Henrik Grubbström (Grubba) | | test_any_equal([[
// Test that filename and line numbers in backtraces are correct.
// This specific test used to trigger two different bugs.
// cf [LysLysKOM 22997909].
int whee(string w)
{
|
128d10 | 2019-01-16 | Henrik Grubbström (Grubba) | | #line 8 "whee-before"
|
075e83 | 2018-11-21 | Henrik Grubbström (Grubba) | | int x = 0;
error("whee!\n");
|
128d10 | 2019-01-16 | Henrik Grubbström (Grubba) | | #line 11 "whee-after"
|
075e83 | 2018-11-21 | Henrik Grubbström (Grubba) | | string q = "wq";
q += "21";
return sizeof(q + w);
|
128d10 | 2019-01-16 | Henrik Grubbström (Grubba) | | };
#line 16 "test"
|
075e83 | 2018-11-21 | Henrik Grubbström (Grubba) | | mixed err = catch { whee("foo"); };
return ({ err[1][-1][0], err[1][-1][1] });
|
6377d2 | 2019-01-16 | Henrik Grubbström (Grubba) | | ]], ({ "whee-before", 9 }))
|
075e83 | 2018-11-21 | Henrik Grubbström (Grubba) | |
|
218176 | 2014-08-15 | Martin Nilsson | | test_compile_warning([[
class A { static int foo = 1; int bar() { return foo; } }
]])
|
64b1dd | 2009-06-21 | Henrik Grubbström (Grubba) | | test_any([[
// Test multiple inherit of same symbol,
// where later symbol is protected.
class A { constant foo = 1; };
class B { constant foo = 2; };
class C { inherit A; protected inherit B; };
return C()->foo;
]], 1)
test_any([[
// Test multiple inherit of same symbol,
// where later symbol is protected.
class A { constant foo = 1; };
class B { protected constant foo = 2; };
class C { inherit A; inherit B; };
return C()->foo;
]], 1)
|
f99b1e | 2008-09-15 | Henrik Grubbström (Grubba) | | test_any_equal([[
// Test that extern works as intended.
class A { extern mixed foo; };
class B { inherit A; mixed foo; object get_a() { return A::this; } };
object(B) b = B();
b->foo = 17;
array res = ({ b->foo, b->get_a()->foo });
b->get_a()->foo = 10;
return res + ({ b->foo, b->get_a()->foo });
]], ({ 17, 17, 10, 10 }))
test_eval_error([[
// Test that extern works as intended.
class A { extern mixed foo; };
class B { inherit A; mixed bar; };
object(B) b = B();
b->bar = 17;
b->foo = 10;
return b->foo;
]])
|
f73a7b | 2000-02-09 | Fredrik Hübinette (Hubbe) | | test_compile_error([[
class A { constant q = "x"; }
class B { inherit A; string z="z"; constant q="x"+z; }
]])
|
bff94f | 2000-09-10 | Mirar (Pontus Hagland) | | test_compile_any([[
class A
{
object x(int y)
{
return B(y);
}
}
|
13670c | 2015-05-25 | Martin Nilsson | |
|
bff94f | 2000-09-10 | Mirar (Pontus Hagland) | | class B
{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create(int y)
|
bff94f | 2000-09-10 | Mirar (Pontus Hagland) | | {
}
}
]])
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | |
|
e26ca3 | 2015-05-15 | Henrik Grubbström (Grubba) | | // Test that prototypes are equal() to zero.
test_any_equal([[
|
eb4677 | 2003-02-24 | Martin Stjernholm | | class Foo {int foo();};
|
e26ca3 | 2015-05-15 | Henrik Grubbström (Grubba) | | return Foo()->foo;
]], 0)
|
eb4677 | 2003-02-24 | Martin Stjernholm | | test_any_equal([[
class Foo {int foo();};
return indices(Foo());
]], ({"foo"}))
test_any_equal([[
class Foo {int foo();};
return values(Foo());
]], ({0}))
|
e26ca3 | 2015-05-15 | Henrik Grubbström (Grubba) | | test_any_equal([[
|
0d6adc | 2001-07-04 | Henrik Grubbström (Grubba) | | class Foo
{
int foo();
|
e26ca3 | 2015-05-15 | Henrik Grubbström (Grubba) | | function f()
|
0d6adc | 2001-07-04 | Henrik Grubbström (Grubba) | | {
|
e26ca3 | 2015-05-15 | Henrik Grubbström (Grubba) | | return foo;
|
0d6adc | 2001-07-04 | Henrik Grubbström (Grubba) | | }
|
a27a68 | 2001-07-04 | Henrik Grubbström (Grubba) | | };
|
0d6adc | 2001-07-04 | Henrik Grubbström (Grubba) | | return Foo()->f();
|
e26ca3 | 2015-05-15 | Henrik Grubbström (Grubba) | | ]], 0)
|
0d6adc | 2001-07-04 | Henrik Grubbström (Grubba) | | test_any([[
class Foo
{
int foo();
|
eb4677 | 2003-02-24 | Martin Stjernholm | | int(0..1) f()
{
return functionp(foo);
}
};
class Bar
{
inherit Foo;
int foo() {}
|
a27a68 | 2001-07-04 | Henrik Grubbström (Grubba) | | };
|
eb4677 | 2003-02-24 | Martin Stjernholm | | return Bar()->f();
|
0d6adc | 2001-07-04 | Henrik Grubbström (Grubba) | | ]], 1)
|
3c8e37 | 2017-10-07 | Henrik Grubbström (Grubba) | | dnl equal() on functions.
test_any([[
class A { int a(){} }
return equal(A()->a, A()->a);
]], 1)
test_any([[
class A { int a(){} }
class B { inherit A; }
return equal(A()->a, B()->a);
]], 1)
test_any([[
class A { int a(){} }
class B { inherit A; int a(){} }
|
571bd0 | 2017-10-08 | Martin Nilsson | | return equal(A()->a, B()->a);
|
3c8e37 | 2017-10-07 | Henrik Grubbström (Grubba) | | ]], 0)
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | | test_do([[
class Foo
{
inherit Stdio.File;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() { }
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | | };
class Bar
{
int y;
class Gazonk
{
inherit Foo;
|
13670c | 2015-05-25 | Martin Nilsson | |
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | |
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create(Stdio.File f)
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | | {
assign(f);
}
}
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create()
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | | {
Gazonk(Stdio.stdin);
}
};
Bar();
]])
|
813164 | 2001-01-17 | Martin Stjernholm | | test_any([[
object f = class {
array recursive(mixed func, array data, mixed ... args)
{
array ret=({});
foreach(data, mixed foo)
{
if(arrayp(foo))
{
ret+=({ recursive(func, foo, @args) });
}else{
ret+=({ foo });
}
}
|
13670c | 2015-05-25 | Martin Nilsson | |
|
813164 | 2001-01-17 | Martin Stjernholm | | return func(ret, @args);
};
}();
mixed x = ({ "A", ({}) });
x = f->recursive(replace, x, "B", ({}));
for(int i = 0; i < sizeof(x); i++) {
if (!stringp(x[i]) && !arrayp(x[i])) return 0;
}
return 1;
]], 1);
|
c22d27 | 2002-04-09 | Henrik Grubbström (Grubba) | | test_compile_error( [[
// This triggs a compiler bug on old Pike 7.3.
non_existant(17) {
return 0;
}
]])
|
deb36c | 2008-11-21 | Henrik Grubbström (Grubba) | | test_compile_error( [[
// This triggs a segfault on Pike 7.4.
void f()
{
|
13670c | 2015-05-25 | Martin Nilsson | | constant days =
|
deb36c | 2008-11-21 | Henrik Grubbström (Grubba) | | ([ "1" : "Sunday"
"2" : "Monday" ]);
}
]])
|
3c995d | 2004-03-18 | Henrik Grubbström (Grubba) | | test_compile_error( [[
// This triggs a compiler bug on old Pike 7.5.
return lambda(object (([mixed]a)->syntax_error) { return 0; }(0);
]])
|
a884df | 2007-05-04 | Henrik Grubbström (Grubba) | | test_compile_error( [[
// [bug 4362] This triggs a segfault on some versions of Pike 7.7.
mixed x = all_constants()[undefined_identifier];
]])
|
8a1fe1 | 2008-05-08 | Henrik Grubbström (Grubba) | | test_compile_warning([[
#pragma strict_types
// NB: This case used to leak the type function(:string).
|
c61660 | 2008-05-08 | Henrik Grubbström (Grubba) | | string x (string s) {return s;};
void y (string|int s) {x (s);};
|
8a1fe1 | 2008-05-08 | Henrik Grubbström (Grubba) | | ]])
|
f93895 | 2008-08-07 | Martin Stjernholm | | test_compile_any([[
#pragma strict_types
array(string) x = ({"A", "B"});
mixed a() {return map (x, lower_case);}
]])
|
bbc79f | 2009-11-10 | Martin Stjernholm | | test_compile_any([[
class X {
X bar();
}
class Y {
constant X = global::X;
X foo();
}
]])
|
ef0a50 | 2001-09-23 | Mirar (Pontus Hagland) | | test_any( [[
// bug [1996] ------------------------------------------------------------
// http://community/crunch/show_bug.cgi?id=1996
class Implementation
{
int foo() { return 1; }
};
class Prototype
{
int foo();
int bar() { return foo(); }
};
class Test
{
inherit Implementation;
inherit Prototype;
int test() { return bar(); }
};
|
13670c | 2015-05-25 | Martin Nilsson | | return Test()->test();
|
ef0a50 | 2001-09-23 | Mirar (Pontus Hagland) | | ]], 1 );
test_any( [[
// bug [721] -------------------------------------------------------------
// http://community/crunch/show_bug.cgi?id=721
int res=0;
catch
{
add_constant("test_a",compile_string("int foo();","test_a"));
add_constant("test_b",compile_string("int foo();","test_b"));
add_constant("test_c",compile_string(
"inherit test_a;\n"
"inherit test_b;\n"
"final int foo() { return 1; }\n","test_c"));
res=compile_string("inherit test_c;\n","test_d")()->foo();
};
return res;
]],1);
|
9040cc | 2002-10-14 | Martin Nilsson | | test_do(add_constant("test_a"))
test_do(add_constant("test_b"))
test_do(add_constant("test_c"))
|
ef0a50 | 2001-09-23 | Mirar (Pontus Hagland) | |
|
8d813e | 2001-09-23 | Mirar (Pontus Hagland) | | test_any( [[
// bug [1858] ------------------------------------------------------------
// http://community/crunch/show_bug.cgi?id=1858
string s=#"
|
f960bd | 2015-07-31 | Martin Nilsson | | constant foo=({this});
|
8d813e | 2001-09-23 | Mirar (Pontus Hagland) | | int|string test()
{
if (!foo[0]) return sprintf(\"foo is %O\\n\",foo)-\"\\n\";
|
f960bd | 2015-07-31 | Martin Nilsson | | if (foo[0]==this) return 1;
|
8d813e | 2001-09-23 | Mirar (Pontus Hagland) | | return sprintf(\"foo is %O\\n\",foo)-\"\\n\";
}
";
class handler { void compile_error(string file, int line, string err) { }};
catch {
program p=compile_string(s,"test",handler());
return p()->test();
};
return 1; // compile error is ok
]],1);
|
ef0a50 | 2001-09-23 | Mirar (Pontus Hagland) | | // -----------------------------------------------------------------------
|
ec6f97 | 2001-01-19 | Martin Stjernholm | | // This test checks for excessive recursion in
// destruct_objects_to_destruct, and also that it keeps the destruct
// order sane.
test_do([[
class Top
{
int count = 0;
class Foo
{
int c;
object foo;
|
35f51c | 2008-06-28 | Martin Nilsson | | protected void create(object o)
|
ec6f97 | 2001-01-19 | Martin Stjernholm | | {
foo = o;
c = count++;
}
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct()
|
ec6f97 | 2001-01-19 | Martin Stjernholm | | {
count--;
if (count != c)
error ("Destruct out of sequence, "
"%d destructed when %d should be.\n", c, count);
object x = foo && Foo(0);
x = 0;
// Cause call to destruct_objects_to_destruct.
|
552072 | 2007-06-18 | Martin Stjernholm | | for (int j = 0; j < 10; j++) write ("");
|
ec6f97 | 2001-01-19 | Martin Stjernholm | | }
}
|
64621b | 2004-07-16 | Henrik Grubbström (Grubba) | | mixed eat_stack(int|void probe)
|
ec6f97 | 2001-01-19 | Martin Stjernholm | | {
|
64621b | 2004-07-16 | Henrik Grubbström (Grubba) | | // Avoid eating as much C-stack by releasing the
// catch at every level.
if (probe) return 1;
if (catch(eat_stack(1))) return 1;
|
ec6f97 | 2001-01-19 | Martin Stjernholm | | mixed err = 1;
|
64621b | 2004-07-16 | Henrik Grubbström (Grubba) | | if ((err = eat_stack()) != 10)
return intp(err) && err > 0 ? err + 1 : err;
|
ec6f97 | 2001-01-19 | Martin Stjernholm | | if (err = catch {
Foo foo;
for(int i=0; i < 10000; i++)
foo = Foo(foo);
foo = 0;
// Cause call to destruct_objects_to_destruct.
|
552072 | 2007-06-18 | Martin Stjernholm | | for (int j = 0; j < 10; j++) write ("");
|
ec6f97 | 2001-01-19 | Martin Stjernholm | |
}) return err;
}
|
35f51c | 2008-06-28 | Martin Nilsson | | protected void create()
|
ec6f97 | 2001-01-19 | Martin Stjernholm | | {
if (mixed err = eat_stack()) {
catch (err[1] = err[1][sizeof (err[1]) - 50..]);
throw (err);
}
}
};
Top();
]]);
|
a3d4d4 | 2003-04-08 | Martin Stjernholm | | // Testing stack popping wrt the various function call opcodes
|
692ebe | 2001-02-08 | Martin Stjernholm | | test_program([[
inherit Thread.Mutex : monitor;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
}
int a()
{
object key = monitor::lock();
return f (1); // F_CALL_LFUN_AND_RETURN
};
]]);
test_program([[
inherit Thread.Mutex : monitor;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
mixed g = f;
int a()
{
object key = monitor::lock();
return g (1); // F_CALL_FUNCTION_AND_RETURN
}
]]);
test_program([[
Thread.Mutex monitor = Thread.Mutex();
int f (int x)
{
if(monitor->trylock(1))
return 0;
return x;
}
int a()
{
add_constant ("f", f);
add_constant ("monitor", monitor);
return compile_string(#"
int g()
{
object key = monitor->lock();
return f (1); // F_APPLY_AND_RETURN
}")()->g();
}
]]);
|
9b036b | 2003-04-08 | Martin Stjernholm | | test_program([[
inherit Thread.Mutex : monitor;
int dummy;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
int a()
{
object key = monitor::lock();
int res = this->f (1); // F_CALL_OTHER (no `->)
dummy = random (res);
return res;
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int dummy;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
int a()
{
object key = monitor::lock();
int res = this->f (1); // F_CALL_OTHER (with `->)
dummy = random (res);
return res;
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int res = 0;
void f (int x)
{
if(monitor::trylock(1))
res = 0;
else
res = x;
};
int a()
{
object key = monitor::lock();
this->f (1); // F_CALL_OTHER_AND_POP (no `->)
return res;
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int res = 0;
void f (int x)
{
if(monitor::trylock(1))
res = 0;
else
res = x;
};
int a()
{
object key = monitor::lock();
this->f (1); // F_CALL_OTHER_AND_POP (with `->)
return res;
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
int a()
{
object key = monitor::lock();
return this->f (1); // F_CALL_OTHER_AND_RETURN (no `->)
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
int a()
{
object key = monitor::lock();
return this->f (1); // F_CALL_OTHER_AND_RETURN (with `->)
}
]]);
|
692ebe | 2001-02-08 | Martin Stjernholm | | test_program([[
inherit Thread.Mutex : monitor;
int iter = 0;
int a (void|int x)
{
if (iter == 1) {
if (monitor::trylock(1))
return 0;
return x;
}
else {
object key = monitor::lock();
iter = 1;
return a (1); // F_COND_RECUR
}
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
if (monitor::trylock(1))
return 0;
return x;
}
else {
object key = monitor::lock();
iter = 2;
return a (1); // F_TAIL_RECUR
}
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
if (monitor::trylock(1))
return 0;
return x;
}
else {
object key = monitor::lock();
iter = 2;
int res = a (1); // F_RECUR
iter = -1;
return res;
}
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
if (monitor::trylock(1))
iter = 0;
iter = x;
}
else {
object key = monitor::lock();
iter = 2;
a (1); // F_RECUR_AND_POP
return iter;
}
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
}
int a()
{
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m)
return f (m); // F_CALL_LFUN_AND_RETURN
|
692ebe | 2001-02-08 | Martin Stjernholm | | };
]]);
test_program([[
inherit Thread.Mutex : monitor;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
mixed g = f;
int a()
{
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m)
return g (m); // F_CALL_FUNCTION_AND_RETURN
|
692ebe | 2001-02-08 | Martin Stjernholm | | }
]]);
test_program([[
Thread.Mutex monitor = Thread.Mutex();
int f (int x)
{
if(monitor->trylock(1))
return 0;
return x;
}
int a()
{
add_constant ("f", f);
add_constant ("monitor", monitor);
return compile_string(#"
int g()
{
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor->lock()}), mixed m)
return f (m); // F_APPLY_AND_RETURN
|
692ebe | 2001-02-08 | Martin Stjernholm | | }")()->g();
}
]]);
|
9b036b | 2003-04-08 | Martin Stjernholm | | test_program([[
inherit Thread.Mutex : monitor;
int dummy;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
int a()
{
int res;
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m) {
res = this->f (m); // F_CALL_OTHER (no `->)
|
9b036b | 2003-04-08 | Martin Stjernholm | | dummy = random (res);
return res;
}
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int dummy;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
int a()
{
int res;
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m) {
res = this->f (m); // F_CALL_OTHER (with `->)
|
9b036b | 2003-04-08 | Martin Stjernholm | | dummy = random (res);
return res;
}
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int res = 0;
void f (int x)
{
if(monitor::trylock(1))
res = 0;
else
res = x;
};
int a()
{
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m) {
this->f (m); // F_CALL_OTHER_AND_POP (no `->)
|
9b036b | 2003-04-08 | Martin Stjernholm | | return res;
}
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int res = 0;
void f (int x)
{
if(monitor::trylock(1))
res = 0;
else
res = x;
};
int a()
{
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m) {
this->f (m); // F_CALL_OTHER_AND_POP (with `->)
|
9b036b | 2003-04-08 | Martin Stjernholm | | return res;
}
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
int a()
{
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m)
return this->f (m); // F_CALL_OTHER_AND_RETURN (no `->)
|
9b036b | 2003-04-08 | Martin Stjernholm | | }
]]);
test_program([[
inherit Thread.Mutex : monitor;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int f (int x)
{
if(monitor::trylock(1))
return 0;
return x;
};
int a()
{
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m)
return this->f (m); // F_CALL_OTHER_AND_RETURN (with `->)
|
9b036b | 2003-04-08 | Martin Stjernholm | | }
]]);
|
692ebe | 2001-02-08 | Martin Stjernholm | | test_program([[
inherit Thread.Mutex : monitor;
int iter = 0;
int a (void|int x)
{
if (iter == 1) {
if (monitor::trylock(1))
return 0;
return x;
}
else {
iter = 1;
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m)
return a (m); // F_COND_RECUR
|
692ebe | 2001-02-08 | Martin Stjernholm | | }
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
if (monitor::trylock(1))
return 0;
return x;
}
else {
iter = 2;
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m)
return a (m); // F_TAIL_RECUR
|
692ebe | 2001-02-08 | Martin Stjernholm | | }
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
if (monitor::trylock(1))
return 0;
return x;
}
else {
iter = 2;
int res;
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m) {
res = a (m); // F_RECUR
|
8e27a3 | 2001-02-10 | Martin Stjernholm | | iter = random (res);
return res;
}
|
692ebe | 2001-02-08 | Martin Stjernholm | | }
}
]]);
test_program([[
inherit Thread.Mutex : monitor;
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
if (monitor::trylock(1))
iter = 0;
iter = x;
}
else {
iter = 2;
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | foreach (({1, monitor::lock()}), mixed m) {
a (m); // F_RECUR_AND_POP
|
8e27a3 | 2001-02-10 | Martin Stjernholm | | return iter;
}
|
692ebe | 2001-02-08 | Martin Stjernholm | | }
}
]]);
|
9040cc | 2002-10-14 | Martin Nilsson | | test_do(add_constant("f"))
test_do(add_constant("monitor"))
|
692ebe | 2001-02-08 | Martin Stjernholm | |
|
a3d4d4 | 2003-04-08 | Martin Stjernholm | | // Testing scoped frames wrt the various function call opcodes
test_program([[
int f (int x)
{
return x;
}
int a (void|int x)
{
function s = lambda () {return x;};
return f (1); // F_CALL_LFUN_AND_RETURN
};
]]);
test_program([[
int f (int x)
{
return x;
};
mixed g = f;
int a (void|int x)
{
function s = lambda () {return x;};
return g (1); // F_CALL_FUNCTION_AND_RETURN
}
]]);
test_program([[
int f (int x)
{
return x;
}
int a()
{
add_constant ("f", f);
return compile_string(#"
int g (void|int x)
{
function s = lambda () {return x;};
return f (1); // F_APPLY_AND_RETURN
}")()->g();
}
]]);
|
9b036b | 2003-04-08 | Martin Stjernholm | | test_program([[
int dummy;
int f (int x)
{
return x;
};
int a (void|int x)
{
function s = lambda () {return x;};
int res = this->f (1); // F_CALL_OTHER (no `->)
dummy = random (res);
return res;
}
]]);
test_program([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int dummy;
int f (int x)
{
return x;
};
int a (void|int x)
{
function s = lambda () {return x;};
int res = this->f (1); // F_CALL_OTHER (with `->)
dummy = random (res);
return res;
}
]]);
test_program([[
int res = 0;
void f (int x)
{
res = x;
};
int a (void|int x)
{
function s = lambda () {return x;};
this->f (1); // F_CALL_OTHER_AND_POP (no `->)
return res;
}
]]);
test_program([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int res = 0;
void f (int x)
{
res = x;
};
int a (void|int x)
{
function s = lambda () {return x;};
this->f (1); // F_CALL_OTHER_AND_POP (with `->)
return res;
}
]]);
test_program([[
int f (int x)
{
return x;
};
int a (void|int x)
{
function s = lambda () {return x;};
return this->f (1); // F_CALL_OTHER_AND_RETURN (no `->)
}
]]);
test_program([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string what) {return this[what];}
|
9b036b | 2003-04-08 | Martin Stjernholm | | int f (int x)
{
return x;
};
int a (void|int x)
{
function s = lambda () {return x;};
return this->f (1); // F_CALL_OTHER_AND_RETURN (with `->)
}
]]);
|
a3d4d4 | 2003-04-08 | Martin Stjernholm | | test_program([[
int iter = 0;
int a (void|int x)
{
if (iter == 1) {
return x;
}
else {
function s = lambda () {return x;};
iter = 1;
return a (1); // F_COND_RECUR
}
}
]]);
test_program([[
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
return x;
}
else {
function s = lambda () {return x;};
iter = 2;
return a (1); // F_TAIL_RECUR
}
}
]]);
test_program([[
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
return x;
}
else {
function s = lambda () {return x;};
iter = 2;
int res = a (1); // F_RECUR
iter = -1;
return res;
}
}
]]);
test_program([[
int iter = 0;
int a (void|int x)
{
if (!iter) {
iter = 1;
return a (x);
}
else if (iter == 2) {
iter = x;
}
else {
function s = lambda () {return x;};
iter = 2;
a (1); // F_RECUR_AND_POP
return iter;
}
}
]]);
test_do(add_constant("f"))
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | test_false([[object_variablep(class { int y; int z() { return 1; }}(),"foo")]])
test_false([[object_variablep(class { int y; int z() { return 1; }}(),"z")]])
test_true([[object_variablep(class { int y; int z() { return 1; }}(),"y")]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | |
test_any([[ int a,b; [a,b]=({1,2}); return a]],1)
test_any([[ int a,b; [a,b]=({1,2}); return b]],2)
test_any([[ int a,b; [ [a],b]=({ ({ 1 }) ,2}); return a]],1)
test_any([[ int a,b; [ [a],b]=({ ({ 1 }) ,2}); return b]],2)
|
f869d4 | 2008-01-29 | Henrik Grubbström (Grubba) | | test_any([[ int a; catch { [a]=({1,2}); return 0; }; return 1]],1)
test_compile_error([[ int a,b; catch { [a,b]=({1}); return 0; }; return 1]],1)
|
f840e7 | 2008-01-29 | Henrik Grubbström (Grubba) | | test_any([[ int a,b; catch { [a,b]=lambda(){ return ({1}); }(); return 0; }; return 1]],1)
|
aa73fc | 1999-10-21 | Fredrik Hübinette (Hubbe) | | test_any([[ mapping m=([]); m[m]=m; return stringp(sprintf("%O",m)); ]],1)
|
13670c | 2015-05-25 | Martin Nilsson | | dnl test_any([[
|
4b9f0d | 2001-10-02 | Fredrik Hübinette (Hubbe) | | dnl // don't know if this /should/ be valid /Mirar
dnl // remove if it shouldn't
dnl
dnl // I see no reason this should be allowed - Hubbe
dnl
dnl array a=({});
dnl []=a; return 1; ]],1)
|
aa73fc | 1999-10-21 | Fredrik Hübinette (Hubbe) | |
|
395899 | 2001-06-23 | Fredrik Hübinette (Hubbe) | | test_any([[
int q() { throw(1); };
catch {
return q();
};
return 17;
]],17)
test_any([[
return class
{
int q() { throw(1); };
int p() {
catch {
return q();
};
return 17;
}
}()->p();
]],17)
|
0893ca | 1999-12-09 | Henrik Grubbström (Grubba) | | test_compile_error([[
|
35f51c | 2008-06-28 | Martin Nilsson | | protected function foo(string ...:object);
|
0893ca | 1999-12-09 | Henrik Grubbström (Grubba) | | int bar()
{
return 17;
}
]])
|
13670c | 2015-05-25 | Martin Nilsson | | test_compile_error([[
|
55356e | 1999-05-26 | Fredrik Hübinette (Hubbe) | | array a;
a = path_info[..(sizeof(path_info)-2]*"/";
]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_compile_error([[ default ; ]])
|
5dd218 | 1999-01-29 | Fredrik Hübinette (Hubbe) | | test_compile_error([[ 0999; ]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_compile_error([[ int a,b; [a,b]++; ]])
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | test_compile_error([[
array(int) x;
string foo()
{
return "foo "+(array(string) x) * ",";
}
int main()
{
return 0;
}
]])
|
da26fe | 2000-03-09 | Henrik Grubbström (Grubba) | | dnl
dnl this_program
dnl
|
b58421 | 2002-05-11 | Martin Stjernholm | |
|
da26fe | 2000-03-09 | Henrik Grubbström (Grubba) | | test_true(this_program)
test_any([[int this_program; return this_program;]], 0)
|
3895da | 2000-03-09 | Henrik Grubbström (Grubba) | | test_any([[class A { int a() { return this_program == A; }}; return A()->a();]], 1)
|
50e388 | 2002-04-13 | Martin Stjernholm | | test_program([[
class A (int v)
{
this_program clone() {return this_program (v);}
}
int a() {return A (4)->clone()->v == 4;}
]])
test_program([[
int i = 17, j = 18;
class A (int v)
{
this_program clone() {return this_program (i);}
}
int a() {return A (4)->clone()->v == 17;}
]])
test_program([[
class A (int v)
{
this_program clone() {return this_program (j);}
}
int i = 17, j = 18;
int a() {return A (4)->clone()->v == 18;}
]])
test_program([[
int i = 17, v;
this_program clone() {return this_program (i);}
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create (int v_) {v = v_;}
|
50e388 | 2002-04-13 | Martin Stjernholm | | int a() {return clone()->v == 17;}
]])
test_program([[
this_program clone() {return this_program (i);}
int i = 17, v;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create (int v_) {v = v_;}
|
50e388 | 2002-04-13 | Martin Stjernholm | | int a() {return clone()->v == 17;}
]])
test_program([[
class A {this_program clone() {return this_program();}}
class B {inherit A;}
|
daa74f | 2002-11-07 | Marcus Comstedt | | int a() {return object_program (B()->clone()) == B;}
|
50e388 | 2002-04-13 | Martin Stjernholm | | ]])
|
d1c9bc | 2002-11-07 | Marcus Comstedt | | test_program([[
class A {this_program clone() {return this_program();}}
class B {inherit A;}
int a() {return typeof(B()->clone()) <= B;}
]])
|
da26fe | 2000-03-09 | Henrik Grubbström (Grubba) | |
|
b58421 | 2002-05-11 | Martin Stjernholm | | test_program([[
class A {
class B {
mixed f() {
return ({global::this_program,
A::this_program, // Works, but not really useful.
B::this_program, // Ditto.
this_program});
}
}
}
int a() {
|
f960bd | 2015-07-31 | Martin Nilsson | | return equal (A()->B()->f(), ({object_program (this), A, A.B, A.B}));
|
c0afd0 | 2002-11-28 | Henrik Grubbström (Grubba) | | }
]])
test_compile_error([[
mixed x() {
return ::x;
|
b58421 | 2002-05-11 | Martin Stjernholm | | }
]])
test_program([[
class A {
class B {
constant this_program = "foo";
mixed f (int this_program) {
return ({A::this_program, B::this_program, this_program});
}
}
}
int a() {
return equal (A()->B()->f (1), ({A, "foo", 1}));
}
]])
test_program([[
class I {
string this_program = "foo";
}
class A {
class B {
inherit I;
mixed f (int this_program) {
return ({A::this_program, B::this_program, this_program});
}
}
}
int a() {
return equal (A()->B()->f (1), ({A, "foo", 1}));
}
]])
test_program([[
string this_program = "foo";
class A {
class B {
mixed f() {
return ({A::this_program, B::this_program, this_program});
}
}
}
int a() {
return equal (A()->B()->f(), ({A, A.B, "foo"}));
}
]])
test_compile_error_any([[
class A {}
class B {
|
785490 | 2004-12-19 | Henrik Grubbström (Grubba) | | inherit A:C;
|
b58421 | 2002-05-11 | Martin Stjernholm | | mixed f() {return A::this_program;}
}
]])
|
785490 | 2004-12-19 | Henrik Grubbström (Grubba) | | test_any([[
class A {};
class B {
inherit A:C;
mixed f() {return C::this_program;}
};
return B()->f() == A;
]], 1)
|
0f9107 | 2013-04-27 | Henrik Grubbström (Grubba) | | test_any([[
class A {
class Nested {
constant nested = 1;
}
};
class B {
inherit A;
class Nested {
inherit ::this_program;
constant other = 2;
}
};
object n = B()->Nested();
return n->nested + n->other;
]], 3)
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | dnl test_compile_error(0())
test_compile_error(1())
test_compile_error(""())
test_compile_error(([])())
test_compile_error(([])())
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_any([[ class X { int y; class Z { protected void _destruct() { y++; } } }; X x=X(); destruct(x->Z()); return x->y;]],1)
|
2c1709 | 1999-06-22 | Fredrik Hübinette (Hubbe) | |
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_eval_error([[ class Z { protected int _destruct() { return 1/y; } }(); ]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | |
|
c3c33e | 2017-11-05 | Henrik Grubbström (Grubba) | | test_any([[ class X { int y; class Z { protected void _destruct() { y++; } } }; X x=X(); destruct(x->Z()); return x->y;]],1)
|
35f51c | 2008-06-28 | Martin Nilsson | | test_any([[ class X { int y; class Z { protected void create() { y++; } } }; X x=X(); destruct(x->Z()); return x->y;]],1)
|
2c1709 | 1999-06-22 | Fredrik Hübinette (Hubbe) | |
|
323682 | 2015-11-15 | Martin Nilsson | | ifefun(_debug,
|
a4b812 | 1998-04-28 | Fredrik Hübinette (Hubbe) | | [[
test_do(_debug(_debug(0)))
]])
|
e70e2f | 2003-07-30 | Martin Stjernholm | | test_do(indices(_static_modules))
|
694bb1 | 1998-04-23 | Fredrik Hübinette (Hubbe) | | test_compile_any([[import Stdio; class x { string y() { read_file("foo"); } }]])
|
b82cc9 | 1999-10-04 | Fredrik Hübinette (Hubbe) | |
|
f57ba3 | 2001-10-05 | Mirar (Pontus Hagland) | | dnl ----------------------------------------------------------------
dnl backtrace/linenumber tests
dnl ----------------------------------------------------------------
test_any([[
program p=compile_string(
"int foo()\n"
"{\n"
" error(\"test error\\n\"); // line 3\n"
" return 17;\n"
"}","test");
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | mixed err=catch { p()->foo(); };
if (err[1][-1][1]!=3)
{
werror("backtrace is:\n"+master()->describe_backtrace(err));
}
return err[1][-1][1];
]],3);
|
93c16b | 2002-01-04 | Henrik Grubbström (Grubba) | |
// Bug 2660
test_any([[
int foo(mixed a, mixed ... b) {
return sizeof(backtrace()[-1]) - (3 + 1 + sizeof(b));
};
return foo(1,2,3,4)|foo(1);
]], 0)
|
13670c | 2015-05-25 | Martin Nilsson | |
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | define(test_backtrace_line_charset, [[
test_any([[
program p=compile_string(
|
0b8d2f | 2013-06-17 | Martin Nilsson | | Charset.encoder("]]$1[[")->feed(
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | "#charset ]]$1[[\n"
"int foo()\n"
"{\n"
" error(\"test error\\n\"); // line 3\n"
" return 17;\n"
"}")->drain(),"test");
|
f57ba3 | 2001-10-05 | Mirar (Pontus Hagland) | | mixed err=catch { p()->foo(); };
if (err[1][0][1]!=3)
{
werror("backtrace is:\n"+master()->describe_backtrace(err));
}
return err[1][0][1];
]],3);
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | ]])
dnl test_backtrace_line_charset(utf-7)
|
f57ba3 | 2001-10-05 | Mirar (Pontus Hagland) | |
|
ec3c9d | 2002-04-28 | Martin Stjernholm | | test_program([[
class X
{
|
35f51c | 2008-06-28 | Martin Nilsson | | protected void create (int i)
|
ec3c9d | 2002-04-28 | Martin Stjernholm | | {
if (i)
error ("foo\n"); // Line 7
}
}
int f()
{
X (0);
X (1); // Line 14
}
int a()
{
array bt = catch (f())[1];
int ok = 0;
|
13670c | 2015-05-25 | Martin Nilsson | | foreach (reverse (bt), object ent)
|
ec3c9d | 2002-04-28 | Martin Stjernholm | | switch (functionp (ent[2]) && function_name (ent[2])) {
case "create": if (ent[1] == 7) ok++; break;
case "f": if (ent[1] == 14) ok++; break;
}
return ok == 2;
}
]])
|
f5ee3c | 2002-04-28 | Martin Stjernholm | | test_program([[// [bug 3060]
void x (mixed val)
{
}
class X
{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() {error ("foo\n");} // Line 8
|
f5ee3c | 2002-04-28 | Martin Stjernholm | | }
object rx = class {}();
int y()
{
x (rx->x);
rx = X(); // Line 16
}
int a()
{
mixed bt = catch (y())[1];
int ok = 0;
foreach (reverse (bt), object ent)
switch (functionp (ent[2]) && function_name (ent[2])) {
case "create": if (ent[1] == 8) ok++; break;
case "y": if (ent[1] == 16) ok++; break;
}
return ok == 2;
}
]])
|
4fa058 | 2003-03-20 | Martin Stjernholm | | test_any([[
// Test a lot of code without a relative pc update in it. There must
// not be any labels in it since the pc counting is reset then.
int a = 1, b = 1, c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c; c=a+b,a=b,b=c;
return __LINE__ == backtrace()[-1][1];
]], 1)
|
b58db9 | 2002-05-11 | Martin Stjernholm | | dnl Note: This line number error tend to go away with more debug.
test_program([[
int x = 0;
int y = [int] backtrace()[-1][1];
int a() {return y == 3;}
]])
|
f1accd | 2010-02-04 | Henrik Grubbström (Grubba) | | dnl This test used to get the last line of the else block
test_any([[
int expected_line;
void foo(object o)
{
expected_line = __LINE__ + 1;
if (o->a && b) {
o->a = o->b;
} else if (o->b) {
o->b = o->a;
}
};
mixed err = catch { foo(UNDEFINED); };
return err[1][-1][1] - expected_line;
]], 0)
|
1f4dbd | 2001-05-19 | Mirar (Pontus Hagland) | | dnl ----------------------------------------------------------------
dnl scopes and stuff
dnl ----------------------------------------------------------------
|
4705b5 | 2002-05-01 | Martin Stjernholm | | test_program([[
class A {
string f() {return "A";}
}
class B {
string f() {return "B";}
}
class C {
inherit B;
}
class D {
inherit A;
inherit C;
string g() {return f();}
}
int a() {
return D()->g() == "B";
}
]])
test_program([[
class A {
string f() {return "A";}
}
class B {
string f() {return "B";}
}
class C {
inherit B;
}
class D {
inherit C;
inherit A;
string g() {return f();}
}
int a() {
return D()->g() == "A";
}
]])
test_program([[
class A {
string f() {return "A";}
}
class B {
string f() {return "B";}
}
class C {
inherit B;
}
class D {
string f() {return "D";}
inherit A;
inherit C;
string g() {return f();}
}
int a() {
return D()->g() == "D";
}
]])
|
086acc | 1999-09-11 | Fredrik Hübinette (Hubbe) | | test_compile_any([[
class Bar
{
int f() {return 17;}
class Foo {
int g() {return f();}
}
inherit Foo;
}
]])
|
94b524 | 1999-11-01 | Mirar (Pontus Hagland) | | test_compile_any([[
|
086acc | 1999-09-11 | Fredrik Hübinette (Hubbe) | | class Bar
{
int f() {return 17;}
class Foo {
int g() {return f();}
}
}
class Gnu
{
inherit Bar;
inherit Foo;
}
]])
|
ae60c2 | 1999-12-02 | Mirar (Pontus Hagland) | |
|
93c16b | 2002-01-04 | Henrik Grubbström (Grubba) | | dnl Bug 2571
|
8e5b45 | 2001-11-27 | Martin Stjernholm | | test_any([[
int var;
void x() {var++;};
lambda () {x();}();
return var;
]], 1);
|
10c07f | 2002-11-16 | Henrik Grubbström (Grubba) | | test_do([[
// Save our constants for future use...
add_constant("__saved_constants__", ([]) + all_constants());
]])
|
1f4dbd | 2001-05-19 | Mirar (Pontus Hagland) | | test_any([[
Stdio.write_file("testsuite_test.pmod",
#"
// this crashes Pike /Mirar 2001-05-19
// I haven't been able to minimize it futher,
// and it needs to be in a separate module.
mapping es=0;
string efoo(string e)
{
if (!es)
{
mapping res=([]);
string l;
if (sscanf(l,\"%s%s\",string ext,string type)==4 &&
ext!=\"\" && ext[0]!=\"#\") // note the type error
res[ext]=type;
es=res;
}
|
13670c | 2015-05-25 | Martin Nilsson | | }
|
1f4dbd | 2001-05-19 | Mirar (Pontus Hagland) | | ");
|
6edc4f | 2001-05-24 | Henrik Grubbström (Grubba) | | // Compilation handler that hides compilation errors.
class handler
{
void compile_error(string file, int line, string err)
{
|
50ab1c | 2010-07-12 | Martin Stjernholm | | // log_msg("file: %O, line: %O, err: %O\n", file, line, err);
|
6edc4f | 2001-05-24 | Henrik Grubbström (Grubba) | | }
};
|
1f4dbd | 2001-05-19 | Mirar (Pontus Hagland) | | // turn this on when the bug is found
// master()->set_inhibit_compile_errors(lambda(){});
|
ba14f3 | 2001-05-22 | Henrik Grubbström (Grubba) | | //_optimizer_debug(2);
//_assembler_debug(20);
|
1184fa | 2001-12-12 | Martin Stjernholm | | object orig_master = master();
replace_master(object_program(orig_master)());
|
1f4dbd | 2001-05-19 | Mirar (Pontus Hagland) | | catch {
|
6edc4f | 2001-05-24 | Henrik Grubbström (Grubba) | | compile_string("import \".\";\n"
"int foo() { testsuite_test.efoo; }\n",
"testsuite_test", handler());
|
1f4dbd | 2001-05-19 | Mirar (Pontus Hagland) | | };
|
1184fa | 2001-12-12 | Martin Stjernholm | | replace_master(orig_master);
|
1f4dbd | 2001-05-19 | Mirar (Pontus Hagland) | | return 0;
]],0);
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | test_any([[
// infokom:350113
|
1184fa | 2001-12-12 | Martin Stjernholm | | Stdio.recursive_rm("testsuite_test_dir.pmod");
|
6c6776 | 2001-10-06 | Mirar (Pontus Hagland) | | mkdir("testsuite_test_dir.pmod");
Stdio.write_file("testsuite_test_dir.pmod/module.pmod",
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | #"
.A a() {return 0;}
");
|
6c6776 | 2001-10-06 | Mirar (Pontus Hagland) | | Stdio.write_file("testsuite_test_dir.pmod/A.pike",
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | #"
void create (.X x) {.y();}
");
// Compilation handler that hides compilation errors.
class handler
|
8307ee | 2001-11-08 | Fredrik Hübinette (Hubbe) | | {
void handle_error(array(mixed)|object trace) { }
|
13670c | 2015-05-25 | Martin Nilsson | | void compile_error(string file, int line, string err) { }
void compile_warning(string file, int line, string err) { }
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | };
|
1184fa | 2001-12-12 | Martin Stjernholm | | object orig_master = master();
replace_master(object_program(orig_master)());
|
8307ee | 2001-11-08 | Fredrik Hübinette (Hubbe) | | master()->set_inhibit_compile_errors(handler());
mixed err = catch {
compile_string("import \".\"; "
|
1184fa | 2001-12-12 | Martin Stjernholm | | "int foo() { testsuite_test_dir.a(); }",
"test",handler());
|
8307ee | 2001-11-08 | Fredrik Hübinette (Hubbe) | | };
master()->set_inhibit_compile_errors(0);
|
1184fa | 2001-12-12 | Martin Stjernholm | | replace_master(orig_master);
|
8307ee | 2001-11-08 | Fredrik Hübinette (Hubbe) | | if(err)
|
13670c | 2015-05-25 | Martin Nilsson | | {
|
1184fa | 2001-12-12 | Martin Stjernholm | | Stdio.recursive_rm("testsuite_test_dir.pmod");
|
8307ee | 2001-11-08 | Fredrik Hübinette (Hubbe) | | return 0;
}
|
13670c | 2015-05-25 | Martin Nilsson | |
|
8307ee | 2001-11-08 | Fredrik Hübinette (Hubbe) | | return 1;
|
34db63 | 2001-10-06 | Mirar (Pontus Hagland) | | ]],0);
|
11cbae | 2001-11-10 | Martin Stjernholm | | test_do([[
Stdio.recursive_rm("testsuite_test_dir.pmod");
mkdir("testsuite_test_dir.pmod");
Stdio.write_file("testsuite_test_dir.pmod/module.pmod",
#"
.A a();
class X {}
");
Stdio.write_file("testsuite_test_dir.pmod/A.pike",
#"
.X f() {return 0;}
");
|
1184fa | 2001-12-12 | Martin Stjernholm | | object orig_master = master();
replace_master(object_program(orig_master)());
mixed err = catch {
compile_string("import \".\"; "
"int foo() { testsuite_test_dir.A(); }",
"test");
};
replace_master(orig_master);
if (err) throw (err);
|
11cbae | 2001-11-10 | Martin Stjernholm | |
Stdio.recursive_rm("testsuite_test_dir.pmod");
]]);
|
06203b | 2001-12-15 | Martin Stjernholm | | test_do([[
Stdio.recursive_rm ("testsuite_test_dir.pmod");
mkdir ("testsuite_test_dir.pmod");
Stdio.write_file ("testsuite_test_dir.pmod/module.pmod", #"\
.B b();
class X {}");
Stdio.write_file ("testsuite_test_dir.pmod/A.pike", #"\
int f() {return 0;}");
Stdio.write_file ("testsuite_test_dir.pmod/B.pike", #"\
inherit .A;
.X g() {return f() && .X();}");
object orig_master = master();
replace_master (object_program (orig_master)());
mixed err = catch {
compile_string ("import \".\";\n"
"int foo() { testsuite_test_dir.B(); }",
"test");
};
replace_master (orig_master);
if (err) throw (err);
Stdio.recursive_rm ("testsuite_test_dir.pmod");
]]);
test_do([[
Stdio.recursive_rm ("testsuite_test_dir.pmod");
mkdir ("testsuite_test_dir.pmod");
Stdio.write_file ("testsuite_test_dir.pmod/module.pmod", #"\
|
9439bd | 2003-01-16 | Henrik Grubbström (Grubba) | | .B.B b();
|
06203b | 2001-12-15 | Martin Stjernholm | | class X {}");
Stdio.write_file ("testsuite_test_dir.pmod/A.pike", #"\
int f() {return 0;}");
Stdio.write_file ("testsuite_test_dir.pmod/B.pmod", #"\
class B {
inherit .A;
.X g() {return f() && .X();}
}");
object orig_master = master();
replace_master (object_program (orig_master)());
mixed err = catch {
compile_string ("import \".\";\n"
"int foo() { testsuite_test_dir.B.B(); }",
"test");
};
replace_master (orig_master);
if (err) throw (err);
Stdio.recursive_rm ("testsuite_test_dir.pmod");
]]);
|
a244cc | 2002-03-01 | Martin Stjernholm | | test_do([[
// Problem: The expression .B.c in module.pmod is resolved during
// compilation pass 1 of B.pike, but it's only declared then and
// doesn't yet have any value.
Stdio.recursive_rm ("testsuite_test_dir.pmod");
mkdir ("testsuite_test_dir.pmod");
Stdio.write_file ("testsuite_test_dir.pmod/module.pmod", #"\
mixed x = .B.c;
class A {}");
Stdio.write_file ("testsuite_test_dir.pmod/B.pike", #"\
constant c = .A();"); // Should give a "not constant" compile error.
// Compilation handler that hides compilation errors.
class handler
{
void handle_error(array(mixed)|object trace) { }
|
13670c | 2015-05-25 | Martin Nilsson | | void compile_error(string file, int line, string err) { }
void compile_warning(string file, int line, string err) { }
|
a244cc | 2002-03-01 | Martin Stjernholm | | };
object orig_master = master();
replace_master (object_program (orig_master)());
mixed err = catch {
compile_string (#"\
mixed foo() {return .testsuite_test_dir.A;}",
"test", handler());
};
replace_master (orig_master);
if (!err) error ("Expected compile error.\n");
if (!objectp (err) || !err->is_compilation_error) throw (err);
Stdio.recursive_rm("testsuite_test_dir.pmod");
]]);
|
fa8c4f | 2002-03-01 | Martin Stjernholm | | test_any_equal([[
|
a244cc | 2002-03-01 | Martin Stjernholm | | // Problem: module.pmod is in pass 1 when it tries to resolve the
// .B.c constant and is therefore temporarily interned as a
|
fa8c4f | 2002-03-01 | Martin Stjernholm | | // placeholder object. The (<>) in B.pike is equivalent to
// aggregate_multiset, which due to the import is looked up in the
|
a244cc | 2002-03-01 | Martin Stjernholm | | // placeholder object and therefore resolved as a nonconstant
// placeholder object.
|
fa8c4f | 2002-03-01 | Martin Stjernholm | | Stdio.recursive_rm ("testsuite_test_dir.pmod");
mkdir ("testsuite_test_dir.pmod");
Stdio.write_file ("testsuite_test_dir.pmod/module.pmod", #"\
|
a244cc | 2002-03-01 | Martin Stjernholm | | mixed x = .B.C;
mixed foo() {return x->c;}");
|
fa8c4f | 2002-03-01 | Martin Stjernholm | | Stdio.write_file ("testsuite_test_dir.pmod/B.pike", #"\
import \".\";
|
a244cc | 2002-03-01 | Martin Stjernholm | | class C {
constant c = (<>);
}");
|
fa8c4f | 2002-03-01 | Martin Stjernholm | |
object orig_master = master();
replace_master (object_program (orig_master)());
mixed res;
mixed err = catch {
res = compile_string (#"\
|
a244cc | 2002-03-01 | Martin Stjernholm | | mixed foo() {return .testsuite_test_dir.foo();}",
|
fa8c4f | 2002-03-01 | Martin Stjernholm | | "test")()->foo();
};
replace_master (orig_master);
if (err) throw (err);
|
a244cc | 2002-03-01 | Martin Stjernholm | | Stdio.recursive_rm("testsuite_test_dir.pmod");
|
fa8c4f | 2002-03-01 | Martin Stjernholm | | return res;
]], (<>));
|
569c6c | 2003-03-05 | Martin Stjernholm | | test_do([[
Stdio.recursive_rm ("testsuite_test_dir.pmod");
mkdir ("testsuite_test_dir.pmod");
Stdio.write_file ("testsuite_test_dir.pmod/A.pmod", #"\
string pof() {return testsuite_test_dir.A.bingo();}
string bingo () {return \"17\";}");
object orig_master = master();
replace_master (object_program (orig_master)());
master()->add_module_path (getcwd());
mixed err = catch {
compile_string (#"\
string foo() {
return testsuite_test_dir.A.pof();
}", "test");
};
replace_master (orig_master);
if (err) throw (err);
Stdio.recursive_rm ("testsuite_test_dir.pmod");
]])
|
1899f8 | 2003-03-27 | Martin Stjernholm | | test_do([[
Stdio.recursive_rm ("testsuite_test_dir.pmod");
mkdir ("testsuite_test_dir.pmod");
Stdio.write_file ("testsuite_test_dir.pmod/module.pmod", #"\
.Foo.C x;");
Stdio.write_file ("testsuite_test_dir.pmod/Foo.pmod", #"\
import \".\";
class C
{
int f (array x)
{
return lambda() {
// 'sizeof' below will be a placeholder object in
// pass 1. That shouldn't cause a type error.
int i = sizeof (x);
return i;
}();
}
}");
object orig_master = master();
replace_master (object_program (orig_master)());
mixed err = catch {
compile_string (#"\
mixed foo() {return .testsuite_test_dir.x;}",
"test");
};
replace_master (orig_master);
if (err) throw (err);
Stdio.recursive_rm("testsuite_test_dir.pmod");
]]);
|
6c9261 | 2008-08-17 | Martin Stjernholm | | test_do([[
Stdio.write_file ("testsuite_test_a.pmod", #"
class a {}
testsuite_test_b.b2 foo() {return testsuite_test_b.b2 (17);}");
Stdio.recursive_rm ("testsuite_test_b.pmod");
mkdir ("testsuite_test_b.pmod");
Stdio.write_file ("testsuite_test_b.pmod/b1.pike", #"
protected void create() {}");
Stdio.write_file ("testsuite_test_b.pmod/b2.pike", #"
inherit testsuite_test_b.b1;
constant a = testsuite_test_a.a;
protected void create (int i) {}");
object orig_master = master();
replace_master (object_program (orig_master)());
master()->add_module_path (getcwd());
mixed err = catch {
compile_string ("inherit testsuite_test_b.b2;");
};
replace_master (orig_master);
if (err) throw (err);
Stdio.recursive_rm ("testsuite_test_a.pmod");
Stdio.recursive_rm ("testsuite_test_b.pmod");
]])
|
3843f5 | 2001-12-16 | Martin Stjernholm | | cond(0,[[
test_do([[
// This is a case of cyclic references I think should work, but
// afaict it's not possible without changing the resolve methods
// thoroughly. /mast
Stdio.recursive_rm ("testsuite_test_dir.pmod");
mkdir ("testsuite_test_dir.pmod");
Stdio.write_file ("testsuite_test_dir.pmod/A.pmod", #"\
.B.B b() {}
class A {}
class Ab {int ai() {return 4711;}}
class Ad {inherit .B.Bb; int ai() {return bi() + 1;}}");
Stdio.write_file ("testsuite_test_dir.pmod/B.pmod", #"\
.A.A a() {}
class B {}
class Bb {int bi() {return 17;}}
class Bd {inherit .A.Ab; int bi() {return ai() - 1;}}");
object orig_master = master();
replace_master (object_program (orig_master)());
mixed err = catch {
compile_string (#"\
import \".\";
int foo() {
testsuite_test_dir.A.Ad();
testsuite_test_dir.B.Bd();
}", "test");
};
replace_master (orig_master);
if (err) throw (err);
Stdio.recursive_rm ("testsuite_test_dir.pmod");
]]);
]]);
|
10c07f | 2002-11-16 | Henrik Grubbström (Grubba) | | test_do([[
// Restore constants that were zapped by the various masters used above.
|
e68090 | 2015-03-22 | Henrik Grubbström (Grubba) | | foreach(__saved_constants__; string const_name; mixed val) {
add_constant(const_name, val);
|
10c07f | 2002-11-16 | Henrik Grubbström (Grubba) | | }
|
13670c | 2015-05-25 | Martin Nilsson | | add_constant("__saved_constants__");
|
10c07f | 2002-11-16 | Henrik Grubbström (Grubba) | | ]])
|
ae60c2 | 1999-12-02 | Mirar (Pontus Hagland) | | test_compile_any([[int log() { return 17; } class Greta { int hanna() { return log(); } }]])
test_compile_any([[int kajsa(int a,int b) { return 17; } class Jenny { int kajsa() { return 17; } class Greta { int hanna() { return kajsa(); } } }]])
|
40c290 | 1999-12-02 | Mirar (Pontus Hagland) | | test_any([[add_constant("kajsa",lambda(int a,int b) { return 17; }); return compile_string("int kajsa() { return 17; } class Greta { int hanna() { return kajsa(); } }")()->kajsa()]],17)
|
9040cc | 2002-10-14 | Martin Nilsson | | test_do(add_constant("kajsa"))
|
ae60c2 | 1999-12-02 | Mirar (Pontus Hagland) | |
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | test_compile([[Stdio.File foo=Stdio.File();]])
|
4b3837 | 1998-04-28 | Fredrik Hübinette (Hubbe) | | test_compile([[ string|multiset(string) foo;
array(string) gazonk;
array(string) bar = indices(foo)-gazonk;
]])
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | test_compile([[class { Stdio.File foo=Stdio.File(); }]])
test_compile_any([[void foo(Stdio.FILE f) {}]])
test_compile_any([[void foo(array(Stdio.FILE) f) {}]])
test_compile_any([[void foo(array(Stdio.FILE) f) {}]])
test_compile_any([[Stdio.File foo(array(Stdio.FILE) f) { return f[0]; }]])
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | test_compile_any([[
class a {
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int `== (mixed x) {
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | return 0;
}
}
class b {
inherit a;
class c {
int d (string x, string y) {
return x==y;
}
}
}
]])
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | test_compile([[Stdio.File foo=Stdio.FILE();]])
|
87c9d2 | 1998-04-09 | Fredrik Hübinette (Hubbe) | |
|
c2a952 | 2013-06-08 | Henrik Grubbström (Grubba) | | dnl variant
test_any([[
class A {
variant string a() { return "A:a()"; }
variant string a(string s) { return sprintf("A:a(%q)", s); }
};
class B {
inherit A;
variant string a(int i) { return local::a() + ":" + local::a((string)i) + ":" + ::a((string)i); }
variant string a(string s) { return sprintf("B:a(%q)", s); }
};
class C {
inherit B;
string a() { return "C:a()"; }
variant string a(string s) { return ::a(sizeof(s)) + "|" + ::a(s) + "|" + a(); }
};
return C()->a("foo");
]], "A:a():B:a(\"3\"):A:a(\"3\")|B:a(\"foo\")|C:a()")
|
c8bd89 | 2016-10-30 | Henrik Grubbström (Grubba) | | test_any([[
class A {
string a() { return "A"; }
variant string a(int i) { return "B"+i+"B"; }
};
return A()->a() + A()->a(1);
]], "AB1B")
|
b681db | 2016-10-31 | Henrik Grubbström (Grubba) | | test_any([[
class A {
string a(int i) { return "B"+i+"B"; }
variant string a() { return "A"; }
};
return A()->a() + A()->a(1);
]], "AB1B")
|
c8bd89 | 2016-10-30 | Henrik Grubbström (Grubba) | | test_compile_warning([[
class A {
string a() { return "A"; }
variant string a(int|void i) { return "B"+i+"B"; }
};
return A()->a() + A()->a(1);
]])
dnl test_any([[
dnl class A {
dnl string a(int|void i) { return "A" + i + "A"; }
dnl variant string a(int i) { return "B"+i+"B"; }
dnl };
dnl return A()->a() + A()->a(1);
dnl ]], "A0AB1B")
test_compile_warning([[
class A {
string a(int i) { return "A"+i+"A"; }
variant string a(int|void i) { return "B"+i+"B"; }
};
return A()->a() + A()->a(1);
]])
dnl test_any([[
dnl class A {
dnl string a(int|void i) { return "A" + i + "A"; }
dnl variant string a(int i, int|void j) { return "B"+i+"C"+j+"C"+"B"; }
dnl };
dnl return A()->a() + A()->a(1) + A()->a(2, 3);
dnl ]], "A0AB1C0CBB2C3CB")
test_compile_warning([[
class A {
string a(int i) { return "A"+i+"A"; }
variant string a(int i, int|void j) { return "B"+i+"C"+j+"C"+"B"; }
};
return A()->a(1) + A()->a(2, 3);
]])
|
ce3293 | 2016-10-31 | Henrik Grubbström (Grubba) | | test_any([[
class A { string a(){ return "A"; } };
class B { int a(){ return 17; } };
class C {
string c(A a) { return "C" + a->a() + "C"; }
variant string c(B b) { return "CB" + b->a() + "BC"; }
};
A a = A();
B b = B();
C c = C();
return c->c(a) + c->c(b);
]], "CACCB17BC")
test_compile_warning([[
// Bug 7812.
class A { string a(){ return "A"; } };
class B { int a(){ return 17; } };
class C {
string c(array(A) a) { return "C" + (a->a() * "C") + "C"; }
variant string c(array(B) b) { return "CB" + `+(0, @b->a()) + "BC"; }
};
A a = A();
B b = B();
C c = C();
return c->c(({a,a})) + c->c(({b,b}));
]])
|
4a06ad | 2016-11-05 | Henrik Grubbström (Grubba) | | test_any([[
// Test the __weak__ modifier.
class A {
class Q{};
__weak__ Q q_w = Q();
__weak__ mixed m_w = Q();
Q q = Q();
mixed m = Q();
};
A a = A();
gc();
return !a->q_w && !a->m_w && a->q && a->m && 1;
]], 1)
|
d16515 | 2008-05-03 | Henrik Grubbström (Grubba) | | test_any([[
// Test symbol lookup for inherit in multi-pass.
// LysLysKOM 16472935
// An old pike will attempt to lookup X in the innermost X
// during the second pass and thus fail with a compilation error.
class X {
constant foo = "outer";
class X {
constant foo = "middle";
class X {
constant foo = "inner";
}
}
};
class Y {
inherit X.X;
};
return Y()->foo;
]], "middle")
|
33d4cf | 2010-01-21 | Henrik Grubbström (Grubba) | | test_any([[
|
67731b | 2010-01-21 | Henrik Grubbström (Grubba) | | // Test external symbol lookup in las.c:eval_low_safe_and_stupid().
|
33d4cf | 2010-01-21 | Henrik Grubbström (Grubba) | | // LysLysKOM 18285732
// An old pike will fail with the fatal
// "Identifier out of range, loc->parent_identifer=-1!"
// during __INIT().
class A
{
|
218176 | 2014-08-15 | Martin Nilsson | | protected string foo = "bar";
|
33d4cf | 2010-01-21 | Henrik Grubbström (Grubba) | | };
|
13670c | 2015-05-25 | Martin Nilsson | |
|
33d4cf | 2010-01-21 | Henrik Grubbström (Grubba) | | string to_compile=#"
constant fum = \"gazonk\";
|
13670c | 2015-05-25 | Martin Nilsson | |
|
33d4cf | 2010-01-21 | Henrik Grubbström (Grubba) | | class B()
{
inherit A;
|
67731b | 2010-01-21 | Henrik Grubbström (Grubba) | | int fi()
|
33d4cf | 2010-01-21 | Henrik Grubbström (Grubba) | | {
return fum?1:0;
}
}
";
|
13670c | 2015-05-25 | Martin Nilsson | |
|
33d4cf | 2010-01-21 | Henrik Grubbström (Grubba) | | add_constant("A",A);
compile_string(to_compile);
add_constant("A");
return 0;
]], 0)
|
be2d7f | 2019-04-04 | Henrik Grubbström (Grubba) | | test_any_equal([[
// Test automap combined with splice. [LysLysKOM 23258037]
array ret = ({});
for (int x = 0; x < 10; x++) {
array a = ({ x, });
ret += `+(a[*], @a);
}
return ret;
]], ({ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 }))
|
479afe | 2010-02-09 | Henrik Grubbström (Grubba) | | test_any([[
// Test eval_low() on seemingly constant expressions, that
// attempt to access variables in the fake object. [Bug 5273]
// An old pike (with RTL debug) will fail with the fatal
// "Invalid type 33896 in svalue at 891e510."
// during compilation.
class Test
{
protected object foo;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (mixed what)
|
479afe | 2010-02-09 | Henrik Grubbström (Grubba) | | {
return foo;
}
int bar ()
{
|
f960bd | 2015-07-31 | Martin Nilsson | | return (this->gazonk == "foo") ? 1 : 0;
|
479afe | 2010-02-09 | Henrik Grubbström (Grubba) | | }
};
return Test()->bar;
]], 0)
|
493913 | 2017-09-09 | Martin Nilsson | | test_compile_error([[
class {
int a() { }
void b() { return a(); }
}
]])
test_do([[
class {
void a() { }
void b() { return a(); }
}
]])
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | test_any([[string gurk="bozo"; string b(int x) { return (x?b(x-1)+gurk:""); }; return b(5)]],[["bozo"*5]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | dnl this should really work...
dnl test_compile_any([[void foo(int,string,...);]])
|
9ddbf2 | 2001-05-10 | Fredrik Hübinette (Hubbe) | | dnl This test doesn't run out of stack anymore, freaky
dnl test_eval_error([[class X { int create() { create(); } }();]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_compile_error([[ int float; ]])
test_compile_error([[ int array; ]])
test_compile_error([[ int function; ]])
test_compile_error([[ int int; ]])
test_compile_error([[ int mapping; ]])
test_compile_error([[ int multiset; ]])
test_compile_error([[ int object; ]])
test_compile_error([[ int string; ]])
test_compile_error([[ int void; ]])
test_compile_error([[ int inline; ]])
test_compile_error([[ int local; ]])
test_compile_error([[ int predef; ]])
test_compile_error([[ int private; ]])
test_compile_error([[ int protected; ]])
test_compile_error([[ int public; ]])
test_compile_error([[ int static; ]])
test_compile_error([[ int final; ]])
test_compile_error([[ int do; ]])
test_compile_error([[ int else; ]])
test_compile_error([[ int return; ]])
test_compile_error([[ int constant; ]])
test_compile_error([[ int import; ]])
test_compile_error([[ int inherit; ]])
test_compile_error([[ int catch; ]])
|
ee2f20 | 1999-10-10 | Fredrik Noring | | test_compile_error([[ float gauge; ]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_compile_error([[ int lambda; ]])
test_compile_error([[ int sscanf; ]])
test_compile_error([[ int switch; ]])
test_compile_error([[ int typeof; ]])
test_compile_error([[ int break; ]])
test_compile_error([[ int case; ]])
test_compile_error([[ int continue; ]])
test_compile_error([[ int default; ]])
test_compile_error([[ int for; ]])
test_compile_error([[ int foreach; ]])
test_compile_error([[ int if; ]])
test_compile_error([[ int float = 0; ]])
test_eval_error([[ return 0.0[0]; ]])
test_eval_error([[ return 0[0]; ]])
|
a3a6c2 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | test_compile_error([[constant x=class {}(); ]])
|
73406b | 1999-02-14 | Fredrik Hübinette (Hubbe) | |
|
6b3f5c | 2002-04-11 | Martin Nilsson | | test_compile_error_any([[
|
199425 | 1999-09-06 | Fredrik Hübinette (Hubbe) | | mixed foo;
mapping query_variables() { return ([]); };
mixed foo(mixed bar) { return 1/foo; }
]])
|
6b3f5c | 2002-04-11 | Martin Nilsson | | test_compile_error_any([[
|
282369 | 1999-11-27 | Martin Stjernholm | | class A {int wrong = "bogus"; void create() {}}
class B {inherit A;}
]])
|
199425 | 1999-09-06 | Fredrik Hübinette (Hubbe) | |
|
45ad7f | 2005-07-13 | Henrik Grubbström (Grubba) | | test_any([[
|
300d02 | 2016-11-05 | Martin Nilsson | | #pragma dynamic_dot
|
45ad7f | 2005-07-13 | Henrik Grubbström (Grubba) | | // Test dynamic module indexing.
object protocols = Protocols;
return protocols.HTTP.get_url_data;
]], [[ Protocols.HTTP.get_url_data ]])
|
199425 | 1999-09-06 | Fredrik Hübinette (Hubbe) | |
|
ee2f20 | 1999-10-10 | Fredrik Noring | | test_compile([[float x=(gauge { return; },1.0);]])
|
3e5021 | 2014-08-18 | Martin Nilsson | | test_compile_error([[object x = Gmp.mpz(17); constant y = x;]])
|
a83f8c | 1998-03-20 | Fredrik Hübinette (Hubbe) | | test_any([[object(Stdio.File) f; f=Stdio.File(); return 1]],1)
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | test_compile([[float t=gauge { string foo; foo; };]])
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_compile_any([[class Foo { object(Stdio.FILE) f; protected void create() { f=Stdio.FILE(); }}]])
|
097e3d | 1998-02-27 | Fredrik Hübinette (Hubbe) | | test_eq([[compile_string("#define A(X) (X)\nint x() { return A \n\t(1); }")()->x()]],1)
|
3b589f | 1999-02-04 | Fredrik Hübinette (Hubbe) | |
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_any([[class G { mapping t=([]);
|
f960bd | 2015-07-31 | Martin Nilsson | | class tO { void init(string name) { t[name]=this; }}
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class W { inherit tO; protected void create() { init("foo"); }}
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | }; object x=G(); x->W(); return objectp(x->t->foo)]],1)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
51ffdb | 1998-01-19 | Fredrik Hübinette (Hubbe) | | test_program([[class foo { program x() { return class {}; }}; class bar { inherit foo; program x() { return class {}; }} int a() { return foo()->x != bar()->x(); }]])
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | test_any([[
class A {
constant gurka = 2;
int foo = gurka;
};
class B {
|
35f51c | 2008-06-28 | Martin Nilsson | | protected inherit A;
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | constant gurka = 1;
int bar;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() { bar = foo; }
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | };
return B()->bar;
]], 1)
test_any([[
class A {
constant gurka = 2;
int foo = gurka;
};
class B {
|
35f51c | 2008-06-28 | Martin Nilsson | | protected inherit A;
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | constant gurka = 1;
int bar;
int baz = 3;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() { bar = baz + foo; }
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | };
return B()->bar;
]], 4)
test_any([[
class A {
|
18c2b7 | 1999-03-06 | Henrik Grubbström (Grubba) | | constant gurka = 1;
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | int foo = gurka;
};
class B {
|
18c2b7 | 1999-03-06 | Henrik Grubbström (Grubba) | | constant banan = 2;
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | int foo = banan;
};
class C {
|
35f51c | 2008-06-28 | Martin Nilsson | | protected inherit A;
protected inherit B;
|
18c2b7 | 1999-03-06 | Henrik Grubbström (Grubba) | | constant gurka = 3;
constant banan = 4;
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | int bar;
|
18c2b7 | 1999-03-06 | Henrik Grubbström (Grubba) | | int baz = 5;
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | |
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() { bar = baz + A::foo + B::foo; }
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | | };
|
13d401 | 1999-03-06 | Henrik Grubbström (Grubba) | | return C()->bar;
|
18c2b7 | 1999-03-06 | Henrik Grubbström (Grubba) | | ]], 12)
|
265b72 | 1999-03-06 | Henrik Grubbström (Grubba) | |
|
a3ece0 | 1999-03-15 | Henrik Grubbström (Grubba) | | test_any([[
class A { int a = 1; };
class B { int b = 2; };
class C {
inherit A;
inherit B;
int c = 4;
};
class D {
inherit C;
};
object d = D();
return d->a + d->b + d->c;
]], 7)
|
6b3f5c | 2002-04-11 | Martin Nilsson | | test_compile_error_any([[
|
199425 | 1999-09-06 | Fredrik Hübinette (Hubbe) | | class AScope
{
int gurka;
class A
{
int func() { return gurka; }
}
}
|
13670c | 2015-05-25 | Martin Nilsson | |
|
199425 | 1999-09-06 | Fredrik Hübinette (Hubbe) | | class CScope
{
string hohum;
class C
{
inherit AScope.A;
}
}
]])
|
9669c1 | 2003-06-06 | Marcus Comstedt | | test_program([[
class A
{
constant x = 1.0;
}
class B
{
inherit A;
class C
{
constant y = x+2.0;
}
}
mixed a()
{
return 3.0 == B()->C()->y;
}
]])
|
e5c297 | 2003-08-18 | Martin Stjernholm | | test_program_eq([[
constant x = X;
class X {constant c = "right";}
constant y = Y;
class Y {constant c = "wrong";}
string a()
{
return ::`[]("x")->c;
}
]], "right")
|
06b16a | 2003-08-20 | Martin Stjernholm | | test_program_eq([[
class A {
string x = "x";
class B {
string f() {return x;}
}
}
class C {
inherit A;
constant D = A::B;
}
string a() {
return C()->D()->f();
}
]], "x")
test_program_eq([[
class A {
string x = "x";
class B {
string f() {return x;}
}
}
class C {
inherit A;
string x = "y";
constant D = A::B;
}
string a() {
return C()->D()->f();
}
]], "y")
test_program_eq([[
class A {
local string x = "x";
class B {
string f() {return x;}
}
}
class C {
inherit A;
string x = "y";
constant D = A::B;
}
string a() {
return C()->D()->f();
}
]], "x")
test_program_eq([[
class A {
local string x = "x";
class B {
void set (string new) {x = new;}
string f() {return x;}
}
}
class C {
inherit A;
string x = "y";
constant D = A::B;
}
string a() {
C c = C();
C.D d = c->D();
d->set ("bar");
c->x = "foo";
return d->f();
}
]], "bar")
|
9669c1 | 2003-06-06 | Marcus Comstedt | |
|
bb4e05 | 2000-02-11 | Fredrik Hübinette (Hubbe) | | dnl Come back when we decide that this should be possible
dnl test_do([[
dnl class A {
dnl constant i = 5;
dnl };
dnl class B {
dnl inherit A;
dnl int i = 17;
dnl };
dnl B();
dnl ]])
|
6c6c1b | 2000-02-07 | Martin Stjernholm | |
|
199425 | 1999-09-06 | Fredrik Hübinette (Hubbe) | |
test_any([[
class A {};
class B { inherit A; };
class C { inherit B; };
class D { inherit C; };
return Program.inherits(D,A);
]],1)
test_any([[
class A {};
class B { inherit A; };
class C { inherit B; };
class D { inherit C; };
return Program.inherits(A,D);
]],0)
test_any([[
class A {};
class B { inherit A; };
class C { inherit B; };
class D { inherit C; };
return Program.inherits(A,C);
]],0)
test_any([[
class A {};
class B { inherit A; };
class C { inherit B; };
class D { inherit C; };
return Program.inherits(C,A);
]],1)
test_any_equal([[
class A {};
class B { inherit A; };
class C { inherit B; };
class D { inherit C; };
return Program.inherit_list(D);
]],[[ ({ C }) ]] )
test_any_equal([[
class A {};
class B { inherit A; };
class C { inherit B; };
class D { inherit A; inherit B; inherit C; };
return Program.inherit_list(D);
]],[[ ({ A,B,C }) ]])
test_any_equal([[
class A {};
class B { inherit A; };
class C { inherit B; };
class D { inherit C; };
return Program.inherit_tree(D);
]],[[ ({D, ({C, ({B, ({A})})})}) ]])
test_any([[
class A {};
class B { inherit A; };
class C { inherit B; };
class D { inherit C; };
return sizeof( Program.all_inherits(D) - ({A,B,C}) );
]],0)
|
e92ea2 | 2004-04-23 | Martin Stjernholm | | test_any_equal([[
class A {
class C {}
};
class B {
class C {}
};
return ({A <= B, A >= B});
]], ({1, 1}))
|
878bf4 | 2002-05-02 | Martin Nilsson | | test_tests([[
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | |
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | int errors;
int tests;
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | int maxdepth;
|
852727 | 2002-04-18 | Henrik Grubbström (Grubba) | | class Codec {
string nameof(mixed x)
{
|
552072 | 2007-06-18 | Martin Stjernholm | | return ([ trace:"efun:trace", write:"efun:write", `+:"efun:`+" ])[x];
|
852727 | 2002-04-18 | Henrik Grubbström (Grubba) | | }
function functionof(string x)
{
|
552072 | 2007-06-18 | Martin Stjernholm | | return ([ "efun:trace":trace, "efun:write":write, "efun:`+":`+ ])[x] ||
|
852727 | 2002-04-18 | Henrik Grubbström (Grubba) | | 0;
}
|
4f101c | 2002-05-02 | Martin Stjernholm | |
mixed encode_object (object o) {}
void decode_object (object o, mixed d) {}
|
852727 | 2002-04-18 | Henrik Grubbström (Grubba) | | }
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | void low_generate(int depth,
array(string) code,
string acc,
string ans,
int cnt)
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | {
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | mixed tmp;
if(--depth<0)
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | {
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | string res="None";
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | tests++;
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | |
if(!(tests & 63))
|
13670c | 2015-05-25 | Martin Nilsson | | {
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | __signal_watchdog();
|
4da933 | 2011-04-04 | Martin Stjernholm | | log_status("Testing vtables and scope access: %d:%d",maxdepth,tests);
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | }
string test=code*"\n"+"\n"
"mixed Q() { return "+acc+"();}\n"
|
552072 | 2007-06-18 | Martin Stjernholm | | "int main() { trace(9); write(\"%O\\n\","+acc+"()); }\n"
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | ;
|
ed1aad | 2000-09-01 | Fredrik Hübinette (Hubbe) | |
|
52f66d | 2003-08-03 | Martin Stjernholm | | mixed tmp, x;
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | mixed err=catch {
|
ed1aad | 2000-09-01 | Fredrik Hübinette (Hubbe) | | tmp=compile_string(test)();
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | res=tmp->Q();
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | if(res != ans)
|
52f66d | 2003-08-03 | Martin Stjernholm | | throw("Test failed");
res = "None";
|
852727 | 2002-04-18 | Henrik Grubbström (Grubba) | | tmp = decode_value(encode_value(tmp, Codec()), Codec());
res=tmp->Q();
if(res != ans)
|
52f66d | 2003-08-03 | Martin Stjernholm | | throw("Test failed for encode/decode.");
x=Program.inherit_list(object_program(tmp));
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | };
if(err)
{
errors++;
|
50ab1c | 2010-07-12 | Martin Stjernholm | | log_msg("Test failed:\n"
"----------------------------------\n"
"%s\n"
"---------------------------------\n"
"expected answer: %O\n"
"Answer received: %O\n",test,ans,res);
|
852727 | 2002-04-18 | Henrik Grubbström (Grubba) | | if(!stringp(err) || !has_prefix(err, "Test failed"))
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | {
string tmp=master()->describe_backtrace(err);
array s=tmp/"\n";
s=s[..20];
|
50ab1c | 2010-07-12 | Martin Stjernholm | | log_msg("%s\n",s*"\n");
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | }
|
5b1379 | 2004-03-08 | Henrik Grubbström (Grubba) | | if (res == "None") {
// Probable decode error; try to get some debug.
catch {
|
50ab1c | 2010-07-12 | Martin Stjernholm | | log_msg("Encoding...\n");
|
5b1379 | 2004-03-08 | Henrik Grubbström (Grubba) | | string encoded = ((function)encode_value)(tmp, Codec(), 6);
|
50ab1c | 2010-07-12 | Martin Stjernholm | | log_msg("Decoding...\n");
|
5b1379 | 2004-03-08 | Henrik Grubbström (Grubba) | | tmp = ((function)decode_value)(encoded, Codec(), 6);
|
50ab1c | 2010-07-12 | Martin Stjernholm | | log_msg("Strange... No error thrown...\n");
|
5b1379 | 2004-03-08 | Henrik Grubbström (Grubba) | | };
}
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | return;
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | }
}else{
|
13670c | 2015-05-25 | Martin Nilsson | | low_generate(depth,
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | code+
({sprintf("string F%d(){ return %s()+\"F%d\"; }",cnt,acc,cnt)}),
sprintf("F%d",cnt),
sprintf("%sF%d",ans,cnt),
cnt+1);
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | |
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | for(int e=0;e<sizeof(code);e++)
{
|
13670c | 2015-05-25 | Martin Nilsson | | low_generate(depth,
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | code[..e-1]+({
|
4da933 | 2011-04-04 | Martin Stjernholm | | sprintf("class C%d {\n%s\n};",cnt,code[e..]*"\n")
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | }),
sprintf("C%d()->%s",cnt,acc),
ans,cnt+1);
}
|
13670c | 2015-05-25 | Martin Nilsson | |
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | |
if(sscanf(acc,"%s()->%s",string classname,string rest))
{
|
13670c | 2015-05-25 | Martin Nilsson | | low_generate(depth,
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | code+({sprintf("inherit %s;",classname) }),
rest,
ans,
cnt);
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | }
}
}
|
878bf4 | 2002-05-02 | Martin Nilsson | | array(int) a()
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | {
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | int total_tests;
for(maxdepth=1;maxdepth<9 && !errors;maxdepth++)
{
low_generate(maxdepth,
({ "string X(){return \"X\";}" }),
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | "X",
"X",0);
|
8307ee | 2001-11-08 | Fredrik Hübinette (Hubbe) | |
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | total_tests+=tests;
tests=0;
}
|
13670c | 2015-05-25 | Martin Nilsson | |
|
878bf4 | 2002-05-02 | Martin Nilsson | | return ({ total_tests-errors, errors });
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | }
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | |
|
562a40 | 2000-08-06 | Fredrik Hübinette (Hubbe) | | ]])
|
1f4dbd | 2001-05-19 | Mirar (Pontus Hagland) | |
|
199425 | 1999-09-06 | Fredrik Hübinette (Hubbe) | | test_true([[Program.implements( class { int x; string y; void foo(int x) {} },
class { void foo(mixed z) {} int x; })]])
test_false([[Program.implements( class { int x; string y; void foo(int x) {} },
class { void foo(mixed z) {} string x; })]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_eq([[object_program(master())]],[[(program)"/master"]])
test_compile([[object("master") m = master();]])
|
612647 | 2000-03-02 | Fredrik Hübinette (Hubbe) | | test_any([[if(int x=1,y=2) return x;]],1)
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_any([[int x; x++; if(x) return x; return -1;]],1)
test_any([[int x; if(x) return x; return -1;]],-1)
test_any([[int x,y; if(x==y || x==1) return 2; return 0;]],2);
test_any([[int x,y; if(x==y && x==0) return 2; return 0;]],2);
test_any([[int x,y=1; if(x==y || x==1) return 2; return 0;]],0);
test_any([[int x,y=1; if(x==y && x==0) return 2; return 0;]],0);
|
96794f | 2008-03-22 | Henrik Grubbström (Grubba) | | test_any([[int x = 1; x = x + (x = 0, 1); return x;]], 2);
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | |
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | |
test_any([[
return class { int i=17; }()["i"]
]],17)
test_any([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | return class { int i=17; protected mixed `[](string foo) { return i; }}()[""]
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | ]],17)
test_any([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | return class { int i=17; protected mixed `[](string foo) { return ::`[]("i"); }}()[""]
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | ]],17)
test_any([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | return class { int i=17; protected mixed `[](string foo) { return ::`[]; }}()[""]("i")
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | ]],17)
test_any([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | return class { int i=17; protected mixed `[](string foo) { return ::`[]; }}()[""]("y")
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | ]],0)
|
686df7 | 1999-03-04 | Fredrik Hübinette (Hubbe) | | test_any([[
object o=class {
int i=17;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `[](string foo) { return ::`[]=; }
protected mixed `[]=(string ind, mixed foo) {}
|
686df7 | 1999-03-04 | Fredrik Hübinette (Hubbe) | | }();
o[""]("i",99);
return o->i;
]],99)
|
70e978 | 1999-03-06 | Fredrik Hübinette (Hubbe) | | test_any([[
object o=class {
int foo=7;
int bar=11;
int i=17;
int gazonk=12;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `[](string foo) { return ::`[]=; }
protected mixed `[]=(string ind, mixed foo) {}
|
70e978 | 1999-03-06 | Fredrik Hübinette (Hubbe) | | }();
o[""]("i",99);
return o->i;
]],99)
test_any([[
class Fonk {
int foo=1;
int bar=2;
int i=17;
int gazonk=3;
};
object o=class
{
inherit Fonk;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `[](string foo) { return ::`[]=; }
protected mixed `[]=(string ind, mixed foo) {}
|
70e978 | 1999-03-06 | Fredrik Hübinette (Hubbe) | | }();
o[""]("i",99);
return o->i;
]],99)
test_any([[
class Fonk {
int foo=1;
int bar=2;
int i=17;
int gazonk=3;
};
object o=class
{
inherit Fonk : zonk;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `[](string foo) { return zonk::`[]=; }
protected mixed `[]=(string ind, mixed foo) {}
|
70e978 | 1999-03-06 | Fredrik Hübinette (Hubbe) | | }();
o[""]("i",99);
return o->i;
]],99)
|
68cf01 | 2000-01-07 | Martin Stjernholm | | test_any([[
class A {int foo() {return bar();} int bar();};
class B {int bar() {return 1;}};
class C {inherit A; inherit B; int bar() {return B::bar();}};
return C()->foo();
]], 1)
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | test_compile_any([[
class X { void hej() {} }
class Y { inherit X:banan; void hopp() { banan::hej(); } }
]])
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | |
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | test_compile_any([[
|
35f51c | 2008-06-28 | Martin Nilsson | | class X { protected void hej() {} }
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | class Y { inherit X:banan; void hopp() { ::hej(); } }
]])
test_compile_any([[
|
35f51c | 2008-06-28 | Martin Nilsson | | class X { protected void hej() {} }
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | class Y { inherit X; void hopp() { X::hej(); } }
]])
test_compile_any([[
|
35f51c | 2008-06-28 | Martin Nilsson | | class X { protected void hej() {} }
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | class Y { public inherit X:banan; void hopp() { banan::hej(); } }
]])
test_compile_any([[
|
35f51c | 2008-06-28 | Martin Nilsson | | class X { protected void hej() {} }
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | class Y { inherit X:banan; void hopp() { banan::hej(); } }
|
91b0d9 | 2002-05-05 | Martin Stjernholm | | ]])
|
59e765 | 2002-05-11 | Martin Stjernholm | | // Testing hidden identifier lookup with ::
|
360436 | 2002-05-05 | Martin Stjernholm | |
|
91b0d9 | 2002-05-05 | Martin Stjernholm | | test_program([[
class X {
int i = 17;
class Y {
constant i = 18;
mixed f (int i) {return ({i, Y::i, X::i});}
}
}
int a() {return equal (X()->Y()->f (19), ({19, 18, 17}));}
]])
test_compile_error_any([[
class X {
constant i = 18;
mixed f() {return Y::i;}
}
]])
test_program([[
class A {
int i = 17;
}
class X {
inherit A: Y;
class Y {
constant i = 18;
mixed f() {return Y::i;}
}
}
int a() {return X()->Y()->f() == 18;}
]])
|
7245b6 | 2015-12-10 | Martin Nilsson | | ignore_warning("Attempt to override a non local variable s with a non-variable.",[[
|
91b0d9 | 2002-05-05 | Martin Stjernholm | | test_program([[
class A {
string s = "A";
}
class B {
constant s = "B";
}
class X {
constant s = "X";
inherit A;
class Y {
inherit B: A;
constant s = "Y";
mixed f() {return X::s + X::A::s + Y::s + Y::A::s + A::s;}
}
}
|
90bf26 | 2004-01-15 | Martin Nilsson | |
int a() {
return X()->Y()->f() == "XAYBB";
}
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | ]])
|
7245b6 | 2015-12-10 | Martin Nilsson | | ]])
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | |
|
f34f64 | 2002-05-05 | Martin Stjernholm | | test_program([[
class A {
string s = "A";
}
inherit A;
class X {
constant s = "X";
mixed f (string s) {return s + X::s + A::s;}
}
int a() {return X()->f("L") == "LXA";}
]])
|
59e765 | 2002-05-11 | Martin Stjernholm | | test_program([[
class A {
string f() {return "A";}
string g() {return A::f();}
}
class B {
inherit A;
string f() {return "B";}
}
int a() {return B()->g() == "B";}
]])
test_program([[
class A {
string g() {return A::f();}
string f() {return "A";}
}
class B {
inherit A;
string f() {return "B";}
}
int a() {return B()->g() == "B";}
]])
test_program([[
class A {
string f() {return "A";}
string g() {return A::f();}
}
class B {
string f() {return "B";}
inherit A;
}
int a() {return B()->g() == "B";}
]])
test_program([[
class A {
string f() {return "A";}
class I {
string g() {return A::f();}
}
}
class B {
inherit A;
string f() {return "B";}
}
int a() {return B()->I()->g() == "B";}
]])
|
f34f64 | 2002-05-05 | Martin Stjernholm | | // Testing 'global::'
|
360436 | 2002-05-05 | Martin Stjernholm | |
test_equal([[
compile_string (#"
string p = \"g\";
mixed f (string p) {return ({global::p, p});}")()->f ("l");
]], ({"g", "l"}))
|
220413 | 2015-12-10 | Martin Nilsson | | test_compile_error([[
string pp = "g";
mixed f (string p) {return global::p;}
|
360436 | 2002-05-05 | Martin Stjernholm | | ]])
test_equal([[
compile_string (#"
int x = 23;
class A {
constant x = 24;
}
inherit A;
class X {
int x = 32;
mixed f (int x) {return ({global::x, global::A::x, X::x, x});}
}")()->X()->f (33);
]], ({23, 24, 32, 33}))
|
f34f64 | 2002-05-05 | Martin Stjernholm | | // Testing 'global.'
test_compile([[
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | mixed a() {return global.Parser.HTML;}; a;
|
f34f64 | 2002-05-05 | Martin Stjernholm | | ]], 0);
test_any([[
if (!programp (Parser.HTML)) error ("This test uses the existence of Parser.HTML.\n");
return compile_string (#"
class Parser {constant HTML = 1;}
mixed foo() {return programp (Parser.HTML);}")()->foo();
]], 0);
test_any([[
if (!programp (Parser.HTML)) error ("This test uses the existence of Parser.HTML.\n");
return compile_string (#"
mixed foo() {return programp (Parser.HTML);}
class Parser {constant HTML = 1;}")()->foo();
]], 0);
test_any([[
if (!programp (Parser.HTML)) error ("This test uses the existence of Parser.HTML.\n");
return compile_string (#"
class Parser {constant HTML = 1;}
mixed foo() {return programp (global.Parser.HTML);}")()->foo();
]], 1);
test_any([[
if (!programp (Parser.HTML)) error ("This test uses the existence of Parser.HTML.\n");
return compile_string (#"
mixed foo() {return programp (global.Parser.HTML);}
class Parser {constant HTML = 1;}")()->foo();
]], 1);
|
07d3f2 | 1999-04-08 | Fredrik Hübinette (Hubbe) | | // testing virtual overloading
test_any([[
class fnord
{
int ber() { return 1; }
int goo() { return ber(); }
};
class blorg
{
inherit fnord;
int ber() { return 2; }
};
return blorg()->goo();
]],2)
// testing 'local'
test_any([[
class fnord
{
local int ber() { return 1; }
int goo() { return ber(); }
};
class blorg
{
inherit fnord;
int ber() { return 2; }
};
return blorg()->goo();
]],1)
|
f7d431 | 2000-06-21 | Henrik Grubbström (Grubba) | | // testing 'local::'
test_any([[
class fnord
{
int ber() { return 1; }
int goo() { return local::ber(); }
};
class blorg
{
inherit fnord;
int ber() { return 2; }
};
return blorg()->goo();
]],1)
|
4a906f | 2000-06-22 | Henrik Grubbström (Grubba) | | test_any([[
class fnord
{
int ber() { return 1; }
int goo() { return local::ber()+ber(); }
};
class blorg
{
inherit fnord;
int ber() { return 2; }
};
return blorg()->goo();
]],3)
test_any([[
class fnord
{
int ber() { return 1; }
int goo() { return ber()+local::ber(); }
};
class blorg
{
inherit fnord;
int ber() { return 2; }
};
return blorg()->goo();
]],3)
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | |
|
934a66 | 2002-09-21 | Martin Stjernholm | | test_compile_error_any([[class X {int x; int f() {return local::x;}}]])
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | // Testing the 'inline' keyword
|
31e0d3 | 1998-01-29 | Fredrik Hübinette (Hubbe) | | test_program([[class foo { inline int c() { return time(); } int d() { return c(); } }; class bar { inherit foo; int c() { return 0; } } int a() { return bar()->d(); }]],0)
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | |
|
086bfa | 1998-04-09 | Fredrik Hübinette (Hubbe) | | test_compile_any([[
class top
{
class the_class
{
}
}
|
13670c | 2015-05-25 | Martin Nilsson | |
|
086bfa | 1998-04-09 | Fredrik Hübinette (Hubbe) | | class inherit_top
{
inherit top:top;
|
13670c | 2015-05-25 | Martin Nilsson | |
|
086bfa | 1998-04-09 | Fredrik Hübinette (Hubbe) | | constant top_the_class=top::the_class;
|
13670c | 2015-05-25 | Martin Nilsson | |
|
086bfa | 1998-04-09 | Fredrik Hübinette (Hubbe) | | class the_other_class
{
inherit top_the_class;
}
}
]])
|
34c76c | 1998-04-11 | Henrik Grubbström (Grubba) | |
|
3c75f3 | 2003-04-02 | Martin Stjernholm | | // Identity of nested programs.
test_program([[
class A {int i; class X {int j;};}
class B {inherit A;}
int a() {return A()->X == B()->X;}
]])
test_program([[
class A {int i; class X {int j;};}
class B {inherit A;}
int a() {return A.X == B.X;}
]])
test_program([[
class A {int i; class X {int j = i;};}
class B {inherit A;}
int a() {return A()->X != B()->X;}
]])
test_program([[
class A {int i; class X {int j = i;};}
class B {inherit A;}
int a() {return A.X == B.X;}
]])
|
34c76c | 1998-04-11 | Henrik Grubbström (Grubba) | | // Testing __INIT
test_any([[
|
bf6ea8 | 2013-08-12 | Martin Nilsson | | class X { int x = 1; int zz = 1; int zzz=8; int xx=16; };
|
c2076f | 2013-08-05 | Martin Nilsson | | class Y { int y = 2; int xx; };
class Z { inherit X; inherit Y; int z = 4; int zz = 0; int zzz; };
|
34c76c | 1998-04-11 | Henrik Grubbström (Grubba) | | object zz = Z();
|
c2076f | 2013-08-05 | Martin Nilsson | | return zz->x + zz->y + zz->z + zz->zz + zz->zzz + zz->xx;
]], 15)
|
34c76c | 1998-04-11 | Henrik Grubbström (Grubba) | |
|
bb6ffa | 2013-07-15 | Henrik Grubbström (Grubba) | | test_any([[
// Test __INIT with forward references to programs needing their parents.
class X {
program y = Y;
local class Y {
program z = y;
};
};
object x = X();
return x->y == x->Y;
]], 1)
|
a85e2f | 2006-10-28 | Henrik Grubbström (Grubba) | | // Testing getter/setters
test_any([[
// Trivial case.
class X {
int `->x() { return 5; }
};
return X()->x;
]], 5)
test_any([[
// Strange behaviour getter & setter.
class X {
int y = 2;
int `->x() { return y*3; }
void `->x=(int z) { y += z*5; }
};
X x = X();
x->x = 2;
return x->x;
]], 36)
test_any([[
// Multiple inheritance.
class X {
int y = 0;
int `->x() { return y; }
void `->x=(int z) { y = z; }
};
class Y {
inherit X:x1;
inherit X:x2;
int `->x1() { return x1::x; }
void `->x1=(int z) { x1::x = z; }
int `->x2() { return x2::x; }
void `->x2=(int z) { x2::x = z; }
};
Y y = Y();
y->x1 = 1;
y->x2 = 2;
return (y->x1 + y->x2) * y->x;
]], 6)
|
d7e1de | 2007-09-14 | Henrik Grubbström (Grubba) | | test_any([[
// Triggered fatal error "Getter/setter variable outside program!".
class X {
|
35f51c | 2008-06-28 | Martin Nilsson | | protected int xx;
|
d7e1de | 2007-09-14 | Henrik Grubbström (Grubba) | | int `->x() { return xx; }
void `->x=(int xxx) { xx = xxx; }
|
35f51c | 2008-06-28 | Martin Nilsson | | protected void create(int xxx) {
|
d7e1de | 2007-09-14 | Henrik Grubbström (Grubba) | | x = xxx;
}
};
class Y {
inherit X;
|
35f51c | 2008-06-28 | Martin Nilsson | | protected void create(int yyy) {
|
73817f | 2015-11-07 | Henrik Grubbström (Grubba) | | X::x = yyy + 2;
|
d7e1de | 2007-09-14 | Henrik Grubbström (Grubba) | | }
};
return Y(5)->x;
]], 7)
|
64523e | 2015-02-01 | Arne Goedeke | | test_any([[
// Since the addition of F_APPEND_MAPPING in set_bar below
// the setter is not being called anymore. Instead, the mapping
// _data->foo is modified in place.
class A(mapping _data) {
mapping _modified = ([]);
mixed `foo=(mixed v) {
return _modified["foo"] = v;
}
mixed `foo() {
return _data["foo"];
}
void set_bar(int v) {
this->foo += ([ "bar" : v ]);
}
};
object a = A(([ "foo" : ([]) ]));
a->set_bar(2);
return has_index(a->_modified, "foo");
]], 1)
|
55d9c9 | 2015-03-25 | Henrik Grubbström (Grubba) | | test_any([[
// Since the addition of F_APPEND_MAPPING in set_bar below
// the setter is not being called anymore. Instead, the mapping
// _data->foo is modified in place.
class A(mapping foo) {
mapping _modified = ([]);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `->=(string sym, mixed v) {
|
55d9c9 | 2015-03-25 | Henrik Grubbström (Grubba) | | return _modified[sym] = v;
}
void set_bar(int v) {
this->foo += ([ "bar" : v ]);
}
};
object a = A(([ "foo" : ([]) ]));
a->set_bar(2);
return has_index(a->_modified, "foo");
]], 1)
|
7bd436 | 2015-03-23 | Henrik Grubbström (Grubba) | | test_any([[
// Since the addition of F_APPEND_ARRAY the setter is not being
// called anymore. Instead, the array _data is modified in place.
class A(array _data) {
int counter;
void `foo=(mixed v) {
counter += !!v;
_data = v;
}
mixed `foo() {
return _data;
}
};
object a = A(({}));
for (int i = 0; i < 6; i++) {
a->foo += ({ i });
}
return a->counter;
]], 6)
test_any([[
// Since the addition of F_APPEND_ARRAY the setter is not being
// called anymore. Instead, the array _data is modified in place.
class A(array foo) {
int counter;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void `->=(string sym, mixed v) {
|
7bd436 | 2015-03-23 | Henrik Grubbström (Grubba) | | counter += !!v;
|
3abb3b | 2016-12-08 | Henrik Grubbström (Grubba) | | ::`->=(sym, v);
|
7bd436 | 2015-03-23 | Henrik Grubbström (Grubba) | | }
};
object a = A(({}));
for (int i = 0; i < 6; i++) {
a->foo += ({ i });
}
return a->counter;
]], 6)
|
bbbf5f | 2015-01-27 | Arne Goedeke | | test_any([[
// Triggered fatal since object_equal_p did not handle
// getter/setter identifier correctly
class A {
string `foo() { return "bar"; }
|
0bbb9c | 2015-01-31 | Arne Goedeke | | };
|
bbbf5f | 2015-01-27 | Arne Goedeke | |
return equal(A(), A());
]], 1)
|
a3b1dc | 2010-09-27 | Henrik Grubbström (Grubba) | | test_eval_error([[
// Triggered infinite recursion and core dump.
// cf LysLysKOM 18719518/Pike mailinglist 12047.
object o = class{}();
o->foo += "";
]])
|
9bab65 | 2007-03-20 | Henrik Grubbström (Grubba) | | test_compile_error([[
class X {
int x;
int `->x() { return 0; }
};
]])
test_compile_error([[
class X {
int `->x() { return 0; }
int x;
};
]])
test_compile_error([[
class X {
int x;
void `->x=(int z) { }
};
]])
test_compile_error([[
class X {
void `->x=(int z) { }
int x;
};
]])
test_compile_error([[
class X {
void `->x(int z) { }
};
]])
// Disabled for now.
cond([[ 0 ]], [[
test_compile_error([[
class X {
int `->x=() { }
};
]])
]])
test_compile_warning([[
class X {
|
35f51c | 2008-06-28 | Martin Nilsson | | protected int `->x() { return 0; }
|
9bab65 | 2007-03-20 | Henrik Grubbström (Grubba) | | private void `->x=(int x) { }
};
]])
test_compile_warning([[
class X {
|
35f51c | 2008-06-28 | Martin Nilsson | | protected int `->x() { return 0; }
|
9bab65 | 2007-03-20 | Henrik Grubbström (Grubba) | | void `->x=(int x) { }
};
]])
|
11762b | 2000-02-08 | Martin Stjernholm | | test_do([[
|
bcc7d6 | 2002-04-12 | Martin Nilsson | | // bug 3006
|
11762b | 2000-02-08 | Martin Stjernholm | | class X {
constant foo = Foo;
class Foo {}
|
4fefbf | 2002-05-12 | Martin Stjernholm | | void bar()
{
foo f = Foo();
}
};
]])
|
5590d7 | 2002-05-12 | Martin Stjernholm | | test_program([[
// Another variant of [bug 3006].
|
4fefbf | 2002-05-12 | Martin Stjernholm | | class X {
|
5590d7 | 2002-05-12 | Martin Stjernholm | | constant foo = Foo;
|
4fefbf | 2002-05-12 | Martin Stjernholm | | class Foo {}
|
5590d7 | 2002-05-12 | Martin Stjernholm | | }
int a() {return programp (X.foo);}
]])
cond(0,[[
test_program([[
// This shows a case when on-demand resolving is required.
class X {
constant foo = a + 1;
constant a = b + 1;
constant b = c + 1;
constant c = d + 1;
constant d = 1;
};
int a() {return X.foo == 5;}
]])
test_program([[
// Reference case for the test above.
class X {
constant d = 1;
constant c = d + 1;
constant b = c + 1;
constant a = b + 1;
constant foo = a + 1;
};
int a() {return X.foo == 5;}
]])
|
11762b | 2000-02-08 | Martin Stjernholm | | ]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_any([[
class X {
|
35f51c | 2008-06-28 | Martin Nilsson | | protected string f() { return "p"; }
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected class gazonk { protected void create() { f(); }};
protected class g { object e() { return gazonk(); }};
protected void create() { g()->e(); }}; return objectp(X()); ]],1)
|
021a2d | 2007-10-06 | Henrik Grubbström (Grubba) | | 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)
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_any([[class C { int q() { return p(); } int p() { return 17; }}; return C()->q();]],17)
test_any([[class C1 {
class D { string id() { return "foo"; } };
class Y { program YinD() { return D; }} };
class C2 { inherit C1; class D { string id() { return "bar"; } } };
return C2()->Y()->YinD()()->id()]],"bar")
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | 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;}}}()); ]])
|
675c1b | 2016-11-25 | Henrik Grubbström (Grubba) | | test_any([[class { inherit GURKA2.bar; }(); return GURKA2->c;]],17)
test_any([[class { inherit GURKA2.bar; }(); return GURKA2->c;]],34)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_do([[add_constant("GURKA2",class { int c; class bar{protected void create() { class { protected void create() {c+=17;}}(); }}}()); ]])
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | test_any([[class { inherit GURKA2.bar; }(); return GURKA2->c;]],17)
test_any([[class { inherit GURKA2.bar; }(); return GURKA2->c;]],34)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | test_do([[add_constant("GURKA2");]]);
|
35f51c | 2008-06-28 | Martin Nilsson | | test_eq(class { protected int foo=17; }()->foo,0)
test_eval_error(class c { protected int foo=17; }()->foo=18;)
|
de2a58 | 1997-09-28 | Fredrik Hübinette (Hubbe) | | test_equal( [[ ({ (["foo":"bar"]), (<"foo">), ([]) })->foo ]], [[ ({"bar",1,0}) ]])
|
fc3345 | 1997-10-02 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a=({([]),0}); a[1]=a; return a->foo[0];]],0)
|
2c24a6 | 1997-10-07 | Fredrik Hübinette (Hubbe) | | test_eval_error([[return column(({0}),"foo");]])
|
284c36 | 1997-09-15 | Fredrik Hübinette (Hubbe) | |
|
bb0f71 | 2016-11-29 | Martin Nilsson | | test_equal([[ ((mixed)({ }))->foo ]], ({ }))
test_compile_error([[ ({})->foo; ]])
|
b3776a | 2016-11-05 | Arne Goedeke | | test_equal([[ `->(({ }), "foo") ]], ({ }))
|
bb0f71 | 2016-11-29 | Martin Nilsson | | test_equal([[ ((mixed)({ }))["foo"] ]], ({ }))
test_compile_error([[ ({})["foo"]; ]])
|
b3776a | 2016-11-05 | Arne Goedeke | |
|
3b9009 | 1998-02-11 | Henrik Grubbström (Grubba) | | test_any([[
class A { constant a=0; int foo() { return a; } };
class B { inherit A; constant a=1; };
return B()->foo(); ]], 1)
|
2d9cbe | 1997-09-08 | Fredrik Hübinette (Hubbe) | | test_any([[
class p1 { int foo() { return 1; }};
|
7fda7a | 1997-09-08 | Fredrik Hübinette (Hubbe) | | class p2 { int foo() { return 3; }};
|
2d9cbe | 1997-09-08 | Fredrik Hübinette (Hubbe) | | class c1 { inherit p1; inherit p2; int foo() { return p1::foo()+p2::foo(); }};
|
7fda7a | 1997-09-08 | Fredrik Hübinette (Hubbe) | | class c2 { inherit c1; }; return c2()->foo();]],4)
test_any([[
class p1 { int foo() { return 1; } };
class p2 { int foo() { return 2; } };
class c1 { inherit p1; inherit p2; };
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | return c1()->foo();]],2)
|
7fda7a | 1997-09-08 | Fredrik Hübinette (Hubbe) | |
|
345f10 | 1998-11-06 | Fredrik Hübinette (Hubbe) | | test_any([[
mixed ret=({});
int a, b = 3;
for (a = 0; a < b; a++) {
ret+=({a,b});
if (a % 2) b += 1;
}
return equal(ret,({0,3,1,3,2,4,3,4,4,5}));
]],1)
test_any([[
mixed ret=({});
int a, b = 3;
for (a = 0; a < b; a++) {
ret+=({a,b});
if (a % 2) b ++;
}
return equal(ret,({0,3,1,3,2,4,3,4,4,5}));
]],1)
test_any([[
mixed ret=({});
int a, b = 3;
for (a = 0; a < b; a++) {
ret+=({a,b});
if (a % 2) b=b+1;
}
return equal(ret,({0,3,1,3,2,4,3,4,4,5}));
]],1)
test_any([[
mixed ret=({});
int a, b = 3;
for (a = 0; a < b; a++) {
ret+=({a,b});
if (a % 2) b-=-1;
}
return equal(ret,({0,3,1,3,2,4,3,4,4,5}));
]],1)
|
097e3d | 1998-02-27 | Fredrik Hübinette (Hubbe) | | test_compile_error([[void foo() { 1++; }]])
|
f960bd | 2015-07-31 | Martin Nilsson | | dnl test_compile_error([[void foo() { return destruct(this); }]])
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | test_any([[class foo { constant x=17; }; class bar { inherit foo; constant x=18; }; return bar()->x;]],18)
|
419fab | 1997-03-09 | Fredrik Hübinette (Hubbe) | | test_program([[inline string foo(string s){ while(s[0] == ' ' || s[0] == '\t') s = s[1..]; return(s); } string a() { return foo(" bar"); }]])
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | |
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | |
// lambda function tests
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | test_true([[lambda(int x) { return lambda() { return x; };}]])
test_eq([[lambda(int x) { return lambda() { return x; };}(4)()]],4)
test_eq([[lambda(int x) { return lambda() { return x; };}(17)()]],17)
test_eq([[lambda(int x) { return lambda() { return lambda() { return x; };};}(17)()()]],17)
|
ea1368 | 2003-01-15 | Martin Stjernholm | | // trampoline tests
test_do([[{
function trampoline =
lambda() {
int i = 17;
return lambda () {
error ("Trampoline called.\n");
return i;
};
}();
// Now find the trampoline object. Pike tries very hard to hide
|
77c6b3 | 2003-02-13 | Martin Stjernholm | | // it, so we have to do it the hard way..
|
ea1368 | 2003-01-15 | Martin Stjernholm | | object obj;
find_trampoline_object: {
|
beedd7 | 2015-03-16 | Martin Nilsson | | for (obj = Debug.next_object();
|
77c6b3 | 2003-02-13 | Martin Stjernholm | | objectp (obj) || // It's a normal object.
(intp (obj) && obj); // It's a bignum object.
|
beedd7 | 2015-03-16 | Martin Nilsson | | obj = Debug.next_object (obj))
|
ea1368 | 2003-01-15 | Martin Stjernholm | | if (obj->`() == trampoline) break find_trampoline_object;
error ("Trampoline object not found.\n");
}
if (!obj) error ("Trampoline object false.\n");
if (!stringp (sprintf ("%O", obj)))
// The important part is to try to call the _sprintf lfun in the
// trampoline object, not to check what sprintf() returns.
error ("Failed to describe trampoline object.\n");
}]])
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | // local function tests
|
e391b7 | 2000-03-07 | Fredrik Noring | | test_eq(120,
|
662a90 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | [[ lambda()
|
e391b7 | 2000-03-07 | Fredrik Noring | | {
int f(int i) { return i == 0 ? 1 : i*f(i-1); };
return f(5);
|
662a90 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | }(); ]])
|
13670c | 2015-05-25 | Martin Nilsson | |
|
36e93d | 1999-08-03 | Fredrik Noring | | test_eq([[function f;
for(int i = 0; i < 2; i++)
{ {int _i = i; f = lambda(int j) { return _i+j; }; } }
return f(17);]],
[[function f;
for(int i = 0; i < 2; i++)
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | { {int _i = i; f = lambda(int j) { return _i+j; }; } int FEL; FEL; }
|
36e93d | 1999-08-03 | Fredrik Noring | | return f(17);]]);
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | test_any([[
int x,y,z;
function p;
void foo() { y+=7; };
void bar()
{
foo();
void gazonk()
{
foo();
void quux()
{
foo();
y+=4711;
};
p=quux;
};
gazonk();
gazonk();
};
foo();
bar();
p();
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | return y; x; z;
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | ]], 7 * 5 + 4711 )
|
71bde8 | 2001-03-16 | Fredrik Hübinette (Hubbe) | |
|
1b5405 | 2001-06-11 | Henrik Grubbström (Grubba) | | test_any([[
int x=1;
void for10(function f) { for(int e=0;e<10;e++) f(); };
for10(lambda() { x++; });
return x;
]], 11)
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | // implicit lambda tests
|
71bde8 | 2001-03-16 | Fredrik Hübinette (Hubbe) | | test_any([[
int x=1;
void for10(function f) { for(int e=0;e<10;e++) f(); };
|
74d75d | 2002-09-16 | Marcus Comstedt | | for10() { x++; };
|
71bde8 | 2001-03-16 | Fredrik Hübinette (Hubbe) | | return x;
]], 11)
|
74d75d | 2002-09-16 | Marcus Comstedt | | test_compile_error([[
int x=1;
void for10(function f) { for(int e=0;e<10;e++) f(); };
for10() { x++; }
return x;
]])
|
43acdb | 2001-03-20 | Henrik Grubbström (Grubba) | | test_any([[
int x;
for(int i=5; i < 10; i++) x++;
return x;
]], 5)
|
f960bd | 2015-07-31 | Martin Nilsson | | test_true([[lambda(function f) {return 1;}(this_program);]])
|
2898e6 | 2001-08-02 | Fredrik Hübinette (Hubbe) | | test_any([[
function my_lambda;
{
string foo = "foo", bar = "bar";
my_lambda = lambda() { return foo; };
}
int really_magic_var;
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | return my_lambda(); really_magic_var;
|
2898e6 | 2001-08-02 | Fredrik Hübinette (Hubbe) | | ]],"foo")
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_eq([[class { protected int `()(){ return 4711; } }()(); ]],4711)
|
034fb9 | 1997-02-24 | Fredrik Hübinette (Hubbe) | | teste_eval_error(mixed foo=({}); sort(@foo); )
test_compile_error([[int foo() { return 1} ; constant foo=(["foo":foo]); return foo->foo();]])
|
febbc8 | 1997-04-22 | Fredrik Hübinette (Hubbe) | | test_compile_error([[class T{void p(object e,object f){lambda::create(f);}}]])
|
18cfc1 | 2002-05-24 | Martin Nilsson | | test_eval_error(array foo=({}); return mkmapping(foo,({1})); )
|
0a6ffb | 1997-02-13 | Fredrik Hübinette (Hubbe) | | test_compile_error([[mapping (string:array(string:string)) foo=([]); ]])
test_compile_error([[int a() { switch(random(2)) { case 3: if(random(2)) { case 0: return 1; } else { case 1: return 2; } } }]])
|
5b4303 | 1997-01-27 | Fredrik Hübinette (Hubbe) | | test_true(encode_value(0)[0]=='\266')
|
2d8c5d | 2000-03-26 | Martin Stjernholm | | define(test_encode, [[ test_equal($1, decode_value(encode_value($1)))
test_equal($1, decode_value(encode_value_canonic($1))) ]])
|
a99145 | 1997-07-08 | Fredrik Hübinette (Hubbe) | | test_eq(replace("foobar","","X"),"fXoXoXbXaXr")
|
5b4303 | 1997-01-27 | Fredrik Hübinette (Hubbe) | | test_encode(0)
test_encode("")
test_encode(0.0)
test_encode(1.0)
|
bc86b3 | 1997-10-19 | Fredrik Hübinette (Hubbe) | | test_encode(-1.0)
|
5b4303 | 1997-01-27 | Fredrik Hübinette (Hubbe) | | test_encode(12.0)
test_encode(100000.0)
|
f09afa | 2000-10-21 | Henrik Grubbström (Grubba) | | test_encode(3.1875)
|
bcc8af | 2000-10-21 | Henrik Grubbström (Grubba) | | test_encode(0.0000019073486328125)
|
5b4303 | 1997-01-27 | Fredrik Hübinette (Hubbe) | | test_encode(({}))
|
ab18db | 2008-02-25 | Per Hedbor | | // This should work both with and without bignums.
test_encode(({0xffffffff+1, 0xffffffff+2}))
|
5b4303 | 1997-01-27 | Fredrik Hübinette (Hubbe) | | test_encode(([]))
test_encode("foobar")
test_encode((<>))
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | test_encode("\7")
test_encode("\77")
test_encode("\777")
test_encode("\7777")
test_encode("\77777")
test_encode("\777777")
test_encode("\7777777")
test_encode("\77777777")
|
2d8c5d | 2000-03-26 | Martin Stjernholm | | test_encode(({"en","sv","de"}))
test_encode((<"en","sv","de">))
test_encode((["en":1,"sv":2,"de":3]))
|
bcc8af | 2000-10-21 | Henrik Grubbström (Grubba) | | test_encode(({"s",1,0,-3.40625}))
test_encode((<"s",1,0,-3.40625>))
test_encode((["s":1,1:2,0:3,-3.40625:4]))
|
523cfb | 2000-08-18 | Henrik Grubbström (Grubba) | | test_encode((<1, 2, 2, 3, 3, 3>))
|
5b4303 | 1997-01-27 | Fredrik Hübinette (Hubbe) | | test_eq(decode_value("\210\201"),1)
test_eq(decode_value("\210\011\001"),-1)
test_eq(decode_value("\206\200"),""))
test_equal(decode_value("\200\200"),({}))
test_equal(decode_value("\206\206\146\157\157\142\141\162"),"foobar")
test_any([[mixed a=({0}); a[0]=a; return equal(a, decode_value(encode_value(a)));]], 1)
test_any([[ int e; for(e=0;e<100000;e+=1+(e>>4)) if(decode_value(encode_value(e))!=e) return e; return -1;]], -1)
test_any([[ int e; for(e=0;e<100000;e+=1+(e>>4)) if(decode_value(encode_value(-e))!=-e) return e; return -1;]], -1)
|
be1daa | 1999-11-15 | Henrik Grubbström (Grubba) | | test_eval_error([[return decode_value("\266ke0\241\346abc\b&\346de~\200\335\1\362PO\35\242")]])
test_eval_error([[return decode_value("\266ke0\241\346abcpf\221\337v\37\224")]])
test_eval_error([[return decode_value("\266ke0\241\346abc\b&\346def`\266\212\340\337\b\252\b")]])
test_eval_error([[return decode_value("\266ke0\241\346abc\b&\346def`\266\264\22\330\207")]])
test_eval_error([[return decode_value("\266ke0\241\262\266\216\213{@\333|")]])
test_eval_error([[return decode_value("\266ke0\241\346a\211[\266SN\313\331")]])
test_eval_error([[return decode_value("\266ke0\241\346ab-\266""6\227}u\320\274\251\211")]])
test_eval_error([[return decode_value("\266ke0\241\346abc\b&\346de\276\266\364\30\251s\233UF\362")]])
test_eval_error([[return decode_value("\266ke0\241\346abcv\22C\246\264\264L" )]])
test_eval_error([[return decode_value("\266ke0\241\260\303\rl")]])
|
ab01ea | 1999-09-21 | Fredrik Hübinette (Hubbe) | |
|
2d8c5d | 2000-03-26 | Martin Stjernholm | | test_equal(encode_value_canonic ((["en":1,"sv":2,"de":3])),
encode_value_canonic ((["en":1,"de":3,"sv":2])))
test_equal(encode_value_canonic ((["en":1,"sv":2,"de":3])),
encode_value_canonic ((["de":3,"sv":2,"en":1])))
test_equal(encode_value_canonic ((["en":1,"sv":2,"de":3])),
encode_value_canonic ((["sv":2,"en":1,"de":3])))
test_equal(encode_value_canonic ((<"en","sv","de">)),
encode_value_canonic ((<"en","de","sv">)))
test_equal(encode_value_canonic ((<"en","sv","de">)),
encode_value_canonic ((<"de","sv","en">)))
test_equal(encode_value_canonic ((<"en","sv","de">)),
encode_value_canonic ((<"sv","en","de">)))
|
ab01ea | 1999-09-21 | Fredrik Hübinette (Hubbe) | |
|
017674 | 2001-07-12 | Fredrik Hübinette (Hubbe) | |
test_any([[
|
a662f8 | 2002-04-15 | Martin Nilsson | | // bug 3013
|
017674 | 2001-07-12 | Fredrik Hübinette (Hubbe) | | class Test
{
class Resolver (array c)
{
mixed resolv (string id)
{
if (id == "c") return c;
}
}
class Codec
{
mixed fooof (string name) {return all_constants()[name];}
function objectof = fooof;
function functionof = fooof;
function programof = fooof;
string nameof (mixed what)
{
if (string name = search (all_constants(), what)) return name;
return ([])[0];
}
|
4f101c | 2002-05-02 | Martin Stjernholm | |
mixed encode_object (object o) {}
void decode_object (object o, mixed d) {}
|
017674 | 2001-07-12 | Fredrik Hübinette (Hubbe) | | }
mixed main()
{
array c = ({"subres"});
object o = compile (
|
f65286 | 2007-04-07 | Henrik Grubbström (Grubba) | | #"string res() {return `+(@((array(function(:string)))c)());}
|
017674 | 2001-07-12 | Fredrik Hübinette (Hubbe) | | string subres() {return \"foo\";}",
Resolver (c))();
for (int i = 0; i < sizeof (c); i++)
if (stringp (c[i])) c[i] = o[c[i] ];
#ifdef DEBUG
#define D ,1
#else
#define D
#endif
function e=encode_value;
function d=decode_value;
return d (e (o, Codec() D), Codec() D)->res();
}
};
return Test()->main();
]],"foo")
|
3b8c9b | 2001-07-15 | Fredrik Hübinette (Hubbe) | | test_any([[
|
a662f8 | 2002-04-15 | Martin Nilsson | | // bug 3014
|
3b8c9b | 2001-07-15 | Fredrik Hübinette (Hubbe) | | class Test
{
class Codec
{
mixed nameof (mixed what)
{
return ([])[0];
}
|
4f101c | 2002-05-02 | Martin Stjernholm | | mixed encode_object (object o) {}
void decode_object (object o, mixed d) {}
|
3b8c9b | 2001-07-15 | Fredrik Hübinette (Hubbe) | | }
int main()
{
object o = compile_string (#"
constant x = ({0});
int f() {return 17;}
|
f65286 | 2007-04-07 | Henrik Grubbström (Grubba) | | int g() {return ((array(function(:int)))x)[0]();}
|
3b8c9b | 2001-07-15 | Fredrik Hübinette (Hubbe) | | ")();
o->x[0] = o->f;
function e=encode_value;
function d=decode_value;
o = d (e (o, Codec()), Codec());
return function_object (o->x[0]) == o;
}
};
return Test()->main();
]],1);
|
7961fb | 1997-10-10 | Fredrik Hübinette (Hubbe) | | 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);
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_any([[float p=2.0; p--; return p;]],1.0)
test_any([[float p=2.0; return --p;]],1.0)
|
9bb90a | 2014-12-05 | Henrik Grubbström (Grubba) | | test_any([[mapping m=([0:2]); m[0]++; return m[0]++;]], 3);
test_any([[mapping m=([0:2]); ++m[0]; return ++m[0];]], 4);
test_any([[mapping m=([0:2]); m[0]--; return m[0]--;]], 1);
test_any([[mapping m=([0:2]); --m[0]; return --m[0];]], 0);
|
5b4303 | 1997-01-27 | Fredrik Hübinette (Hubbe) | |
|
0db1d1 | 2016-10-25 | Henrik Grubbström (Grubba) | | test_any_equal([[
// Test that the type fields are cleared when the mapping is cleared.
mapping m = (["a":"a"]);
m_delete(m, "a");
return m;
]], ([]))
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | | test_compile_error(int foo() { LJjjjjJJJ ; })
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | test_true(class { constant i=1; }()->i)
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | 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")
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | |
|
849cfb | 2008-12-13 | Martin Nilsson | | test_do([[
#pragma strict_types
class A { int a; optional int x; };
class B { int a; };
A a = B();
return a;
]])
test_compile_error_any([[
#pragma strict_types
class A { int a; optional int x; };
class B { int b; };
A a = B();
return a;
]])
|
21b2c9 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | test_eq((["static":42])->static,42)
|
35f51c | 2008-06-28 | Martin Nilsson | | test_eq((["protected":42])->protected,42)
|
21b2c9 | 1999-12-17 | Fredrik Hübinette (Hubbe) | |
|
086bfa | 1998-04-09 | Fredrik Hübinette (Hubbe) | | test_compile_any(class A {}; class B { inherit A; })
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | |
|
6bd4cc | 2004-05-28 | Henrik Grubbström (Grubba) | | test_any([[
// Check that indexing of objects works as expected.
object m = master();
array(mixed) val = values(m);
foreach(indices(m); int i; string ind) {
if (m[ind] != val[i]) {
error("Indexing error: master()[%O]:%O != %O.\n",
ind, m[ind], val[i]);
}
}
]], 0)
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | |
// Automap tests
test_equal([[ ({10,20})[*] + 30 ]], [[ ({40, 50}) ]])
test_equal([[ 30 + ({10,20})[*] ]], [[ ({40, 50}) ]])
test_equal([[ ({1,2})[*] + ({10,20})[*] ]], [[ ({11, 22}) ]])
test_equal([[ ({ ({10,20}), ({30,40}) })[*][*] + 5 ]],
[[ ({ ({15,25}), ({35,45}) }) ]])
test_equal([[ 5 + ({ ({10,20}), ({30,40}) })[*][*] ]],
[[ ({ ({15,25}), ({35,45}) }) ]])
test_any_equal([[
array a=({ ({10,20}), ({30,40}) });
a[*][*] += 5;
return a;
]],
[[ ({ ({15,25}), ({35,45}) }) ]])
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | test_any_equal([[
mixed a=({1,2,3});
a[*] += -2;
return a;
]], [[ ({-1,0,1}) ]])
test_any_equal([[
mixed a=({1,2,3});
a[*] += -1;
return a;
]], [[ ({0,1,2}) ]])
test_any_equal([[
mixed a=({1,2,3});
a[*] += 0;
return a;
]], [[ ({1,2,3}) ]])
test_any_equal([[
mixed a=({1,2,3});
a[*] += 1;
return a;
]], [[ ({2,3,4}) ]])
test_any_equal([[
mixed a=({1,2,3});
a[*] += 2;
return a;
]], [[ ({3,4,5}) ]])
test_any_equal([[
mixed a=({1,2,3});
return a[*] += -2;
]], [[ ({-1,0,1}) ]])
test_any_equal([[
mixed a=({1,2,3});
return a[*] += -1;
]], [[ ({0,1,2}) ]])
test_any_equal([[
mixed a=({1,2,3});
return a[*] += 0;
]], [[ ({1,2,3}) ]])
test_any_equal([[
mixed a=({1,2,3});
return a[*] += 1;
]], [[ ({2,3,4}) ]])
test_any_equal([[
mixed a=({1,2,3});
return a[*] += 2;
]], [[ ({3,4,5}) ]])
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | test_equal([[ "foo"[ ({ 2,0,1,2 })[*] ] ]],
[[ ({ 'o', 'f', 'o', 'o' }) ]])
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | test_equal([[ ({ ({1}), ({2}), ({3}) })[*][0] ]],
[[ ({ 1,2,3 }) ]])
test_equal([[ ({ ({1,2}), ({3,4}), ({5,6}) })[*][ ({0,1,1})[*] ] ]],
[[ ({ 1,4,6 }) ]])
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | // map tests
|
28d2be | 2014-08-28 | Martin Nilsson | | test_eq(map("abc", `+, 1), "bcd")
test_equal(map((["a":1,"b":2]), `+, 1), (["a":2,"b":3]))
test_equal(map((<1,2,3>), `+, 1), (<2,3,4>))
test_any_equal(class A { constant a=1; constant b=2; }; return map(A, `+ ,1);, (["a":2,"b":3]))
test_any_equal(class A { protected mixed cast(string t) { if(t=="mapping") return (["a":1,"b":2]);}}; return map(A(), `+, 1);, (["a":2,"b":3]))
test_any_equal(class A { protected mixed cast(string t) { if(t=="array") return ({1,2,3});}}; return map(A(), `+, 1);, ({2,3,4}))
test_any_equal(class A { protected mixed cast(string t) { if(t=="multiset") return (<1,2,3>);}}; return map(A(), `+, 1);, (<2,3,4>))
|
014c36 | 1999-08-17 | Martin Stjernholm | | test_any_equal(array a = ({({1,0,0}),({1,1,0}),({0,1,1})}); return map(a,`[],1);,
({0,1,1}))
test_any_equal(array a = ({({1,0,0}),({1,1,0}),({0,1,1})}); map(a,`[]=,1,0); return a;,
({({1,0,0}),({1,0,0}),({0,0,1})}))
test_any_equal(array a = ({(<1>),(<1,2>),(<2,3>),(<1,3>)}); return map(a,`[],1);,
({1,1,0,1}))
test_any_equal(array a = ({(<1>),(<1,2>),(<2,3>),(<1,3>)}); map(a,`[]=,1,0); return a;,
({(<>),(<2>),(<2,3>),(<3>)}))
test_any_equal(array a = ({(<"a">),(<"b">),(<>)}); map(a,`->=,"a",1); return a;,
({(<"a">),(<"a","b">),(<"a">)}))
test_any_equal(array a = ({([1:10]),([1:11,2:12]),([2:13])}); return map(a,`[],1);,
({10,11,0}))
test_any_equal(array a = ({([1:10]),([1:11,2:12]),([2:13])}); map(a,`[]=,1,1); return a;,
({([1:1]),([1:1,2:12]),([1:1,2:13])}))
test_any_equal(array a = ({(["a":10]),(["b":11]),([])}); map(a,`->=,"a",1); return a;,
({(["a":1]),(["a":1,"b":11]),(["a":1])}))
|
2228d5 | 1999-08-20 | Martin Stjernholm | | test_any_equal(array a = ({(["i":1]),([])}); return a["i"];,
({1,0}))
test_any_equal(array a = ({(["i":1]),([])}); a["i"] = 7; return a;,
({(["i":7]),(["i":7])}))
|
014c36 | 1999-08-17 | Martin Stjernholm | | test_any([[
|
96df32 | 2000-01-03 | Martin Stjernholm | | class A {local int i = 10; int ii(){return i;}};
|
014c36 | 1999-08-17 | Martin Stjernholm | | class B {inherit A;};
class C {inherit A; int i = 11;};
|
96df32 | 2000-01-03 | Martin Stjernholm | | array a = ({A(),B(),C()});
|
014c36 | 1999-08-17 | Martin Stjernholm | | map(a,`[]=,"i",7);
|
96df32 | 2000-01-03 | Martin Stjernholm | | return equal(a->i,({7,7,7})) && equal(a->ii(),({7,7,10}));
|
327c05 | 1999-11-24 | Fredrik Hübinette (Hubbe) | | ]],1)
|
014c36 | 1999-08-17 | Martin Stjernholm | | test_any([[
|
96df32 | 2000-01-03 | Martin Stjernholm | | class A {local int i = 10; int ii(){return i;}};
|
014c36 | 1999-08-17 | Martin Stjernholm | | class B {inherit A;};
class C {inherit A; int i = 11;};
|
96df32 | 2000-01-03 | Martin Stjernholm | | array a = ({A(),B(),C()});
|
014c36 | 1999-08-17 | Martin Stjernholm | | a->i = 7;
|
96df32 | 2000-01-03 | Martin Stjernholm | | return equal(a->i,({7,7,7})) && equal(a->ii(),({7,7,10}));
|
327c05 | 1999-11-24 | Fredrik Hübinette (Hubbe) | | ]],1)
|
014c36 | 1999-08-17 | Martin Stjernholm | | test_any([[
|
96df32 | 2000-01-03 | Martin Stjernholm | | class A {local int i = 10; int ii(){return i;}};
|
014c36 | 1999-08-17 | Martin Stjernholm | | class B {inherit A;};
class C {inherit A; int i = 11;};
|
96df32 | 2000-01-03 | Martin Stjernholm | | array a = ({A(),B(),C()});
|
014c36 | 1999-08-17 | Martin Stjernholm | | map(a,`->=,"i",7);
|
96df32 | 2000-01-03 | Martin Stjernholm | | return equal(a->i,({7,7,7})) && equal(a->ii(),({7,7,10}));
|
327c05 | 1999-11-24 | Fredrik Hübinette (Hubbe) | | ]],1)
|
014c36 | 1999-08-17 | Martin Stjernholm | | test_any_equal([[
array a = ({({(["a":"b"]),([]),(["c":17])}),({(["a":"b"]),(["a":7])}),(["b":"d"])});
a->a = 1;
return a;
]], ({({(["a":1]),(["a":1]),(["a":1,"c":17])}),
({(["a":1]),(["a":1])}),
(["a":1,"b":"d"])}))
test_any_equal([[
array a = ({({(["a":"b"]),([]),(["c":17])}),({(["a":"b"]),(["a":7])}),(["b":"d"])});
map(a,`->=,"a",1);
return a;
]], ({({(["a":1]),(["a":1]),(["a":1,"c":17])}),
({(["a":1]),(["a":1])}),
(["a":1,"b":"d"])}))
|
28d2be | 2014-08-28 | Martin Nilsson | |
|
469b53 | 2000-01-19 | Martin Stjernholm | | test_any_equal([[
/* This test tests a wild program pointer in the object o. The bug can trig
a coredump in a later test. */
class A {
array a = ({1});
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void `->= (string var, mixed val) {::`->= (var, val);}
|
469b53 | 2000-01-19 | Martin Stjernholm | | };
class B {
inherit A;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void `->= (string var, mixed val) {if (var) ::`->= (var, val);}
|
469b53 | 2000-01-19 | Martin Stjernholm | | };
object o = B();
o->a += ({2});
return o->a;
]], ({1,2}))
|
6168ce | 2000-01-27 | Fredrik Hübinette (Hubbe) | |
|
469b53 | 2000-01-19 | Martin Stjernholm | | test_any_equal([[
class A {
array a = ({1});
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void `->= (string var, mixed val) {::`->= (var, val);}
|
469b53 | 2000-01-19 | Martin Stjernholm | | };
class B {
inherit A;
};
object o = B();
o->a += ({2});
return o->a;
]], ({1,2}))
|
6168ce | 2000-01-27 | Fredrik Hübinette (Hubbe) | | test_any_equal([[
class A {
array a = ({1});
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | // protected void `->= (string var, mixed val) {::`->= (var, val);}
|
6168ce | 2000-01-27 | Fredrik Hübinette (Hubbe) | | };
class B {
int z;
inherit A;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void `->= (string var, mixed val) { A::`->= (var, val);}
|
6168ce | 2000-01-27 | Fredrik Hübinette (Hubbe) | | };
object o = B();
o->a += ({2});
return o->a;
]], ({1,2}))
test_any_equal([[
class FOO
{
int q,w,z;
};
class A {
array a = ({1});
};
class B {
inherit FOO;
int b,c,d,e,f,g;
inherit A;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void `->= (string var, mixed val) { A::`->= (var, val);}
|
6168ce | 2000-01-27 | Fredrik Hübinette (Hubbe) | | };
object o = B();
o->a += ({2});
return o->a;
]], ({1,2}))
test_any_equal([[
class A {
array a = ({1});
};
class B {
int z;
inherit A : FNORD;
class Q
{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed `-> (string var)
|
6168ce | 2000-01-27 | Fredrik Hübinette (Hubbe) | | {
return FNORD::`-> (var);
}
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void `->= (string var, mixed val)
|
6168ce | 2000-01-27 | Fredrik Hübinette (Hubbe) | | {
FNORD::`->= (var, val);
}
}
};
object o = B();
object o2=o->Q();
o2->a += ({2});
return o->a;
]], ({1,2}))
|
ef0a50 | 2001-09-23 | Mirar (Pontus Hagland) | |
|
23d1c7 | 2000-09-30 | Martin Stjernholm | | dnl // Undefined behaviour, don't do this - Hubbe
|
bb4e05 | 2000-02-11 | Fredrik Hübinette (Hubbe) | | dnl test_any_equal([[
dnl class A {
dnl array a = ({1});
dnl void `->= (string var, mixed val) {::`->= (var, val); a += ({17});}
dnl };
dnl class B {
dnl inherit A;
dnl };
dnl object o = B();
dnl o->a += ({2});
dnl return o->a;
dnl ]], ({1,2,17}))
|
00689d | 2000-02-10 | Martin Stjernholm | |
cond(0,[[
dnl This test is not really right, since ::`->= is defined to look up
dnl statically. Still, a variant of ::`->= that does a low-level dynamic
dnl lookup instead would be really useful in cases like this.
test_any_equal([[
class A {
int f;
void `->= (string var, mixed val) {::`->= (var, val); f = 17;}
};
class B {
inherit A;
array a = ({1});
};
object o = B();
o->a += ({2});
return o->a + ({o->f});
]], ({1,2,17}))
]])
|
8e9fdf | 1996-12-04 | Fredrik Hübinette (Hubbe) | | test_true(mappingp(_memory_usage()))
|
dc3883 | 2006-09-04 | Martin Nilsson | | test_any([[
int ret = 1;
foreach(_memory_usage(); string type; int value)
if(value<0)
{
werror("_memory_usage()->%s has value %d which is <0\n",
type, value);
ret = 0;
}
return ret;
]],1)
|
8e9fdf | 1996-12-04 | Fredrik Hübinette (Hubbe) | |
|
2898e6 | 2001-08-02 | Fredrik Hübinette (Hubbe) | | test_any([[
object q=class {}();
|
f960bd | 2015-07-31 | Martin Nilsson | | object o=Debug.next(this);
|
5c4aa9 | 2015-03-16 | Martin Nilsson | | while(zero_type(o)) o=Debug.next(o); /* skip destructed */
|
2898e6 | 2001-08-02 | Fredrik Hübinette (Hubbe) | | catch { if(objectp(o) || object_program(o)) return 1; };
|
f960bd | 2015-07-31 | Martin Nilsson | | o=Debug.prev(this);
|
5c4aa9 | 2015-03-16 | Martin Nilsson | | while(zero_type(o)) o=Debug.prev(o); /* skip destructed */
|
2898e6 | 2001-08-02 | Fredrik Hübinette (Hubbe) | | catch { if(objectp(o) || object_program(o)) return 1; };
|
13670c | 2015-05-25 | Martin Nilsson | | return 0;
|
2898e6 | 2001-08-02 | Fredrik Hübinette (Hubbe) | | ]],1)
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_any([[object(Stdio.File) o=Stdio.File(); return objectp(o);]],1)
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | test_any([[class Test {}; object(Test) o=Test(); return object_program(o);]],Test)
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_define_program(test,[[constant foo = 1; int a() { return foo; }]])
|
2aeef5 | 2002-11-26 | Martin Nilsson | | test_true(test()->a())
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | 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; )
|
2aeef5 | 2002-11-26 | Martin Nilsson | | test_do(add_constant("test");)
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | |
test_any([[
|
b9836b | 2001-07-05 | Fredrik Hübinette (Hubbe) | | /* don't save parent */
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | class Foo { };
|
c3b564 | 2003-01-09 | Henrik Grubbström (Grubba) | | return (!function_object(object_program(Foo()))) &&
(function_program(object_program(Foo())) ==
|
f960bd | 2015-07-31 | Martin Nilsson | | this_program);
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | ]], 1)
test_any([[
class Foo { };
|
dfaacc | 2009-02-21 | Henrik Grubbström (Grubba) | | return function_name(object_program(Foo()));
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | ]], "Foo")
|
5a6d7d | 2001-04-10 | Fredrik Hübinette (Hubbe) | | test_any([[
int q;
return stringp(function_name( lambda() { return q; }));
]],1)
|
dfaacc | 2009-02-21 | Henrik Grubbström (Grubba) | | test_any([[
// Named lambda.
int foo(){};
return function_name(foo);
]], "foo")
test_any([[
// Named trampoline.
int q;
int foo() { return q; };
return function_name(foo);
]], "foo")
|
5a6d7d | 2001-04-10 | Fredrik Hübinette (Hubbe) | | test_any([[
int q;
return function_object( lambda() { return q; });
|
f960bd | 2015-07-31 | Martin Nilsson | | ]],[[this]])
|
13670c | 2015-05-25 | Martin Nilsson | |
|
5a6d7d | 2001-04-10 | Fredrik Hübinette (Hubbe) | |
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | test_compile([[
class {
|
f19b3f | 2016-12-01 | Henrik Grubbström (Grubba) | | class foobar {};
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | object(Stdio.File) foo = foobar();
}]])
test_compile(class { object(Stdio.File) foo=class {} ();})
test_compile_error(class { object(Stdio.File) foo = class {float is_file;} ();})
test_compile(class { object(Stdio.File) foo = class { int is_file;} ();})
test_do(class { object foo; object(Stdio.File) bar=foo; })
test_do(class { object foo; Stdio.File bar=foo; })
test_do(class { object(Stdio.File) foo; object bar=foo; })
test_do(class { Stdio.File foo; object bar=foo; })
|
2f3743 | 1996-11-25 | Fredrik Hübinette (Hubbe) | | test_any(if(int i=1) return i; return 0;,1)
test_compile(for(int i=0;i<100;i++) return 0;)
|
161582 | 2008-01-04 | Henrik Grubbström (Grubba) | | test_compile(foreach(({}),mixed i){i;})
|
9e8521 | 2008-05-18 | Henrik Grubbström (Grubba) | | test_compile(sscanf("","%O",mixed foo);foo;)
test_compile_error(sscanf("","",mixed foo);)
test_compile_error(sscanf("","%f",float))
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_compile_error(sscanf("",float))
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | |
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // ++
test_any([[int e; e++; return e;]],1)
test_any([[int e; ++e; return e;]],1)
test_any([[int e; return e++;]],0)
test_any([[int e; return ++e;]],1)
test_any([[int e; if(e++) return 0; return e;]],1)
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_any([[string e=""; e++; return e;]],"1")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// --
test_any([[int e; e--; return e;]],-1)
test_any([[int e; --e; return e;]],-1)
test_any([[int e; return e--;]],0)
test_any([[int e; return --e;]],-1)
test_any([[int e; if(e--) return 0; return e;]],-1)
|
6b3f5c | 2002-04-11 | Martin Nilsson | | test_compile_error_any(master()->add_precompiled_program(\"/test\",compile_string(\"int foo() { return 17; }\",\"62\")))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
866ee9 | 2016-01-18 | Martin Nilsson | | test_any([[function f=time; int t; foreach(allocate(1),t) f(t); return 1;]],1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_compile([[while(0)if(0)continue;else;]])
|
c05f7c | 1999-11-20 | Mirar (Pontus Hagland) | | test_compile([[do { break; } while (0);]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_program([[int b=1,c; int a() { c=b+2; return c==3; }]])
test_true([[ ("foobar"/"o") & ({ "foo" }) ]])
test_any([[ array a="foo bar"/" "; return sizeof(a & ({"foo"}))]],1)
|
323682 | 2015-11-15 | Martin Nilsson | | ifefun(_verify_internals,
|
c0988f | 1998-04-17 | Fredrik Hübinette (Hubbe) | | [[
test_do(_verify_internals())
]])
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_begin([[all_constants()->thread_create]])
|
6f6eb2 | 1996-10-05 | Fredrik Hübinette (Hubbe) | | // thread_create
test_do(thread_create(lambda() { }))
// /precompiled/mutex
|
3f8f98 | 1997-02-27 | Fredrik Hübinette (Hubbe) | | test_true(Thread.Mutex())
|
a0de78 | 1997-02-27 | Fredrik Hübinette (Hubbe) | | test_do(add_constant("_tmp_mutex",Thread.Mutex()))
|
7f15d6 | 1996-12-07 | Fredrik Hübinette (Hubbe) | | test_true(_tmp_mutex->lock())
test_true(_tmp_mutex->lock())
test_true(_tmp_mutex->trylock())
test_true(_tmp_mutex->trylock())
|
9c9ee0 | 1997-02-27 | Fredrik Hübinette (Hubbe) | | test_do(add_constant("_tmp_mutex_lock",_tmp_mutex->lock()))
|
b17d20 | 1997-09-03 | Henrik Grubbström (Grubba) | | test_true(catch(_tmp_mutex->trylock()))
|
9c9ee0 | 1997-02-27 | Fredrik Hübinette (Hubbe) | | test_do(add_constant("_tmp_mutex_lock"))
test_true(_tmp_mutex->trylock())
|
0a250e | 1996-12-07 | Fredrik Hübinette (Hubbe) | | test_do(add_constant("_tmp_mutex"))
|
d644c1 | 2009-03-15 | Martin Stjernholm | |
test_any([[
object m = Thread.Mutex();
object k = m->lock();
thread_create(lambda(object k){
sleep(10);
catch { destruct(k); };
}, k);
if (catch{
m->lock();
return 0;
}) {
return 1;
}
return 0;
]],1)
test_any([[
array data=({0,Thread.Mutex(),Thread.Mutex(),0});
data[3]=data[2]->lock();
thread_create(lambda(array data) {
object o=data[1]->lock();
destruct(data[3]);
sleep(10);
data[0]=1;
destruct(o);
},data);
object l=data[2]->lock(1);
object ll=data[1]->lock();
return data[0];
]],1)
|
5b8380 | 1997-09-09 | Fredrik Hübinette (Hubbe) | | test_any([[
|
0d6f01 | 2002-10-01 | Henrik Grubbström (Grubba) | | array data=({1, Thread.Mutex(), Thread.Condition(), 0});
object key = data[1]->lock();
for(int e=0;e<3;e++) {
data[3]++;
thread_create(lambda(array data) {
for(int e=0;e<1000;e++) {
object o=data[1]->lock();
data[0]*=2;
for(int d=0;d<5;d++) {
data[0]--;
data[0]*=2;
}
data[0]--;
destruct(o);
}
object o = data[1]->lock();
data[3]--;
data[2]->signal();
}, data);
}
while(data[3])
data[2]->wait(key);
return data[0];
]],1)
|
3e9fd3 | 2002-10-28 | Martin Stjernholm | | test_any([[
object lock = Thread.Mutex()->lock();
gc();
return objectp (lock);
]], 1)
|
6f6eb2 | 1996-10-05 | Fredrik Hübinette (Hubbe) | |
// /precompiled/condition
|
3f8f98 | 1997-02-27 | Fredrik Hübinette (Hubbe) | | test_true(Thread.Condition())
test_do(Thread.Condition()->signal())
test_do(Thread.Condition()->broadcast())
|
6f6eb2 | 1996-10-05 | Fredrik Hübinette (Hubbe) | |
|
2aeef5 | 2002-11-26 | Martin Nilsson | | test_true(objectp(Thread.Fifo()))
test_true(objectp(Thread.Queue()))
|
a0de78 | 1997-02-27 | Fredrik Hübinette (Hubbe) | |
|
3c4794 | 2008-07-24 | Henrik Grubbström (Grubba) | | // Check that Thread.Queue works on the basic level.
test_any([[
Thread.Queue q = Thread.Queue();
int to_write = 100000;
int to_read = 0;
while (to_write + to_read) {
|
e27dea | 2008-07-24 | Henrik Grubbström (Grubba) | | if (!to_write || random(4 * to_read)) {
|
3c4794 | 2008-07-24 | Henrik Grubbström (Grubba) | | int val = q->read();
|
e27dea | 2008-07-24 | Henrik Grubbström (Grubba) | | if (val != (to_write + to_read))
return val + " != " + (to_write + to_read);
|
3c4794 | 2008-07-24 | Henrik Grubbström (Grubba) | | to_read--;
} else {
q->write(to_write--);
|
e27dea | 2008-07-24 | Henrik Grubbström (Grubba) | | to_read++;
|
3c4794 | 2008-07-24 | Henrik Grubbström (Grubba) | | }
}
return 0;
]], 0)
|
d644c1 | 2009-03-15 | Martin Stjernholm | | 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)
|
dad2bb | 2001-05-15 | Mirar (Pontus Hagland) | |
dnl this will crash pike on out-of-address-space-related errors
dnl test_any([[ catch { allocate(10000,thread_create)(lambda() { sleep(1); })->wait(); } ]])
|
1943a1 | 2003-11-25 | Martin Stjernholm | |
|
6ac3cf | 2018-02-12 | Henrik Grubbström (Grubba) | | test_any_equal([[
// Check the compiler for too aggressive constant folding.
#pragma dynamic_dot
int test_thread() {
return Thread.this_thread()->id_number() ==
Thread.this_thread().id_number();
}
return ({ Thread.Thread, Thread.Thread })(test_thread)->wait();
]], ({ 1, 1 }))
|
381baa | 2011-04-02 | Henrik Grubbström (Grubba) | | cond_end // thread_create
|
52500d | 2011-04-02 | Martin Stjernholm | | cond(0, [[
|
1943a1 | 2003-11-25 | Martin Stjernholm | | test_any([[
// Test that a loop relinquishes the interpreter lock every now and then.
|
52500d | 2011-04-02 | Martin Stjernholm | | //
// This test is unfortunately disabled since it fails too often.
// The subthread does really yield in the loop, but the main
// thread, which really is waiting, fails to run. My conclusion is
// that the problem is the unreliability of th_yield() - we need
// to replace it with something else. :(
// /mast
|
e9a547 | 2010-10-26 | Martin Stjernholm | | int count, stop, fail;
Thread.thread_create (lambda() {
|
b4226f | 2011-03-30 | Henrik Grubbström (Grubba) | | int t_start = time();
// Note: We need sub-second precision.
float stop_time = 1.0 + time(t_start);
|
e9a547 | 2010-10-26 | Martin Stjernholm | | while (!stop) {
count++;
|
b4226f | 2011-03-30 | Henrik Grubbström (Grubba) | | if (time(t_start) > stop_time) {
|
e9a547 | 2010-10-26 | Martin Stjernholm | | fail = 1;
break;
}
}
});
|
1943a1 | 2003-11-25 | Martin Stjernholm | | sleep (0.1);
stop = 1;
sleep (0.1);
|
e9a547 | 2010-10-26 | Martin Stjernholm | | return fail ? -1 : count > 0;
|
1943a1 | 2003-11-25 | Martin Stjernholm | | ]], 1)
|
52500d | 2011-04-02 | Martin Stjernholm | | ]])
|
381baa | 2011-04-02 | Henrik Grubbström (Grubba) | | cond_begin([[all_constants()->thread_create]])
|
4ce3e4 | 2001-01-01 | Mirar (Pontus Hagland) | |
|
9fe0a4 | 2001-11-01 | Martin Stjernholm | | // _disable_threads
test_any([[
|
90d08a | 2001-11-01 | Martin Stjernholm | | #ifndef __NT__
// Using a named pipe here to make open() block. That doesn't exist on NT.
|
9fe0a4 | 2001-11-01 | Martin Stjernholm | | object t = class {
void log (function f, string msg)
{
#if 0
if (f == test) msg = "[T] " + msg;
else if (f == thread_disabler) msg = " " * 20 + "[D] " + msg;
else if (f == mutex_locker) msg = " " * 40 + "[L] " + msg;
|
50ab1c | 2010-07-12 | Martin Stjernholm | | log_msg (msg);
|
9fe0a4 | 2001-11-01 | Martin Stjernholm | | #endif
}
mixed err;
string fifo = "/tmp/testpipe." + getpid();
int started;
Thread.Mutex start_lock = Thread.Mutex();
Thread.Mutex locker_lock = Thread.Mutex();
Thread.Mutex locked_mutex = Thread.Mutex();
Thread.MutexKey locked_mutex_key;
void mutex_locker()
{
log (mutex_locker, "locker started\n");
started++;
Thread.MutexKey k = start_lock->lock();
k = 0;
k = locker_lock->lock();
k = 0;
log (mutex_locker, "locker running\n");
err = catch (k = locked_mutex->lock());
log (mutex_locker, "locker done, error: " + (err && describe_error (err)) + "\n");
k = 0;
}
void thread_disabler()
{
log (thread_disabler, "disabler started\n");
Thread.MutexKey locker_key = locker_lock->lock();
started++;
Thread.MutexKey k = start_lock->lock();
k = 0;
sleep (0.1);
log (thread_disabler, "disabling\n");
locker_key = 0;
// Race: Don't want mutex_locker to get the lock on locker_lock
// until we're in _disable_threads.
object disable = _disable_threads();
log (thread_disabler, "disabled\n");
sleep (0.1);
disable = 0;
log (thread_disabler, "disabler done\n");
}
void test()
{
locked_mutex_key = locked_mutex->lock();
started = 0;
Thread.MutexKey start_key = start_lock->lock();
object disabler = thread_create (thread_disabler);
object locker = thread_create (mutex_locker);
while (started < 2) sleep (0.1);
|
e9b010 | 2003-05-17 | Henrik Grubbström (Grubba) | | Process.Process writer = Process.create_process(
RUNPIKE_ARRAY + ({
|
9fe0a4 | 2001-11-01 | Martin Stjernholm | | "-e",
|
e9b010 | 2003-05-17 | Henrik Grubbström (Grubba) | | sprintf ("sleep(0.5); "
"Stdio.File f = Stdio.File(%O, \"w\"); "
"sleep(0.5); "
"f->close();", fifo)
}));
|
9fe0a4 | 2001-11-01 | Martin Stjernholm | |
log (test, "opening pipe\n");
start_key = 0;
Stdio.File f = Stdio.File (fifo, "r");
log (test, "pipe opened\n");
locked_mutex_key = 0;
f->close();
disabler->wait();
locker->wait();
writer->wait();
log (test, "test done\n");
}
}();
rm (t->fifo);
Process.system ("mkfifo " + t->fifo);
for (int i = 0; i < 5; i++) {
t->test();
if (t->err) return 0;
t->log (0, "------------\n");
}
rm (t->fifo);
|
90d08a | 2001-11-01 | Martin Stjernholm | |
#endif
|
9fe0a4 | 2001-11-01 | Martin Stjernholm | | return 1;
]], 1);
|
d0ba9c | 2008-09-09 | Martin Stjernholm | |
test_do([[
object l = _disable_threads();
Thread.thread_create (lambda () {});
destruct (l);
]])
|
9fe0a4 | 2001-11-01 | Martin Stjernholm | |
|
dde557 | 2009-03-13 | Martin Stjernholm | | test_any([[
int run = 1;
mapping(string:int) rounds = ([]);
void imutex_locker (string id)
{
while (run) {
|
5c5f5b | 2009-03-14 | Martin Stjernholm | | #ifdef __NT__
// Windows got an imutex in create_process. It doesn't have to
// be successful.
catch (Process.create_process (({""})));
#else
// Unix systems don't have an imutex in create_process, but
// they got the standard password functions.
|
dde557 | 2009-03-13 | Martin Stjernholm | | getpwuid (0);
|
5c5f5b | 2009-03-14 | Martin Stjernholm | | #endif
|
dde557 | 2009-03-13 | Martin Stjernholm | | rounds[id]++;
//werror (id);
}
};
void threads_disabler (string id)
{
while (run) {
object l = _disable_threads();
rounds[id]++;
//werror (id);
l = 0;
}
};
array(Thread.Thread) t = ({
Thread.thread_create (imutex_locker, "0"),
Thread.thread_create (imutex_locker, "1"),
Thread.thread_create (imutex_locker, "2"),
Thread.thread_create (threads_disabler, "a"),
Thread.thread_create (threads_disabler, "b"),
});
sleep (5);
run = 0;
t->wait();
//werror ("%O\n", rounds);
|
5c5f5b | 2009-03-14 | Martin Stjernholm | |
|
dde557 | 2009-03-13 | Martin Stjernholm | | return 1;
]], 1)
|
d644c1 | 2009-03-15 | Martin Stjernholm | |
|
74efe6 | 2009-09-29 | Martin Stjernholm | | test_any([[
Stdio.write_file ("testsuite_test.pike", #"\
int main()
{
Thread.Mutex m = Thread.Mutex();
Thread.MutexKey l = m->lock();
Thread.thread_create (lambda () {m->lock(); exit (0);});
call_out (destruct, 0, l);
return -1;
}");
return Process.system (RUNPIKE +" testsuite_test.pike");
]], 0)
|
d273ca | 2014-12-07 | Henrik Grubbström (Grubba) | | test_eval_error([[
Thread.thread_create(lambda(){
// NB: It's currently not possible to inhibit the
// backtrace (without messing with the master).
error("Ignore the following line.\n");
})->wait();
]])
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_end // thread_create
|
dde557 | 2009-03-13 | Martin Stjernholm | |
|
4716f0 | 2001-01-14 | Mirar (Pontus Hagland) | | cond([[0]],
[[
|
4ce3e4 | 2001-01-01 | Mirar (Pontus Hagland) | | test_any([[
// test if read() hangs when fd is closed by other thread
|
20a286 | 2001-01-01 | Mirar (Pontus Hagland) | | object f=Stdio.File();
object g=f->pipe();
|
4ce3e4 | 2001-01-01 | Mirar (Pontus Hagland) | | object t=thread_create(
lambda()
{
|
20a286 | 2001-01-01 | Mirar (Pontus Hagland) | | g->read(4);
|
4ce3e4 | 2001-01-01 | Mirar (Pontus Hagland) | | });
sleep(0.1); // yield
|
20a286 | 2001-01-01 | Mirar (Pontus Hagland) | | g->close(); // close same side of pipe as we have in read above
|
4ce3e4 | 2001-01-01 | Mirar (Pontus Hagland) | | sleep(0.1); // yield
if (!t->status()) return 0; // should be done now
|
20a286 | 2001-01-01 | Mirar (Pontus Hagland) | | // if not, there's no way to kill that thread
|
4ce3e4 | 2001-01-01 | Mirar (Pontus Hagland) | | return 1;]],1);
|
6f6eb2 | 1996-10-05 | Fredrik Hübinette (Hubbe) | | ]])
|
747bb8 | 1996-10-15 | Fredrik Hübinette (Hubbe) | |
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // m_delete
|
8d1c57 | 2000-07-11 | Fredrik Hübinette (Hubbe) | | test_any_equal([[ mapping m=([1:1]); m_delete(m,0); return m; ]],[[ ([1:1]) ]])
test_any_equal([[ mapping m=([1:1,0:3]); m_delete(m,0); return m; ]],[[ ([1:1]) ]])
test_any([[mapping a=([1:1]); return m_delete(a,1)]],1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any([[mapping m=([]); m[1]++; return m[1];]],1)
test_any([[mapping m=([1:1]); m[1]++; return m[1];]],2)
|
1d96e7 | 2003-01-15 | Martin Nilsson | | test_any([[mapping m=([1:1]); m[1]++; return m[1]++;]],2)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any([[mapping m=([]); m[1]++; m[1]++; return m[1];]],2)
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | // multiset tests
test_any([[multiset m=(<>);int e;
for(e=0;e<1000;e++) m[e]=1;
for(e=0;e<1000;e++) if(!m[e]) return e;
return -1;
]],-1)
test_any([[multiset m=(<>);int e;
for(e=0;e<1000;e++) m[e]++;
for(e=0;e<1000;e++) if(!m[e]) return e;
return -1;
]],-1)
test_any([[multiset m=(<>);int e;
for(e=0;e<1000;e++) m[e]=1;
for(e=999;e>=0;e--) if(!m[e]) return e;
return -1;
]],-1)
test_any([[multiset m=(<>);int e;
for(e=999;e>=0;e--) m[e]=1;
for(e=0;e<1000;e++) if(!m[e]) return e;
return -1;
]],-1)
test_any([[multiset m=(<>);int e;
for(e=999;e>=0;e--) m[e]=1;
for(e=999;e>=0;e--) if(!m[e]) return e;
return -1;
]],-1)
test_any([[multiset m=(<>);int e;
for(e=0;e<1000;e++) m[reverse(e)]=1;
for(e=0;e<1000;e++) if(!m[reverse(e)]) return e;
return -1;
]],-1)
test_any([[multiset m=(<>);int e;
for(e=999;e>=0;e--) m[reverse(e)]=1;
for(e=0;e<1000;e++) if(!m[reverse(e)]) return e;
return -1;
]],-1)
test_any([[multiset m=(<>);int e;
for(e=0;e<1000;e++) m[reverse(e)]=1;
for(e=0;e<1000;e++) m[reverse(e)]=0;
return sizeof(m);
]],0)
test_any([[multiset m=(<>);int e;
for(e=0;e<1000;e++) m[reverse(e)]=1;
for(e=0;e<1000;e+=2) m[reverse(e)]=0;
for(e=0;e<1000;e+=2) if(m[reverse(e)]) return e;
for(e=1;e<1000;e+=2) if(!m[reverse(e)]) return e;
return -1;
]],-1)
test_any([[multiset m=(<>);int e;
for(e=0;e<1000;e++) m[reverse(e)]=1;
for(e=0;e<1000;e++) m[reverse(e)]++;
for(e=0;e<1000;e++) if(m[reverse(e)]!=1) return e;
return -1;
]],-1)
|
2ec2c3 | 2018-12-10 | Henrik Grubbström (Grubba) | | test_any([[multiset m = (<>); int e; int f;
for (e = 0; e < 100;e++) {
for (f = e; f < 100; f++) {
m_add(m, f);
}
}
for (e = 0; e < 100; e++) {
f = -1;
while (m_delete(m, e)) f++;
if (f != e) return e;
}
return -1;
]], -1)
test_any([[multiset m = (<>); int e; int f;
for (e = 0; e < 100;e++) {
for (f = e; f < 100; f++) {
m_add(m, e);
}
}
for (e = 0; e < 100; e++) {
f = e;
while (m_delete(m, e)) f++;
if (f != 100) return e;
}
return -1;
]], -1)
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_any([[multiset m=(<>);int e;
mixed a;
a=allocate(1000);
for(e=0;e<1000;e++)
{
m[reverse(e)]=1;
a[e]=reverse(e);
}
add_constant("mtest_m",m);
add_constant("mtest_i",a);
return 1;
]],1)
|
bdba3f | 2001-06-20 | Henrik Grubbström (Grubba) | | test_any([[
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | multiset m = set_weak_flag((<>), 1);
m[1] = 1;
return sizeof(m);
]], 1)
test_true([[
multiset m = set_weak_flag((<>), 1);
m[1] = 1;
return get_weak_flag(m);
]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_eq([[sizeof(mtest_m)]],sizeof(mtest_i))
test_equal(Array.sort_array(indices(mtest_m)),Array.sort_array(mtest_i))
test_equal(mtest_m,copy_value(mtest_m))
test_any([[multiset m=(<>);int e;
mixed a;
a=allocate(100);
for(e=0;e<100;e++)
{
m[reverse(e-50)]=1;
a[e]=reverse(e-50);
if(sizeof(m)!=e+1) return e;
}
add_constant("mtest_m2",m);
add_constant("mtest_i2",a);
return -1;
]],-1)
|
562562 | 2011-03-06 | Martin Stjernholm | | test_any_equal([[
class X (float i)
{
protected int `< (X o) {return i < o->i;}
protected int id = ++all_constants()->cnt;
protected string _sprintf() {return "X(" + i + ")[" + id + "]";}
};
X x1 = X(1.0), x2 = X(1.0);
multiset m = (<x1, X(2.0), X(3.0)>);
m[x2] = 1;
add_constant ("cnt");
return ({m[x1], m[x2], m[X(0.5)]});
]], [[({1, 1, 0})]])
test_any_equal([[
class X (float i)
{
protected int `< (X o) {return i < o->i;}
protected int id = ++all_constants()->cnt;
protected string _sprintf() {return "X(" + i + ")[" + id + "]";}
};
X x1 = X(1.0), x2 = X(1.0);
multiset m = (<x1, X(2.0), X(3.0)>);
m[x2] = 1;
add_constant ("cnt");
return ({(m[x1] = 1, sizeof (m)),
(m[x2] = 1, sizeof (m)),
(m[X(0.5)] = 1, sizeof (m))});
]], [[({4, 4, 5})]])
|
b23a6d | 2012-02-20 | Martin Nilsson | | test_do(add_constant("cnt");)
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_eq([[sizeof(mtest_m2)]],sizeof(mtest_i2))
|
66ee82 | 2015-05-11 | Henrik Grubbström (Grubba) | |
test_any([[
// Test subtraction of multisets of objects.
class X(int a)
{
protected int `<(mixed o) { return objectp(o) && (a < o->a); }
protected int `==(mixed o) { return objectp(o) && (a == o->a); }
};
multiset m = (< @map(allocate(5), X) >);
return sizeof(m - (<0>));
]], 5)
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_any([[int e;multiset q=(<>),p=(<>); for(e=0;e<1000;e++) { p[reverse(e)]=1; q+=(<reverse(e)>); if(!equal(sort(indices(p)),sort(indices(q)))) return 0; } return 1;]],1)
test_equal(sort(indices(mtest_m|mtest_m2)),sort(mtest_i|mtest_i2))
test_equal(sort(indices(mtest_m&mtest_m2)),sort(mtest_i&mtest_i2))
test_equal(sort(indices(mtest_m-mtest_m2)),sort(mtest_i-mtest_i2))
test_equal(sort(indices(mtest_m^mtest_m2)),sort(mtest_i^mtest_i2))
test_equal(sort(indices(mtest_m2|mtest_m)),sort(mtest_i2|mtest_i))
test_equal(sort(indices(mtest_m2&mtest_m)),sort(mtest_i2&mtest_i))
test_equal(sort(indices(mtest_m2-mtest_m)),sort(mtest_i2-mtest_i))
test_equal(sort(indices(mtest_m2^mtest_m)),sort(mtest_i2^mtest_i))
test_do(add_constant("mtest_m"); add_constant("mtest_i"); )
test_do(add_constant("mtest_m2"); add_constant("mtest_i2"); )
|
ebb0b4 | 1998-04-29 | Fredrik Hübinette (Hubbe) | | define([[MTEST]],[[test_equal([[mkmultiset(indices(allocate($1)))]],[[mkmultiset(reverse(indices(allocate($1))))]])]])
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | |
MTEST(0)
MTEST(1)
MTEST(2)
MTEST(3)
MTEST(5)
MTEST(8)
MTEST(13)
MTEST(21)
MTEST(34)
MTEST(55)
define([[MTEST]])
|
17f2a4 | 2001-03-02 | Marcus Comstedt | | test_equal([[lambda(multiset x){return ({x[17]++,x[17]++,x[17]++});}((<>))]],
[[({0,1,1})]])
|
7f202a | 2004-06-13 | Martin Stjernholm | | test_any([[
object o1 = class{}(), o2 = class{}(), o3 = class{}();
multiset m = (<o1, o2, o3, 17>);
destruct (o1), destruct (o2), destruct (o3);
return m[17];
]], 1);
test_any_equal([[
object o1 = class{}(), o2 = class{}(), o3 = class{}();
multiset m = (<o1, o2, o3, 17>);
destruct (o1), destruct (o2), destruct (o3);
return copy_value (m);
]], (<17>));
|
fb025e | 2004-05-19 | Martin Stjernholm | | test_do([[
multiset a = copy_value ((<(<1,2,3>), ({5,4}), ([1:2]), 1, ({}), (<1,2>), "foo">));
foreach (a; mixed i;)
if (!a[i]) error ("Can't find multiset member in itself: %O\n", i);
]])
|
f8d940 | 2006-07-07 | Martin Stjernholm | | test_any_equal([[
multiset m=(<"Stone","2","%70">);
foreach(m;string k;)
{
if(k=="%70")
|
13670c | 2015-05-25 | Martin Nilsson | | {
|
f8d940 | 2006-07-07 | Martin Stjernholm | | m[k]=0;
break;
}
}
return sort ((array) (m - (<>)));
]], ({"2", "Stone"}))
|
94bf3d | 2010-10-17 | Martin Stjernholm | | test_any([[
class X (int i) {
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int `< (mixed o) {return 0;}
protected int `== (mixed o) {return 0;}
|
94bf3d | 2010-10-17 | Martin Stjernholm | | };
multiset m = (<X(2)>);
m[X(4)] = 1;
m[X(1)] = 1;
m[X(3)] = 1;
return sizeof (m);
]], 4)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // mapping tests
test_any([[mapping m=([]);int e;
for(e=0;e<1000;e++) m[e]=e;
for(e=0;e<1000;e++) if(m[e]!=e) return 0;
return 1;
]],1)
test_any([[mapping m=([]);int e;
for(e=0;e<1000;e++) m[e]=e;
for(e=999;e>=0;e--) if(m[e]!=e) return 0;
return 1;
]],1)
test_any([[mapping m=([]);int e;
for(e=999;e>=0;e--) m[e]=e;
for(e=0;e<1000;e++) if(m[e]!=e) return 0;
return 1;
]],1)
test_any([[mapping m=([]);int e;
for(e=999;e>=0;e--) m[e]=e;
for(e=999;e>=0;e--) if(m[e]!=e) return 0;
return 1;
]],1)
test_any([[mapping m=([]);int e;
for(e=0;e<1000;e++) m[reverse(e)]=e;
for(e=0;e<1000;e++) if(m[reverse(e)]!=e) return 0;
return 1;
]],1)
test_any([[mapping m=([]);int e;
for(e=999;e>=0;e--) m[reverse(e)]=e;
for(e=0;e<1000;e++) if(m[reverse(e)]!=e) return 0;
return 1;
]],1)
test_any([[mapping m=([]);int e;
for(e=0;e<1000;e++) m[reverse(e)]=e;
for(e=0;e<1000;e++) m_delete(m,reverse(e));
return sizeof(m);
]],0)
test_any([[mapping m=([]);int e;
for(e=0;e<1000;e++) m[reverse(e)]=e;
for(e=0;e<1000;e+=2) m_delete(m,reverse(e));
for(e=0;e<1000;e+=2) if(m[reverse(e)]) return 0;
for(e=1;e<1000;e+=2) if(m[reverse(e)]!=e) return 0;
return 1;
]],1)
test_any([[mapping m=([]);int e;
for(e=0;e<1000;e++) m[reverse(e)]=e;
for(e=0;e<1000;e++) m[reverse(e)]++;
for(e=0;e<1000;e++) if(m[reverse(e)]!=e+1) return 0;
return 1;
]],1)
test_any([[mapping m=([]);int e;
mixed a,b;
a=allocate(1000);
b=allocate(1000);
for(e=0;e<1000;e++)
{
m[reverse(e)]=e;
a[e]=reverse(e);
b[e]=e;
}
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | add_constant("mtest_m",m);
add_constant("mtest_i",a);
add_constant("mtest_v",b);
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | return 1;
]],1)
test_eq([[sizeof(mtest_m)]],sizeof(mtest_i))
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_equal(Array.sort_array(indices(mtest_m)),Array.sort_array(mtest_i))
test_equal(Array.sort_array(values(mtest_m)),Array.sort_array(mtest_v))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_equal(mtest_m,copy_value(mtest_m))
test_any([[int e; for(e=0;e<1000;e++) if(!equal(mtest_m[mtest_i[e] ],mtest_v[e])) return 0; return 1;]],1)
test_any([[mapping m=([]);int e;
mixed a,b;
a=allocate(100);
b=allocate(100);
for(e=0;e<100;e++)
{
m[reverse(e-50)]=e-50;
a[e]=reverse(e-50);
|
1b8b4f | 2003-11-12 | Henrik Grubbström (Grubba) | | b[e]=e-50;
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | }
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | add_constant("mtest_m2",m);
add_constant("mtest_i2",a);
add_constant("mtest_v2",b);
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | return 1;
]],1)
test_any([[int e;mapping q=([]),p=([]); for(e=0;e<1000;e++) { p[reverse(e)]=e; q+=([reverse(e):e]); if(!equal(sort(indices(p)),sort(indices(q)))) return 0; } return 1;]],1)
test_any([[mapping m=([]); m+=(["foo":"bar"]); m+=(["bar":"foo"]); m+=(["foo":"foo"]); if(sizeof(m)==3) return 1; return m["foo"]=="foo" && m["bar"]=="foo"]],1)
test_equal(sort(indices(mtest_m|mtest_m2)),sort(mtest_i|mtest_i2))
test_equal(sort(indices(mtest_m&mtest_m2)),sort(mtest_i&mtest_i2))
test_equal(sort(indices(mtest_m-mtest_m2)),sort(mtest_i-mtest_i2))
test_equal(sort(indices(mtest_m^mtest_m2)),sort(mtest_i^mtest_i2))
test_equal(sort(indices(mtest_m2|mtest_m)),sort(mtest_i2|mtest_i))
test_equal(sort(indices(mtest_m2&mtest_m)),sort(mtest_i2&mtest_i))
test_equal(sort(indices(mtest_m2-mtest_m)),sort(mtest_i2-mtest_i))
test_equal(sort(indices(mtest_m2^mtest_m)),sort(mtest_i2^mtest_i))
|
1b8b4f | 2003-11-12 | Henrik Grubbström (Grubba) | | test_equal(sort(values(mtest_m|mtest_m2)),sort(map(mtest_i|mtest_i2,mtest_m|mtest_m2)))
test_equal(sort(values(mtest_m&mtest_m2)),sort(map(mtest_i&mtest_i2,mtest_m|mtest_m2)))
test_equal(sort(values(mtest_m-mtest_m2)),sort(map(mtest_i-mtest_i2,mtest_m|mtest_m2)))
test_equal(sort(values(mtest_m^mtest_m2)),sort(map(mtest_i^mtest_i2,mtest_m|mtest_m2)))
test_equal(sort(values(mtest_m2|mtest_m)),sort(map(mtest_i2|mtest_i,mtest_m|mtest_m2)))
test_equal(sort(values(mtest_m2&mtest_m)),sort(map(mtest_i2&mtest_i,mtest_m|mtest_m2)))
test_equal(sort(values(mtest_m2-mtest_m)),sort(map(mtest_i2-mtest_i,mtest_m|mtest_m2)))
test_equal(sort(values(mtest_m2^mtest_m)),sort(map(mtest_i2^mtest_i,mtest_m|mtest_m2)))
|
e66441 | 1998-04-27 | Fredrik Hübinette (Hubbe) | | test_do(add_constant("mtest_m"); add_constant("mtest_i"); add_constant("mtest_v");)
test_do(add_constant("mtest_m2"); add_constant("mtest_i2"); add_constant("mtest_v2");)
|
ebb0b4 | 1998-04-29 | Fredrik Hübinette (Hubbe) | | define([[MTEST]],[[test_equal([[mkmapping(indices(allocate($1)),reverse(indices(allocate($1))))]],[[mkmapping(reverse(indices(allocate($1))),indices(allocate($1)))]])]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
MTEST(0)
MTEST(1)
MTEST(2)
MTEST(3)
MTEST(5)
MTEST(8)
MTEST(13)
MTEST(21)
MTEST(34)
MTEST(55)
define([[MTEST]])
|
9e6d45 | 2001-09-04 | Fredrik Hübinette (Hubbe) | | test_do([[
class X {
mapping gurka;
class Tomat
{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int `==(mixed x)
|
9e6d45 | 2001-09-04 | Fredrik Hübinette (Hubbe) | | {
/* make hash bigger */
for(int e=sizeof(gurka);e<1000;e++) gurka[e]=e;
return 0;
}
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int __hash()
|
9e6d45 | 2001-09-04 | Fredrik Hübinette (Hubbe) | | {
return 99999;
}
};
class Sallad
{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int __hash()
|
9e6d45 | 2001-09-04 | Fredrik Hübinette (Hubbe) | | {
return 99999;
}
};
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create()
|
9e6d45 | 2001-09-04 | Fredrik Hübinette (Hubbe) | | {
for(int x=1;x<255;x++)
{
gurka=([]);
for(int e=0;e<x;e++) gurka[~e]=e;
gurka[Sallad()]=-2;
gurka[Tomat()]=-3;
}
}
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | }
X();
|
9e6d45 | 2001-09-04 | Fredrik Hübinette (Hubbe) | |
]])
|
3b2cd4 | 2012-11-04 | Arne Goedeke | | test_any([[
mapping m = ([ "foo" : 1 ]);
class A {
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int __hash() { return hash_value("foo"); }
protected int `==(mixed o) { return o == "foo"; }
|
3b2cd4 | 2012-11-04 | Arne Goedeke | | };
|
dd4077 | 2016-08-18 | Martin Nilsson | | if( !m[A()] )
return (string)hash_value("foo");
return 0;
]], 0)
|
3b2cd4 | 2012-11-04 | Arne Goedeke | |
test_any([[
mapping m = ([ "foo" : 1 ]);
class A {
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int __hash() { return hash_value("foo"); }
protected int `==(mixed o) { return o == "foo"; }
|
3b2cd4 | 2012-11-04 | Arne Goedeke | | };
|
dd4077 | 2016-08-18 | Martin Nilsson | | if( sizeof(m - ([ A() : 1 ])) )
return (string)hash_value("foo");
return 0;
|
3b2cd4 | 2012-11-04 | Arne Goedeke | | ]], 0)
|
e66441 | 1998-04-27 | Fredrik Hübinette (Hubbe) | | test_equal([[ `+( ([1:2]) )]],[[ ([1:2]) ]])
test_false( `+( ([1:2]) ) == ([1:2]) )
test_equal([[ `+( ([1:2]), ([1:2]) )]],[[ ([1:2]) ]])
test_equal([[ `+( ([1:2]), ([1:2]), ([2:3,4:5]) )]],[[ ([1:2,2:3,4:5]) ]])
test_equal([[ `+( ([1:2]), ([1:2]), ([2:3,4:5]), ([6:7,1:2]) )]],[[ ([1:2,2:3,4:5,6:7]) ]])
test_equal([[ `+( ([1:2]), ([1:2]), ([2:3,4:5]), ([6:7,1:2]),([8:9]) )]],[[ ([1:2,2:3,4:5,6:7,8:9]) ]] )
test_any([[mapping m=([1:2,3:2]); return search(m,2,search(m,2))!=-1;]],1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
ee3780 | 1999-02-09 | Fredrik Hübinette (Hubbe) | | test_any([[mapping m=([]); for(int e=0;e<1000;e++) m[e&3]+=({e}); return sizeof(m)==4 && sizeof(m[0])==250;]],1)
|
958ced | 2001-01-26 | Martin Stjernholm | | test_any([[
mapping m = set_weak_flag (([1:1]), 1);
m_delete (m, 1);
return get_weak_flag (([]));
]], 0);
|
17f2a4 | 2001-03-02 | Marcus Comstedt | | test_equal([[lambda(mapping x){return ({x[17]++,x[17]++,x[17]++});}(([]))]],
[[({0,1,2})]])
|
5215a8 | 2003-06-02 | Martin Stjernholm | | test_equal([[([1:2, 3:4]) - (<0, 1, 2>)]], ([3:4]))
test_equal([[([1:2, 3:4]) - ({0, 1, 2})]], ([3:4]))
test_equal([[([1:2, 3:4]) & (<0, 1, 2>)]], ([1:2]))
test_equal([[([1:2, 3:4]) & ({0, 1, 2})]], ([1:2]))
|
639e6e | 2000-09-04 | Martin Stjernholm | | // destructed indices
test_any([[{
object o = class{}();
mapping m = ([o: 1]);
destruct (o);
return equal (m, ([])) && equal (m, ([]));
}]], 1)
test_any([[{
object o = class{}();
mapping m = ([o: 1]), n = ([class{}(): 1]);
destruct (o);
return !equal (m, n) && !equal (m, n);
}]], 1)
|
72a90c | 2000-09-23 | Martin Stjernholm | | test_any([[{
object o = class{}();
mapping m = ([o: 1]);
destruct (o);
return sizeof (indices (m)) || sizeof (m);
}]], 0)
test_any([[{
object o = class{}();
mapping m = ([o: 1]);
destruct (o);
return sizeof (values (m)) || sizeof (m);
}]], 0)
|
639e6e | 2000-09-04 | Martin Stjernholm | |
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // gc
|
44dbb6 | 2003-02-12 | Martin Stjernholm | |
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_true(intp(gc()));
|
6ea4d6 | 2008-08-23 | Martin Stjernholm | | test_true(mappingp (((function) Debug.gc_status)()))
|
d9e9bd | 1996-12-05 | Fredrik Hübinette (Hubbe) | | test_any([[ array a=({0}); a[0]=a; gc(); a=0; return gc() > 0; ]],1);
test_any([[mapping m=([]); m[m]=m; gc(); m=0; return gc() > 0; ]],1);
test_any([[multiset m=(<>); m[m]=1; gc(); m=0; return gc() > 0; ]],1);
|
5953b2 | 2000-06-10 | Martin Stjernholm | | test_any([[{
#if !constant (_debug)
int _debug (int d) {return 0;};
#endif
// Must turn off debug in this test or else we'll get extra
// references to p in the backlog.
int dlevel = _debug (0);
program p=compile_string("constant a=({0});");
object o=p();
o->a[0]=p;
gc();
p=o=0;
_debug (dlevel);
return gc() > 0;
}]], 1);
|
c023e9 | 1999-11-18 | Fredrik Hübinette (Hubbe) | |
|
14db07 | 2003-02-13 | Martin Stjernholm | | test_any([[
object o = class {function f; void foo() {}}();
o->f = o->foo;
gc();
o = 0;
return gc();
]], 0)
test_any([[
object o = class {object o;}();
o->o = o;
gc();
o = 0;
return gc();
]], 0)
test_any([[
class X {function f; void foo() {}};
object o1 = X(), o2 = X();
o1->f = o2->foo;
o2->f = o1->foo;
gc();
o1 = o2 = 0;
return gc();
]], 2)
test_any([[
class X {object o;};
object o1 = X(), o2 = X();
o1->o = o2;
o2->o = o1;
gc();
o1 = o2 = 0;
return gc();
]], 2)
|
c023e9 | 1999-11-18 | Fredrik Hübinette (Hubbe) | | test_any([[gc();
int q=lambda() { mixed foo; foo=lambda() { return foo; }; return 1; }();
return gc()>0;
]],1)
|
2db242 | 1999-10-29 | Martin Stjernholm | | test_true([[
object o = class{}();
mapping m = ([class{}(): o, o: class{}()]);
set_weak_flag (m, 1);
gc();
return !sizeof (m);
]])
|
9da7f4 | 2001-06-05 | Martin Stjernholm | | test_true([[
object o = class{}();
mapping m = ([class{}(): o, o: class{}()]);
set_weak_flag (m, Pike.WEAK_INDICES);
gc();
return sizeof (m);
]])
test_true([[
object o = class{}();
mapping m = ([class{}(): o, o: class{}()]);
set_weak_flag (m, Pike.WEAK_VALUES);
gc();
return sizeof (m);
]])
test_true([[
|
2db242 | 1999-10-29 | Martin Stjernholm | | object o = class{}();
multiset m = (<o>);
set_weak_flag (m, 1);
m[class{}()] = 1;
m[o] = 0;
gc();
return !sizeof (m);
]])
|
1f342f | 2000-02-04 | Fredrik Hübinette (Hubbe) | |
|
813164 | 2001-01-17 | Martin Stjernholm | | test_do([[
|
64621b | 2004-07-16 | Henrik Grubbström (Grubba) | | mixed eat_stack(int|void probe)
|
813164 | 2001-01-17 | Martin Stjernholm | | {
|
64621b | 2004-07-16 | Henrik Grubbström (Grubba) | | // Avoid eating as much C-stack by releasing the
// catch at every level.
if (probe) return 1;
if (catch(eat_stack(1))) return 1;
|
5f03ba | 2001-01-18 | Martin Stjernholm | | mixed err = 1;
|
64621b | 2004-07-16 | Henrik Grubbström (Grubba) | | if ((err = eat_stack()) != 10)
return intp(err) && err > 0 ? err + 1 : err;
|
5f03ba | 2001-01-18 | Martin Stjernholm | | if (err = catch {
class Foo
{
object foo;
|
35f51c | 2008-06-28 | Martin Nilsson | | protected void create(object o) {foo = o;}
|
5f03ba | 2001-01-18 | Martin Stjernholm | | };
Foo foo;
for(int i=0; i < 10000; i++)
foo = Foo(foo);
gc();
}) return err;
|
813164 | 2001-01-17 | Martin Stjernholm | | };
|
45b9cf | 2001-01-18 | Martin Stjernholm | | if (mixed err = eat_stack()) throw (err);
|
813164 | 2001-01-17 | Martin Stjernholm | | ]])
|
1f342f | 2000-02-04 | Fredrik Hübinette (Hubbe) | | test_any([[
mapping m=([]);
m->self=m;
mapping q=(["foo":"bar","gazonk":1]);
m->q=q;
q+=([]);
m=0;
gc();
return sizeof(q);
]],2)
|
3825ec | 2000-04-14 | Martin Stjernholm | |
|
297f79 | 2016-11-23 | Martin Karlgren | | test_any([[
|
3825ec | 2000-04-14 | Martin Stjernholm | | int dummy;
gc();
function f = lambda() {
object o = class{}();
int i;
return lambda() {return i;};
}();
lambda() {dummy++;}(); // Ensure refcount garbing is done.
int n = gc();
// n should be 0; o should be refcount garbed above, the frame for f
// should be intact for use below.
dummy += f();
return n;
]], 0)
|
297f79 | 2016-11-23 | Martin Karlgren | | test_any([[
// Make sure we don't get trampoline garbage with (named) lambdas
// that reference variables in the parent scope.
gc();
mapping m = ([]);
class Refcounter()
{ mapping state;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create(mapping m) { state = m; state->refs++;}
protected void _destruct() {state->refs--;}
|
297f79 | 2016-11-23 | Martin Karlgren | | };
int final_res;
function foo()
{
object refc = Refcounter(m);
final_res += m->refs; // Should add 1 here.
int i = 1;
int bar()
{
return i++;
};
return bar;
};
function bar = foo();
final_res += m->refs; // Should add 0 here.
bar();
bar = 0;
final_res += m->refs; // Should add 0 here.
final_res += gc(); // Should add 0 here.
return final_res; // 1 expected.
]], 1)
|
3825ec | 2000-04-14 | Martin Stjernholm | | test_true([[
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | class
|
3825ec | 2000-04-14 | Martin Stjernholm | | {
object c;
class A {object b;}
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class B {object a; protected void _destruct() {c = class{}();}}
|
3825ec | 2000-04-14 | Martin Stjernholm | | mixed test()
{
object a = A(), b = B();
a->b = b;
b->a = a;
a = b = 0;
gc();
return c;
}
}()->test();
]])
|
5953b2 | 2000-06-10 | Martin Stjernholm | |
test_any([[{
array a = ({({0})}); a[0][0] = a;
gc(); a = 0; return gc() > 0;
}]], 1)
|
f06dc3 | 2000-12-14 | Martin Stjernholm | | test_any([[{
object o = class {}();
mapping m = ([o: ({17})]);
gc(); destruct (o); return gc() > 0;
}]], 1)
|
5953b2 | 2000-06-10 | Martin Stjernholm | | test_any([[{
class Dead {object o;};
object o = Dead(); o->o = Dead(); o->o->o = o;
gc(); o = 0; return gc() > 0;
}]], 1)
test_any([[{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | object o = Live(); o->o = Live(); o->o->o = o;
gc(); o = 0; return gc() > 0;
}]], 1)
test_any([[{
class Dead {object o;};
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | object o = Dead(); o->o = Live(); o->o->o = o;
gc(); o = 0; return gc() > 0;
}]], 1)
test_any([[{
class Dead {object o;};
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | object o = Live(); o->o = Dead(); o->o->o = o;
gc(); o = 0; return gc() > 0;
}]], 1)
test_any_equal([[{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | array a = set_weak_flag(({Live()}), 1);
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | gc();
return set_weak_flag(a, 0);
|
5953b2 | 2000-06-10 | Martin Stjernholm | | }]], ({0}))
test_any_equal([[{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | multiset l = set_weak_flag((<Live()>), 1);
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | gc();
return set_weak_flag(l, 0);
|
5953b2 | 2000-06-10 | Martin Stjernholm | | }]], (<>))
test_any_equal([[{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | mapping m = set_weak_flag(([0: Live()]), 1);
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | gc();
return set_weak_flag(m, 0);
|
5953b2 | 2000-06-10 | Martin Stjernholm | | }]], ([]))
test_any_equal([[{
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | mapping m = set_weak_flag(([Live(): 0]), 1);
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | gc();
return set_weak_flag(m, 0);
|
5953b2 | 2000-06-10 | Martin Stjernholm | | }]], ([]))
test_any_equal([[{
array a = set_weak_flag(({4711, 0x54325827a124*0x12348795482485425}), 1);
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | gc();
return set_weak_flag(a, 0);
|
5953b2 | 2000-06-10 | Martin Stjernholm | | }]], ({4711, 0x54325827a124*0x12348795482485425}))
|
a44f1a | 2000-09-15 | Martin Stjernholm | | test_any_equal([[{
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | object o = class {
|
14db07 | 2003-02-13 | Martin Stjernholm | | array g;
|
a44f1a | 2000-09-15 | Martin Stjernholm | | array a = ({17});
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() {g = ({this});}
protected void _destruct() {all_constants()->kablutt = a;}
|
a44f1a | 2000-09-15 | Martin Stjernholm | | }();
o = 0;
gc();
return all_constants()->kablutt;
}]], ({17}));
test_any([[{
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | object o = class {
|
14db07 | 2003-02-13 | Martin Stjernholm | | array g;
|
a44f1a | 2000-09-15 | Martin Stjernholm | | array a = set_weak_flag (({({17})}), 1);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() {g = ({this});}
protected void _destruct() {
|
a44f1a | 2000-09-15 | Martin Stjernholm | | if (!equal (a, ({({17})})))
error ("Contents in weak array zapped: %O.\n", a);
}
}();
o = 0;
return gc() >= 3;
}]], 1);
test_any_equal([[{
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | object o = class {
|
14db07 | 2003-02-13 | Martin Stjernholm | | array g;
|
a44f1a | 2000-09-15 | Martin Stjernholm | | array a = set_weak_flag (({({17})}), 1);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() {g = ({this});}
protected void _destruct() {all_constants()->blatinka = a;}
|
a44f1a | 2000-09-15 | Martin Stjernholm | | }();
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}));
|
2aeef5 | 2002-11-26 | Martin Nilsson | | test_do(add_constant("kablutt");)
test_do(add_constant("blatinka");)
|
5bf37d | 2000-10-13 | Fredrik Hübinette (Hubbe) | |
|
0455ff | 2003-03-30 | Martin Stjernholm | | test_any([[{
#if constant (_debug)
// Temporarily disable debug so we don't get references to p in
// the intepreter backlog.
int old_debug = _debug (0);
#endif
object o = class {program p; object o;}();
class Resolver (mixed x) {mixed resolv (string id) {return x;}};
program p = compile ("constant o = foo;", Resolver (o));
o->p = p;
o->o = p();
gc();
o = p = 0;
#if constant (_debug)
_debug (old_debug);
#endif
return gc() > 0;
}]], 1)
|
5953b2 | 2000-06-10 | Martin Stjernholm | | 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)
test_any([[{
class Dead {object o;};
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | 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;};
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Live {object o; protected void _destruct() {}};
|
5953b2 | 2000-06-10 | Martin Stjernholm | | object o = Dead(); o->o = Live();
array a = set_weak_flag(({o}), 1);
gc(); o = 0; return gc() > 0;
}]], 1)
|
96dd6f | 2000-06-12 | Martin Stjernholm | | test_do([[{
object o = class {}();
array a = ({o});
destruct (o);
gc();
}]]);
|
6d30f5 | 2000-07-11 | Martin Stjernholm | | test_any([[{
array a = ({0}), b = ({a, set_weak_flag (({a}), 1)});
array x = set_weak_flag (({a}), 1);
a[0] = b;
a = b = 0;
gc();
return !x[0];
}]], 1);
test_any([[{
mapping a = ([]), b = ([a:set_weak_flag (([a:a]), 1)]);
mapping x = set_weak_flag (([a:2]), 1);
a[b] = b;
a = b = 0;
gc();
return !sizeof (x);
}]], 1);
test_any([[{
multiset a = (<>), b = (<a, set_weak_flag ((<a>), 1)>);
multiset x = set_weak_flag ((<a>), 1);
a[b] = 1;
a = b = 0;
gc();
return !sizeof (x);
}]], 1);
|
5bf37d | 2000-10-13 | Fredrik Hübinette (Hubbe) | |
|
6d30f5 | 2000-07-11 | Martin Stjernholm | | test_any([[{
class Foo {
|
f960bd | 2015-07-31 | Martin Nilsson | | array(Foo) f = ({this});
multiset(Foo) g = set_weak_flag((<this>), 1);
|
6d30f5 | 2000-07-11 | Martin Stjernholm | | };
multiset(Foo) x = set_weak_flag ((<Foo()>), 1);
gc();
return !sizeof (x);
}]], 1);
test_any([[{
class Foo {
|
f960bd | 2015-07-31 | Martin Nilsson | | array(Foo) f = ({this});
multiset(Foo) g = set_weak_flag((<this>), 1);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct() {add_constant("beltbent_oblivion", 1);}
|
6d30f5 | 2000-07-11 | Martin Stjernholm | | };
multiset(Foo) x = set_weak_flag ((<Foo()>), 1);
gc();
int res = all_constants()->beltbent_oblivion;
add_constant("beltbent_oblivion");
return res;
}]], 1);
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | test_any([[{
|
bc23b4 | 2003-01-11 | Martin Stjernholm | | gc();
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | array x = set_weak_flag (({0}), 1);
x[0] = x;
multiset b = set_weak_flag ((<x>), 1);
array a = ({17});
b[a] = 1;
x = 0;
|
bc23b4 | 2003-01-11 | Martin Stjernholm | | return gc() >= 1;
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | }]], 1);
test_any([[{
|
bc23b4 | 2003-01-11 | Martin Stjernholm | | gc();
|
f960bd | 2015-07-31 | Martin Nilsson | | array a = set_weak_flag (({0, this}), 1);
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | a[0] = a;
a = 0;
|
bc23b4 | 2003-01-11 | Martin Stjernholm | | return gc() >= 1;
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | }]], 1);
test_any([[{
|
bc23b4 | 2003-01-11 | Martin Stjernholm | | gc();
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | array y = set_weak_flag (({0}), 1), z = set_weak_flag (({y}), 1);
y[0] = z;
y = z = 0;
|
bc23b4 | 2003-01-11 | Martin Stjernholm | | return gc() >= 2;
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | }]], 1);
test_any([[{
class Live {
array a;
|
f960bd | 2015-07-31 | Martin Nilsson | | array g = ({this});
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create()
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | {
a = set_weak_flag (({0}), 1);
array b = set_weak_flag (({a}), 1);
a[0] = b;
}
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct()
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | {
if (!arrayp(a) || !arrayp(a[0]) || a[0][0] != a)
|
3cc12a | 2001-07-01 | Martin Stjernholm | | add_constant ("my_little_error", "GC garbed weak things too early.\n");
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | }
};
|
bc23b4 | 2003-01-11 | Martin Stjernholm | | gc();
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | object o = Live();
o = 0;
|
bc23b4 | 2003-01-11 | Martin Stjernholm | | int res = gc() >= 3;
|
3cc12a | 2001-07-01 | Martin Stjernholm | | if (all_constants()->my_little_error)
error (all_constants()->my_little_error);
return res;
|
10c4a4 | 2000-08-17 | Martin Stjernholm | | }]], 1);
|
3cc12a | 2001-07-01 | Martin Stjernholm | | test_do([[{
class Live
{
Foo f;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct()
|
3cc12a | 2001-07-01 | Martin Stjernholm | | {
if (!f->l || !f->a || !f->a[0] || !f->a[1])
add_constant ("my_little_error", "GC garbed live things.\n");
}
};
class Foo
{
int i;
class Bar
{
int j = i++; // Ensure parent pointer.
array a = ({j});
}
Live l;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create (Live _l)
|
3cc12a | 2001-07-01 | Martin Stjernholm | | {
l = _l;
|
f960bd | 2015-07-31 | Martin Nilsson | | l->f = this;
|
3cc12a | 2001-07-01 | Martin Stjernholm | | }
array a = allocate (2, Bar)();
};
object o = Foo(Live());
o = 0;
gc(), gc();
if (all_constants()->my_little_error)
error (all_constants()->my_little_error);
}]]);
|
3fe44f | 2001-07-02 | Martin Stjernholm | |
test_do([[{
object o = compile_string(#"
class Foo
{
int i;
class Bar
{
int j = i++; // Ensure parent pointer.
}
inherit Bar;
}")();
o = 0;
gc();
}]]);
|
5bf37d | 2000-10-13 | Fredrik Hübinette (Hubbe) | |
|
639e6e | 2000-09-04 | Martin Stjernholm | | test_do([[{
mapping a = ([1:({17}),2:3,4:5,6:7,8:9]), b = a + ([]);
set_weak_flag (b, 1);
gc();
}]]);
test_do([[{
mapping a = ([1:({17})]), b = a + ([]);
set_weak_flag (b, 1);
gc();
}]]);
test_any([[{
mapping a = ([17:({17})]);
for (int i = 0; i < 10; i++) a[class{}()] = i;
mapping b = a + ([]);
set_weak_flag (b, 1);
foreach (indices (a), mixed o) if (objectp (o)) destruct (o);
gc();
return sizeof (a) == 1 && sizeof (b) == 1;
}]], 1);
test_any([[{
mapping a = ([17:({17})]);
for (int i = 0; i < 10; i++) a[class{}()] = i;
mapping b = a + ([]);
set_weak_flag (a, 1);
foreach (indices (a), mixed o) if (objectp (o)) destruct (o);
gc();
return sizeof (a) == 1 && sizeof (b) == 1;
}]], 1);
test_any([[{
mapping a = ([17:({17})]);
for (int i = 0; i < 10; i++) a[class{}()] = i;
mapping b = a + ([]);
set_weak_flag (a, 1);
set_weak_flag (b, 1);
foreach (indices (a), mixed o) if (objectp (o)) destruct (o);
gc();
return !sizeof (a) && !sizeof (b);
}]], 1);
test_any([[{
|
0db376 | 2013-08-03 | Arne Goedeke | | mapping a = ([17:17]);
|
639e6e | 2000-09-04 | Martin Stjernholm | | set_weak_flag (a, 1);
for (int i = 0; i < 10; i++) a[class{}()] = i;
mapping b = a + ([]);
foreach (indices (a), mixed o) if (objectp (o)) destruct (o);
gc();
return sizeof (a) == 1 && sizeof (b) == 1;
}]], 1);
|
a44f1a | 2000-09-15 | Martin Stjernholm | | test_any([[{
mapping a = set_weak_flag (([17: set_weak_flag (({({17})}), 1)]), 1);
return gc() >= 2 && !sizeof (a);
}]], 1);
|
639e6e | 2000-09-04 | Martin Stjernholm | |
|
23d1c7 | 2000-09-30 | Martin Stjernholm | | test_any([[{
object o = class{}();
mapping a = set_weak_flag ((["foo": o]), 1);
gc();
return sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([o: o]), 1);
gc();
return sizeof (a);
}]], 1);
test_any([[{
object o1 = class{}(), o2 = class{}();
mapping a = set_weak_flag (([o1: o2]), 1);
gc();
return sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([o: o]), 1);
o = 0;
return gc() >= 1 && !sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([class{}(): o]), 1);
return gc() >= 1 && !sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([o: class{}()]), 1);
return gc() >= 1 && !sizeof (a);
}]], 1);
test_any([[{
mapping a = set_weak_flag (([class{}(): class{}()]), 1);
return gc() >= 2 && !sizeof (a);
}]], 1);
|
f06dc3 | 2000-12-14 | Martin Stjernholm | | test_any([[{
|
23d1c7 | 2000-09-30 | Martin Stjernholm | | object o = class{}();
mapping a = set_weak_flag ((["foo": o]), 1);
destruct (o);
gc();
return !sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([o: o]), 1);
destruct (o);
gc();
return !sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([class{}(): o]), 1);
destruct (o);
return gc() >= 1 && !sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([o: class{}()]), 1);
destruct (o);
return gc() >= 1 && !sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([o: o]), 0);
destruct (o);
gc();
return !sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([class{}(): o]), 0);
destruct (o);
gc();
return sizeof (a);
}]], 1);
test_any([[{
object o = class{}();
mapping a = set_weak_flag (([o: class{}()]), 0);
destruct (o);
gc();
return !sizeof (a);
}]], 1);
|
a1cf47 | 2001-07-12 | Martin Stjernholm | | test_any_equal([[{
array a = set_weak_flag (({1, "foo", 3.14}), 1);
gc();
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | return set_weak_flag(a, 0);
|
a1cf47 | 2001-07-12 | Martin Stjernholm | | }]], ({1, "foo", 3.14}));
test_any_equal([[{
multiset a = set_weak_flag ((<1, "foo", 3.14>), 1);
gc();
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | return set_weak_flag(a, 0);
|
a1cf47 | 2001-07-12 | Martin Stjernholm | | }]], (<1, "foo", 3.14>));
test_any_equal([[{
mapping a = set_weak_flag (([1: 1, "foo": "foo", 3.14: 3.14]), 1);
gc();
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | return set_weak_flag(a, 0);
|
a1cf47 | 2001-07-12 | Martin Stjernholm | | }]], ([1: 1, "foo": "foo", 3.14: 3.14]));
|
4c7c35 | 2001-10-15 | Martin Stjernholm | |
test_do([[{
object f = class
{
object o = class {}();
array a = set_weak_flag (({o}), 1);
|
f960bd | 2015-07-31 | Martin Nilsson | | object this = this;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() {destruct (o);}
|
4c7c35 | 2001-10-15 | Martin Stjernholm | | }();
f = 0;
gc();
}]]);
test_do([[{
object f = class
{
object o = class {}();
mapping m = set_weak_flag (([1:o]), 1);
|
f960bd | 2015-07-31 | Martin Nilsson | | object this = this;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() {destruct (o);}
|
4c7c35 | 2001-10-15 | Martin Stjernholm | | }();
f = 0;
gc();
}]]);
test_do([[{
object f = class
{
object o = class {}();
mapping m = set_weak_flag (([o:1]), 1);
|
f960bd | 2015-07-31 | Martin Nilsson | | object this = this;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() {destruct (o);}
|
4c7c35 | 2001-10-15 | Martin Stjernholm | | }();
f = 0;
gc();
}]]);
test_do([[{
object f = class
{
object o = class {}();
multiset m = set_weak_flag ((<o>), 1);
|
f960bd | 2015-07-31 | Martin Nilsson | | object this = this;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void create() {destruct (o);}
|
4c7c35 | 2001-10-15 | Martin Stjernholm | | }();
f = 0;
gc();
}]]);
|
5bf37d | 2000-10-13 | Fredrik Hübinette (Hubbe) | |
|
007e54 | 2003-01-28 | Marcus Comstedt | | test_tests([[inherit "]]SRCDIR[[/test_gc.pike";]])
|
46d4e7 | 2000-06-12 | Martin Stjernholm | |
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);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_do([[class bar { object foo; protected void create(void|object tmp) { foo=tmp; } };
|
46d4e7 | 2000-06-12 | Martin Stjernholm | | object o=bar(),o2=o;
for(int e=0;e<10000;e++) o=bar(o);
o2->foo=o;
o=o2=0;
gc();
]])
|
9da7f4 | 2001-06-05 | Martin Stjernholm | |
test_any([[
object o = class{}();
mapping m = set_weak_flag (([o: "x"]), Pike.WEAK_INDICES);
gc();
return sizeof (m);
]], 1)
test_any([[
object o = class{}();
mapping m = set_weak_flag (([o: "x"]), Pike.WEAK_VALUES);
gc();
return sizeof (m);
]], 1)
test_any([[
object o = class{}();
mapping m = set_weak_flag ((["x": o]), Pike.WEAK_INDICES);
gc();
return sizeof (m);
]], 1)
test_any([[
object o = class{}();
mapping m = set_weak_flag ((["x": o]), Pike.WEAK_VALUES);
gc();
return sizeof (m);
]], 1)
test_any([[
mapping m = set_weak_flag (([class{}(): "x"]), Pike.WEAK_INDICES);
gc();
return sizeof (m);
]], 0)
test_any([[
mapping m = set_weak_flag (([class{}(): "x"]), Pike.WEAK_VALUES);
gc();
return sizeof (m);
]], 1)
test_any([[
mapping m = set_weak_flag ((["x": class{}()]), Pike.WEAK_INDICES);
gc();
return sizeof (m);
]], 1)
test_any([[
mapping m = set_weak_flag ((["x": class{}()]), Pike.WEAK_VALUES);
gc();
return sizeof (m);
]], 0)
test_any([[
object o = class{}();
mapping m = set_weak_flag (([o: o]), Pike.WEAK_INDICES);
o = 0;
gc();
return sizeof (m);
]], 1)
test_any([[
object o = class{}();
mapping m = set_weak_flag (([o: o]), Pike.WEAK_VALUES);
o = 0;
gc();
return sizeof (m);
]], 1)
test_any([[
object o = class{}();
mapping m = set_weak_flag (([o: o]), Pike.WEAK);
o = 0;
gc();
return sizeof (m);
]], 0)
test_any([[
object o = class{}();
mapping m = set_weak_flag (([o: "x"]), Pike.WEAK_INDICES);
destruct (o);
gc();
return sizeof (m);
]], 0)
test_any([[
object o = class{}();
mapping m = set_weak_flag (([o: "x"]), Pike.WEAK_VALUES);
destruct (o);
gc();
return sizeof (m);
]], 0)
test_any([[
object o = class{}();
mapping m = ([o: "x"]);
destruct (o);
gc();
return sizeof (m);
]], 0)
test_any([[
object o = class{}();
mapping m = set_weak_flag ((["x": o]), Pike.WEAK_INDICES);
destruct (o);
gc();
return sizeof (m);
]], 1)
test_any([[
object o = class{}();
mapping m = set_weak_flag ((["x": o]), Pike.WEAK_VALUES);
destruct (o);
gc();
return sizeof (m);
]], 0)
test_any([[
object o = class{}();
mapping m = (["x": o]);
destruct (o);
gc();
return sizeof (m);
]], 1)
|
b2764a | 2001-06-27 | Martin Stjernholm | |
|
fcb322 | 2001-07-05 | Martin Stjernholm | | test_do([[
mapping m = set_weak_flag (([]), Pike.WEAK_INDICES);
object o = class {object o;}();
m[o] = ({1});
o->o = o;
o = 0;
gc();
]])
test_do([[
mapping m = set_weak_flag (([]), Pike.WEAK_INDICES);
object o = class {object o;}();
m[o] = ({1});
array a = set_weak_flag (({class (object o) {} (o)}), 1);
o = 0;
gc();
]])
|
b2764a | 2001-06-27 | Martin Stjernholm | | test_any([[
return class {
mapping x;
int test()
{
object o = class {
|
f960bd | 2015-07-31 | Martin Nilsson | | mapping a = ([1: this]);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct() {x = a;}
|
b2764a | 2001-06-27 | Martin Stjernholm | | }();
o = 0;
gc();
return x && !x[1];
}
}()->test();
]], 1)
test_any([[
return class {
multiset x;
int test()
{
object o = class {
|
f960bd | 2015-07-31 | Martin Nilsson | | multiset a = (<this>);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct() {x = a;}
|
b2764a | 2001-06-27 | Martin Stjernholm | | }();
o = 0;
gc();
|
e813b0 | 2001-12-10 | Martin Stjernholm | | return x && !sizeof (indices (x + (<>)));
|
b2764a | 2001-06-27 | Martin Stjernholm | | }
}()->test();
]], 1)
test_any([[
return class {
array x;
int test()
{
object o = class {
|
f960bd | 2015-07-31 | Martin Nilsson | | array a = ({this});
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct() {x = a;}
|
b2764a | 2001-06-27 | Martin Stjernholm | | }();
o = 0;
gc();
return x && !x[0];
}
}()->test();
]], 1)
test_any([[
return class {
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Obj (object o) {protected void _destruct() {}}
|
b2764a | 2001-06-27 | Martin Stjernholm | | Obj x;
int test()
{
object o = class {
|
f960bd | 2015-07-31 | Martin Nilsson | | Obj a = Obj (this);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct() {x = a;}
|
b2764a | 2001-06-27 | Martin Stjernholm | | }();
o = 0;
gc();
return !x;
}
}()->test();
]], 1)
test_any([[
return class {
class Obj (object o) {}
Obj x;
int test()
{
object o = class {
|
f960bd | 2015-07-31 | Martin Nilsson | | Obj a = Obj (this);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected void _destruct() {x = a;}
|
b2764a | 2001-06-27 | Martin Stjernholm | | }();
o = 0;
gc();
return x && !x->o;
}
}()->test();
]], 1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
f83f0a | 2008-05-11 | Martin Stjernholm | | // Pike.count_memory
|
6490fb | 2008-10-12 | Martin Stjernholm | | test_do([[
add_constant ("count_memory_stats",
lambda (int|mapping opts, mixed... things) {
if (intp (opts))
opts = (["lookahead": opts, "collect_stats": 1]);
else
opts += (["collect_stats": 1]);
Pike.count_memory (opts, @things);
return sprintf ("i:%d,c:%d,e:%d,v:%d,r:%d,rnd:%d",
opts->internal, opts->cyclic, opts->external,
opts->visits, opts->revisits, opts->rounds);
})
]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | // time(1) is used below to avoid constants with extra refs.
|
6490fb | 2008-10-12 | Martin Stjernholm | | test_true([[Pike.count_memory (-1) == 0]])
test_true([[Pike.count_memory (-1, ({})) > 0]])
test_true([[Pike.count_memory (-1, ({time(1)})) > 0]])
test_true([[Pike.count_memory (-1, (<>)) > 0]])
test_true([[Pike.count_memory (-1, (<time(1)>)) >
Pike.count_memory (-1, (<>))]])
test_true([[Pike.count_memory (-1, (<time(1)>)) >
Pike.count_memory (-1, (<1>))]])
test_true([[Pike.count_memory (-1, ([])) > 0]])
test_true([[Pike.count_memory (-1, ([1: time(1)])) >
Pike.count_memory (-1, ([]))]])
test_true([[Pike.count_memory (-1, ([1: time(1)])) >
Pike.count_memory (-1, ([1: 2]))]])
test_true([[Pike.count_memory (-1, class {}) > 0]])
test_true([[Pike.count_memory (-1, class {float f;}) >
Pike.count_memory (-1, class {})]])
test_true([[Pike.count_memory (-1, class {constant f = 0.0;}) >
Pike.count_memory (-1, class {})]])
test_true([[Pike.count_memory (-1, class {}()) > 0]])
test_true([[Pike.count_memory (-1, class {float f;}()) >
Pike.count_memory (-1, class {}())]])
test_true([[Pike.count_memory (-1, class {constant f = 0.0;}()) ==
Pike.count_memory (-1, class {}())]])
test_true([[Pike.count_memory (-1, "foo") > 0]])
test_true([[Pike.count_memory (-1, typeof (map)) > 0]])
test_true([[Pike.count_memory (-1, 17) == 0]])
test_true([[Pike.count_memory (-1, ({"some string with no other ref in memory "+
Standards.UUID.make_version4()->str()})) ==
Pike.count_memory (-1, ({""}))]])
test_true([[Pike.count_memory (0, ({"some string with no other ref in memory " +
|
42df3a | 2008-10-04 | Martin Stjernholm | | Standards.UUID.make_version4()->str()})) >
|
6490fb | 2008-10-12 | Martin Stjernholm | | Pike.count_memory (0, ({""}))]])
test_true([[Pike.count_memory (-1, ({time(1)})) +
Pike.count_memory (-1, ([1: time(1)])) ==
Pike.count_memory (0, ({([1: time(1)])}))]])
|
f19b3f | 2016-12-01 | Henrik Grubbström (Grubba) | | test_true([[Pike.count_memory (0, class {mapping(this_program:array(int)) x;}) >
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | Pike.count_memory (0, class {int x;})]])
|
6490fb | 2008-10-12 | Martin Stjernholm | | test_true([[Pike.count_memory (0, ({compile (
|
5adf94 | 2011-03-23 | Henrik Grubbström (Grubba) | | "constant x = ([1: " + time(1) +
"]);")})) >
|
6490fb | 2008-10-12 | Martin Stjernholm | | Pike.count_memory (0, ({([1: time(1)])}))]])
test_eq([[count_memory_stats (-1, ({time(1)}))]],
[["i:1,c:0,e:0,v:1,r:0,rnd:1"]])
test_eq([[count_memory_stats (-1, (<time(1)>))]],
[["i:1,c:0,e:0,v:2,r:0,rnd:1"]])
test_eq([[count_memory_stats (-1, ([1: time(1)]))]],
[["i:1,c:0,e:0,v:2,r:0,rnd:1"]])
test_eq([[count_memory_stats (-1, class {float f;})]],
[["i:1,c:0,e:0,v:1,r:0,rnd:1"]])
test_eq([[count_memory_stats (-1, class {float f;}())]],
[["i:1,c:0,e:0,v:1,r:0,rnd:1"]])
test_eq([[count_memory_stats (-1, "foo")]],
[["i:1,c:0,e:0,v:1,r:0,rnd:1"]])
test_eq([[count_memory_stats (-1, typeof(all_constants()))]],
[["i:1,c:0,e:0,v:1,r:0,rnd:1"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
array a1 = ({({time(1)})}), a2 = ({a1[0]});
|
6490fb | 2008-10-12 | Martin Stjernholm | | return Pike.count_memory (0, a1, a2) >
Pike.count_memory (0, a1) + Pike.count_memory (0, a2);
|
f83f0a | 2008-05-11 | Martin Stjernholm | | ]], 1)
test_any([[
mapping m = ([1: time(1)]);
|
6490fb | 2008-10-12 | Martin Stjernholm | | return Pike.count_memory (0, ({m})) == Pike.count_memory (0, ({0}));
|
f83f0a | 2008-05-11 | Martin Stjernholm | | ]], 1)
test_any([[
array a = ({([1: time(1)])});
|
6490fb | 2008-10-12 | Martin Stjernholm | | return Pike.count_memory (0, a) > Pike.count_memory (0, ({([])}));
|
f83f0a | 2008-05-11 | Martin Stjernholm | | ]], 1)
test_any([[
program p = class {};
|
6490fb | 2008-10-12 | Martin Stjernholm | | return Pike.count_memory (0, p) > Pike.count_memory (0, p());
|
f83f0a | 2008-05-11 | Martin Stjernholm | | ]], 1)
test_any([[
class X (void|object a) {};
|
42df3a | 2008-10-04 | Martin Stjernholm | | X o = X (X());
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (0, o);
]], [["i:2,c:0,e:0,v:2,r:0,rnd:1"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
class X (void|object a) {};
X o = X (X (X()));
|
6490fb | 2008-10-12 | Martin Stjernholm | | o->a->a->a = o;
return count_memory_stats (0, o);
]], [["i:3,c:0,e:0,v:3,r:0,rnd:1"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
f83f0a | 2008-05-11 | Martin Stjernholm | | class X (void|object a) {};
X o = X (X (X()));
o->a->a->a = o->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (2, o);
]], [["i:3,c:2,e:0,v:7,r:4,rnd:2"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
f83f0a | 2008-05-11 | Martin Stjernholm | | class X (void|object a) {};
X o = X (X (X()));
o->a->a->a = o->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (1, o);
]], [["i:1,c:0,e:1,v:3,r:1,rnd:1"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
class X (void|object a) {};
X o = X (X (X()));
|
6490fb | 2008-10-12 | Martin Stjernholm | | int size = Pike.count_memory (0, o);
o->a->a->a = o->a;
return Pike.count_memory ((["lookahead": 2]), o) == size;
|
f83f0a | 2008-05-11 | Martin Stjernholm | | ]], 1)
test_any([[
class X (void|object a) {};
X o = X (X (X()));
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats ((["block_objects": 1]), o);
]], [["i:3,c:0,e:0,v:3,r:0,rnd:1"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
class X (void|object a) {};
X o = X (X (X()));
|
f83f0a | 2008-05-11 | Martin Stjernholm | | o->a->a->a = o->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats ((["lookahead": 2, "block_objects": 1]), o);
]], [["i:1,c:0,e:0,v:1,r:0,rnd:1"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
f83f0a | 2008-05-11 | Martin Stjernholm | | class X (void|object a) {};
X o = X (X (X()));
o->a->a->a = o->a;
X r = o->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (10, o);
]], [["i:1,c:0,e:2,v:7,r:4,rnd:1"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
42df3a | 2008-10-04 | Martin Stjernholm | | class X (void|object a) {};
X o = X (X (X()));
o->a->a->a = o->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | X r = o->a->a;
return count_memory_stats (2, o);
]], [["i:1,c:0,e:2,v:7,r:4,rnd:1"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
f83f0a | 2008-05-11 | Martin Stjernholm | | class X (void|object a) {};
X o = X (X (X()));
o->a->a->a = o->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | X r = o->a;
return count_memory_stats (2, o);
]], [["i:1,c:0,e:2,v:5,r:2,rnd:1"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
42df3a | 2008-10-04 | Martin Stjernholm | | class X (void|object a, void|object b) {};
X o = X (X (X (X (X (X ())))));
o->a->b = o;
o->a->a->b = o->a;
o->a->a->a->b = o->a->a;
o->a->a->a->a->b = o->a->a->a;
o->a->a->a->a->a->b = o->a->a->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (1, o);
]], [["i:1,c:0,e:1,v:3,r:1,rnd:1"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
42df3a | 2008-10-04 | Martin Stjernholm | | class X (void|object a, void|object b) {};
X o = X (X (X (X (X (X ())))));
o->a->b = o;
o->a->a->b = o->a;
o->a->a->a->b = o->a->a;
o->a->a->a->a->b = o->a->a->a;
o->a->a->a->a->a->b = o->a->a->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (2, o);
]], [["i:6,c:5,e:0,v:19,r:13,rnd:2"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
42df3a | 2008-10-04 | Martin Stjernholm | | class X (void|object a, void|object b) {};
X o = X (X (X (X (X (X ())))));
o->a->b = o;
o->a->a->b = o->a;
o->a->a->a->b = o->a->a;
o->a->a->a->a->b = o->a->a->a;
o->a->a->a->a->a->b = o->a->a->a->a;
X p = o->a->a->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (2, o);
]], [["i:1,c:0,e:5,v:17,r:11,rnd:1"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
42df3a | 2008-10-04 | Martin Stjernholm | | class X (void|object a, void|object b) {constant pike_cycle_depth = 2;};
X o = X (X (X (X (X (X ())))));
o->a->b = o;
o->a->a->b = o->a;
o->a->a->a->b = o->a->a;
o->a->a->a->a->b = o->a->a->a;
o->a->a->a->a->a->b = o->a->a->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (0, o);
]], [["i:6,c:5,e:0,v:19,r:13,rnd:2"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
class X (void|object a, void|object b) {constant pike_cycle_depth = 1;};
X o = X (X (X (X (X (X ())))));
o->a->b = o;
o->a->a->b = o->a;
o->a->a->a->b = o->a->a;
o->a->a->a->a->b = o->a->a->a;
o->a->a->a->a->a->b = o->a->a->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (0, o);
]], [["i:1,c:0,e:1,v:3,r:1,rnd:1"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
42df3a | 2008-10-04 | Martin Stjernholm | | class X (void|object a, void|object b) {constant pike_cycle_depth = 0;};
X o = X (X (X (X (X (X ())))));
o->a->b = o;
o->a->a->b = o->a;
o->a->a->a->b = o->a->a;
o->a->a->a->a->b = o->a->a->a;
o->a->a->a->a->a->b = o->a->a->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (2, o);
]], [["i:1,c:0,e:0,v:1,r:0,rnd:1"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
class X (void|object a, void|object b) {constant pike_cycle_depth = 2;};
X o = X (X (X (X (X (X ())))));
o->a->b = o;
o->a->a->b = o->a;
o->a->a->a->b = o->a->a;
o->a->a->a->a->b = o->a->a->a;
o->a->a->a->a->a->b = o->a->a->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats ((["block_pike_cycle_depth": 1]), o);
]], [["i:1,c:0,e:0,v:1,r:0,rnd:1"]])
test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
6490fb | 2008-10-12 | Martin Stjernholm | | class X (void|object a, void|object b) {constant pike_cycle_depth = 4;};
class Y (void|object a) {constant pike_cycle_depth = 0;};
X o = X (X(), X());
o->a->a = o->b;
o->b->a = o->a;
o->a->b = o->b->b = Y (Y());
return count_memory_stats (0, o);
]], [["i:5,c:2,e:0,v:8,r:3,rnd:2"]])
test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
6490fb | 2008-10-12 | Martin Stjernholm | | class X (void|object a, void|object b) {constant pike_cycle_depth = 4;};
class Y (void|object a) {constant pike_cycle_depth = 0;};
X o = X (X(), X());
o->a->a = o->b;
o->b->a = o->a;
o->a->b = o->b->b = Y (Y());
o->a->b->a->a = o->a->b;
return count_memory_stats (0, o);
]], [["i:3,c:2,e:0,v:6,r:3,rnd:2"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
f83f0a | 2008-05-11 | Martin Stjernholm | | class X (void|object a, void|object b) {};
X o = X (X (X()));
o->a->a->a = o->a;
X o2 = X();
o->b = o2;
o2->a = o->a->a;
o2 = 0;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (2, o);
]], [["i:4,c:2,e:0,v:7,r:3,rnd:2"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
42df3a | 2008-10-04 | Martin Stjernholm | | class X (void|object a, void|object b) {};
X o = X (X (X()));
o->a->a->a = o->a;
X o2 = X();
o->b = o2;
o2->a = o->a->a;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (2, o);
]], [["i:1,c:0,e:3,v:9,r:5,rnd:1"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
f83f0a | 2008-05-11 | Martin Stjernholm | | class X (void|object a, void|object b) {};
X o = X (X(), X());
o->a->b = o->b;
o->b->a = o->a;
o->a->a = o->b->b = X();
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (2, o);
]], [["i:4,c:3,e:0,v:8,r:4,rnd:2"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
f83f0a | 2008-05-11 | Martin Stjernholm | | class X (void|object a, void|object b) {};
X o = X (X(), X());
o->a->b = o->b;
o->b->a = o->a;
X o2 = X (X(), X());
o2->a->b = o2->b;
o2->b->a = o2->a;
o2->a->a = o2->b->b = X();
o->a->a = o->b->b = o2;
o2 = 0;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (1, o);
]], [["i:7,c:6,e:0,v:15,r:8,rnd:2"]])
test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
6490fb | 2008-10-12 | Martin Stjernholm | | class X (void|object a, void|object b) {};
X o = X (X(), X());
o->a->b = o->b;
o->b->a = o->a;
X o2 = X (X(), X());
o2->a->b = o2->b;
o2->b->a = o2->a;
o2->a->a = o2->b->b = X();
o->a->a = o->b->b = o2;
o2 = o2->b;
mapping m = (["lookahead": 1,
"collect_stats": 1,
"collect_direct_externals": 1]);
|
f83f0a | 2008-05-11 | Martin Stjernholm | | Pike.count_memory (m, o);
|
6490fb | 2008-10-12 | Martin Stjernholm | | //werror ("%O\n", m);
return m->internal == 4 && m->cyclic == 3 && m->external == 3 &&
equal (m->collect_direct_externals, ({o2}));
|
f83f0a | 2008-05-11 | Martin Stjernholm | | ]], 1)
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
mixed r = ([]), p = r;
p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = 0;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (1, r);
]], [["i:1,c:0,e:1,v:6,r:2,rnd:1"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
mixed r = ([]), p = r;
p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = 0;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return count_memory_stats (2, r);
]], [["i:6,c:5,e:0,v:38,r:26,rnd:2"]])
|
42df3a | 2008-10-04 | Martin Stjernholm | | test_any([[
mixed r = ([]), p = r;
p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = p->next; p->next = ([]); p->next->prev = p;
p = 0;
|
6490fb | 2008-10-12 | Martin Stjernholm | | return Pike.count_memory ((["lookahead": 2, "return_count": 1]), r);
|
42df3a | 2008-10-04 | Martin Stjernholm | | ]], 6)
|
6490fb | 2008-10-12 | Martin Stjernholm | | test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
6490fb | 2008-10-12 | Martin Stjernholm | | class X (void|array|object a, void|array|object b) {};
array a = ({X (X())});
object o = a[0];
o->a->a = o; o->b = ({X (X())}); o = o->b[0];
o->a->a = o; o->b = ({X (X())}); o = o->b[0];
o->a->a = o; o->b = ({X (X())}); o = o->b[0];
o->a->a = o; o->b = ({X (X())}); o = o->b[0];
o->a->a = o; o = 0;
return count_memory_stats ((["lookahead": 2, "block_arrays": 1]), a);
]], [["i:15,c:10,e:0,v:35,r:20,rnd:6"]])
test_any([[
|
5dffec | 2015-12-27 | Martin Nilsson | | /* don't save parent */
|
6490fb | 2008-10-12 | Martin Stjernholm | | class X (void|array|object a, void|array|object b) {};
array a = ({X (X())});
object o = a[0];
o->a->a = o; o->a->b = ({X (X())}); o = o->a->b[0];
o->a->a = o; o->a->b = ({X (X())}); o = o->a->b[0];
o->a->a = o; o->a->b = ({X (X())}); o = o->a->b[0];
o->a->a = o; o->a->b = ({X (X())}); o = o->a->b[0];
o->a->a = o; o = 0;
return count_memory_stats ((["lookahead": 2, "block_arrays": 1]), a);
]], [["i:15,c:10,e:0,v:35,r:20,rnd:6"]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | | test_true([[Pike.count_memory (Int.NATIVE_MAX, ({master()})) ==
|
6490fb | 2008-10-12 | Martin Stjernholm | | Pike.count_memory (-1, ({0}))]])
test_any([[
|
f83f0a | 2008-05-11 | Martin Stjernholm | | mapping m = (["lookahead": Int.NATIVE_MAX,
"block_programs": 0,
"collect_stats": 1]);
Pike.count_memory (m, master());
|
6490fb | 2008-10-12 | Martin Stjernholm | | return m->rounds;
|
c28a54 | 2019-04-29 | Henrik Grubbström (Grubba) | | ]], 1)
|
031171 | 2013-06-17 | Martin Nilsson | | test_true([[Pike.count_memory (-1, Int.NATIVE_MAX + 1) >
Pike.count_memory (-1, 17)]])
test_true([[Pike.count_memory (-1, Int.NATIVE_MAX << 100) >
Pike.count_memory (-1, Int.NATIVE_MAX + 1)]])
|
6490fb | 2008-10-12 | Martin Stjernholm | | test_do([[add_constant("count_memory_stats")]])
|
f83f0a | 2008-05-11 | Martin Stjernholm | |
|
84c33e | 2010-04-16 | Martin Stjernholm | | test_program([[
function ff()
{
array x;
array b() {return x;};
x = ({b});
return b;
}
int a()
{
function f = ff();
int s = Pike.count_memory (0, f());
f = 0;
gc();
return s > 0;
}
]])
|
ab8bdc | 2018-05-22 | Henrik Grubbström (Grubba) | | // Pike.identify_cycle
test_any_equal([[
class Foo { Foo next; int counter; };
array(Foo) foos = allocate(10, Foo)();
for (int i = 0; i < 10; i++) {
foos[i]->next = foos[(i+1)%10];
foos[i]->counter = i;
}
return Pike.identify_cycle(foos[0])->counter;
]], ({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }))
test_any([[
// PIKE-106: Mutex not unlocked properly on error in identify_cycle().
class Foo {
int cnt;
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int __hash() { return 0; }
protected int `==(mixed x) { if (!cnt++) error("Comparison failure.\n"); }
|
ab8bdc | 2018-05-22 | Henrik Grubbström (Grubba) | | };
catch {
// This triggered an error.
Pike.identify_cycle(allocate(2, Foo)());
};
catch {
// This hanged due to the mc_mutex not having been released.
Pike.identify_cycle(allocate(2, Foo)());
};
]], 0)
|
00dbf6 | 2003-11-08 | Martin Stjernholm | | // Numerical limits.
test_true([[Int.NATIVE_MIN <= -2147483648]])
test_true([[Int.NATIVE_MAX >= 2147483647]])
test_true([[Float.DIGITS_10 >= 6]])
test_true([[Float.MIN_10_EXP <= -37]])
test_true([[Float.MAX_10_EXP >= 37]])
test_true([[Float.MIN <= 1e-37]])
test_true([[Float.MAX >= 1e37]])
test_true([[Float.EPSILON <= 1e-5]])
|
14bf8b | 2009-11-30 | Henrik Grubbström (Grubba) | | test_true([[1 <= 1.0]])
test_true([[1 >= 1.0]])
test_true([[1.0 <= 1]])
test_true([[1.0 >= 1]])
|
00dbf6 | 2003-11-08 | Martin Stjernholm | |
|
031171 | 2013-06-17 | Martin Nilsson | | // Test the lexer.
test_eq("2147483648", [[ (string)0x80000000 ]])
test_eq("2147483649", [[ (string)0x80000001 ]])
test_eq("-2147483648", [[ (string)-0x80000000 ]])
test_eq("-2147483649", [[ (string)-0x80000001 ]])
test_eq("2147483648", [[ (string)-(-0x80000000) ]])
test_eq("2147483649", [[ (string)-(-0x80000001) ]])
test_eq("9223372036854775808", [[ (string)0x8000000000000000 ]])
test_eq("9223372036854775809", [[ (string)0x8000000000000001 ]])
test_eq("-9223372036854775808", [[ (string)-0x8000000000000000 ]])
test_eq("-9223372036854775809", [[ (string)-0x8000000000000001 ]])
test_eq("9223372036854775808", [[ (string)-(-0x8000000000000000) ]])
test_eq("9223372036854775809", [[ (string)-(-0x8000000000000001) ]])
test_eq("123456789123456789", [[ (string)123456789123456789 ]])
test_eq("-123456789123456789", [[ (string)-123456789123456789 ]])
test_eq("335812727629498640265", [[ (string)0x123456789123456789 ]])
test_eq("-335812727629498640265", [[ (string)-0x123456789123456789 ]])
test_eq("718046312823", [[ (string)012345671234567 ]])
test_eq("-718046312823", [[ (string)-012345671234567 ]])
test_eq("1125899906842624", [[ (string)0b100000000000000000000000000000000000000000000000000 ]])
test_eq("-1125899906842624", [[ (string)-0b100000000000000000000000000000000000000000000000000 ]])
test_eq(500000000 * 10, 5000000000)
test_eq(5000000000000000000 * 10, 50000000000000000000)
// Numbers that shouldn't be native integers. Has to resort to
// strange methods to test this since bignums behave like native
// integers in almost every way.
|
5c4aa9 | 2015-03-16 | Martin Nilsson | | test_do([[ Debug.next ((mixed) Int.NATIVE_MAX + 1) ]])
test_do([[ Debug.next ((mixed) Int.NATIVE_MIN - 1) ]])
|
031171 | 2013-06-17 | Martin Nilsson | |
// These numbers should be native integers.
|
5c4aa9 | 2015-03-16 | Martin Nilsson | | test_eval_error([[ Debug.next ((mixed) -0x80000000) ]])
test_eval_error([[ Debug.next ((mixed) -0x7fffffff) ]])
test_eval_error([[ Debug.next ((mixed) 0x7fffffff) ]])
test_eval_error([[ Debug.next ((mixed) Int.NATIVE_MAX) ]])
test_eval_error([[ Debug.next ((mixed) Int.NATIVE_MIN) ]])
|
031171 | 2013-06-17 | Martin Nilsson | |
// Test incrementations (FIXME: More cases?).
test_eq("2147483648",
[[ (string)(class { int f(int x) { x++; return x; } })()->f(0x7fffffff) ]])
test_eq("2147483648",
[[ (string)(class { int f(int x) { ++x; return x; } })()->f(0x7fffffff) ]])
test_eq("2147483648",
[[ (string)(class { int x=0x7fffffff;int f() { ++x;return x; } })()->f() ]])
test_eq("2147483648",
[[ (string)(class { int x=0x7fffffff;int f() { x++;return x; } })()->f() ]])
test_eq("2147483648",
[[ (string)(class { int f() { int x=0x7fffffff;++x;return x; } })()->f() ]])
test_eq("2147483648",
[[ (string)(class { int f() { int x=0x7fffffff;x++;return x; } })()->f() ]])
test_eq("9223372036854775808",
[[ (string)(class { int f(int x) { x++; return x; } })()->f(0x7fffffffffffffff) ]])
test_eq("9223372036854775808",
[[ (string)(class { int f(int x) { ++x; return x; } })()->f(0x7fffffffffffffff) ]])
test_eq("9223372036854775808",
[[ (string)(class { int x=0x7fffffffffffffff;int f() { ++x;return x; } })()->f() ]])
test_eq("9223372036854775808",
[[ (string)(class { int x=0x7fffffffffffffff;int f() { x++;return x; } })()->f() ]])
test_eq("9223372036854775808",
[[ (string)(class { int f() { int x=0x7fffffffffffffff;++x;return x; } })()->f() ]])
test_eq("9223372036854775808",
[[ (string)(class { int f() { int x=0x7fffffffffffffff;x++;return x; } })()->f() ]])
// Test decrementations (FIXME: More cases?).
test_eq("-2147483649",
[[ (string)(class { int f(int x) { x--; return x; } })()->f(-0x80000000) ]])
test_eq("-2147483649",
[[ (string)(class { int f(int x) { --x; return x; } })()->f(-0x80000000) ]])
test_eq("-2147483649",
[[ (string)(class { int x=-0x80000000;int f() { --x;return x; } })()->f()]])
test_eq("-2147483649",
[[ (string)(class { int x=-0x80000000;int f() { x--;return x; } })()->f()]])
test_eq("-2147483649",
[[ (string)(class { int f() { int x=-0x80000000;--x;return x; } })()->f()]])
test_eq("-2147483649",
[[ (string)(class { int f() { int x=-0x80000000;x--;return x; } })()->f()]])
test_eq("-9223372036854775809",
[[ (string)(class { int f(int x) { x--; return x; } })()->f(-0x8000000000000000) ]])
test_eq("-9223372036854775809",
[[ (string)(class { int f(int x) { --x; return x; } })()->f(-0x8000000000000000) ]])
test_eq("-9223372036854775809",
[[ (string)(class { int x=-0x8000000000000000;int f() { --x;return x; } })()->f()]])
test_eq("-9223372036854775809",
[[ (string)(class { int x=-0x8000000000000000;int f() { x--;return x; } })()->f()]])
test_eq("-9223372036854775809",
[[ (string)(class { int f() { int x=-0x8000000000000000;--x;return x; } })()->f()]])
test_eq("-9223372036854775809",
[[ (string)(class { int f() { int x=-0x8000000000000000;x--;return x; } })()->f()]])
test_encode(1<<99);
// - Left shift.
test_eq("1073741824", [[ (string)(1<<30) ]])
test_eq("2147483648", [[ (string)(1<<31) ]])
test_eq("4294967296", [[ (string)(1<<32) ]])
test_eq("8589934592", [[ (string)(1<<33) ]])
test_eq("1267650600228229401496703205376", [[ (string)(1<<100) ]])
test_eval_error(return 1<<100000000000000000000)
test_eval_error(return (-1)<<100000000000000000000)
test_eq(0<<100000000000000000000, 0)
test_eval_error(return 100000000000000000000<<100000000000000000000)
test_eval_error(return (-100000000000000000000)<<100000000000000000000)
// - Right shift.
test_eq("53265209898187398182",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)((int)"54543574935743895738479">>10) ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_false([[ objectp((int)"54543574935743895738479">>60) ]])
test_eq(0, [[ 25>>30 ]])
test_eq(0, [[ 25>>31 ]])
test_eq(0, [[ 25>>32 ]])
test_eq(0, [[ 25>>33 ]])
test_eq(1>>100000000000000000000, 0)
test_eq(-1>>100000000000000000000, -1)
test_eq(0>>100000000000000000000, 0)
test_eq(100000000000000000000>>100000000000000000000, 0)
test_eq((-100000000000000000000)>>100000000000000000000, -1)
// - abs.
test_eq("2147483648", [[ (string)abs(-0x80000000) ]])
test_eq("2147483648", [[ (string)abs(0x80000000) ]])
test_eq("2147483649", [[ (string)abs(0x80000001) ]])
test_eq("2147483649", [[ (string)abs(-0x80000001) ]])
test_eq("9223372036854775808", [[ (string)abs(-0x8000000000000000) ]])
test_eq("9223372036854775808", [[ (string)abs(0x8000000000000000) ]])
test_eq("9223372036854775809", [[ (string)abs(0x8000000000000001) ]])
test_eq("9223372036854775809", [[ (string)abs(-0x8000000000000001) ]])
// - Add.
test_eq("2147483648", [[ (string)(0x7fffffff + 1) ]])
test_eq("2147483649", [[ (string)(0x7fffffff + 2) ]])
test_eq("-2147483648", [[ (string)((-0x80000001) + 1) ]])
test_eq("9223372036854775808", [[ (string)(0x7fffffffffffffff + 1) ]])
test_eq("9223372036854775809", [[ (string)(0x7fffffffffffffff + 2) ]])
test_eq("-9223372036854775808", [[ (string)((-0x8000000000000001) + 1) ]])
test_eq("2684354560", [[ (string)(0x50000000 + 0x50000000) ]])
test_eq("-2684354560", [[ (string)((-0x50000000) + (-0x50000000)) ]])
test_false([[ objectp((-0x80000001) + 1) ]])
// - Add-eq.
test_eq([[lambda() { int a=0x100000000; int b = a; a += 1; return b+a; }()]],
|
a105d7 | 1999-10-31 | Henrik Grubbström (Grubba) | | [[0x200000001]])
|
cb5d8e | 1999-10-31 | Henrik Grubbström (Grubba) | |
|
031171 | 2013-06-17 | Martin Nilsson | | // - Sub.
test_eq("-2147483648", [[ (string)(-0x7fffffff - 1) ]])
test_eq("-2147483649", [[ (string)(-0x80000000 - 1) ]])
test_eq("2147483647", [[ (string)(0x80000000 - 1) ]])
test_eq("-9223372036854775808", [[ (string)(-0x7fffffffffffffff - 1) ]])
test_eq("-9223372036854775809", [[ (string)(-0x8000000000000000 - 1) ]])
test_eq("9223372036854775807", [[ (string)(0x8000000000000000 - 1) ]])
test_false([[ objectp(0x80000000 - 1) ]])
// - Multiplication.
test_eq("6442450941", [[ (string)(0x7fffffff * 3) ]])
test_eq("-6442450941", [[ (string)(0x7fffffff * -3) ]])
test_eq(-2147483648*-1,2147483648)
test_eq(-9223372036854775808*-1,9223372036854775808)
// Division.
test_eq("1073741824", [[ (string)((int)"2147483648" / 2) ]])
test_false([[ objectp((int)"2147483648" / 2) ]])
test_eq("13934998268672547360069539025",
[[ (string)(48324683476346278246238462784624627348 / 3467864333) ]])
// - sscanf.
test_eq("12345678901234567890",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("12345678901234567890", "%d")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("1375488932614371410344080",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("123456789F01234567890", "%x")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("1375488932614371410344080",
|
f21880 | 2001-06-05 | Fredrik Hübinette (Hubbe) | | [[ (string)array_sscanf("0x123456789F01234567890", "%x")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("1375488932614371410344080",
|
f21880 | 2001-06-05 | Fredrik Hübinette (Hubbe) | | [[ (string)array_sscanf("0X123456789F01234567890", "%x")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("1375488932614371410344080",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("0x123456789F01234567890", "%i")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("1375488932614371410344080",
|
f21880 | 2001-06-05 | Fredrik Hübinette (Hubbe) | | [[ (string)array_sscanf("0X123456789F01234567890", "%i")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("45954944846776",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("1234567012345670", "%o")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("45954944846776",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("01234567012345670", "%i")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("11", [[ (string)array_sscanf("1011", "%b")[0] ]])
test_eq("1125968643114208", [[ (string)array_sscanf("100000000000001000000000001000000000100010011100000", "%b")[0] ]])
test_eq("11", [[ (string)array_sscanf("0b1011", "%i")[0] ]])
test_eq("1125968643114208", [[ (string)array_sscanf("0b100000000000001000000000001000000000100010011100000", "%i")[0] ]])
test_eq("-12345678901234567890",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("-12345678901234567890", "%d")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("-1375488932614371410344080",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("-123456789F01234567890", "%x")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("-1375488932614371410344080",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("-0x123456789F01234567890","%i")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("-45954944846776",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("-1234567012345670", "%o")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("-45954944846776",
|
a0bcec | 1999-10-23 | Fredrik Noring | | [[ (string)array_sscanf("-01234567012345670", "%i")[0] ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq("-11", [[ (string)array_sscanf("-1011", "%b")[0] ]])
test_eq("-1125968643114208", [[ (string)array_sscanf("-100000000000001000000000001000000000100010011100000", "%b")[0] ]])
test_eq("-11", [[ (string)array_sscanf("-0b1011", "%i")[0] ]])
test_eq("-1125968643114208", [[ (string)array_sscanf("-0b100000000000001000000000001000000000100010011100000", "%i")[0] ]])
test_eq([[ sprintf("%x", @array_sscanf("\0\0\0\0\1\2\3\4", "%4c")) ]], "0")
test_eq([[ sprintf("%x", @array_sscanf("\0\0\0\0\1\2\3\4", "%8c")) ]], "1020304")
test_eq([[ sprintf("%08x", @array_sscanf("\0\0\0\0\1\2\3\4", "%8c")) ]], "01020304")
test_eq([[ sprintf("%08x", @array_sscanf("\0\0\0\5\1\2\3\4", "%8c")) ]], "501020304")
test_eq([[ sprintf("%08x", @array_sscanf("\0\0\6\5\1\2\3\4", "%8c")) ]], "60501020304")
test_eq([[ sprintf("%08x", @array_sscanf("\0\7\6\5\1\2\3\4", "%8c")) ]], "7060501020304")
test_eq([[ sprintf("%08x", @array_sscanf("8\7\6\5\1\2\3\4", "%8c")) ]], "3807060501020304")
test_eq([[ sprintf("%08x", @array_sscanf("\010\7\6\5\1\2\3\4", "%8c")) ]], "807060501020304")
test_equal([[ ({ 118 }) ]], [[ array_sscanf("0x76", "%x") ]])
test_equal([[ ({42 }) ]], [[ array_sscanf("101010", "%b") ]])
test_equal([[ ({42 }) ]], [[ array_sscanf("0b101010", "%b") ]])
test_equal([[ ({42 }) ]], [[ array_sscanf("0B101010", "%b") ]])
test_equal([[ ({ 557239244978618154304871 }) ]],
[[ array_sscanf("0x76000000000001234567", "%x") ]])
test_equal([[array_sscanf("foo \12345 bar <fie>","%[^<]")]],
|
58d1d2 | 2001-05-14 | Fredrik Hübinette (Hubbe) | | [[ ({"foo \12345 bar " }) ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_equal(471100000000000000000000000000000000000000000000042,
(int)(mixed)471100000000000000000000000000000000000000000000042)
test_eq(6745697846498645967,
|
3e5021 | 2014-08-18 | Martin Nilsson | | [[ (int)Gmp.mpz("6745697846498645967") ]])
|
031171 | 2013-06-17 | Martin Nilsson | |
test_eq(0x7fffffff, [[ decode_value(encode_value(0x7fffffff)) ]])
test_eq(0x7ffffffff, [[ decode_value(encode_value(0x7ffffffff)) ]])
test_eq(0x7fffffffff, [[ decode_value(encode_value(0x7fffffffff)) ]])
test_eq(0x7ffffffffff, [[ decode_value(encode_value(0x7ffffffffff)) ]])
test_eq(0x7fffffffffff, [[ decode_value(encode_value(0x7fffffffffff)) ]])
test_eq(0x7ffffffffffff, [[ decode_value(encode_value(0x7ffffffffffff)) ]])
test_eq(0x80000000, [[ decode_value(encode_value(0x80000000)) ]])
test_eq(0x800000000, [[ decode_value(encode_value(0x800000000)) ]])
test_eq(0x8000000000, [[ decode_value(encode_value(0x8000000000)) ]])
test_eq(0x80000000000, [[ decode_value(encode_value(0x80000000000)) ]])
test_eq(0x800000000000, [[ decode_value(encode_value(0x800000000000)) ]])
test_eq(0x8000000000000, [[ decode_value(encode_value(0x8000000000000)) ]])
test_eq(0x12345678, [[ decode_value(encode_value(0x12345678)) ]])
test_eq(0x123456780, [[ decode_value(encode_value(0x123456780)) ]])
test_eq(0x1234567801, [[ decode_value(encode_value(0x1234567801)) ]])
test_eq(0x12345678012, [[ decode_value(encode_value(0x12345678012)) ]])
test_eq(0x123456780123, [[ decode_value(encode_value(0x123456780123)) ]])
test_eq(0x1234567801234, [[ decode_value(encode_value(0x1234567801234)) ]])
test_eq(-0x7fffffff, [[ decode_value(encode_value(-0x7fffffff)) ]])
test_eq(-0x7ffffffff, [[ decode_value(encode_value(-0x7ffffffff)) ]])
test_eq(-0x7fffffffff, [[ decode_value(encode_value(-0x7fffffffff)) ]])
test_eq(-0x7ffffffffff, [[ decode_value(encode_value(-0x7ffffffffff)) ]])
test_eq(-0x7fffffffffff, [[ decode_value(encode_value(-0x7fffffffffff)) ]])
test_eq(-0x7ffffffffffff, [[ decode_value(encode_value(-0x7ffffffffffff))]])
test_eq(-0x80000000, [[ decode_value(encode_value(-0x80000000)) ]])
test_eq(-0x800000000, [[ decode_value(encode_value(-0x800000000)) ]])
test_eq(-0x8000000000, [[ decode_value(encode_value(-0x8000000000)) ]])
test_eq(-0x80000000000, [[ decode_value(encode_value(-0x80000000000)) ]])
test_eq(-0x800000000000, [[ decode_value(encode_value(-0x800000000000)) ]])
test_eq(-0x8000000000000, [[ decode_value(encode_value(-0x8000000000000))]])
test_eq(-0x12345678, [[ decode_value(encode_value(-0x12345678)) ]])
test_eq(-0x123456780, [[ decode_value(encode_value(-0x123456780)) ]])
test_eq(-0x1234567801, [[ decode_value(encode_value(-0x1234567801)) ]])
test_eq(-0x12345678012, [[ decode_value(encode_value(-0x12345678012)) ]])
test_eq(-0x123456780123, [[ decode_value(encode_value(-0x123456780123)) ]])
test_eq(-0x1234567801234, [[ decode_value(encode_value(-0x1234567801234))]])
|
5c4aa9 | 2015-03-16 | Martin Nilsson | | test_eval_error([[ Debug.next ((mixed) decode_value (encode_value (Int.NATIVE_MAX))) ]])
test_eval_error([[ Debug.next ((mixed) decode_value (encode_value (Int.NATIVE_MIN))) ]])
test_do([[ Debug.next ((mixed) decode_value (encode_value (Int.NATIVE_MAX + 1))) ]])
test_do([[ Debug.next ((mixed) decode_value (encode_value (Int.NATIVE_MIN - 1))) ]])
|
031171 | 2013-06-17 | Martin Nilsson | | test_eq(2147483648, -2147483648/-1)
test_eq(2147483648, -2147483648*-1)
test_true([[ sqrt(0x7fffffff)+1 ]])
test_true([[ sqrt(0x7ffffffff)+1 ]])
test_true([[ catch { destruct((mixed)0x4783647824687234628462); } ]])
|
2db242 | 1999-10-29 | Martin Stjernholm | |
|
031171 | 2013-06-17 | Martin Nilsson | | test_any_equal([[
array a = ({4711, 0x54325827a124*0x12348795482485425});
set_weak_flag (a, 1);
gc();
return set_weak_flag(a, 0);
]], [[ ({4711, 0x54325827a124*0x12348795482485425}) ]])
|
2db242 | 1999-10-29 | Martin Stjernholm | |
|
031171 | 2013-06-17 | Martin Nilsson | | test_any_equal([[
mapping m = ([
|
2db242 | 1999-10-29 | Martin Stjernholm | | 4711: 0x54325827a124*0x12348795482485425,
0x54325827124*0x1234879548a2485425: 1174,
|
031171 | 2013-06-17 | Martin Nilsson | | ]);
set_weak_flag (m, 1);
gc();
return set_weak_flag(m, 0);
]], [[ ([
4711: 0x54325827a124*0x12348795482485425,
0x54325827124*0x1234879548a2485425: 1174,
]) ]])
test_any([[int a=2147483648; a=a+17; return a]], 2147483665)
test_any([[int a=2147483648; a=a-17; return a]], 2147483631)
test_any([[int a=2147483648; a=a*17; return a]], 36507222016)
test_any([[int a=2147483648; a=a/17; return a]], 126322567)
test_any([[int a=2147483648; a=a%17; return a]], 9)
test_any([[int a=2147483648; a=a^17; return a]], 2147483665)
test_any([[int a=2147483648; a=a&17; return a]], 0)
test_any([[int a=2147483648; a=a|17; return a]], 2147483665)
test_any([[int a=2147483648; a=a<<17; return a]], 281474976710656)
test_any([[int a=2147483648; a=a>>17; return a]], 16384)
test_eq([[2147483648+17 ]], 2147483665)
test_eq([[2147483648-17 ]], 2147483631)
test_eq([[2147483648*17 ]], 36507222016)
test_eq([[2147483648/17 ]], 126322567)
test_eq([[2147483648%17 ]], 9)
test_eq([[2147483648^17 ]], 2147483665)
test_eq([[2147483648&17 ]], 0)
test_eq([[2147483648|17 ]], 2147483665)
test_eq([[2147483648<<17]], 281474976710656)
test_eq([[2147483648>>17]], 16384)
test_true([[ floatp((1<<99)/3.14) ]]);
test_true([[ floatp((1<<99)*3.14) ]]);
test_true([[ floatp((1<<99)-3.14) ]]);
test_true([[ floatp((1<<99)+3.14) ]]);
test_eq([[(12)+(3)]],0xf);
test_eq([[(12)+(3*(1<<32))]],0x30000000c);
test_eq([[(12)+(3*(1<<64))]],0x3000000000000000c);
test_eq([[(12)+(3*(1<<128))]],0x30000000000000000000000000000000c);
test_eq([[(12*(1<<32))+(3)]],0xc00000003);
test_eq([[(12*(1<<32))+(3*(1<<32))]],0xf00000000);
test_eq([[(12*(1<<32))+(3*(1<<64))]],0x30000000c00000000);
test_eq([[(12*(1<<32))+(3*(1<<128))]],0x300000000000000000000000c00000000);
test_eq([[(12*(1<<64))+(3)]],0xc0000000000000003);
test_eq([[(12*(1<<64))+(3*(1<<32))]],0xc0000000300000000);
test_eq([[(12*(1<<64))+(3*(1<<64))]],0xf0000000000000000);
test_eq([[(12*(1<<64))+(3*(1<<128))]],0x3000000000000000c0000000000000000);
test_eq([[(12*(1<<128))+(3)]],0xc00000000000000000000000000000003);
test_eq([[(12*(1<<128))+(3*(1<<32))]],0xc00000000000000000000000300000000);
test_eq([[(12*(1<<128))+(3*(1<<64))]],0xc00000000000000030000000000000000);
test_eq([[(12*(1<<128))+(3*(1<<128))]],0xf00000000000000000000000000000000);
test_eq([[(12)-(3)]],0x9);
test_eq([[(12)-(3*(1<<32))]],-0x2fffffff4);
test_eq([[(12)-(3*(1<<64))]],-0x2fffffffffffffff4);
test_eq([[(12)-(3*(1<<128))]],-0x2fffffffffffffffffffffffffffffff4);
test_eq([[(12*(1<<32))-(3)]],0xbfffffffd);
test_eq([[(12*(1<<32))-(3*(1<<32))]],0x900000000);
test_eq([[(12*(1<<32))-(3*(1<<64))]],-0x2fffffff400000000);
test_eq([[(12*(1<<32))-(3*(1<<128))]],-0x2fffffffffffffffffffffff400000000);
test_eq([[(12*(1<<64))-(3)]],0xbfffffffffffffffd);
test_eq([[(12*(1<<64))-(3*(1<<32))]],0xbfffffffd00000000);
test_eq([[(12*(1<<64))-(3*(1<<64))]],0x90000000000000000);
test_eq([[(12*(1<<64))-(3*(1<<128))]],-0x2fffffffffffffff40000000000000000);
test_eq([[(12*(1<<128))-(3)]],0xbfffffffffffffffffffffffffffffffd);
test_eq([[(12*(1<<128))-(3*(1<<32))]],0xbfffffffffffffffffffffffd00000000);
test_eq([[(12*(1<<128))-(3*(1<<64))]],0xbfffffffffffffffd0000000000000000);
test_eq([[(12*(1<<128))-(3*(1<<128))]],0x900000000000000000000000000000000);
test_eq([[(12)*(3)]],0x24);
test_eq([[(12)*(3*(1<<32))]],0x2400000000);
test_eq([[(12)*(3*(1<<64))]],0x240000000000000000);
test_eq([[(12)*(3*(1<<128))]],0x2400000000000000000000000000000000);
test_eq([[(12*(1<<32))*(3)]],0x2400000000);
test_eq([[(12*(1<<32))*(3*(1<<32))]],0x240000000000000000);
test_eq([[(12*(1<<32))*(3*(1<<64))]],0x24000000000000000000000000);
test_eq([[(12*(1<<32))*(3*(1<<128))]],0x240000000000000000000000000000000000000000);
test_eq([[(12*(1<<64))*(3)]],0x240000000000000000);
test_eq([[(12*(1<<64))*(3*(1<<32))]],0x24000000000000000000000000);
test_eq([[(12*(1<<64))*(3*(1<<64))]],0x2400000000000000000000000000000000);
test_eq([[(12*(1<<64))*(3*(1<<128))]],0x24000000000000000000000000000000000000000000000000);
test_eq([[(12*(1<<128))*(3)]],0x2400000000000000000000000000000000);
test_eq([[(12*(1<<128))*(3*(1<<32))]],0x240000000000000000000000000000000000000000);
test_eq([[(12*(1<<128))*(3*(1<<64))]],0x24000000000000000000000000000000000000000000000000);
test_eq([[(12*(1<<128))*(3*(1<<128))]],0x240000000000000000000000000000000000000000000000000000000000000000);
test_eq([[(12)/(3)]],0x4);
test_eq([[(12)/(3*(1<<32))]],0x0);
test_eq([[(12)/(3*(1<<64))]],0x0);
test_eq([[(12)/(3*(1<<128))]],0x0);
test_eq([[(12*(1<<32))/(3*(1<<32))]],0x4);
test_eq([[(12*(1<<32))/(3*(1<<64))]],0x0);
test_eq([[(12*(1<<32))/(3*(1<<128))]],0x0);
test_eq([[(12*(1<<64))/(3*(1<<64))]],0x4);
test_eq([[(12*(1<<64))/(3*(1<<128))]],0x0);
test_eq([[(12*(1<<128))/(3*(1<<128))]],0x4);
test_eq([[(17+12)%(3)]],0x2);
test_eq([[(17+12)%(3*(1<<32))]],0x1d);
test_eq([[(17+12)%(3*(1<<64))]],0x1d);
test_eq([[(17+12)%(3*(1<<128))]],0x1d);
test_eq([[(17+12*(1<<32))%(3*(1<<32))]],0x11);
test_eq([[(17+12*(1<<32))%(3*(1<<64))]],0xc00000011);
test_eq([[(17+12*(1<<32))%(3*(1<<128))]],0xc00000011);
test_eq([[(17+12*(1<<64))%(3*(1<<64))]],0x11);
test_eq([[(17+12*(1<<64))%(3*(1<<128))]],0xc0000000000000011);
test_eq([[(17+12*(1<<128))%(3*(1<<128))]],0x11);
test_eq([[Gmp.mpz(68719476736)/Gmp.mpz(12884901888)]],5);
test_eq([[Gmp.mpz(123456789012345678901234567890)/Gmp.mpz(12884901888)]],
Gmp.mpz(9581507883061474724));
test_eq([[Gmp.mpz(123456789012345678901234567890)/
Gmp.mpz(67890123456789012345)]],1818479371);
test_eq([[Gmp.mpz(123456789012345678901234567890)/
Gmp.mpz(67890123456789)]],Gmp.mpz(1818479371169857));
|
13670c | 2015-05-25 | Martin Nilsson | | test_any([[int a=10->pow(30); int b=1000000000000000000000000000000;
|
031171 | 2013-06-17 | Martin Nilsson | | return ([a:1])[b]]],1);
|
13670c | 2015-05-25 | Martin Nilsson | | test_any([[int a=10->pow(30); int b=1000000000000000000000000000000;
|
031171 | 2013-06-17 | Martin Nilsson | | return (<a>)[b]]],1);
|
13670c | 2015-05-25 | Martin Nilsson | | test_any([[int a=10->pow(30); int b=1000000000000000000000000000000;
|
031171 | 2013-06-17 | Martin Nilsson | | return sizeof( ({a})-({b}) )]],0);
|
13670c | 2015-05-25 | Martin Nilsson | | test_any([[int a=10->pow(30); int b=1000000000000000000000000000000;
|
031171 | 2013-06-17 | Martin Nilsson | | return sizeof( ({a})&({b}) )]],1);
|
13670c | 2015-05-25 | Martin Nilsson | | test_any([[int k=10->pow(30);
|
9c8ca0 | 2000-11-05 | Mirar (Pontus Hagland) | | array a=({k+17,k+16,k+13,k+14,k+12,k,k+9});
|
031171 | 2013-06-17 | Martin Nilsson | | return sort(a)[0]==k && sort(a)[-1]==k+17]],1)
|
9c8ca0 | 2000-11-05 | Mirar (Pontus Hagland) | |
|
031171 | 2013-06-17 | Martin Nilsson | | test_do([[
// This is a memleak test
rm("testsuite_test.pike");
Stdio.write_file("testsuite_test.pike",
|
997b73 | 2001-09-10 | Fredrik Hübinette (Hubbe) | | "constant Q=10000000000000000;\n"
"int main() {}\n");
|
031171 | 2013-06-17 | Martin Nilsson | | Process.system(RUNPIKE +" testsuite_test.pike");
rm("testsuite_test.pike");
]])
|
997b73 | 2001-09-10 | Fredrik Hübinette (Hubbe) | |
|
9c8ca0 | 2000-11-05 | Mirar (Pontus Hagland) | | // test the corresponding integer operations first
|
031171 | 2013-06-17 | Martin Nilsson | | test_any([[int k=100; int j=k+1;
array a=({k+17,k+16,k+13,k+14,k+12,k,k+9});
array b=({j+16,j+15,j+12,j+13,j+11,j-1,j+8});
return sizeof( a&b )]],7);
test_any([[int k=100; int j=k+1;
array a=({k+17,k+16,k+13,k+14,k+12,k,k+9});
array b=({j+13,j+11,j-1,j+8,j+16,j+15,j+12});
return sizeof( a-b )]],0);
|
9c8ca0 | 2000-11-05 | Mirar (Pontus Hagland) | |
// now the bignum ones
|
031171 | 2013-06-17 | Martin Nilsson | | test_any([[int k=10->pow(30); int j=k+1;
array a=({k+17,k+16,k+13,k+14,k+12,k,k+9});
array b=({j+16,j+15,j+12,j+13,j+11,j-1,j+8});
return sizeof( a&b )]],7);
test_any([[int k=10->pow(30); int j=k+1;
array a=({k+17,k+16,k+13,k+14,k+12,k,k+9});
array b=({j+13,j+11,j-1,j+8,j+16,j+15,j+12});
return sizeof( a-b )]],0);
|
9c8ca0 | 2000-11-05 | Mirar (Pontus Hagland) | |
|
323682 | 2015-11-15 | Martin Nilsson | | ifefun(_verify_internals,
|
c0988f | 1998-04-17 | Fredrik Hübinette (Hubbe) | | [[
test_do(_verify_internals())
]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
test_eq("\377"[0],255)
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | test_do(add_constant("foo",class {int i;}()))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eq(foo->i,0)
test_do(foo->i=17)
test_eq(foo->i,17)
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_do(add_constant("foo"));
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | test_do(add_constant("foo",class {array(int) i=({0});}()))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eq(foo->i[0],0)
test_do(foo->i[0]=17)
test_eq(foo->i[0],17)
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_do(add_constant("foo"));
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// signum, signame
|
e42eaf | 1998-01-02 | Fredrik Hübinette (Hubbe) | | test_true(intp(signum("SIGKILL")))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// kill, signal, getpid
test_true(intp(getpid()))
|
89d108 | 2018-07-14 | Henrik Grubbström (Grubba) | | cond([[all_constants()->kill && (cpp("__NT__")/"\n")[-1]=="__NT__" ]],
|
e42eaf | 1998-01-02 | Fredrik Hübinette (Hubbe) | | [[
test_do(signal(signum("SIGFPE"),lambda() { add_constant("AFJLLAF",17); }))
test_do(kill(getpid(),signum("SIGFPE")))
test_do(sleep(2))
test_eq(AFJLLAF,17)
test_do(add_constant("AFJLLAF"))
|
4e7870 | 1999-11-24 | Henrik Grubbström (Grubba) | | test_do(signal(signum("SIGFPE"), 0))
|
e42eaf | 1998-01-02 | Fredrik Hübinette (Hubbe) | | test_do(signal(signum("SIGFPE")))
]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// typeof
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_eq(sprintf("%O", typeof(1)),"int(1..1)")
|
71a4bf | 2007-05-03 | Henrik Grubbström (Grubba) | | test_eq(sprintf("%O", typeof("")),"string(zero)")
|
94fd48 | 2014-05-11 | Martin Nilsson | | ignore_warning("Indexing the empty string.", [[
test_aq([[ sprintf("%O", typeof(""[0])) ]], "zero")
]])
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_eq(sprintf("%O", typeof(0.0)),"float")
test_eq(sprintf("%O", typeof(all_constants()["all_constants"])),"mixed")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
4fbfe2 | 1998-12-21 | Fredrik Hübinette (Hubbe) | | // _typeof
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_eq(sprintf("%O", _typeof(1)),"int(1..1)")
|
71a4bf | 2007-05-03 | Henrik Grubbström (Grubba) | | test_eq(sprintf("%O", _typeof("")),"string(zero)")
|
440592 | 2000-05-25 | Henrik Grubbström (Grubba) | | test_eq(sprintf("%O", _typeof("x"[0])),"int(120..120)")
test_eq(sprintf("%O", _typeof(0.0)),"float")
|
b58421 | 2002-05-11 | Martin Stjernholm | | test_eq([[sscanf(sprintf("%Ox", _typeof(this_object))-" ",
|
780c2b | 2007-05-09 | Henrik Grubbström (Grubba) | | "function(void|int(0..%*[0-9]):object)%*c")]], 2)
|
4fbfe2 | 1998-12-21 | Fredrik Hübinette (Hubbe) | |
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // class
|
675c1b | 2016-11-25 | Henrik Grubbström (Grubba) | | test_true(programp(class {}))
test_true(functionp(class { int foo() { return 1; }}()->foo))
test_true(class { int foo() { return 1; }}()->foo())
test_true(class { int i=1; }()->i)
test_false(class { int foo() { return 1; }}()->bar)
|
f19b3f | 2016-12-01 | Henrik Grubbström (Grubba) | | test_eq(class { program foo = class { int i=20; }; }()->foo()->i,20)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
31fb1d | 2000-07-10 | Henrik Grubbström (Grubba) | | // class()
|
5aa137 | 2016-11-24 | Henrik Grubbström (Grubba) | | test_true(programp(class (){}))
test_equal(indices(class (string a,protected int b){}("foo",0)), ({"a"}))
test_equal(values(class (string a,protected int b){}("foo",0)), ({"foo"}))
test_true(programp(class (string ... a){}))
test_equal(indices(class (string a,protected int ... b){}("foo",0)), ({"a"}))
test_equal(values(class (protected string a, int ... b){}("foo",0)), ({({0})}))
|
31fb1d | 2000-07-10 | Henrik Grubbström (Grubba) | |
|
f8b6ba | 2001-11-28 | Martin Stjernholm | | test_do([[
class A (int i) {};
class B (int i, int j) {inherit A;};
class C {inherit B;};
C (1,1);
]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // type checks
test_compile_error([[} int foo() { return]]);
test_compile_error([[} void foo() { return 1]]);
|
62cda4 | 1999-11-23 | Martin Stjernholm | | test_compile([[mapping a; int b; a = b = 0;]]);
test_compile_error([[mapping a; int b; a = b = 1;]]);
|
327c05 | 1999-11-24 | Fredrik Hübinette (Hubbe) | | test_compile_any([[void a(int q){} void b(function(int:void) f){} void c(){b(a);}]]);
|
6b3f5c | 2002-04-11 | Martin Nilsson | | test_compile_error_any([[void a(int i){} void b(function(:void) f){} void c(){b(a);}]]);
|
653c36 | 1999-11-24 | Martin Stjernholm | | test_compile_any([[void a(){} function(int:void) b = a;]]);
|
6b3f5c | 2002-04-11 | Martin Nilsson | | test_compile_error_any([[void a(int i){} function(:void) b = a;]]);
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
1edce9 | 2000-11-04 | Martin Stjernholm | | // Duplicate local variable
test_compile_error([[void f() {int i; int i;}]]);
test_compile_error([[void f() {int i; mapping i;}]]);
test_compile_error([[void f() {int i; void i() {};}]]);
test_compile_error([[void f (int i) {string i;}]]);
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // Not yet cataloged
|
7991f1 | 2008-01-05 | Henrik Grubbström (Grubba) | | test_any(int i=10; { int i=0; } return i, 10)
|
563973 | 2001-07-04 | Henrik Grubbström (Grubba) | | test_program(void foo(int a, int b){} function(int,int:void) a() { return foo; })
test_program(void foo(int a, int ... b){} function(int,int ...:void) a() { return foo; })
test_program(void foo(){} function(:void) a() { return foo; })
test_compile_error([[} void foo(){} function(:string) a() { return foo;]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
test_do(lambda(){return;}())
test_equal( ({ lambda() { return 3; } , lambda() { return 7; }, lambda() { return 9; } })(), ({ 3,7,9 }))
|
3488ef | 2000-04-17 | Henrik Grubbström (Grubba) | | test_any(array(int) a=({10}); a[0]++; return a[0], 11)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any(mapping a=([10:11]); a[10]++; return a[10], 12)
test_equal(mkmapping( ({3,6,2}), ({"3","6","2"})), ([3:"3", 6:"6", 2:"2"]))
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_equal(`+(([3:"3", 6:"6", 2:"2"])), ([3:"3", 6:"6", 2:"2"]))
test_true(`+(([3:"3", 6:"6", 2:"2"])) != ([3:"3", 6:"6", 2:"2"]))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
test_true(predef::stringp(""))
test_equal([["a,b,4,7,8s,asfd,a,d,f" / ","]],[["a,b,4,7,8s,asfd,a,d,f" / ","]])
|
3488ef | 2000-04-17 | Henrik Grubbström (Grubba) | | test_any([[array(string) a="a,b"/","; a[0]="c"; return equal(a,({"c","b"}))]],1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_true(0||1)
test_true(1||0)
test_true(!0||!0)
test_true(!0&&!0)
test_any(mixed a=1; a+=1; return a,2)
test_any(mixed a=1; a-=1; return a,0)
test_equal("abcd"/"" - indices("abcd"),({"a","b","c","d"}))
test_equal("abcd"/"" & indices("abcd"),({}))
test_eq(sizeof("abcd"/"" & "de"/""),1)
test_equal( ({0,0,0,0,0}), ({0,0,0,0,0}))
|
8267f4 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | test_equal( ({"object","object","object","object","object"}), allocate(5,"object"))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | 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)
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_define_program(test,[[int foo() { return 17; }]])
|
2aeef5 | 2002-11-26 | Martin Nilsson | | test_any(function bar=test()->foo; return bar(),17)
test_do(add_constant("test"))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// sscanf
test_any([[mixed a; return sscanf("11","%d",a)]],1)
|
3a1e7e | 2008-05-18 | Henrik Grubbström (Grubba) | | test_any([[return sscanf("11","%*d")]],1)
|
b01dbc | 2007-05-20 | Martin Nilsson | | test_any([[mixed a; return sscanf("11","_%d",a)]],0)
test_any([[mixed a,b,c; return sscanf("11","%1d%1d%1d",a,b,c)]],2)
|
6c35af | 1998-04-14 | Fredrik Hübinette (Hubbe) | |
|
b01dbc | 2007-05-20 | Martin Nilsson | | test_any([[mixed a; sscanf("11","%b",a); return a]],0b11)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | 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)
|
6c35af | 1998-04-14 | Fredrik Hübinette (Hubbe) | |
|
b01dbc | 2007-05-20 | Martin Nilsson | | test_any([[mixed a; sscanf("11","%2b",a); return a]],0b11)
|
6c35af | 1998-04-14 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a; sscanf("11","%2d",a); return a]],11)
test_any([[mixed a; sscanf("11","%2o",a); return a]],011)
test_any([[mixed a; sscanf("11","%2x",a); return a]],0x11)
test_any([[mixed a; sscanf("11","%2D",a); return a]],11)
|
b01dbc | 2007-05-20 | Martin Nilsson | | test_any([[mixed a; sscanf("11","%4711b",a); return a]],0b11)
|
6c35af | 1998-04-14 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a; sscanf("11","%4711d",a); return a]],11)
test_any([[mixed a; sscanf("11","%4711o",a); return a]],011)
test_any([[mixed a; sscanf("11","%4711x",a); return a]],0x11)
test_any([[mixed a; sscanf("11","%4711D",a); return a]],11)
|
b01dbc | 2007-05-20 | Martin Nilsson | | test_any([[mixed a; sscanf("11","%1b",a); return a]],1)
|
6c35af | 1998-04-14 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a; sscanf("11","%1d",a); return a]],1)
test_any([[mixed a; sscanf("11","%1o",a); return a]],1)
test_any([[mixed a; sscanf("11","%1x",a); return a]],1)
test_any([[mixed a; sscanf("11","%1D",a); return a]],1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a; sscanf("0x11","%D",a); return a]],0x11)
test_any([[mixed a; sscanf("011","%D",a); return a]],011)
|
7991f1 | 2008-01-05 | Henrik Grubbström (Grubba) | | test_any([[mixed a; return sscanf("11foo","%dfoo",a)]],1)
test_any([[mixed a; sscanf("11foo","%dfoo",a); return a]],11)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a,b; return sscanf("11foo","%d%s",a,b)]],2)
test_any([[mixed a,b; sscanf("11foo","%d%s",a,b); return b]],"foo")
test_any([[mixed a,b; return sscanf("foo","%c%s",b,a)]],2)
test_any([[mixed a,b; sscanf("foo","%c%s",b,a); return b]],'f')
test_any([[mixed a,b; sscanf("foo","%c%s",b,a); return a]],"oo")
|
7991f1 | 2008-01-05 | Henrik Grubbström (Grubba) | | test_any([[mixed a; return sscanf("1.0","%f",a),a]],1.0)
test_any([[mixed a; return sscanf("-1.0","%f",a),a]],-1.0)
test_any([[mixed a; return sscanf("1.25","%f",a),a]],1.25)
test_any([[mixed a; return sscanf("-1.25","%f",a),a]],-1.25)
test_any([[mixed a; return sscanf("1.25e3","%f",a),a]],1.25e3)
test_any([[mixed a; return sscanf("-1.25e3","%f",a),a]],-1.25e3)
test_any([[mixed a; return sscanf("1.25e-3","%f",a),a]],1.25e-3)
test_any([[mixed a; return sscanf("-1.25e-3","%f",a),a]],-1.25e-3)
test_any([[mixed a; sscanf("1.0","%f",a); return a]],1.0)
|
dca598 | 1998-04-15 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a,b; sscanf("-z ","%[-z]%s",a,b); return a]],"-z")
test_any([[mixed a,b; sscanf("-z ","%[z-]%s",a,b); return a]],"-z")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a,b; sscanf("abcdeFGji","%[a-z]%s",a,b); return a]],"abcde")
test_any([[mixed a,b; sscanf("abcdeFGji","%[a-z]%s",a,b); return b]],"FGji")
test_any([[mixed a,b; return sscanf("foo-%-bar","%s-%%-%s",a,b);]],2)
test_any([[mixed a,b; sscanf("foo-%-bar","%s-%%-%s",a,b); return a]],"foo")
test_any([[mixed a,b; sscanf("foo-%-bar","%s-%%-%s",a,b); return b]],"bar")
test_any([[mixed a; sscanf("ab","%2c",a); return a]],'a'*256+'b')
test_any([[mixed a; sscanf("abc","%3c",a); return a]],'a'*256*256+'b'*256+'c')
test_any([[mixed a; sscanf("abc","%2c",a); return a]],'a'*256+'b')
test_any([[mixed a; sscanf("ac","%3c",a); return a]],0)
test_any([[mixed a; sscanf("ab","%2s",a); return a]],"ab")
test_any([[mixed a; sscanf("abc","%3s",a); return a]],"abc")
test_any([[mixed a; sscanf("abc","%2s",a); return a]],"ab")
test_any([[mixed a; sscanf("ac","%3s",a); return a]],0)
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_any([[mixed a; sscanf("a3","%*s%d",a); return a]],3)
test_any([[mixed a; sscanf("a3","%s%*d",a); return a]],"a")
test_any([[mixed a; sscanf("a93","%s%*o",a); return a]],"a9")
test_any([[mixed a; sscanf("a93","%*s%o",a); return a]],3)
test_any([[mixed a; sscanf("a93","%s%*x",a); return a]],"")
test_any([[mixed a; sscanf("a93","%*s%x",a); return a]],0xa93)
test_any([[mixed a; sscanf("f","f%n",a); return a]],1)
|
f480c4 | 2015-01-31 | Arne Goedeke | | test_any([[
string y = "32";
{
string foo = "bar";
}
if (1 || sscanf(y, "%d", int x)) return !x;
]], 1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
a2133d | 2014-04-17 | Arne Goedeke | | define(test_sscanf, [[
test_any([[$1 a = $3, b; string s = sprintf($2, a); sscanf(s, $2, b); return s == sprintf($2, b);]], 1)
]])
define(test_sscanf_F, [[
test_sscanf(float, "%8F", $1)
test_sscanf(float, "%-8F", $1)
test_sscanf(float, "%4F", $1)
test_sscanf(float, "%-4F", $1)
]])
test_sscanf_F(Math.e)
test_sscanf_F(Math.pi)
test_sscanf_F(Math.nan)
test_sscanf_F(Math.inf)
|
e478b1 | 1998-05-25 | Marcus Comstedt | | test_any([[mixed a; sscanf("\102\052\100\000","%F",a); return a]],42.5625)
test_any([[mixed a; sscanf("\102\052\100\000","%4F",a); return a]],42.5625)
test_any([[mixed a; sscanf("\100\105\110\000\0\0\0\0","%8F",a); return a]],42.5625)
test_any([[mixed a; sscanf("\275\007\053\002","%4F",a); return a]],-0.032999999821186065673828125)
test_any([[mixed a; sscanf("\277\240\345\140\100\0\0\0","%8F",a); return a]],-0.032999999821186065673828125)
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | // Inf
|
dd6624 | 2000-11-18 | Marcus Comstedt | | test_any([[mixed a; sscanf("\177\200\0\0","%4F",a); return a>0.0]],1)
test_any([[mixed a; sscanf("\177\200\0\0","%4F",a); return (a/2)==a]],1)
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | // -Inf
|
dd6624 | 2000-11-18 | Marcus Comstedt | | test_any([[mixed a; sscanf("\377\200\0\0","%4F",a); return a<0.0]],1)
test_any([[mixed a; sscanf("\377\200\0\0","%4F",a); return (a/2)==a]],1)
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | // NaN
|
dd6624 | 2000-11-18 | Marcus Comstedt | | test_any([[mixed a; sscanf("\177\300\0\0","%4F",a); return a>0.0]],0)
test_any([[mixed a; sscanf("\177\300\0\0","%4F",a); return a<0.0]],0)
test_any([[mixed a; sscanf("\177\300\0\0","%4F",a); return a==0.0]],0)
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | // -NaN
|
dd6624 | 2000-11-18 | Marcus Comstedt | | test_any([[mixed a; sscanf("\377\300\0\0","%4F",a); return a>0.0]],0)
test_any([[mixed a; sscanf("\377\300\0\0","%4F",a); return a<0.0]],0)
test_any([[mixed a; sscanf("\377\300\0\0","%4F",a); return a==0.0]],0)
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | // Inf
|
dd6624 | 2000-11-18 | Marcus Comstedt | | test_any([[mixed a; sscanf("\177\360\0\0\0\0\0\0","%8F",a); return a>0.0]],1)
test_any([[mixed a; sscanf("\177\360\0\0\0\0\0\0","%8F",a); return(a/2)==a]],1)
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | // -Inf
|
dd6624 | 2000-11-18 | Marcus Comstedt | | test_any([[mixed a; sscanf("\377\360\0\0\0\0\0\0","%8F",a); return a<0.0]],1)
test_any([[mixed a; sscanf("\377\360\0\0\0\0\0\0","%8F",a); return(a/2)==a]],1)
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | // NaN
|
dd6624 | 2000-11-18 | Marcus Comstedt | | test_any([[mixed a; sscanf("\177\370\0\0\0\0\0\0","%8F",a); return a>0.0]],0)
test_any([[mixed a; sscanf("\177\370\0\0\0\0\0\0","%8F",a); return a<0.0]],0)
test_any([[mixed a; sscanf("\177\370\0\0\0\0\0\0","%8F",a); return a==0.0]],0)
|
d5202d | 2001-06-20 | Henrik Grubbström (Grubba) | | // -NaN
|
dd6624 | 2000-11-18 | Marcus Comstedt | | test_any([[mixed a; sscanf("\377\370\0\0\0\0\0\0","%8F",a); return a>0.0]],0)
test_any([[mixed a; sscanf("\377\370\0\0\0\0\0\0","%8F",a); return a<0.0]],0)
test_any([[mixed a; sscanf("\377\370\0\0\0\0\0\0","%8F",a); return a==0.0]],0)
|
dca598 | 1998-04-15 | Fredrik Hübinette (Hubbe) | | test_equal([[array_sscanf("10 20 30","%d %d %d")]],[[({10,20,30})]])
test_equal([[array_sscanf("1 2 3 4 5 6 7 8 9","%d %d %d %d %d %d %d %d %s")]],[[({1,2,3,4,5,6,7,8,"9"})]])
test_equal([[array_sscanf("abc","%{%c%}")]],[[ ({ ({ ({'a'}), ({'b'}), ({'c'}) }) }) ]])
|
eccd0a | 1999-10-29 | Fredrik Noring | | test_equal([[array_sscanf("\x7fffffab#", "%c%c")]], [[ ({ 0x7fffffab, '#' }) ]])
|
22d95e | 1999-11-04 | Fredrik Hübinette (Hubbe) | | test_equal([[array_sscanf("\x7fffffab#", "%1c%1c")]], [[ ({ }) ]])
|
eccd0a | 1999-10-29 | Fredrik Noring | |
|
c5ad62 | 1999-06-15 | Mirar (Pontus Hagland) | | test_true([[array_sscanf("(02323) 23455 344","%{%*[^0-9]%[0-9]%}")]])
|
622953 | 1999-11-01 | Mirar (Pontus Hagland) | | test_eq([[ array_sscanf(sprintf("%4c",16909060),"%4c")[0] ]],16909060)
test_eq([[ array_sscanf(sprintf("%-4c",16909060),"%-4c")[0] ]],16909060)
|
64979f | 2003-09-10 | Henrik Grubbström (Grubba) | | test_eq([[ array_sscanf(sprintf("%4c",16909060),"%+4c")[0] ]],16909060)
test_eq([[ array_sscanf(sprintf("%-4c",16909060),"%+-4c")[0] ]],16909060)
test_eq([[ array_sscanf(sprintf("%4c",-16909060),"%+4c")[0] ]],-16909060)
test_eq([[ array_sscanf(sprintf("%-4c",-16909060),"%+-4c")[0] ]],-16909060)
|
622953 | 1999-11-01 | Mirar (Pontus Hagland) | |
|
e7a172 | 1999-11-04 | Fredrik Hübinette (Hubbe) | | test_equal([[array_sscanf("\1000\1001\2000","%[\1000-\1111]%s")]],
[[ ({ "\1000\1001", "\2000" }) ]])
test_equal([[array_sscanf("foo\1000\1001\1111\1110\2000","%s%[\1000-\1111]%s")]],
[[ ({ "foo", "\1000\1001\1111\1110", "\2000" }) ]])
test_equal([[array_sscanf("\2000\1000\1111\1001\1110foo","%s%[\1000-\1111]%s")]],
[[ ({ "\2000", "\1000\1111\1001\1110", "foo"}) ]])
|
2b2459 | 1999-11-04 | Fredrik Hübinette (Hubbe) | |
test_equal([[ array_sscanf("02 00 DC 00 0B","%{%x%*[\0-/:-@]%}")[0] ]],
[[ ({ ({2}), ({0}), ({220}),({0}), ({11}) }) ]])
|
035b2d | 2000-08-13 | Henrik Grubbström (Grubba) | |
test_equal([[ array_sscanf("\51726\30212\66610\30131", "%*[ \t]%s")[0] ]],
|
57fbc8 | 2000-08-14 | Henrik Grubbström (Grubba) | | [[ "\51726\30212\66610\30131" ]])
|
e45d9a | 2001-01-14 | Mirar (Pontus Hagland) | |
test_equal([[ array_sscanf("hej","%s") ]], [[ ({ "hej" }) ]])
test_equal([[ array_sscanf("hej","%s%n") ]], [[ ({ "hej", 3 }) ]])
|
e02b4f | 2010-11-21 | Henrik Grubbström (Grubba) | | test_equal([[ array_sscanf("hejhopp", "%*!3s%s%n") ]], [[ ({ "hopp", 4 }) ]])
|
e45d9a | 2001-01-14 | Mirar (Pontus Hagland) | | test_eval_error([[ function f=array_sscanf; f("hej","%s% ") ]])
|
209e17 | 2003-02-19 | Marcus Comstedt | |
|
d3ade9 | 2003-02-19 | Henrik Grubbström (Grubba) | | test_equal([[ array_sscanf("\x304b\x3066\x3044\x308a\x3087\x3046\x308a", "%[^\x3042\x3044\x3046\x3048\x304a]")[0] ]],
|
209e17 | 2003-02-19 | Marcus Comstedt | | [[ "\x304b\x3066" ]])
|
56ec3b | 2004-03-07 | Martin Nilsson | | test_equal( array_sscanf("xfoox", "%sfoo%s"), ({ "x", "x" }) )
test_equal( array_sscanf("xfoox", "%sfo\400%s"), ({}) )
test_equal( array_sscanf("xfoox", "%sfo\200000%s"), ({}) )
test_equal( array_sscanf("xfo\400x", "%sfoo%s"), ({}) )
test_equal( array_sscanf("xfo\400x", "%sfo\400%s"), ({ "x", "x" }) )
test_equal( array_sscanf("xfo\400x", "%sfo\200000%s"), ({}) )
test_equal( array_sscanf("xfo\200000x", "%sfoo%s"), ({}) )
test_equal( array_sscanf("xfo\200000x", "%sfo\400%s"), ({}) )
test_equal( array_sscanf("xfo\200000x", "%sfo\200000%s"), ({ "x", "x" }) )
|
b01dbc | 2007-05-20 | Martin Nilsson | | test_any([[mixed a; sscanf("","%H",a); return a]],0)
test_any([[mixed a; sscanf("\0","%H",a); return a]],"")
test_any([[mixed a; sscanf("\4","%H",a); return a]],0)
test_any([[mixed a; sscanf("\4hello","%H",a); return a]],"hell")
test_eval_error([[mixed a; sscanf("","%0H",a); return a]])
test_eval_error([[mixed a; sscanf("\0","%0H",a); return a]])
test_eval_error([[mixed a; sscanf("\4","%0H",a); return a]])
test_eval_error([[mixed a; sscanf("\4hello","%0H",a); return a]])
test_any([[mixed a; sscanf("","%1H",a); return a]],0)
test_any([[mixed a; sscanf("\0","%1H",a); return a]],"")
test_any([[mixed a; sscanf("\4","%1H",a); return a]],0)
test_any([[mixed a; sscanf("\4hello","%1H",a); return a]],"hell")
test_any([[mixed a; sscanf("","%-1H",a); return a]],0)
test_any([[mixed a; sscanf("\0","%-1H",a); return a]],"")
test_any([[mixed a; sscanf("\4","%-1H",a); return a]],0)
test_any([[mixed a; sscanf("\4hello","%-1H",a); return a]],"hell")
test_any([[mixed a; sscanf("","%2H",a); return a]],0)
test_any([[mixed a; sscanf("\0\0","%2H",a); return a]],"")
test_any([[mixed a; sscanf("\0","%2H",a); return a]],0)
test_any([[mixed a; sscanf("\0\4","%2H",a); return a]],0)
test_any([[mixed a; sscanf("\0\4hello","%2H",a); return a]],"hell")
test_any([[mixed a; sscanf("","%-2H",a); return a]],0)
test_any([[mixed a; sscanf("\0\0","%-2H",a); return a]],"")
test_any([[mixed a; sscanf("\4","%-2H",a); return a]],0)
test_any([[mixed a; sscanf("\4\0","%-2H",a); return a]],0)
test_any([[mixed a; sscanf("\4\0hello","%-2H",a); return a]],"hell")
|
13670c | 2015-05-25 | Martin Nilsson | |
|
99aaf2 | 1999-11-17 | Henrik Grubbström (Grubba) | | test_any([[
class Bar {
string sum = "";
void bar(string s) {
sum += s;
}
string foo()
{
foreach(({ "foo ", "bar ", "baz " }), string s) {
sscanf(s, "%*[\t ]%[^ \t]", s);
switch(foo) {
default:
bar(s);
break;
}
}
return sum;
}
};
return Bar()->foo()
]], "foobarbaz")
|
37e413 | 2008-05-17 | Marcus Comstedt | | test_equal( array_sscanf("^^;|", "%[^-|]%s"), ({ "^^", ";|" }) )
test_any([[mixed a; sscanf("^^;|","%[^-|]",a); return a]],"^^")
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | | // sscanf %O -------------------------------------------------------------
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | define(test_percent_o_raw, [[
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | | test_equal(array_sscanf(]]$3[[,]]$1[[),[[$2]])
]])
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | define(test_percent_o_fmt, [[
test_percent_o_raw(]]$1[[,]]$2[[,sprintf(]]$1[[,@]]$2[[))
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | | ]])
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | define(test_percent_o_char, [[
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | | dnl patsubst doesn't exist on all m4's (it's a gnuism?)
ifdef(patsubst,[[
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | test_percent_o_raw("%O",({']]$1[['}),"']]patsubst($1,\\,\\\\)[['"))
test_percent_o_raw("%O%s",({']]$1[[',"abc"}),"']]patsubst($1,\\,\\\\)[['abc"))
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | | ]])]])
ifdef(patsubst,[[
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | define(test_percent_o_string, [[
test_percent_o_raw("%O",({"]]$1[["}),"\"]]patsubst($1,\\,\\\\)[[\""))
test_percent_o_raw("%O%s",({"]]$1[[","abc"}),"\"]]patsubst($1,\\,\\\\)[[\"abc"))
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | | ]])]])
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | test_percent_o_fmt("%O",({10}))
test_percent_o_fmt("%O%s",({10,"abc"}))
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | |
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | test_percent_o_char([[a]])
test_percent_o_char([[\a]])
test_percent_o_char([[\123]])
test_percent_o_char([[\x4711]])
test_percent_o_char([[\d4711]])
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | |
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | test_percent_o_string([[a]])
test_percent_o_string([[\a]])
test_percent_o_string([[\123]])
test_percent_o_string([[\x4711]])
test_percent_o_string([[\d4711]])
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | |
|
af8e40 | 2003-02-13 | Henrik Grubbström (Grubba) | | test_percent_o_fmt("%O %O %O",({10,20,30}))
test_percent_o_fmt("%O %O %s",({10,20,"30"}))
|
e248ee | 2003-02-13 | Mirar (Pontus Hagland) | |
// -------------------------------------------------------------
|
e7a172 | 1999-11-04 | Fredrik Hübinette (Hubbe) | |
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // Basics
test_true(1)
test_true("")
test_true(!0)
test_true(!(!1))
|
f960bd | 2015-07-31 | Martin Nilsson | | test_true(this)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_true(a) // a is the test function
test_true(0.0)
test_true(([]))
test_true(({}))
test_true((<>))
|
f960bd | 2015-07-31 | Martin Nilsson | | test_true(this_program)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing !
test_equal(!"",0)
|
f960bd | 2015-07-31 | Martin Nilsson | | test_equal(!this,0)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing ==
test_true(1==1)
test_true(!(1==2))
test_true(""=="")
test_true(!(""=="foo"))
|
f960bd | 2015-07-31 | Martin Nilsson | | test_true(this==this)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_true(2.0==2.0)
test_true(({})==({}))
// testing !=
test_true(({1})!=({1}))
test_true(1!=2)
test_true(!(1==2))
test_true(!(""!=""))
test_true(""!="foo")
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_cmp3(1,2,3)
test_cmp3(1.0,2.0,3.0)
test_cmp3(1,2.0,3.6)
test_cmp3(1.0,2,4)
test_cmp3("a","b","c")
test_cmp3("","b","cc")
|
3e625c | 1998-10-11 | Fredrik Hübinette (Hubbe) | | test_cmp3("\x0","\x100","\x10000")
test_cmp3("a\x10000","b\x100","c\x100")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// hex construction
test_eq(0,0x0)
test_eq(1,0x1)
test_eq(10,0xa)
test_eq(16,0x10)
test_eq(65535,0xffff)
test_eq(17*257*65537,0x11111111)
// octal construction
test_eq(0,00)
test_eq(1,01)
test_eq(8,010)
test_eq(64,0100)
test_eq(1073741824,010000000000)
test_eq((8+1)*(8*8+1)*(8*8*8*8+1),011111111)
// string construction tests
test_eq(16,"\20"[0])
test_eq(16,"\020"[0])
test_eq(255,"\377"[0])
test_eq(4,'\4')
|
0346dc | 2014-05-10 | Martin Nilsson | | test_eq('a',0x61)
test_eq('ab',0x6162)
test_eq('abc',0x616263)
test_eq('abcd',0x61626364)
test_true("\r"[-1]!='r')
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eq("\r"[0],'\r')
test_eq("\n"[0],'\n')
// testing +
test_eq(1+1,2)
test_eq(1+(-2),-1)
test_eq((-2)+(-2),-4)
test_eq("hi"+"there","hithere")
test_eq("human"+"number"+666,"humannumber666")
test_eq("human"+("number"+666),"humannumber666")
test_eq(("human"+"number")+666,"humannumber666")
test_eq(("human"+"number")+666+111,"humannumber666111")
test_eq("humannumber"+(666+111),"humannumber777")
test_eq("a"+"b"+"c"+"d"+"e"+"f"+"g"+"h"+"i"+"j"+"k"+"l"+"m"+"n"+"o"+"p"+"q"+"r"+"s"+"t"+"u"+"v"+"x"+"y","abcdefghijklmnopqrstuvxy")
test_eq(1.0+1.0,2.0)
test_eq(1.0+(-1.0),0.0)
test_eq((-1.0)+(-1.0),-2.0)
test_eq(1.0+1,2.0)
test_eq(1+1.0,2.0)
test_eq(1+(-1.0),0.0)
test_eq(1.0+(-1),0.0)
test_eq((-1)+(-1.0),-2.0)
test_eq((-1.0)+(-1),-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]))
|
f960bd | 2015-07-31 | Martin Nilsson | | test_eval_error(return this + this)
|
12cec8 | 2003-01-15 | Martin Nilsson | | test_any(return((1+2+3)-(1+2-3)), 6)
|
31649d | 2014-11-03 | Arne Goedeke | | // testing F_APPEND_MAPPING
test_any([[
// F_APPEND_MAPPING is not used when adding constant mappings
string index = "foo";
mapping m = ([ "foo" : 1 ]);
m += ([ index : 2 ]);
return m->foo;
]], 2)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing -
test_eq(10-3,7)
test_eq(3-10,-7)
test_eq(10.0-3.0,7.0)
test_eq(3.0-10.0,-7.0)
test_eq(10-3.0,7.0)
test_eq(3-10.0,-7.0)
test_eq(10.0-3,7.0)
test_eq(3.0-10,-7.0)
|
0bc4cf | 1998-10-13 | Fredrik Hübinette (Hubbe) | | test_eq(034567 - 10000,4711)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eq("foobargazonk"-"o","fbargaznk")
test_equal(({"foo","bar","gazonk"})-({"foo","gazonk"}),({"bar"}))
test_equal(({"c","foo","bar","gazonk","a","b",})-({"foo","gazonk"}),({"c","bar","a","b"}))
test_equal((<"foo","bar","gazonk">)-(<"foo","gazonk">),(<"bar">))
test_equal((["foo":3,"bar":4,"gazonk":5])-(["foo":3,"gazonk":8]),(["bar":4]))
|
d8ca9d | 2003-03-08 | Mirar (Pontus Hagland) | | test_any([[string s="\57070 abcdefghijklmnopqrstuvwxyz012345678"; return strlen(s-s[1..35])]],37-35)
|
3a2b82 | 2003-03-08 | Mirar (Pontus Hagland) | |
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // testing ~
test_eq(-1-4,~4)
test_eq(-1-627893874,~627893874)
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_eq(~1.0,-2.0)
test_eq(~"\x55","\xaa")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing *
test_eq(3*4,12)
test_eq(4*3,12)
test_eq(2*2*2*2*2,32)
test_eq(3.0*4.0,12.0)
test_eq(4.0*3.0,12.0)
test_eq(2.0*2.0*2.0*2.0*2.0,32.0)
test_eq(3*4.0,12.0)
test_eq(4*3.0,12.0)
test_eq(2*2.0*2.0*2.0*2.0,32.0)
test_eq(3.0*4,12.0)
test_eq(4.0*3,12.0)
test_eq(2.0*2*2.0*2*2.0,32.0)
|
0bc4cf | 1998-10-13 | Fredrik Hübinette (Hubbe) | |
|
12cec8 | 2003-01-15 | Martin Nilsson | | test_eq([[({})*""]],"")
test_eq([[({"foo",0,"bar"})*"-"]],"foo-bar")
test_eq([[({"f","o","o"})*""]],"foo")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eq(({"foo","bar","gazonk"})*"-","foo-bar-gazonk")
|
3e625c | 1998-10-11 | Fredrik Hübinette (Hubbe) | | test_eq(({"f\777\777","bar","gaz\777nk"})*"-","f\777\777-bar-gaz\777nk")
test_eq(({"f\7777777\7777777","bar","gaz\7777777nk"})*"-","f\7777777\7777777-bar-gaz\7777777nk")
|
0bc4cf | 1998-10-13 | Fredrik Hübinette (Hubbe) | |
test_eq(({"foo","bar","gazonk"})*"\777","foo\777bar\777gazonk")
test_eq(({"f\777\777","bar","gaz\777nk"})*"\777","f\777\777\777bar\777gaz\777nk")
test_eq(({"f\7777777\7777777","bar","gaz\7777777nk"})*"\777","f\7777777\7777777\777bar\777gaz\7777777nk")
test_eq(({"foo","bar","gazonk"})*"\7777777","foo\7777777bar\7777777gazonk")
test_eq(({"f\777\777","bar","gaz\777nk"})*"\7777777","f\777\777\7777777bar\7777777gaz\777nk")
test_eq(({"f\7777777\7777777","bar","gaz\7777777nk"})*"\7777777","f\7777777\7777777\7777777bar\7777777gaz\7777777nk")
|
7fa910 | 1997-02-18 | Fredrik Hübinette (Hubbe) | | test_equal( ({ ({1}), ({2}), ({3}) })*({8}), ({1,8,2,8,3}))
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_equal( ({ 1 })*3, ({1,1,1}) )
test_equal( "foo"*3, "foofoofoo" )
|
b0dfdc | 2000-09-26 | Henrik Wallin | | test_equal( "foo"*2.5, "foofoofo" )
test_equal( "\1234oo"*2.5, "\1234oo\1234oo\1234o" )
test_equal( ({1,2,3})*1.5, ({1,2,3,1,2}))
test_equal( ({1,2,3})*1.4, ({1,2,3,1}))
test_equal( ({1,2,3})*0.0, ({}))
test_equal( ({})*3.0, ({}))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing /
test_eq(12/3,4)
test_eq(13/3,4)
test_eq(14/3,4)
test_eq(15/3,5)
|
c93f0e | 1997-12-03 | Fredrik Hübinette (Hubbe) | | test_eq(-2/4,-1)
|
806a2c | 1997-04-28 | Fredrik Hübinette (Hubbe) | | test_eq(-12/3,-4)
test_eq(-13/3,-5)
test_eq(-14/3,-5)
test_eq(-15/3,-5)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eval_error(return 15/0)
test_eq(12.0/3.0,4.0)
test_eq(14.0/4.0,3.5)
test_eq(15.0/3.0,5.0)
test_eq(12/3.0,4.0)
test_eq(14/4.0,3.5)
test_eq(15/3.0,5.0)
test_eq(12.0/3,4.0)
test_eq(14.0/4,3.5)
test_eq(15.0/3,5.0)
test_eval_error(return 15.0/0.0)
test_equal("foo-bar-gazonk"/"-",({"foo","bar","gazonk"}))
test_equal("foobargazonk"/"",({"f","o","o","b","a","r","g","a","z","o","n","k"}))
|
7fa910 | 1997-02-18 | Fredrik Hübinette (Hubbe) | | test_equal(({1,0,1,2,1,2,2,2,1,1,1})/({2}),({ ({1,0,1}), ({1}), ({}), ({}), ({1,1,1}) }))
test_equal(({1,2,3,4})/({}),({ ({1}), ({2}), ({3}), ({4}) }))
|
804552 | 2009-05-02 | Henrik Grubbström (Grubba) | | test_eq(sizeof(allocate(119)/({})), 119)
test_eq(sizeof(allocate(120)/({})), 120)
test_eq(sizeof(allocate(121)/({})), 121)
test_eq(sizeof(allocate(122)/({})), 122)
|
7fa910 | 1997-02-18 | Fredrik Hübinette (Hubbe) | | test_equal(({1,0,1,2,1,2,2,2,1,1,1})/({2,1}),({ ({1,0,1}), ({2,2}), ({1,1}) }))
|
034fb9 | 1997-02-24 | Fredrik Hübinette (Hubbe) | | test_equal( ({1,2,3})/({2,3}), ({ ({1}), ({}) }) )
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq([[`/(20,2,2)]],5)
test_eq([[`/(13,2,3)]],2)
test_equal("foobargazonk"/1,"foobargazonk"/"")
test_equal("foobargazonk"/2,({"fo","ob","ar","ga","zo","nk"}))
test_equal("foobargazonk"/3,({"foo","bar","gaz","onk"}))
test_equal("foobargazonk"/4,({"foob","arga","zonk"}))
test_equal("foobargazonk"/5,({"fooba","rgazo"}))
test_equal("foobargazonk"/-6,({"foobar","gazonk"}))
test_equal("foobargazonk"/-7,({"rgazonk"}))
|
a5a649 | 2011-03-03 | Martin Stjernholm | | test_eq(({})/100.0, ({}));
test_eq(({})/100, ({}));
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | |
test_equal("foobargazonk"/5.0,({"fooba","rgazo","nk"}))
test_equal("foobargazonk"/-5.0,({"fo","obarg","azonk"}))
|
b0dfdc | 2000-09-26 | Henrik Wallin | | test_equal("foobargazonk"/2.5,({"foo","ba","rga","zo","nk"}))
test_equal("foo"/2.6,({"foo",""}))
test_equal("\1233oo"/2.6,({"\1233oo",""}))
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | |
|
0bc4cf | 1998-10-13 | Fredrik Hübinette (Hubbe) | | test_equal("f\777\777bargaz\777nk"/1,"f\777\777bargaz\777nk"/"")
test_equal("f\777\777bargaz\777nk"/2,({"f\777","\777b","ar","ga","z\777","nk"}))
test_equal("f\777\777bargaz\777nk"/3,({"f\777\777","bar","gaz","\777nk"}))
test_equal("f\777\777bargaz\777nk"/4,({"f\777\777b","arga","z\777nk"}))
test_equal("f\777\777bargaz\777nk"/5,({"f\777\777ba","rgaz\777"}))
test_equal("f\777\777bargaz\777nk"/-6,({"f\777\777bar","gaz\777nk"}))
test_equal("f\777\777bargaz\777nk"/-7,({"rgaz\777nk"}))
test_equal("f\777\777bargaz\777nk"/5.0,({"f\777\777ba","rgaz\777","nk"}))
test_equal("f\777\777bargaz\777nk"/-5.0,({"f\777","\777barg","az\777nk"}))
|
1e5db5 | 2000-09-27 | Henrik Wallin | | test_equal("f\777\777bargaz\777nk"/2.5,({"f\777\777","ba","rga","z\777","nk"}))
|
0bc4cf | 1998-10-13 | Fredrik Hübinette (Hubbe) | |
|
12cec8 | 2003-01-15 | Martin Nilsson | | test_equal(""/"hej", ({""}))
test_equal("hej"/"hej", ({"",""}))
|
0bc4cf | 1998-10-13 | Fredrik Hübinette (Hubbe) | | test_equal("f\7777777\7777777bargaz\7777777nk"/1,"f\7777777\7777777bargaz\7777777nk"/"")
test_equal("f\7777777\7777777bargaz\7777777nk"/2,({"f\7777777","\7777777b","ar","ga","z\7777777","nk"}))
test_equal("f\7777777\7777777bargaz\7777777nk"/3,({"f\7777777\7777777","bar","gaz","\7777777nk"}))
test_equal("f\7777777\7777777bargaz\7777777nk"/4,({"f\7777777\7777777b","arga","z\7777777nk"}))
test_equal("f\7777777\7777777bargaz\7777777nk"/5,({"f\7777777\7777777ba","rgaz\7777777"}))
test_equal("f\7777777\7777777bargaz\7777777nk"/-6,({"f\7777777\7777777bar","gaz\7777777nk"}))
test_equal("f\7777777\7777777bargaz\7777777nk"/-7,({"rgaz\7777777nk"}))
test_equal("f\7777777\7777777bargaz\7777777nk"/5.0,({"f\7777777\7777777ba","rgaz\7777777","nk"}))
test_equal("f\7777777\7777777bargaz\7777777nk"/-5.0,({"f\7777777","\7777777barg","az\7777777nk"}))
|
fed8df | 2000-09-27 | Henrik Grubbström (Grubba) | | test_equal("f\7777777\7777777bargaz\7777777nk"/2.5,({"f\7777777\7777777", "ba","rga","z\7777777","nk"}))
|
0bc4cf | 1998-10-13 | Fredrik Hübinette (Hubbe) | |
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_equal(({1,2,3})/1,({ ({1}), ({2}), ({3}) }))
test_equal(({1,2,3})/2,({ ({1,2}) }))
test_equal(({1,2,3})/-2,({ ({2,3}) }))
test_equal(({1,2,3})/2.0,({ ({1,2}), ({3}) }))
test_equal(({1,2,3})/-2.0,({ ({1}), ({2,3}) }))
|
b0dfdc | 2000-09-26 | Henrik Wallin | | test_equal(({1,2,3})/1.5,({ ({1, 2}), ({3}) }))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing %
test_eq(12%3,0)
test_eq(13%3,1)
test_eq(14%3,2)
test_eq(15%3,0)
|
806a2c | 1997-04-28 | Fredrik Hübinette (Hubbe) | | test_eq(2%17,2)
test_eq(2%-17,-15)
test_eq(-2%17,15)
test_eq(-2%-17,-2)
|
284c36 | 1997-09-15 | Fredrik Hübinette (Hubbe) | | test_eq(-10%10,0)
test_eq(10%-10,0)
test_eq(-10%-10,0)
test_eq(10%10,0)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eval_error(return 15 % 0)
test_eq(12.0 % 3.0,0.0)
test_eq(13.0 % 3.0,1.0)
test_eq(14.0 % 3.0,2.0)
test_eq(14.5 % 3.0,2.5)
test_eq(15.0 % 3.0,0.0)
test_eq(13 % 3.0,1.0)
test_eq(14 % 3.0,2.0)
test_eq(13.0 % 3,1.0)
test_eq(14.0 % 3,2.0)
test_eq(14.5 % 3,2.5)
test_eval_error(return 15.0 % 0.0)
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq("foobargazonk"%5,"nk")
test_eq("foobargazonk"%-5,"fo")
|
0bc4cf | 1998-10-13 | Fredrik Hübinette (Hubbe) | | test_eq("f\777\777bargaz\777nk"%5,"nk")
test_eq("f\777\777bargaz\777nk"%-5,"f\777")
test_eq("f\7777777\7777777bargaz\7777777nk"%5,"nk")
test_eq("f\7777777\7777777bargaz\7777777nk"%-5,"f\7777777")
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_equal(({1,2,3})%2,({3}))
test_equal(({1,2,3})%-2,({1}))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // testing &&
test_eq(0 && 1,0)
test_eq(1 && 0,0)
test_eq(0 && 0,0)
test_eq(1 && 1,1)
test_eq(78 && 1,1)
test_eq(78 && 99,99)
test_eq(78 && 99,99)
// testing ||
test_eq(0 || 1,1)
test_eq(1 || 0,1)
test_eq(0 || 0,0)
test_eq(1 || 1,1)
test_eq(78 || 1,78)
test_eq(78 || 0,78)
// testing |
test_eq(0 | 0,0)
test_eq(1 | 1,1)
test_eq(4 | 1,5)
test_eq(1 | 9,9)
|
20d9f9 | 2003-08-10 | Martin Nilsson | | test_eq([[ "\007" | "\023"]],"\027")
test_eq([[ "\177777x" | "ab" ]], "\177777z")
|
934a7f | 2003-11-10 | Martin Stjernholm | | test_equal( ({1,2,3,4,4}) | ({3,5,6}), ({1,2,3,4,4,5,6}))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | 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]) )
|
aa4a32 | 2001-01-03 | Martin Stjernholm | | test_any([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | class Foo {protected int `< (object o) {return 0;}};
|
aa4a32 | 2001-01-03 | Martin Stjernholm | | return sizeof (({Foo()}) | ({Foo()}));
]], 2)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing &
test_eq(0 & 0,0)
test_eq(1 & 1,1)
test_eq(4 & 1,0)
test_eq(1 & 9,1)
|
20d9f9 | 2003-08-10 | Martin Nilsson | | test_eq([[ "\007" & "\023"]],"\003")
test_eq([[ "\177777x" & "ab" ]], "a`")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_equal( ({1,2,3,4,4}) & ({3,5,6}), ({3}))
test_equal( (<4,5,6>) & (<5,5,5>), (<5>) )
test_equal( ([-4:8,8:7]) & ([3:3,8:3]), ([8:3]) )
|
b11798 | 2004-04-15 | Martin Stjernholm | | test_equal(({1,2,1}) & ({1,2}), ({1,2}))
test_equal(({2,1,2}) & ({1,2}), ({2,1}))
test_equal(({1,2,1,2,2}) & ({1,2}), ({1,2}))
test_equal(({2,1,2,1,2}) & ({1,2}), ({2,1}))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing ^
test_eq(0 ^ 0,0)
test_eq(1 ^ 1,0)
test_eq(4 ^ 1,5)
test_eq(1 ^ 9,8)
|
20d9f9 | 2003-08-10 | Martin Nilsson | | test_eq([[ "\007" ^ "\023"]],"\024")
test_eq([[ "\177777x" ^ "ab" ]], "\177636\32")
|
934a7f | 2003-11-10 | Martin Stjernholm | | test_equal( ({1,2,3,4,4}) ^ ({3,5,6}) , ({1,2,4,4,5,6}))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_equal( (<4,5,6>) ^ (<5,5,5>), (<4,5,5,6>) )
test_equal( ([-4:8,8:7]) ^ ([3:3,8:3]), ([-4:8,3:3]) )
|
934a7f | 2003-11-10 | Martin Stjernholm | | test_equal(({1,3,3,3,4}) ^ ({2,3,3,5}), ({1,3,4,2,5}))
test_equal(({1,3,3,4}) ^ ({2,3,3,3,5}), ({1,4,2,3,5}))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing <<
test_eq(1<<0,1)
test_eq(1<<1,2)
test_eq(1<<10,1024)
test_eq(5<<3,40)
|
df8dce | 2002-10-16 | Henrik Grubbström (Grubba) | | test_eval_error(return 17<<-10)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing >>
test_eq(9>>2,2)
test_eq(1>>1,0)
test_eq(1024>>10,1)
test_eq(47>>3,5)
|
0c50a2 | 2002-10-15 | Marcus Comstedt | | test_eq(-10>>10000,-1)
|
df8dce | 2002-10-16 | Henrik Grubbström (Grubba) | | test_eval_error(return 17>>-10)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// testing ? :
test_true(0?0:1)
test_true(1?1:0)
test_true(""?1:0)
test_true(!0?1:0)
test_true(!(!1)?1:0)
|
f960bd | 2015-07-31 | Martin Nilsson | | test_true(this?1:0)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_true(a?1:0) // a is the test function
test_true(0.0?1:0)
test_true(([])?1:0)
test_true(({})?1:0)
test_true((<>)?1:0)
|
f960bd | 2015-07-31 | Martin Nilsson | | test_true(this_program?1:0)
|
8dc4ff | 1999-02-05 | Martin Stjernholm | | test_eq(1 ? "a" : 1 ? "b" : 1, "a")
test_eq(0 ? "a" : 1 ? "b" : 1 ? "c" : 1, "b")
test_eq(0 ? "a" : 0 ? "b" : 1 ? "c" : 1, "c")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
45fe64 | 2013-01-08 | Arne Goedeke | | // testing overflow checks
test_eq(-1 - 0x7fffffff, -0x80000000)
|
34e278 | 2013-01-11 | Arne Goedeke | | test_eq(Int.NATIVE_MIN % -1, 0)
test_eq(Int.NATIVE_MAX % Int.NATIVE_MIN, -1)
|
45fe64 | 2013-01-08 | Arne Goedeke | |
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // testing indexing
test_eq("foo"[0],'f')
test_eq("foo"[1],'o')
test_eq("foo"[2],'o')
test_eq("foo"[-1],'o')
test_eq("foo"[-2],'o')
test_eq("foo"[-3],'f')
|
3e625c | 1998-10-11 | Fredrik Hübinette (Hubbe) | |
test_eq("f\777\777"[0],'f')
test_eq("f\777\777"[1],'\777')
test_eq("f\777\777"[2],'\777')
test_eq("f\777\777"[-1],'\777')
test_eq("f\777\777"[-2],'\777')
test_eq("f\777\777"[-3],'f')
test_eq("f\77777777\77777777"[0],'f')
test_eq("f\77777777\77777777"[1],'\77777777')
test_eq("f\77777777\77777777"[2],'\77777777')
test_eq("f\77777777\77777777"[-1],'\77777777')
test_eq("f\77777777\77777777"[-2],'\77777777')
test_eq("f\77777777\77777777"[-3],'f')
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eq(({'f','o','o'})[0],'f')
test_eq(({'f','o','o'})[1],'o')
test_eq(({'f','o','o'})[2],'o')
test_eq(({'f','o','o'})[-1],'o')
test_eq(({'f','o','o'})[-2],'o')
test_eq(({'f','o','o'})[-3],'f')
test_eq(([0:'f',1:'o',2:'o'])[0],'f')
test_eq(([0:'f',1:'o',2:'o'])[1],'o')
test_eq(([0:'f',1:'o',2:'o'])[2],'o')
|
cf6e63 | 2008-06-28 | Martin Nilsson | | test_eq(([0:'f',1:'o',2:'o'])[random(0)+3],0)
test_eq(([0:'f',1:'o',2:'o'])[random(0)-1],0)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eq((<'f','o','o'>)['o'],1)
test_eq((<'f','o','o'>)['f'],1)
|
cf6e63 | 2008-06-28 | Martin Nilsson | | test_eq((<'f','o','o'>)[random(0)+'b'],0)
|
46e354 | 2015-05-15 | Henrik Grubbström (Grubba) | | test_eq((<'f','o','o'>)[ [int](mixed)-1],0)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_eq([[class { protected mixed `->(mixed x) { return this[x]; } int foo() { return 1; }}()->foo()]],1)
|
99761f | 1998-10-09 | Fredrik Hübinette (Hubbe) | |
|
7ed6bb | 2013-03-06 | Henrik Grubbström (Grubba) | | // Test some indexing opcodes.
test_eval_error([[return ({1})[1];]])
test_eval_error([[int i = 1; return ({1})[i];]])
test_eval_error([[array a = ({ 1 }); return a[1];]])
test_eval_error([[array a = ({ 1 }); int i = 1; return a[i];]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // 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)
|
141487 | 2005-05-18 | Martin Nilsson | | test_any(mixed a="hej"; a[1]='o'; return a,"hoj")
test_do( string x=" "*73; x[64]=1; x[65]=1; )
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_define_program(test,[[public int q,w,e,r; mixed t; mixed getw() { return w; } void setw(int _) { w=_; }]])
|
2aeef5 | 2002-11-26 | Martin Nilsson | | 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(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");)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// 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")
|
e485a0 | 2006-06-16 | Henrik Grubbström (Grubba) | | ignore_warning("Range is always empty.", [[
test_any(return "foo"[1..0];,"")
]])
|
408a1e | 2004-10-30 | Martin Stjernholm | | test_any(int u=-100; return "foo"[0..u];,"") dnl Use variable to avoid warning.
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_eq("foobargazonk"[0..],"foobargazonk")
test_eq("foobargazonk"[1..],"oobargazonk")
test_eq("foobargazonk"[5..],"rgazonk")
test_eq("foobargazonk"[..2],"foo")
test_eq("foobargazonk"[..5],"foobar")
|
63d458 | 2008-09-02 | Martin Stjernholm | | test_eq("1234"[..Int.NATIVE_MAX], "1234")
test_eq("1234"[..Int.NATIVE_MAX - 1], "1234")
test_eq("1234"[Int.NATIVE_MIN..], "1234")
test_eq("1234"[Int.NATIVE_MIN + 1..], "1234")
|
3e625c | 1998-10-11 | Fredrik Hübinette (Hubbe) | |
test_eq("f\7777\7777bargaz\7777nk"[0..],"f\7777\7777bargaz\7777nk")
test_eq("f\7777\7777bargaz\7777nk"[1..],"\7777\7777bargaz\7777nk")
test_eq("f\7777\7777bargaz\7777nk"[5..],"rgaz\7777nk")
test_eq("f\7777\7777bargaz\7777nk"[..2],"f\7777\7777")
test_eq("f\7777\7777bargaz\7777nk"[..5],"f\7777\7777bar")
test_eq("f\77777777\77777777bargaz\77777777nk"[0..],"f\77777777\77777777bargaz\77777777nk")
test_eq("f\77777777\77777777bargaz\77777777nk"[1..],"\77777777\77777777bargaz\77777777nk")
test_eq("f\77777777\77777777bargaz\77777777nk"[5..],"rgaz\77777777nk")
test_eq("f\77777777\77777777bargaz\77777777nk"[..2],"f\77777777\77777777")
test_eq("f\77777777\77777777bargaz\77777777nk"[..5],"f\77777777\77777777bar")
|
a1db06 | 2016-06-07 | Henrik Grubbström (Grubba) | | test_eq("ABCD\u2019"[1..][1..], "ABCD\u2019"[2..])
|
269d33 | 2016-09-14 | Henrik Grubbström (Grubba) | | test_any_equal([[
// Bug 7780
string s1 = "aaaaa";
string s2 = "BBBBBBBB";
s2 = (s2 + s1)[..sizeof(s1) - 1];
return (array)s2;
]], ({ 66, 66, 66, 66, 66 }))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_equal(({1,2,3})[0..0],({1}))
test_equal(({1,2,3})[1..2],({2,3}))
test_equal(({1,2,3})[2..10],({3}))
test_equal(({1,2,3})[-100..0],({1}))
test_equal(({1,2,3})[-100..100],({1,2,3}))
|
e485a0 | 2006-06-16 | Henrik Grubbström (Grubba) | | ignore_warning("Range is always empty.", [[
test_any_equal(return ({1,2,3})[1..0];,({}))
]])
|
408a1e | 2004-10-30 | Martin Stjernholm | | test_any_equal(int u=-100; return ({1,2,3})[0..u];,({})) dnl Use variable to avoid warning.
test_eq("abcdef"[1..3], "bcd")
test_eq("abcdef"[1..<3], "bc")
test_eq("abcdef"[1..], "bcdef")
test_eq("abcdef"[<1..3], "")
test_eq("abcdef"[<1..<3], "")
test_eq("abcdef"[<1..], "ef")
test_eq("abcdef"[<3..3], "cd")
test_eq("abcdef"[<3..<3], "c")
test_eq("abcdef"[<3..], "cdef")
test_eq("abcdef"[..3], "abcd")
test_eq("abcdef"[..<3], "abc")
|
e485a0 | 2006-06-16 | Henrik Grubbström (Grubba) | | ignore_warning("Redundant range operator.", [[
test_eq("abcdef"[..], "abcdef")
]])
|
408a1e | 2004-10-30 | Martin Stjernholm | |
test_equal(`[..] ("abcdef"/"", 1, Pike.INDEX_FROM_BEG, 3, Pike.INDEX_FROM_BEG), "bcd"/"");
test_equal(`[..] ("abcdef"/"", 1, Pike.INDEX_FROM_BEG, 3, Pike.INDEX_FROM_END), "bc"/"");
test_equal(`[..] ("abcdef"/"", 1, Pike.INDEX_FROM_BEG, 3, Pike.OPEN_BOUND), "bcdef"/"");
test_equal(`[..] ("abcdef"/"", 3, Pike.INDEX_FROM_END, 3, Pike.INDEX_FROM_BEG), "cd"/"");
test_equal(`[..] ("abcdef"/"", 3, Pike.INDEX_FROM_END, 3, Pike.INDEX_FROM_END), "c"/"");
test_equal(`[..] ("abcdef"/"", 3, Pike.INDEX_FROM_END, 3, Pike.OPEN_BOUND), "cdef"/"");
test_equal(`[..] ("abcdef"/"", 1, Pike.OPEN_BOUND, 3, Pike.INDEX_FROM_BEG), "abcd"/"");
test_equal(`[..] ("abcdef"/"", 1, Pike.OPEN_BOUND, 3, Pike.INDEX_FROM_END), "abc"/"");
test_equal(`[..] ("abcdef"/"", 1, Pike.OPEN_BOUND, 3, Pike.OPEN_BOUND), "abcdef"/"");
define(test_new_style, [[
test_any_equal([[
object new_style = class {
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected array(int) `[..] (int... args) {return args;}
|
408a1e | 2004-10-30 | Martin Stjernholm | | }();
return new_style $1;
]], $2)
]])
test_new_style([1..3], ({1, Pike.INDEX_FROM_BEG, 3, Pike.INDEX_FROM_BEG}))
test_new_style([1..<3], ({1, Pike.INDEX_FROM_BEG, 3, Pike.INDEX_FROM_END}))
test_new_style([1..], ({1, Pike.INDEX_FROM_BEG, 0, Pike.OPEN_BOUND}))
test_new_style([<1..3], ({1, Pike.INDEX_FROM_END, 3, Pike.INDEX_FROM_BEG}))
test_new_style([<1..<3], ({1, Pike.INDEX_FROM_END, 3, Pike.INDEX_FROM_END}))
test_new_style([<1..], ({1, Pike.INDEX_FROM_END, 0, Pike.OPEN_BOUND}))
test_new_style([..3], ({0, Pike.OPEN_BOUND, 3, Pike.INDEX_FROM_BEG}))
test_new_style([..<3], ({0, Pike.OPEN_BOUND, 3, Pike.INDEX_FROM_END}))
test_new_style([..], ({0, Pike.OPEN_BOUND, 0, Pike.OPEN_BOUND}))
undefine([[test_new_style]])
define(test_old_style, [[
test_any_equal([[
object old_style = class {
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected int _sizeof() {return 6;}
protected array(int) `[] (int... args) {return args;}
|
408a1e | 2004-10-30 | Martin Stjernholm | | }();
return old_style $1;
]], $2)
]])
test_old_style([1..3], ({1, 3}))
test_old_style([1..<3], ({1, 2}))
test_old_style([1..], ({1, Int.NATIVE_MAX})) dnl Upper bound might become larger.
test_old_style([<1..3], ({4, 3}))
test_old_style([<1..<3], ({4, 2}))
test_old_style([<1..], ({4, Int.NATIVE_MAX})) dnl Upper bound might become larger.
test_old_style([..3], ({0, 3}))
test_old_style([..<3], ({0, 2}))
test_old_style([..], ({0, Int.NATIVE_MAX})) dnl Upper bound might become larger.
undefine([[test_old_style]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | // casting
test_eq([[(int)1]],[[1]])
|
17a46a | 2000-06-13 | Martin Nilsson | | test_eq([[(int)-1]],[[-1]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq([[(int)1.0]],[[1]])
|
17a46a | 2000-06-13 | Martin Nilsson | | test_eq([[(int)-1.0]],[[-1]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq([[(int)"1"]],[[1]])
|
17a46a | 2000-06-13 | Martin Nilsson | | test_eq([[(int)"-1"]],[[-1]])
|
f21880 | 2001-06-05 | Fredrik Hübinette (Hubbe) | | test_eq([[(int)"0x1"]],[[0]])
test_eq([[(int)"010"]],[[10]])
|
b83b37 | 2016-12-31 | Martin Nilsson | | test_eq((int)Gmp.mpz(5), 5)
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | 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) {
|
b83b37 | 2016-12-31 | Martin Nilsson | | return 1.0; } }(); ]]);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_eval_error([[ return (int)class { protected mixed cast(string x) {
|
b83b37 | 2016-12-31 | Martin Nilsson | | return ADT.Heap(); } }(); ]]);
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_any([[ return (int)class { protected mixed cast(string x) {
|
b83b37 | 2016-12-31 | Martin Nilsson | | return Gmp.mpz(7); } }(); ]], Gmp.mpz(7));
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq([[(float)"1"]],[[1.0]])
|
17a46a | 2000-06-13 | Martin Nilsson | | test_eq([[(float)"-1"]],[[-1.0]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq([[(float)"1.0"]],[[1.0]])
|
17a46a | 2000-06-13 | Martin Nilsson | | test_eq([[(float)"-1.0"]],[[-1.0]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq([[(float)1.0]],[[1.0]])
|
17a46a | 2000-06-13 | Martin Nilsson | | test_eq([[(float)-1.0]],[[-1.0]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq([[(float)1]],[[1.0]])
|
17a46a | 2000-06-13 | Martin Nilsson | | test_eq([[(float)-1]],[[-1.0]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_eq([[(string)1]],[["1"]])
|
17a46a | 2000-06-13 | Martin Nilsson | | test_eq([[(string)-1]],[["-1"]])
|
d7e29c | 2009-06-30 | Martin Stjernholm | | test_eq([[(string)1.0]],[["1.0"]])
test_eq([[(string)-1.0]],[["-1.0"]])
|
b83b37 | 2016-12-31 | Martin Nilsson | | test_eq((string)Gmp.mpz(5), "5")
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_eq((string)class { protected mixed cast(string x) {
|
b83b37 | 2016-12-31 | Martin Nilsson | | return x=="string" && "7"; } }(), "7")
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | test_eval_error((string)class { protected mixed cast(string x) { return 1.0; }}();)
test_eval_error((string)class { protected mixed cast(string x) {
|
b83b37 | 2016-12-31 | Martin Nilsson | | return ADT.Heap(); }}();)
test_any([[
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | 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(); } }();
|
b83b37 | 2016-12-31 | Martin Nilsson | | return o->q;]], 9)
|
8c7ce9 | 2010-06-02 | Henrik Grubbström (Grubba) | | // Note: 32-bit floats overflow at ~3.4e38.
test_true([[has_value ((string)1e38, ".") ||
has_value ((string)1e38, "e")]])
test_true([[has_value ((string)-1e38, ".") ||
has_value ((string)-1e38, "e")]])
test_true([[has_value ((string)1e-38, ".") ||
has_value ((string)1e-38, "e")]])
test_true([[has_value ((string)-1e-38, ".") ||
has_value ((string)-1e-38, "e")]])
cond([[Float.DIGITS_10 >= 15]], [[ // Usual size with 64 bit IEEE floats.
// Note: 1e100 overflows to infinity with 32 bit floats.
test_true([[has_value ((string)1e100, ".") ||
has_value ((string)1e100, "e")]])
test_true([[has_value ((string)-1e100, ".") ||
has_value ((string)-1e100, "e")]])
]])
// Note: 1e-100 underflows to 0.0 with 32 bit IEEE floats, but that's ok.
|
b13bc3 | 2009-06-30 | Martin Stjernholm | | test_true([[has_value ((string)1e-100, ".") ||
has_value ((string)1e-100, "e")]])
test_true([[has_value ((string)-1e-100, ".") ||
has_value ((string)-1e-100, "e")]])
test_true([[has_value ((string)124354236143512312334562453624.1, ".") ||
has_value ((string)124354236143512312334562453624.1, "e")]])
|
766e0b | 2009-08-05 | Martin Stjernholm | | test_eq([[(string) 0.8]], [["0.8"]])
cond([[Float.DIGITS_10 >= 6]], [[ // Usual size with 32 bit IEEE floats.
test_eq([[(string) 0.811113]], [["0.811113"]])
test_eq([[(string) 0.811114]], [["0.811114"]])
|
ba332a | 2009-08-15 | Martin Stjernholm | | test_true([[Regexp ("^8\\.11113e\\+0*19$")->match ((string) 0.811113e20)]])
test_true([[Regexp ("^8\\.11114e\\+0*19$")->match ((string) 0.811114e20)]])
|
766e0b | 2009-08-05 | Martin Stjernholm | | ]])
cond([[Float.DIGITS_10 >= 15]], [[ // Usual size with 64 bit IEEE floats.
test_eq([[(string) 0.811111111111113]], [["0.811111111111113"]])
test_eq([[(string) 0.811111111111114]], [["0.811111111111114"]])
|
ba332a | 2009-08-15 | Martin Stjernholm | | test_true([[Regexp ("^8\\.11111111111113e\\+0*19$")->match ((string) 0.811111111111113e20)]])
test_true([[Regexp ("^8\\.11111111111114e\\+0*19$")->match ((string) 0.811111111111114e20)]])
|
766e0b | 2009-08-05 | Martin Stjernholm | | ]])
|
adc0e9 | 2008-08-22 | Mirar (Pontus Hagland) | | test_do(return (string)1e308)
test_do(return (string)1e200)
test_do(return (string)1e-200)
test_do(return (string)1e-307)
|
83ffdb | 2003-03-29 | Henrik Grubbström (Grubba) | | test_any([[
array foo=({ 1 });
return (string)sizeof(foo);
]], [["1"]])
test_any([[
array foo=({ -1 });
return (string)-sizeof(foo);
]], [["-1"]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | test_equal([[(array)(["1":1])]],[[ ({ ({"1", 1}) }) ]])
test_equal([[(array(int)) ({"1","4711",2.0,4})]],[[({1,4711,2,4})]])
|
1671fe | 1998-05-16 | Fredrik Hübinette (Hubbe) | | test_equal([[(array(array))({({})})]],[[({({})})]])
|
4234be | 1998-05-16 | Fredrik Hübinette (Hubbe) | | test_equal([[ (array(array(int))) ({ ({"1","4711",2.0,4}) }) ]],[[ ({ ({1,4711,2,4}) }) ]])
|
798adb | 1998-05-16 | Fredrik Hübinette (Hubbe) | | test_equal([[ (array(array(array(int)))) ({ ({ ({"1","4711",2.0,4}) }) }) ]],[[ ({ ({ ({1,4711,2,4}) }) }) ]])
test_equal([[ (array(array(array(array(int))))) ({ ({ ({ ({"1","4711",2.0,4}) }) }) }) ]],[[ ({ ({ ({ ({1,4711,2,4}) }) }) }) ]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | |
|
fb61ba | 1998-04-26 | Fredrik Hübinette (Hubbe) | | test_equal([[(array)"foo"]],[[ values("foo") ]])
test_equal([[(array)(<1,2,3>)]],[[ indices( (<1,2,3>) )]])
|
de51d1 | 1998-05-13 | Fredrik Hübinette (Hubbe) | | test_equal([[sort(column((array)([1:2,3:4]),0))]],[[ sort(indices(([1:2,3:4])) )]])
test_equal([[sort(column((array)([1:2,3:4]),1))]],[[ sort(values(([1:2,3:4])))]])
|
1671fe | 1998-05-16 | Fredrik Hübinette (Hubbe) | | test_true([[(array(array))([]) ]])
test_true([[(array(array))([1:2]) ]])
test_true([[(array(array))([1:2,3:4]) ]])
|
de51d1 | 1998-05-13 | Fredrik Hübinette (Hubbe) | | test_true([[(array(array))([1:2,3:4,5:6]) ]])
|
6168ce | 2000-01-27 | Fredrik Hübinette (Hubbe) | | test_equal( [[ (multiset) ({1})]], [[ (< 1 >) ]] )
|
862bd0 | 2003-08-26 | Henrik Grubbström (Grubba) | | test_equal( [[ (multiset(string)) ({1})]], [[ (< "1" >) ]] )
|
be1daa | 1999-11-15 | Henrik Grubbström (Grubba) | | test_eval_error([[return (mapping)""]])
|
94671c | 2000-11-29 | Mirar (Pontus Hagland) | | test_equal([[ (mapping)({({1,2}),({3,4})})]], [[([1:2,3:4]) ]])
test_equal([[ ({({1,2})})]], [[(array)([1:2]) ]])
test_equal([[ (mapping)({})]], [[ ([]) ]])
test_equal([[ ({}) ]], [[ (array)([]) ]])
|
505aec | 2000-11-29 | Mirar (Pontus Hagland) | | test_eval_error([[ mapping m=(mapping)({ ({1,2,3}), ({4,5,6}) }); ]])
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | |
|
0302ca | 2016-01-14 | Martin Nilsson | | test_equal([[ (mapping)class{int i=3;}() ]],[[ (["i":3]) ]])
test_equal([[ (mapping(string:string))class{int i=3;}() ]],[[ (["i":"3"]) ]])
|
3f3075 | 2016-01-11 | Martin Nilsson | |
|
eba075 | 2004-09-20 | Martin Stjernholm | | test_any([[
object x = class {
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | protected mixed cast (string t) {return t == "string" && "foo";}
|
eba075 | 2004-09-20 | Martin Stjernholm | | }();
destruct (x);
return (string) x;
]], "0")
|
5d100b | 2008-07-17 | Martin Stjernholm | | test_eq([[(string) ({0,1,2})]], "\0\1\2")
test_eq([[(string) ({'z', 0xff, '.'})]], "z\xff.")
test_eq([[(string) ({'z', 0x100, '.'})]], "z\x100.")
test_eq([[(string) ({'z', 0xffff, '.'})]], "z\xffff.")
test_eq([[(string) ({'z', 0x10000, '.'})]], "z\x10000.")
test_eq([[(string) ({'z', -1, '.'})]], "z\xffffffff.")
test_eq([[(string) ({'z', 0x7fffffff, '.'})]], "z\x7fffffff.")
|
50428e | 2008-07-18 | Martin Stjernholm | | test_eval_error([[(string) ({0x80000000})]])
|
5d100b | 2008-07-17 | Martin Stjernholm | | test_eq([[(string) ({'z', -0x80000000, '.'})]], "z\x80000000.")
|
50428e | 2008-07-18 | Martin Stjernholm | | test_eval_error([[(string) ({-0x80000001})]])
|
b1f9b2 | 2019-04-11 | Henrik Grubbström (Grubba) | | 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; } }();]])
|
5d100b | 2008-07-17 | Martin Stjernholm | |
|
2a74cb | 2018-03-25 | Henrik Grubbström (Grubba) | | test_any([[
// Cast to subtyped object.
class A(int val) {
int next() { return ++val; }
}
return ((object(A))17)->next();
]], 18)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // testing @
test_equal(({1,2,3}),lambda(mixed ... x) { return x; }(@a()))
|
2de379 | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_equal("foo"/"",lambda(mixed ... x) { return x; }(@a()))
|
3488ef | 2000-04-17 | Henrik Grubbström (Grubba) | | test_any([[array a=({1,2,3}); return lambda(mixed ... x) { return x; }(@a) !=a]],1)
|
18b0a8 | 2001-01-25 | Fredrik Hübinette (Hubbe) | | test_any([[array z=({lambda(mixed x){return x;},17});return `()(@z);]],17)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
e86564 | 2015-02-14 | Arne Goedeke | | // testing ++
test_any([[ class A(void|int i){}; object a = A(); a->i++; return undefinedp(a->i); ]], 0)
test_any([[ class A(void|int i){}; object a = A(); ++a->i; return undefinedp(a->i); ]], 0)
// testing --
test_any([[ class A(void|int i){}; object a = A(); a->i--; return undefinedp(a->i); ]], 0)
test_any([[ class A(void|int i){}; object a = A(); --a->i; return undefinedp(a->i); ]], 0)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // testing +=
test_any(int a=1; a+=10; return a,11)
|
916f35 | 2007-06-10 | Martin Nilsson | | test_any_equal(mapping m=([]); m->x+=([]); return m->x, ([]))
test_any_equal(mapping m=([]); m->x+=(<>); return m->x, (<>))
test_any_equal(mapping m=([]); m->x+=({}); return m->x, ({}))
test_any_equal([[
array a = ({});
catch {
a += Array.reduce(`+,({}));
};
return a;
]],({}))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // testing -=
test_any(int a=1; a-=10; return a,-9)
|
4e1b09 | 2014-09-30 | Henrik Grubbström (Grubba) | | test_do([[ add_constant("FOO", class {
array(string) arr = ({ "a", "b", "c" });
}()); ]])
test_any_equal([[
// LysLysKOM 20983743.
compile_string("void x() {string z=\"a\"; FOO->arr-=({z});}")()->x();
compile_string("void x() {string z=\"b\"; FOO->arr=FOO->arr-({z});}")()->x();
compile_string("void x() {FOO->arr-=({\"c\"});}")()->x();
return FOO->arr;
]], ({}))
test_do([[ add_constant("FOO"); ]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // testing &=
test_any(int a=3; a&=10; return a,2)
// testing |=
test_any(int a=3; a|=10; return a,11)
|
01980d | 2008-03-22 | Henrik Grubbström (Grubba) | | test_any(int a = UNDEFINED; a|=1; return zero_type(a), 0)
|
5dfb31 | 2009-09-08 | Martin Nilsson | | test_any_equal(array a=({ "x" }); a|=({"x","y"}); return a, ({"x","y"}))
test_any_equal(array a=({ "x" }); a|=({"y"}); return a, ({"x","y"}))
test_any_equal(array a=({ "x" }); a|=({"x"}); return a, ({"x"}))
test_any_equal(array a=({ "x" }); a|=a; return a, ({"x"}))
test_any_equal(array a=({ "x" }); mapping m=(["a":a]); a|=({"x","y"}); return a, ({"x","y"}))
test_any_equal(array a=({ "x" }); mapping m=(["a":a]); a|=({"y"}); return a, ({"x","y"}))
test_any_equal(array a=({ "x" }); mapping m=(["a":a]); a|=({"x"}); return a, ({"x"}))
test_any_equal(array a=({ "x" }); mapping m=(["a":a]); a|=a; return a, ({"x"}))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | // testing ^=
test_any(int a=3; a^=10; return a,9)
// testing <<=
test_any(int a=3; a<<=2; return a,12)
// testing <<=
test_any(int a=12; a>>=2; return a,3)
// testing *=
test_any(int a=12; a*=2; return a,24)
// testing /=
test_any(int a=12; a/=2; return a,6)
// testing %=
test_any(int a=12; a%=7; return a,5)
// testing control structs
test_any(return 1,1)
test_any(return lambda(){return 1;} (),1 )
test_any(if(0) return 0; else return 1,1)
test_any(if(0) return 0; return 1,1)
test_any(if(1) return 1; else return 0,1)
test_any(if("") return 1; else return 0,1)
test_any(if(!0) return 1; else return 0,1)
test_any(if(!(!1)) return 1; else return 0,1)
|
f960bd | 2015-07-31 | Martin Nilsson | | test_any(if(this) return 1; else return 0,1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any(if(a) return 1; else return 0,1) dnl a is the test function
test_any(if(0.0) return 1; else return 0,1)
test_any(if(([])) return 1; else return 0,1)
test_any(if(({})) return 1; else return 0,1)
test_any(if((<>)) return 1; else return 0,1)
|
f960bd | 2015-07-31 | Martin Nilsson | | test_any(if(this_program) return 1; else return 0,1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
// break
test_any(while(1) break; return 1,1)
test_any(while(1) if(1) break; return 1,1)
// for
|
cd90c5 | 1998-08-05 | Fredrik Hübinette (Hubbe) | | test_program(
|
3488ef | 2000-04-17 | Henrik Grubbström (Grubba) | | array(int) ia=({1,2,3,4,5,6});
|
cd90c5 | 1998-08-05 | Fredrik Hübinette (Hubbe) | |
int a()
{
int i;
for (i=0; i<sizeof(ia); i++)
{
if (ia[i]==3)
{
ia=ia[..i-1]+ia[i+1..];
--i;
}
}
return 1;
}
)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any(int e; for(e=0;e<10;e++) break; return e,0)
test_any(int e; for(e=0;e<10;e++) continue; return e,10)
test_any(int e;string t=""; for(e=0;e<10;e++) t+=e; return t,"0123456789")
test_any(int e;string t=""; for(e=0;e<=10;e++) t+=e; return t,"012345678910")
test_any(int e;string t=""; for(e=9;e>0;e--) t+=e; return t,"987654321")
test_any(int e;string t=""; for(e=9;e>=0;e--) t+=e; return t,"9876543210")
test_any(int e;string t=""; for(e=9;e!=0;e--) t+=e; return t,"987654321")
test_any(int e;string t=""; for(e=2;e!=10;e++) t+=e; return t,"23456789")
test_any(int e;string t=""; for(e=0;e>-10;e--) t+=e; return t,"0-1-2-3-4-5-6-7-8-9")
// foreach
test_any([[int e;string t=""; foreach(({7,6,3,8}),e) t+=e; return t]],"7638")
|
3488ef | 2000-04-17 | Henrik Grubbström (Grubba) | | test_any([[
/* FIXME: This test needs to be proofed against the optimizer. */
string s;if(1) foreach(({}),s); else foreach(({}),s); return 1
]],1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
85524c | 2015-02-19 | Henrik Grubbström (Grubba) | | test_any([[
// Bug 7426.
array a = ({});
foreach(a[1..], mixed e) return 0;
return 1;
]], 1)
|
2e952a | 2001-02-27 | Fredrik Hübinette (Hubbe) | | test_any([[
int ret;
foreach( ([1:2,3:5,7:11,13:17]) ; int a ; int b) ret+=a*b;
return ret;
]],315)
test_any([[
int ret;
foreach( ([1:2,3:5,7:11,13:17]) ; ; int b) ret+=b;
return ret;
]],35)
test_any([[
int ret;
foreach( ([1:2,3:5,7:11,13:17]) ; int a; ) ret+=a;
return ret;
]],24)
test_any([[
int ret;
|
1e1794 | 2001-02-28 | Henrik Grubbström (Grubba) | | foreach( (<1,3,7,13>) ; ; int b) ret+=b;
|
2e952a | 2001-02-27 | Fredrik Hübinette (Hubbe) | | return ret;
]],4)
test_any([[
int ret;
foreach( (<1,3,7,13>) ; int a; ) ret+=a;
return ret;
]],24)
|
c8565d | 2001-09-30 | Mirar (Pontus Hagland) | | test_any([[
int ret;
foreach( (<1,3,7,13>) ; ; ) ret++;
return ret;
]],4)
|
2e952a | 2001-02-27 | Fredrik Hübinette (Hubbe) | |
test_any([[
int ret;
foreach( (<1,3,7,13>) ; int a; int b) ret+=a+b;
return ret;
]],24+4)
test_any([[
int ret;
foreach( ({2,5,11,17}) ; int a; ) ret+=a;
return ret;
]],6)
test_any([[
int ret;
foreach( ({2,5,11,17}) ; ; int b) ret+=b;
return ret;
]],35)
test_any([[
int ret;
foreach( ({2,5,11,17}) ; int a; int b) ret+=a*b;
return ret;
]],78)
|
c8565d | 2001-09-30 | Mirar (Pontus Hagland) | | test_any([[
int ret;
foreach( ({2,5,11,17}) ; ; ) ret++;
return ret;
]],4)
|
2e952a | 2001-02-27 | Fredrik Hübinette (Hubbe) | | test_any([[
int ret;
foreach( "foobar" ; int a; int b) ret+=a*b;
return ret;
]],1585)
|
6fda9f | 2001-02-28 | Henrik Grubbström (Grubba) | | test_any([[
int ret;
foreach( "foobar" ; int a;) ret+=a;
return ret;
|
96b998 | 2001-02-28 | Henrik Grubbström (Grubba) | | ]],15)
|
6fda9f | 2001-02-28 | Henrik Grubbström (Grubba) | |
test_any([[
int ret;
foreach( "foobar" ; ; int b) ret+=b;
return ret;
]],633)
|
2e952a | 2001-02-27 | Fredrik Hübinette (Hubbe) | | test_any([[
mapping m=([1:2,3:5,7:11,13:17]);
|
7991f1 | 2008-01-05 | Henrik Grubbström (Grubba) | | foreach(m; int a; int b) if (m_delete(m,a) != b) return -1;
|
2e952a | 2001-02-27 | Fredrik Hübinette (Hubbe) | | return sizeof(m);
]],0)
test_any([[
mapping m=([1:2,3:5,7:11,13:17]);
|
1e1794 | 2001-02-28 | Henrik Grubbström (Grubba) | | int ret;
|
2e952a | 2001-02-27 | Fredrik Hübinette (Hubbe) | | foreach(m ; int a ; int b) { m_delete(m,a); ret+=a*b; }
|
1e1794 | 2001-02-28 | Henrik Grubbström (Grubba) | | return ret;
|
2e952a | 2001-02-27 | Fredrik Hübinette (Hubbe) | | ]],315)
|
13a16d | 2003-05-31 | Martin Stjernholm | | test_eval_error([[
int i;
foreach (class{}(); mixed a; mixed b) i++;
return i;
]])
|
f13918 | 2003-09-05 | Martin Stjernholm | | test_any([[
String.Iterator iter = String.Iterator ("foo");
foreach (iter; int idx;)
if (idx != iter->index()) return 1;
return 0;
]], 0)
|
e9ead0 | 2006-11-07 | Martin Stjernholm | | test_any([[
mapping(object:int) x = ([]);
object o = class {}();
x[o] = 1;
destruct (o);
int i;
|
7991f1 | 2008-01-05 | Henrik Grubbström (Grubba) | | foreach (x;;) i++;
|
e9ead0 | 2006-11-07 | Martin Stjernholm | | return i;
]], 0)
test_any([[
multiset(object) x = (<>);
object o = class {}();
x[o] = 1;
destruct (o);
int i;
|
7991f1 | 2008-01-05 | Henrik Grubbström (Grubba) | | foreach (x;;) i++;
|
e9ead0 | 2006-11-07 | Martin Stjernholm | | return i;
]], 0)
|
b28028 | 2014-07-15 | Henrik Grubbström (Grubba) | | test_any([[
// Check foreach with negative ranges [bug 7216]/[LysLysKOM 20892964].
array a = ({ -2, -1, 0, 1, 2 });
int total;
foreach(a, int start) {
foreach(a[start..], int val) {
if (!intp(val)) error("Invalid svalue!\n");
total += (val + 3)*(start + 3);
}
}
return total;
]], 15 + 30 + 45 + 56 + 60)
|
ff581d | 1998-05-24 | Fredrik Noring | | // do-while
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_any(int e;string t=""; e=0; do{ t+=e; }while(++e<6); return t,"012345";)
// while
test_any(int e;string t=""; e=8; while(--e) t+=e; return t,"7654321";)
test_any(int e;string t=""; e=8; while(e--) t+=e; return t,"76543210";)
test_any(int e;string t=""; e=0; while(++e<6) t+=e; return t,"12345";)
test_any(int e=1;string t=""; while(e<20){t+=e;e*=2;} return t,"124816";)
// Switch
|
1ac94a | 2000-01-04 | Henrik Grubbström (Grubba) | | test_any(switch((mixed)"") { case -1: case "gazonk": return 0; } return 1,1)
test_any(switch((mixed)"") { case -2: case "gazonk": return 0; } return 1,1)
test_any(switch((mixed)"") { case 0: case "gazonk": return 0; } return 1,1)
test_any(switch((mixed)"") { case "gazonk": case 0: return 0; } return 1,1)
test_any(switch((mixed)0) { case 0: case "gazonk": return 0; } return 1,0)
test_any(switch((mixed)"gazonk") { case "gazonk": case 0: return 0; } return 1,0)
test_any(switch((mixed)0) { case "": } return 1,1)
test_any(switch((mixed)1) { case 1: return 1; default: } return 0,1)
test_any(switch((mixed)2) { case 1: return 0; default: return 1;} return 0,1)
test_any(switch((mixed)1) { default: return 0; case 1: return 1; } return 0,1)
test_any(switch((mixed)2) { default: return 1; case 1: return 0; } return 0,1)
test_any(switch((mixed)0) { case "apa": case 1.0: return 0; } return 1,1)
test_any(switch((mixed)"apa") { case "apa": return 1; case 1.0: } return 0,1)
test_any(switch((mixed)1.0) { case "apa": return 0; case 1.0: return 1; } return 0,1)
test_any(switch((mixed)"sune") { case "gunnel": return 0; case "gunnar": return 1; case "sune": case "gusten": return 0; } return 0,0)
test_any(switch((mixed)"a") { case "a": return 1; case "b": case "c": case "d": case 'a': case '1': case '0': default: } return 0,1)
test_any(switch((mixed)"b") { case "a": return 0; case "b": return 1; case "c": case "d": case 'a': case '1': case '0': default: } return 0,1)
test_any(switch((mixed)"c") { case "a": case "b": return 0; case "c": return 1; case "d": case 'a': case '1': case '0': default: } return 0,1)
test_any(switch((mixed)"d") { case "a": case "b": case "c": return 0; case "d": return 1; case 'a': case '1': case '0': default: } return 0,1)
test_any(switch((mixed)'a') { case "a": case "b": case "c": case "d": return 0; case 'a': return 1; case '1': case '0': default: } return 0,1)
test_any(switch((mixed)'1') { case "a": case "b": case "c": case "d": case 'a': return 0; case '1': return 1; case '0': default: } return 0,1)
test_any(switch((mixed)'0') { case "a": case "b": case "c": case "d": case 'a': case '1': return 0; case '0': return 1; default: } return 0,1)
test_any(switch((mixed)"a") { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,1)
test_any(switch((mixed)"b") { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,2)
test_any(switch((mixed)"c") { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,3)
test_any(switch((mixed)"d") { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,4)
test_any(switch((mixed)'a') { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,5)
test_any(switch((mixed)'1') { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,6)
test_any(switch((mixed)'0') { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,7)
test_any(switch((mixed)'9') { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,8)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
d53a94 | 1999-11-17 | Fredrik Hübinette (Hubbe) | | test_program([[
void bar() {}
int a()
{
foreach( ({1}), int n)
{
switch(n)
{
default:
bar();
break;
}
}
return 1;
}
]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
define(test_switch0,[[
|
1ac94a | 2000-01-04 | Henrik Grubbström (Grubba) | | test_any(switch((mixed)$1) { $2; $3; $4; $5; } return 0,$6)
test_any(switch((mixed)$1) { default: return 0; $2; $3; $4; $5; } return -1,$6)
test_any(switch((mixed)$1) { $2; default: return 0; $3; $4; $5; } return -1,$6)
test_any(switch((mixed)$1) { $2; $3; default: return 0; $4; $5; } return -1,$6)
test_any(switch((mixed)$1) { $2; $3; $4; default: return 0; $5; } return -1,$6)
test_any(switch((mixed)$1) { $2; $3; $4; $5; default: return 0; } return -1,$6)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | ]])
define(test_switch1,[[
test_switch0($1, $2,$3,$4,$5, $6)
test_switch0($1, $2,$3,$5,$4, $6)
]])
define(test_switch2,[[
test_switch1($1, $2,$3,$4,$5, $6)
test_switch1($1, $2,$4,$3,$5, $6)
test_switch1($1, $2,$5,$4,$3, $6)
]])
define(test_switch3,[[
test_switch2($1,case $2:return 2,case $3:return 3,case $4:return 4,case $5:return 5,$6)
test_switch2($1,case $3:return 3,case $2:return 2,case $4:return 4,case $5:return 5,$6)
test_switch2($1,case $4:return 4,case $3:return 3,case $2:return 2,case $5:return 5,$6)
test_switch2($1,case $5:return 5,case $3:return 3,case $4:return 4,case $2:return 2,$6)
]])
define(test_switch4,[[
test_switch3($1,$2,$3,$4,$5,0)
test_switch3($2,$2,$3,$4,$5,2)
test_switch3($3,$2,$3,$4,$5,3)
test_switch3($4,$2,$3,$4,$5,4)
test_switch3($5,$2,$3,$4,$5,5)
]])
test_switch4(17,18,19,20,21)
test_switch4("a","b","c","d","e")
test_switch4("a",0,"c","d","e")
test_switch4(1.0,2.0,3.0,4.0,5.0)
|
f960bd | 2015-07-31 | Martin Nilsson | | test_switch4(this,"",0,4.0,1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
test_any(int e;string t=""; for(e=0;e<10;e++) switch(e) { default: t+=e; case 4..8: } return t,"01239")
|
a5c771 | 2001-01-15 | Mirar (Pontus Hagland) | |
// use sprintf here; the sums aren't totally equal for doubles (error~=1e-16)
test_any([[float e,q; q=0.0; for(e=0.1;e<10.0;e+=1.0) switch(e) { default: q+=e; case 4.0..8.0: } return sprintf("%.6f",q)]],[[sprintf("%.6f",0.1+1.1+2.1+3.1+8.1+9.1)]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
d638b5 | 2002-03-02 | Martin Stjernholm | | test_compile_error([[switch (1) {case 1: break; case 1: break;}]])
test_compile_error([[switch (1) {case 1: break; case 0..2: break;}]])
test_compile_error([[switch (1) {case 1..2: break; case 0..3: break;}]])
test_compile_error([[switch (1) {case 1..3: break; case 0..2: break;}]])
test_compile_error([[switch (1) {case 1..2: break; case 0..: break;}]])
test_compile_error([[switch (1) {case 1..2: break; case ..3: break;}]])
test_compile_error([[switch (1) {case 1..: break; case ..3: break;}]])
test_compile_error([[switch (1) {case ..: break;}]])
test_compile_error([[switch (1) {case "x"..: break;}]])
test_compile_error([[switch (1) {case .."y": break;}]])
test_compile_error([[switch (1) {case "x".."y": break;}]])
define(test_switch_ranges,[[
test_any_equal([[
int f (int i) {{$1;} return 0;};
array res = ({});
for (int i = -3; i <= 3; i++) res += ({f (i)});
return res;
]], $2)
]])
test_switch_ranges([[
switch (i) {case 1..2: return 2; case -2..-1: return 1;}
]], ({0, 1, 1, 0, 2, 2, 0}))
test_switch_ranges([[
switch (i) {case 1..2: return 2; case -2..0: return 1;}
]], ({0, 1, 1, 1, 2, 2, 0}))
test_switch_ranges([[
switch (i) {case 1..2: return 2; case -2..-1: return 1; case 0: return 3;}
]], ({0, 1, 1, 3, 2, 2, 0}))
test_switch_ranges([[
switch (i) {case 1..2: return 2; case ..-1: return 1; case 0: return 3;}
]], ({1, 1, 1, 3, 2, 2, 0}))
test_switch_ranges([[
switch (i) {case 1..: return 2; case -2..-1: return 1; case 0: return 3;}
]], ({0, 1, 1, 3, 2, 2, 2}))
test_switch_ranges([[
switch (i) {case 1..: return 2; case ..-1: return 1; case 0: return 3;}
]], ({1, 1, 1, 3, 2, 2, 2}))
|
45f6b5 | 2015-04-13 | Martin Nilsson | | test_any([[
#pragma strict_types
int(-1..1) i = [int(0..1)]random(1);
switch(i)
{
case 0: return 3;
case 1: return 3;
case -1: return 3;
}
return 0;
]], 3)
|
7d8000 | 2001-01-10 | Martin Stjernholm | | // Breaks and continues with labels
|
7f97fe | 2001-01-15 | Martin Stjernholm | | test_compile_error([[break;]])
test_compile_error([[continue;]])
test_compile_error([[foo: break;]])
test_compile_error([[foo: continue;]])
test_compile_error([[break foo;]])
test_compile_error([[continue foo;]])
test_any([[foo: break foo; return 1;]], 1)
test_compile_error([[foo: continue foo;]])
|
7d8000 | 2001-01-10 | Martin Stjernholm | | test_compile_error([[int a; foo: if (a++) a++; else foo: a++;]])
test_compile_error([[int a; foo: foo: if (a++) a++; else a++;]])
|
61f03d | 2015-11-15 | Martin Nilsson | | ignore_warning("Label foo not used.", [[
test_compile([[int a; foo: if (a++) a++; foo: a++;]])
]])
|
7d8000 | 2001-01-10 | Martin Stjernholm | | test_compile_error([[int a; do if (a++) break foo; while (0);]])
test_compile([[int a; do foo: if (a++) break foo; while (0);]])
test_compile([[int a; foo: do if (a++) break foo; while (0);]])
test_compile_error([[int a; do foo: if (a++) continue foo; while (0);]])
test_compile([[int a; foo: do if (a++) continue foo; while (0);]])
|
61f03d | 2015-11-15 | Martin Nilsson | | ignore_warning("Label foo not used.", [[
test_any([[
int i;
for (i = 1; i <= 4; i++)
foo: break;
return i;
]], 1)
test_any([[
int i;
for (int j = 1; j <= 4; j++) {
foo: continue;
i = j;
}
return i;
]], 0)
]])
|
e9ebb7 | 2001-01-15 | Martin Stjernholm | | test_any([[
int i;
for (i = 1; i <= 4; i++)
foo: {
if (i > 5) break foo;
break;
}
return i;
|
90e70e | 2015-11-07 | Martin Nilsson | | ]], 1)
|
7d8000 | 2001-01-10 | Martin Stjernholm | | test_any_equal([[
int a, b;
foo:
for (int i = 1; i <= 4; i++) {
a = i;
switch (1) {
case 1:
if (i >= 3) break foo;
if (i >= 2) continue foo;
}
b = i;
}
return ({a, b});
|
90e70e | 2015-11-07 | Martin Nilsson | | ]], ({3, 1}))
|
ced3f0 | 2001-01-11 | Martin Stjernholm | | test_any_equal([[
int a, b;
foo: {
for (int i = 1; i <= 4; i++) {
a = i;
switch (1) {
case 1:
if (i >= 3) break foo;
}
b = i;
}
}
return ({a, b});
|
90e70e | 2015-11-07 | Martin Nilsson | | ]], ({3, 2}))
|
ced3f0 | 2001-01-11 | Martin Stjernholm | | test_any_equal([[
array res = ({});
foreach (({1, 2, 3}), int x) {
res += ({-x});
foo:
foreach (({1, 2, 3, 4}), int i) {
res += ({i});
foreach (({1, 2}), int y) {
if (i >= 3) break foo;
if (i >= 2) continue foo;
|
7991f1 | 2008-01-05 | Henrik Grubbström (Grubba) | | y;
|
ced3f0 | 2001-01-11 | Martin Stjernholm | | }
res += ({i});
}
}
return res;
|
90e70e | 2015-11-07 | Martin Nilsson | | ]], ({-1, 1, 1, 2, 3, -2, 1, 1, 2, 3, -3, 1, 1, 2, 3}))
|
7d8000 | 2001-01-10 | Martin Stjernholm | | test_any_equal([[
int a, b;
foo:
for (int i = 1; i <= 4; i++) {
a = i;
catch {
catch {
if (i >= 3) break foo;
if (i >= 2) continue foo;
};
};
b = i;
}
return ({a, b});
|
90e70e | 2015-11-07 | Martin Nilsson | | ]], ({3, 1}))
|
61f03d | 2015-11-15 | Martin Nilsson | | ignore_warning("Label foo not used.", [[
test_any_equal([[
int a, b;
foo:
for (int i = 1; i <= 4; i++) {
a = i;
|
|