pike.git
/
src
/
testsuite.in
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/testsuite.in:5126:
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">)))
+
define(test_encode_basic, [[
+
test_equal(decode_value(encode_value_basic($1)), $1)
+
test_equal(decode_value_basic(encode_value_basic($1)), $1) ]])
-
+
test_encode_basic(0);
+
test_encode_basic(1);
+
// Test numbers at around where the encoding
+
// length changes
+
test_encode_basic(0x1010100 + 3 + 1);
+
test_encode_basic(0x1010100 + 3);
+
test_encode_basic(0x1010100 + 3 - 1);
+
test_encode_basic(0x10100 + 3 + 1);
+
test_encode_basic(0x10100 + 3);
+
test_encode_basic(0x10100 + 3 - 1);
+
test_encode_basic(0x100 + 3 + 1);
+
test_encode_basic(0x100 + 3);
+
test_encode_basic(0x100 + 3 - 1);
+
test_encode_basic(3 + 1);
+
test_encode_basic(3);
+
test_encode_basic(3 - 1);
+
+
test_encode_basic(-1);
+
test_encode_basic("Foo");
+
test_encode_basic(({ "Foo" }));
+
test_encode_basic(([ "Foo": 1, 2: 3 ]));
+
test_encode_basic((< "foo", 1, 3, ({ 1, 2, 3 }) >));
+
test_encode_basic(-0.0);
+
test_encode_basic(0.0);
+
test_encode_basic(1.0);
+
test_encode_basic(-1.0);
+
test_encode_basic(Math.inf);
+
test_encode_basic(-Math.inf);
+
test_any([[
-
+
mixed v = decode_value(encode_value_basic(Math.nan));
+
+
return v != v;
+
]], 1);
+
+
test_encode_basic(Val.null);
+
test_encode_basic(Val.true);
+
test_encode_basic(Val.false);
+
+
// Test that cyclic data leads to an error.
+
test_eval_error([[
+
array a = ({ 0 });
+
a[0] = a;
+
return encode_value_basci(a);
+
]])
+
test_eval_error([[
+
mapping m = ([ ]);
+
m[m] = 1;
+
return encode_value_basci(a);
+
]])
+
test_eval_error([[
+
multiset m = (< >);
+
m[m] = 1;
+
return encode_value_basci(a);
+
]])
+
+
// Test that max_depth works.
+
test_eval_error([[
+
return decode_value_basic(encode_value_basic(({ })), 0);
+
]])
+
test_any([[
+
return equal(
+
decode_value_basic(encode_value_basic(({ })), 1),
+
({ })
+
);
+
]], 1)
+
test_eval_error([[
+
return decode_value_basic(encode_value_basic(({ 0, ({ }) })), 1);
+
]])
+
test_any([[
+
return equal(
+
decode_value_basic(encode_value_basic(({ 0, ({ }) })), 2),
+
({ 0, ({ }) })
+
);
+
]], 1)
+
+
test_any([[
// bug 3013 class Test { class Resolver (array c) { mixed resolv (string id) { if (id == "c") return c; } }