-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…1554) Co-authored-by: LetterN <[email protected]> Co-authored-by: wixoa <[email protected]> Co-authored-by: amylizzle <[email protected]>
- Loading branch information
1 parent
e2a403f
commit 39f99ac
Showing
16 changed files
with
929 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/datum/foo | ||
var/best_map = "pl_upward" // mutated by RunTest(), should save | ||
var/worst_map = "pl_badwater" // same as, should not be saved | ||
var/null_me = "ok" // should save as null | ||
|
||
var/tmp/current_map = "yeah" // tmp, should not save | ||
var/const/default_cube = "delete it" // const, should not save | ||
|
||
New(args) | ||
proc_call_order_check += list("New") | ||
..() | ||
|
||
Read(savefile/F) | ||
proc_call_order_check += list("Read") | ||
..() | ||
|
||
Write(savefile/F) | ||
proc_call_order_check += list("Write") | ||
..() | ||
|
||
/var/static/proc_call_order_check = list() | ||
|
||
|
||
/proc/RunTest() | ||
var/savefile/S = new() | ||
|
||
var/datum/foo/F = new() | ||
F.best_map = "pl_pier" | ||
F.null_me = null | ||
|
||
S["mapdata"] << F | ||
|
||
// test the savefile's contents | ||
ASSERT(S["mapdata/.0/type"] == /datum/foo) | ||
ASSERT(S["mapdata/.0/best_map"] == "pl_pier") | ||
ASSERT(S["mapdata/.0/null_me"] == null) | ||
ASSERT(S["mapdata/.0/worst_map"] == null) | ||
ASSERT(S["mapdata/.0/current_map"] == null) | ||
ASSERT(S["mapdata/.0/default_cube"] == null) | ||
|
||
var/datum/foo/W | ||
S["mapdata"] >> W | ||
|
||
// load test | ||
ASSERT(istype(W)) | ||
ASSERT(W != F) //they are equivalent, but not the same datum | ||
ASSERT(W.best_map == "pl_pier") | ||
ASSERT(W.worst_map == "pl_badwater") | ||
ASSERT(W.null_me == null) | ||
|
||
ASSERT(proc_call_order_check ~= list("New","Write","New","Read")) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/obj/savetest | ||
var/obj/savetest/recurse = null | ||
|
||
/proc/RunTest() | ||
var/obj/savetest/O = new() //create a test object | ||
O.name = "test" | ||
//O.recurse = O //TODO | ||
|
||
var/savefile/F = new() //create a temporary savefile | ||
|
||
F["dir"] = O | ||
F["dir2"] = "object(\".0\")" | ||
F["dir3"] = 1080 | ||
F["dir4"] = "the afternoon of the 3rd" | ||
var/savefile/P = new() //nested savefile | ||
P["subsavedir1"] = O | ||
P["subsavedir2"] = "butts" | ||
P["subsavedir3"] = 123 | ||
|
||
F["dir5"] = P | ||
F["dir6/subdir6"] = 321 | ||
F["dir7"] = null | ||
F["dirIcon"] = new /icon() | ||
F["list"] << list("1",2,"three"=3,4, new /datum(), new /datum(), list(1,2,3, new /datum())) | ||
|
||
ASSERT(F.dir ~= list("dir","dir2","dir3","dir4","dir5","dir6","dir7","dirIcon","list")) | ||
ASSERT(F.ExportText("dir6/subdir6") == ". = 321\n") | ||
ASSERT(F.ExportText("dir6/subdir6/") == ". = 321\n") | ||
ASSERT(F.ExportText("dir6") == "\nsubdir6 = 321\n") | ||
var/list_match = {". = list("1",2,"three" = 3,4,object(".0"),object(".1"),list(1,2,3,object(".2")))\n.0\n\ttype = /datum\n.1\n\ttype = /datum\n.2\n\ttype = /datum\n"} | ||
ASSERT(F.ExportText("list") == list_match) | ||
|
||
F.cd = "dir6" | ||
F << "test" | ||
F.cd = "/" | ||
ASSERT(F.ExportText("dir6") == ". = \"test\"\nsubdir6 = 321\n") | ||
ASSERT(F.ExportText("dir6/subdir6/") == ". = 321\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/datum/foobar | ||
|
||
/proc/RunTest() | ||
var/savefile/S = new("savefile.sav") | ||
var/savefile/S2 = null | ||
|
||
|
||
// Indexing the object to write/read the savefile | ||
S["ABC"] = 5 | ||
ASSERT(S["ABC"] == 5) | ||
|
||
S["DEF"] = 10 | ||
ASSERT(S["DEF"] == 10) | ||
|
||
// test path | ||
S["pathymcpathface"] << /datum/foobar | ||
ASSERT(S["pathymcpathface"] == /datum/foobar) | ||
|
||
// test list() | ||
var/list/array = list("3.14159", "pizza") | ||
S["pie"] << array | ||
ASSERT(S["pie"] ~= array) | ||
|
||
// test assoc list() | ||
var/list/assoc = list("6.28" = "pizza", "aaaaa" = "bbbbbbb") | ||
S["pie2"] << assoc | ||
ASSERT(S["pie2"] ~= assoc) | ||
|
||
S.Flush() | ||
|
||
// test loading | ||
//gotta copy it because otherwise we're accessing the cache | ||
fcopy("savefile.sav", "savefile2.sav") | ||
ASSERT(fexists("savefile2.sav")) | ||
S2 = new("savefile2.sav") | ||
ASSERT(S2["ABC"] == 5) | ||
ASSERT(S2["DEF"] == 10) | ||
ASSERT(S2["pathymcpathface"] == /datum/foobar) | ||
ASSERT(S2["pie"] ~= array) | ||
ASSERT(S2["pie2"] ~= assoc) | ||
|
||
|
||
fdel("savefile.sav") | ||
fdel("savefile2.sav") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/datum/test_holder | ||
var/test1 | ||
var/test2 | ||
var/test3 | ||
var/test4 | ||
|
||
/proc/RunTest() | ||
var/savefile/F = new("savtest.sav") | ||
F["savtest1"] = "beep" | ||
F["savtest2"] = "boop" | ||
F["savtest3"] = "berp" | ||
F["savtest4"] = "borp" | ||
del(F) | ||
fcopy("savtest.sav", "savtest2.sav") | ||
var/savefile/F2 = new("savtest2.sav") | ||
var/datum/test_holder/T = new() | ||
T.test1 = F2["savtest1"] | ||
T.test2 = F2["savtest2"] | ||
|
||
F2["savtest1"] >> T.test1 | ||
F2["savtest2"] >> T.test2 | ||
F2["savtest3"] >> T.test3 | ||
F2["savtest4"] >> T.test4 | ||
|
||
ASSERT(T.test1 == "beep") | ||
ASSERT(T.test2 == "boop") | ||
ASSERT(T.test3 == "berp") | ||
ASSERT(T.test4 == "borp") | ||
fdel("savtest.sav") | ||
fdel("savtest2.sav") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.