Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 1262-SmartYield
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss committed Mar 29, 2024
2 parents cb18a4e + 7bfee41 commit eebf85b
Show file tree
Hide file tree
Showing 147 changed files with 4,868 additions and 4,939 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/compiler-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,24 @@ jobs:
run: dotnet build main/DMCompiler/DMCompiler.csproj --configuration Release --no-restore /m
- name: Compile TestGame
run: main\bin\DMCompiler\DMCompiler.exe main\TestGame\environment.dme
- name: Checkout Modified /tg/station
- name: Checkout /tg/station 88bdabe
uses: actions/checkout@v2
with:
repository: wixoaGit/tgstation
repository: tgstation/tgstation
ref: 88bdabe53bb85f2a7f54e479f6c4a243650043d5
path: tg
- name: Compile Modified /tg/station
run: main\bin\DMCompiler\DMCompiler.exe tg\tgstation.dme
- name: Compile /tg/station 88bdabe
run: main\bin\DMCompiler\DMCompiler.exe tg\tgstation.dme
- name: Checkout Goonstation 8c8b527
uses: actions/checkout@v2
with:
repository: goonstation/goonstation
ref: 8c8b5276f231ae42b3b2390d837cab68af138fa6
path: goon
- name: Compile Goonstation 8c8b527
run: |
New-Item goon\+secret\__secret.dme -type file
main\bin\DMCompiler\DMCompiler.exe goon\goonstation.dme --version=514.1584
- name: Checkout 64-bit Paradise
uses: actions/checkout@v2
with:
Expand Down
1 change: 1 addition & 0 deletions Content.Tests/DMProject/Tests/Builtins/JsonEncode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
ASSERT(json_encode(list("A" = 3, "B" = 5)) == @'{"A":3,"B":5}')
ASSERT(json_encode(matrix(1,2,3,4,5,6)) == @'[1,2,3,4,5,6]')
ASSERT(json_encode(/datum/proc/foo) == "\"/datum/proc/foo\"")
ASSERT(length(json_encode(list("name"="fridge", "power"=12))) < length(json_encode(list("name"="fridge", "power"=12), JSON_PRETTY_PRINT))) // Not the best test but copes with CRLF vs LF
8 changes: 8 additions & 0 deletions Content.Tests/DMProject/Tests/Builtins/LocateIn.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/proc/RunTest()
var/obj/obj1 = new()
var/obj/obj2 = new()
var/list/things = list(obj1,"beep","thing","stuff")
var/A = locate(ref(obj1)) in things
ASSERT(A == obj1)
var/B = locate(ref(obj2)) in things
ASSERT(isnull(B))
7 changes: 7 additions & 0 deletions Content.Tests/DMProject/Tests/Builtins/__IMPLIED_TYPE__.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


/datum/test/var/bar = "foobar"
/proc/RunTest()
var/datum/test/D = __IMPLIED_TYPE__
ASSERT(D.bar == "foobar")

29 changes: 29 additions & 0 deletions Content.Tests/DMProject/Tests/Builtins/text2ascii2text.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/proc/RunTest()
ASSERT(text2ascii_char("abcdéfg",6) == 102) //102 is f
ASSERT(ascii2text(text2ascii("a")) == "a")
var/list/values = list(
"©" = 0x00A9,
"®" = 0x00AE,
"" = 0x203C,
"" = 0x2049,
"" = 0x20E3,
"" = 0x2122,
"" = 0x2139,
"" = 0x231A,
"" = 0x231B,
"" = 0x2328,
"" = 0x23CF,
"" = 0x24C2,
"" = 0x25AA,
"" = 0x25AB,
"" = 0x25B6,
"" = 0x25C0,
"" = 0x2934,
"" = 0x2935,
"" = 0x3030,
"" = 0x303D,
"" = 0x3297,
"" = 0x3299,
)
for(var/v in values)
ASSERT(ascii2text(values[v]) == v)
2 changes: 0 additions & 2 deletions Content.Tests/DMProject/Tests/Builtins/text2ascii_char.dm

This file was deleted.

11 changes: 11 additions & 0 deletions Content.Tests/DMProject/Tests/Call/LateralPointlessOverride.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma PointlessParentCall error

