Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/tests/test_Serializer.h
Show First 20 Lines • Show All 683 Lines • ▼ Show 20 Lines | /* expected stream: */ | ||||
"\x05" // SCRIPT_TYPE_INT | "\x05" // SCRIPT_TYPE_INT | ||||
"\x01\0\0\0" // 1 | "\x01\0\0\0" // 1 | ||||
"\x0f" // SCRIPT_TYPE_MAP | "\x0f" // SCRIPT_TYPE_MAP | ||||
"\0\0\0\0" // size | "\0\0\0\0" // size | ||||
"\x05" // SCRIPT_TYPE_INT | "\x05" // SCRIPT_TYPE_INT | ||||
"\x02\0\0\0" // 2 | "\x02\0\0\0" // 2 | ||||
"\x08" // SCRIPT_TYPE_BACKREF | "\x08" // SCRIPT_TYPE_BACKREF | ||||
"\x02\0\0\0" // ref. to object #2, i.e. "b", with #1 being "a" | "\x01\0\0\0" // ref. to object #1, i.e. "b", with #0 being "a" | ||||
); | ); | ||||
} | } | ||||
void test_script_set_nested() | void test_script_set_nested() | ||||
{ | { | ||||
helper_script_roundtrip("Nested sets using backrefs", | helper_script_roundtrip("Nested sets using backrefs", | ||||
"var a = new Set(); var b = new Set(); a.add(b); a.add({\"bar\": b}); a", | "var a = new Set(); var b = new Set(); a.add(b); a.add({\"bar\": b}); a", | ||||
/* expected: */ | /* expected: */ | ||||
"({})", | "({})", | ||||
/* expected stream: */ | /* expected stream: */ | ||||
28, | 28, | ||||
"\x10" // SCRIPT_TYPE_SET | "\x10" // SCRIPT_TYPE_SET | ||||
"\x02\0\0\0" // size | "\x02\0\0\0" // size | ||||
"\x10" // SCRIPT_TYPE_SET | "\x10" // SCRIPT_TYPE_SET | ||||
"\x00\0\0\0" // size | "\x00\0\0\0" // size | ||||
"\x03" // SCRIPT_TYPE_OBJECT | "\x03" // SCRIPT_TYPE_OBJECT | ||||
"\x01\0\0\0" // num props | "\x01\0\0\0" // num props | ||||
"\x01\x03\0\0\0" "bar" // "bar" | "\x01\x03\0\0\0" "bar" // "bar" | ||||
"\x08" // SCRIPT_TYPE_BACKREF | "\x08" // SCRIPT_TYPE_BACKREF | ||||
"\x02\0\0\0" // ref to object #2, i.e. "b", with #1 being "a" | "\x01\0\0\0" // ref to object #1, i.e. "b", with #0 being "a" | ||||
); | ); | ||||
} | } | ||||
// TODO: prototype objects | // TODO: prototype objects | ||||
void test_script_nonfinite() | void test_script_nonfinite() | ||||
{ | { | ||||
helper_script_roundtrip("nonfinite", "[0, Infinity, -Infinity, NaN, -1/Infinity]", "[0, Infinity, -Infinity, NaN, -0]"); | helper_script_roundtrip("nonfinite", "[0, Infinity, -Infinity, NaN, -1/Infinity]", "[0, Infinity, -Infinity, NaN, -0]"); | ||||
▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator