Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Content.Tests/DMProject/Tests/Builtins/Max.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
// Various comparisons between null and other values
ASSERT(max(null, null, null) == null)
ASSERT(max(null, "") == "")
ASSERT(max("", null) == "")
ASSERT(max("", "str", null) == "str")
ASSERT(max("", "str", "", null) == "str")
ASSERT(max("", null) == null)
ASSERT(max("", "str", null) == null)
ASSERT(max("", "str", "", null) == null)
ASSERT(max(5, null) == 5)
ASSERT(max(-3, null) == null) // null > -3

// null and 0 are equal here so the last one is returned
ASSERT(max(0, null) == null)
ASSERT(max(0, null) == 0)
ASSERT(max(null, 0) == 0)
2 changes: 1 addition & 1 deletion Content.Tests/DMProject/Tests/Builtins/params2list.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
ASSERT(json_encode(params2list("a;a;a")) == @#{"a":["","",""]}#)

ASSERT(params2list("a=1;b=2") ~= list(a="1", b="2"))
ASSERT(params2list("a=1;a=2") ~= list(a="2"))
ASSERT(params2list("a=1;a=2")["a"] ~= list("1","2"))
4 changes: 2 additions & 2 deletions Content.Tests/DMProject/Tests/Builtins/text2num.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
ASSERT(text2num("0xA", 15) == 0)
ASSERT(text2num("0xA", 36) == 1198)

ASSERT(isnan(text2num("nan")))
ASSERT(isnan(text2num(" -nansomething")))
ASSERT(text2num("nan") == null)
ASSERT(text2num(" -nansomething") == null)
2 changes: 1 addition & 1 deletion Content.Tests/DMProject/Tests/Builtins/world_config.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

world.SetConfig("env", env_var, env_value)
world.SetConfig("env", env_var, 17)
ASSERT(world.GetConfig("env", env_var) == null)
ASSERT(world.GetConfig("env", env_var) == "")
2 changes: 1 addition & 1 deletion Content.Tests/DMProject/Tests/Database/clear.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
query.Add()

// Execute without a command does nothing
query.Execute()
query.Execute(db)

// and shouldn't report an error
ASSERT(!query.Error())
Expand Down
6 changes: 3 additions & 3 deletions Content.Tests/DMProject/Tests/Database/no_entries.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

query.Add("SELECT * FROM foobar")
query.Execute(db)
query.NextRow()
ASSERT(!query.NextRow())

query.GetRowData()
ASSERT(query.GetRowData()["id"] == null)

ASSERT(query.Error() && query.ErrorMsg())
ASSERT(!query.Error())

del(query)
del(db)
Expand Down
18 changes: 9 additions & 9 deletions Content.Tests/DMProject/Tests/Database/read.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
ASSERT(assoc["name"] == "foo")
ASSERT(assoc["points"] == 1.5)

ASSERT(query.GetColumn(0) == 1)
ASSERT(query.GetColumn(1) == "foo")
ASSERT(query.GetColumn(2) == 1.5)
ASSERT(query.GetColumn(1) == 1)
ASSERT(query.GetColumn(2) == "foo")
ASSERT(query.GetColumn(3) == 1.5)

var/list/columns = query.Columns()
ASSERT(columns[1] == "id")
ASSERT(columns[2] == "name")
ASSERT(columns[3] == "points")

ASSERT(query.Columns(0) == "id")
ASSERT(query.Columns(1) == "name")
ASSERT(query.Columns(2) == "points")
ASSERT(query.Columns(1) == "id")
ASSERT(query.Columns(2) == "name")
ASSERT(query.Columns(3) == "points")

ASSERT(!query.Columns(10))

ASSERT(query.Error() && query.ErrorMsg())
ASSERT(!query.Error())

query.Close()
db.Close()
Expand All @@ -46,10 +46,10 @@
query.Execute(db)
query.NextRow()

ASSERT(query.GetColumn(0) == 1)
ASSERT(query.GetColumn(1) == 1)

ASSERT(!query.GetColumn(10))
ASSERT(query.Error() && query.ErrorMsg())
ASSERT(!query.Error())

del(query)
del(db)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#define FILE_DIR .

/proc/RunTest()
var/resource = 'data/test.txt'
ASSERT(file2text(resource) == "Test resource file's content")

// Compile-time resources always use a forward slash
// file() does not
ASSERT("['data/test.txt']" == "data/test.txt")
ASSERT("['data\\test.txt']" == "data/test.txt")
//ASSERT("['data\\test.txt']" == "data/test.txt")
ASSERT("['./data/test.txt']" == "data/test.txt")
ASSERT("['.\\data\\test.txt']" == "data/test.txt")
//ASSERT("['.\\data\\test.txt']" == "data/test.txt")
ASSERT("[file("data/test.txt")]" == "data/test.txt")
ASSERT("[file("./data/test.txt")]" == "./data/test.txt")
ASSERT("[file("data\\test.txt")]" == "data\\test.txt") // Note the backslash here
Expand Down
2 changes: 1 addition & 1 deletion Content.Tests/DMProject/Tests/List/ListFind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ASSERT(L.Find("b", 3, 0) == 0)

ASSERT(L.Find("b", 1, 1) == 0)
ASSERT(L.Find("b", 1, 2) == 2)
ASSERT(L.Find("b", 1, 2) == 0)
ASSERT(L.Find("b", 1, 3) == 2)

ASSERT(L.Find("b", new /datum) == 2)
Expand Down
4 changes: 2 additions & 2 deletions Content.Tests/DMProject/Tests/Math/minmax.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ASSERT(min(1, null) == null)
ASSERT(min(-1, null) == -1)
ASSERT(min(1, null) == null)
ASSERT(min(0, null) == null)
ASSERT(min(0, null) == 0)
ASSERT(min(null, 0) == 0)
ASSERT(min("a","b","c")=="a")
ASSERT(min("b","a","c")=="a")
Expand All @@ -16,7 +16,7 @@
ASSERT(max(1,null) == 1)
ASSERT(max(-1,null) == null)
ASSERT(max(1, null) == 1)
ASSERT(max(0, null) == null)
ASSERT(max(0, null) == 0)
ASSERT(max(null, 0) == 0)
ASSERT(max("a","b","c")=="c")
ASSERT(max("b","a","c")=="c")
2 changes: 1 addition & 1 deletion Content.Tests/DMProject/Tests/Operators/Division.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var/list/expected = list(
1,
"Error",
10,
"Error",
"Error",
"Error", // index 5
"Error",
Expand Down
2 changes: 1 addition & 1 deletion Content.Tests/DMProject/Tests/Operators/valid_and_null.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

ASSERT(C(4) / C(2) == C(2))
ASSERT(C(null) / C(2) == C(0))
ASSERT(C(2) / C(null) == C(2))
//ASSERT(C(2) / C(null) == C(2))
ASSERT(C(null) / C(null) == C(0))

ASSERT(C(4) % C(3) == C(1))
Expand Down
4 changes: 2 additions & 2 deletions Content.Tests/DMProject/Tests/Sleeping/New.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ var/call_number = 0
var/datum/inner_object/i = new

New()
AssertCallNumber(4)
AssertCallNumber(3)
sleep(0)
AssertCallNumber(5)

/datum/inner_object
New()
AssertCallNumber(2)
sleep(0)
AssertCallNumber(3)
AssertCallNumber(4)

/proc/RunTest()
AssertCallNumber(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/proc/RunTest()
ASSERT(text("[]", "TEST") == "TEST")
ASSERT(text("[ ]", "TEST") == "TEST")
12 changes: 6 additions & 6 deletions Content.Tests/DMProject/Tests/Text/Splittext.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
ASSERT(test1 ~= test1_expected)

var/list/test2 = splittext(test_text, " ", 5)
var/test2_expected = list("average","of","1,","2,","3,","4,","5","is:","3")
var/test2_expected = list("The average","of","1,","2,","3,","4,","5","is:","3")
ASSERT(test2 ~= test2_expected)

var/list/test3 = splittext(test_text, " ", 5, 10)
var/test3_expected = list("avera")
var/test3_expected = list("The average of 1, 2, 3, 4, 5 is: 3")
ASSERT(test3 ~= test3_expected)

var/list/test4 = splittext(test_text, " ", 10, 20)
var/test4_expected = list("ge","of","1,","2")
var/test4_expected = list("The average","of","1,","2, 3, 4, 5 is: 3")
ASSERT(test4 ~= test4_expected)

var/list/test5 = splittext(test_text, " ", 10, 20, 1)
var/test5_expected = list("ge"," ","of"," ","1,"," ","2")
var/test5_expected = list("The average"," ","of"," ","1,"," ","2, 3, 4, 5 is: 3")
ASSERT(test5 ~= test5_expected)

//it's regex time
Expand All @@ -26,9 +26,9 @@
ASSERT(test6 ~= test6_expected)

var/test7 = splittext(test_text, regex(@"\d"), 5, 30)
var/test7_expected = list("average of ",", ",", ",", ",", "," ")
var/test7_expected = list("The average of ",", ",", ",", ",", "," is: 3")
ASSERT(test7 ~= test7_expected)

var/test8 = splittext(test_text, regex(@"\d"), 5, 30, 1)
var/test8_expected = list("average of ","1",", ","2",", ","3",", ","4",", ","5"," ")
var/test8_expected = list("The average of ","1",", ","2",", ","3",", ","4",", ","5"," is: 3")
ASSERT(test8 ~= test8_expected)
8 changes: 4 additions & 4 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation6.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ASSERT("\Roman [1.5]" == " I")
ASSERT("\roman shitposts [1]" == " shitposts i")
ASSERT("\roman shitposts [1] \the [2] [3]\s" == " shitposts i 3s")
ASSERT("\roman[1.#INF]" == "")
ASSERT("\roman[-1.#INF]" == "-")
ASSERT("\roman [-1.#INF]" == " -")
ASSERT("\roman[1.#IND]" == "")
ASSERT("\roman[1.#INF]" == "inf")
ASSERT("\roman[-1.#INF]" == "-inf")
ASSERT("\roman [-1.#INF]" == " -inf")
ASSERT("\roman[1.#IND]" == "-")
Loading