// don't emit the pragma if lateral overrides exist
/datum/foo()
return
/datum/proc/foo()
..()
return

/proc/RunTest()
return
9 changes: 9 additions & 0 deletions Content.Tests/DMProject/Tests/Call/PointlessParentCall.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// COMPILE ERROR
#pragma PointlessParentCall error

/datum/proc/foo()
..()
return

/proc/RunTest()
return
3 changes: 3 additions & 0 deletions Content.Tests/DMProject/Tests/Const/Const_LateDefinition.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var/const/late_defined_const = 1
var/a = 1 + const_var
var/const/const_var = 2

/obj/TestObj/SubType
a = 4 // Catches a regression introduced in #1550

/proc/RunTest()
var/obj/TestObj/o = new
ASSERT(o.const_var == 2)
Expand Down
5 changes: 5 additions & 0 deletions Content.Tests/DMProject/Tests/Dereference/implied_initial.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

/datum/var/bar = "foobar"
/proc/RunTest()
var/datum/D = /datum
ASSERT(D.bar == "foobar")
14 changes: 14 additions & 0 deletions Content.Tests/DMProject/Tests/Image/subclass.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/image/subclass
plane = 123
icon_state = "subclass"

/proc/RunTest()
var/image/test = new /image/subclass
ASSERT(test.plane == 123)
ASSERT(test.icon_state == "subclass")
var/image/subclass/test2 = new(icon())
ASSERT(test2.plane == FLOAT_PLANE)
ASSERT(test2.icon_state == null)
var/image/subclass/test3 = new(icon_state="test")
ASSERT(test3.plane == 123)
ASSERT(test3.icon_state == "test")
13 changes: 13 additions & 0 deletions Content.Tests/DMProject/Tests/List/vars_list.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/datum/test
var/normal_var = 123
var/static/static_var = 321
/proc/RunTest()
var/datum/test/t = new()
var/varlist = t.vars
ASSERT(length(varlist) == 6) // normal_var, static_var, tag, type, parent_type, vars
ASSERT(varlist["static_var"] == 321)
ASSERT(varlist["normal_var"] == 123)
ASSERT(varlist["type"] == /datum/test)
ASSERT(varlist["parent_type"] == /datum)
ASSERT(("vars" in varlist))
ASSERT(varlist["vars"] == varlist)
22 changes: 22 additions & 0 deletions Content.Tests/DMProject/Tests/Math/minmax.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/proc/RunTest()
ASSERT(min(1,2,3) == 1)
ASSERT(min(null, 1) == null)
ASSERT(min(null, -1) == -1)
ASSERT(min(1, null) == null)
ASSERT(min(-1, null) == -1)
ASSERT(min(1, null) == null)
ASSERT(min(0, null) == null)
ASSERT(min(null, 0) == 0)
ASSERT(min("a","b","c")=="a")
ASSERT(min("b","a","c")=="a")

ASSERT(max(1,2,3) == 3)
ASSERT(max(null, 1) == 1)
ASSERT(max(null, -1) == null)
ASSERT(max(1,null) == 1)
ASSERT(max(-1,null) == null)
ASSERT(max(1, null) == 1)
ASSERT(max(0, null) == null)
ASSERT(max(null, 0) == 0)
ASSERT(max("a","b","c")=="c")
ASSERT(max("b","a","c")=="c")
61 changes: 61 additions & 0 deletions Content.Tests/DMProject/Tests/Operators/scope.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/datum
var/static/datum/three/three
var/text = "hello"

var/static/one = "one"

/datum/three
var/static/datum/four/four
text = "hi"
var/overridden_text = type::text
var/original_text = parent_type::text

/datum/three/proc/typetest()
// initial shorthand, type:: and parent_type::
ASSERT(text == "hi")
ASSERT(original_text == "hello")
ASSERT(overridden_text == "hi")
overridden_text = "hi there!"
original_text = "hello there"
text = "hi there"
ASSERT(src::text == "hi")
ASSERT(src::overridden_text == "hi")
ASSERT(src::original_text == "hello")

// proc reference
ASSERT(__PROC__ == /datum/three::typetest())

/datum/four
var/datum/five/five

/datum/five
var/static/six = "three four five six"

/proc/return_two()
return "two"

/proc/RunTest()
// global vars and procs
ASSERT(::one == "one")
ASSERT(::return_two() == "two")

// static vars + chaining
var/datum/test
ASSERT(test::three::four.five::six == "three four five six")
ASSERT(/datum::three::four.five::six == "three four five six")

// reassigning global and static vars
::one = "1"
ASSERT(::one == "1")

/datum::three::four::five::six = "3 4 5 6"
ASSERT(test::three::four.five::six == "3 4 5 6")
ASSERT(/datum::three::four.five::six == "3 4 5 6")

// this does not compile in BYOND, that is just a bug
test::three::four.five::six = "7 8 9 10"
ASSERT(test::three::four.five::six == "7 8 9 10")
ASSERT(/datum::three::four.five::six == "7 8 9 10")

var/datum/three/threetest = new
threetest.typetest()
6 changes: 6 additions & 0 deletions Content.Tests/DMProject/Tests/Operators/scope_proc_name.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/datum/proc/foo()
set name = "abc"
return

/proc/RunTest()
ASSERT((/datum/proc/foo::name) == "foo")
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// COMPILE ERROR
#pragma PointlessScopeOperator error

/datum/proc/foo()
set desc = "abc"
return

/proc/RunTest()
var/desc = (/datum/proc/foo::desc)
6 changes: 6 additions & 0 deletions Content.Tests/DMProject/Tests/Procs/return_type.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Just testing that this parses
/proc/foo() as /list
return list("a","b","c")

/proc/RunTest()
ASSERT(foo()[2] == "b")
60 changes: 60 additions & 0 deletions Content.Tests/DMProject/Tests/Savefile/BasicReadAndWrite.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/datum/foobar

/proc/RunTest()
var/savefile/S = new("savefile.sav")
Expand All @@ -7,15 +8,74 @@
// Indexing the object to write/read the savefile
S["ABC"] = 5
ASSERT(V == null)
ASSERT(S["ABC"] == 5)
V = S["ABC"]
ASSERT(V == 5)

// << and >> can do the same thing
S["DEF"] << 10
S["DEF"] >> V
ASSERT(S["DEF"] == 10)
ASSERT(V == 10)
S["notakey"] >> V
ASSERT(V == null)

// 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)
var/list/assoc = list("6.28" = "pizza", "aaaaa" = "bbbbbbb")
S["pie2"] << assoc
ASSERT(S["pie2"] ~= assoc)

// Shouldn't evaluate CRASH
S2?["ABC"] << CRASH("rhs should not evaluate due to null-conditional")

// Test EOF
S.cd = "DEF"
var/out
ASSERT(S.eof == 0)
S >> out
ASSERT(out == 10)
ASSERT(S.eof == 1)
S.eof = -1
S.cd = "/"
ASSERT(S["DEF"] == null)

//Test dir
S.cd = "/"
var/dir = S.dir
ASSERT(dir ~= list("ABC", "DEF", "notakey", "pathymcpathface", "pie", "pie2"))

//test add
dir += "test/beep"
ASSERT(dir ~= list("ABC", "DEF", "notakey", "pathymcpathface", "pie", "pie2", "test"))
ASSERT(S["test"] == null)
S.cd = "test"
ASSERT(dir ~= list("beep"))

//test del
S.cd = "/"
dir -= "test"
ASSERT(dir ~= list("ABC", "DEF", "notakey", "pathymcpathface", "pie", "pie2"))

//test rename and null
dir[1] = "CBA"
ASSERT(dir ~= list("CBA", "DEF", "notakey", "pathymcpathface", "pie", "pie2"))
ASSERT(S["CBA"] == null)

fdel("savefile.sav")

file("badsavefile.sav") << "hey wait, this isn't json! oh well, better fail miserably and die"

var/savefile/fail
try
fail = new("badsavefile.sav")
catch(var/exception/e)
ASSERT(isnull(fail))
ASSERT(fail == null)
fdel("badsavefile.sav")
52 changes: 52 additions & 0 deletions Content.Tests/DMProject/Tests/Savefile/DatumSaving.dm
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"))

Loading

0 comments on commit eebf85b

Please sign in to comment.