-
Notifications
You must be signed in to change notification settings - Fork 122
Alist unit testing #2339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wixoaGit
merged 16 commits into
OpenDreamProject:master
from
Zonespace27:alist-unit-tests
Oct 15, 2025
Merged
Alist unit testing #2339
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f2493d8
Alist unit testing
Zonespace27 4b35f5c
WIP
Zonespace27 125dd14
more work
Zonespace27 db04fd0
Merge branch 'alist-unit-tests' of https://github.com/Zonespace27/Ope…
johndoe2013 676957a
Merge branch 'master' into alist-unit-tests
Zonespace27 415545a
alist stuff done
johndoe2013 0dcb779
fix tests
johndoe2013 10bad05
compounded test
johndoe2013 55af62c
fix some stuff considered "bad"
johndoe2013 50137cd
whoops
johndoe2013 7a758fc
lint fixes
johndoe2013 cb2e90b
fix 2
johndoe2013 a30e1e2
req. changes
johndoe2013 90d0923
requested changes
johndoe2013 3e64988
Merge branch 'master' of https://github.com/OpenDreamProject/OpenDrea…
johndoe2013 8bbc291
Update OpenDreamRuntime/Procs/Native/DreamProcNativeList.cs
wixoaGit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,9 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| AL.Add("c", "d") | ||
| ASSERT(AL["c"] == -4) | ||
| ASSERT(AL["d"] == null) | ||
|
|
||
| AL.Add(list("c", "d")) | ||
| ASSERT(AL["c"] == -4) | ||
| ASSERT(AL["d"] == null) |
This file contains hidden or 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,6 @@ | ||
| // RUNTIME ERROR | ||
|
|
||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| var/alist/AL2 | ||
| AL2 = AL.Copy(1, 2) |
7 changes: 7 additions & 0 deletions
7
Content.Tests/DMProject/Tests/List/alist/AListCompoundedLists.dm
This file contains hidden or 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,7 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("left"=alist("one"=1,"two"=2),"right"=1) | ||
| ASSERT(istype(AL["left"], /alist)) | ||
| ASSERT(AL["left"]["one"] == 1) | ||
| ASSERT(AL["left"]["two"] == 2) | ||
| ASSERT(AL["right"] == 1) | ||
| ASSERT(!("two" in AL)) |
This file contains hidden or 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,8 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| var/alist/AL2 | ||
| AL2 = AL.Copy() | ||
| ASSERT(AL["a"] == 1) | ||
| ASSERT(AL2["a"] == 1) | ||
| ASSERT(AL2["b"] == 2) | ||
| ASSERT("c" in AL2) |
This file contains hidden or 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,5 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| AL.Cut() | ||
| ASSERT(length(AL) == 0) | ||
| ASSERT(!("a" in AL)) |
This file contains hidden or 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,5 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| ASSERT(AL.Find("a")) | ||
| ASSERT(AL.Find("a", 2, 3)) | ||
| ASSERT(!AL.Find("d")) |
This file contains hidden or 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,5 @@ | ||
| // RUNTIME ERROR | ||
|
|
||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = -2, "c" = 5.05) | ||
| AL.Insert(2, "d", "e") |
This file contains hidden or 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,6 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| var/string_output = AL.Join(",") | ||
| ASSERT(string_output == "a,b,c") | ||
| string_output = AL.Join("", 2) | ||
| ASSERT(string_output == "bc") |
20 changes: 20 additions & 0 deletions
20
Content.Tests/DMProject/Tests/List/alist/AListProcInteractions.dm
This file contains hidden or 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,20 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| values_cut_over(AL, 0) | ||
| ASSERT(AL["a"] == null) | ||
| ASSERT(AL["c"] == -4) | ||
| ASSERT(length(AL) == 1) | ||
|
|
||
| AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| values_cut_under(AL, 0) | ||
| ASSERT(AL["a"] == 1) | ||
| ASSERT(AL["c"] == null) | ||
| ASSERT(length(AL) == 2) | ||
|
|
||
| AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| var/alist/AL2 = alist("c" = 5, "d" = 6, "e" = 2) | ||
| ASSERT(values_dot(AL, AL2) == -20) | ||
|
|
||
| AL = alist("a" = 1, "b" = 2, "c" = -5) | ||
| ASSERT(values_product(AL) == -10) | ||
| ASSERT(values_sum(AL) == -2) |
This file contains hidden or 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,12 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| ASSERT(AL.Remove("a", "b")) | ||
| ASSERT(!("a" in AL)) | ||
| ASSERT(!("b" in AL)) | ||
| ASSERT("c" in AL) | ||
|
|
||
| AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| ASSERT(AL.Remove(list("a", "b"))) | ||
| ASSERT(!("a" in AL)) | ||
| ASSERT(!("b" in AL)) | ||
| ASSERT("c" in AL) |
12 changes: 12 additions & 0 deletions
12
Content.Tests/DMProject/Tests/List/alist/AListRemoveAll.dm
This file contains hidden or 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,12 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| ASSERT(AL.Remove("a", "b")) | ||
| ASSERT(!("a" in AL)) | ||
| ASSERT(!("b" in AL)) | ||
| ASSERT("c" in AL) | ||
|
|
||
| AL = alist("a" = 1, "b" = 2, "c" = -4) | ||
| ASSERT(AL.Remove(list("a", "b"))) | ||
| ASSERT(!("a" in AL)) | ||
| ASSERT(!("b" in AL)) | ||
| ASSERT("c" in AL) | ||
This file contains hidden or 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,7 @@ | ||
| /proc/RunTest() | ||
| var/alist/A1 = alist("1" = 1) | ||
| ASSERT(A1["1"] == 1) | ||
| A1["1"] = 1.5 | ||
| A1["2"] = 2 | ||
| ASSERT(A1["1"] == 1.5) | ||
| ASSERT(A1["2"] == 2) |
This file contains hidden or 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,5 @@ | ||
| // RUNTIME ERROR | ||
|
|
||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = -2, "c" = 5.05) | ||
| AL.Splice(1, 1, "d") |
This file contains hidden or 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,5 @@ | ||
| // RUNTIME ERROR | ||
|
|
||
| /proc/RunTest() | ||
| var/alist/AL = alist("a" = 1, "b" = -2, "c" = 5.05) | ||
| AL.Swap(1, 1) |
14 changes: 14 additions & 0 deletions
14
Content.Tests/DMProject/Tests/List/alist/AListValidKeys.dm
This file contains hidden or 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,14 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist() | ||
| var/datum/D = new() | ||
| var/list/L = new() | ||
| AL[D] = 1 | ||
| AL["A"] = 2 | ||
| AL[5] = 3 | ||
| AL[L] = 4 | ||
| AL[null] = 5 | ||
| ASSERT(AL[D] == 1) | ||
| ASSERT(AL["A"] == 2) | ||
| ASSERT(AL[5] == 3) | ||
| ASSERT(AL[L] == 4) | ||
| ASSERT(AL[null] == 5) |
14 changes: 14 additions & 0 deletions
14
Content.Tests/DMProject/Tests/List/alist/AListValidValues.dm
This file contains hidden or 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,14 @@ | ||
| /proc/RunTest() | ||
| var/alist/AL = alist() | ||
| var/datum/D = new() | ||
| var/list/L = new() | ||
| AL[1] = D | ||
| AL[2] = L | ||
| AL[3] = 3 | ||
| AL[4] = "4" | ||
| AL[5] = null | ||
| ASSERT(AL[1] == D) | ||
| ASSERT(AL[2] == L) | ||
| ASSERT(AL[3] == 3) | ||
| ASSERT(AL[4] == "4") | ||
| ASSERT(AL[5] == null) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.