forked from OpenDreamProject/OpenDream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully implement splittext and add test (OpenDreamProject#1560)
* fully implement splittext and add test * test list comparison * fix include_delimiters * array instead of linq * Update OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs Co-authored-by: wixoa <[email protected]> * duh * I am dum --------- Co-authored-by: wixoa <[email protected]>
- Loading branch information
Showing
2 changed files
with
86 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/proc/RunTest() | ||
var/test_text = "The average of 1, 2, 3, 4, 5 is: 3" | ||
var/list/test1 = splittext(test_text, " ") | ||
var/list/test1_expected = list("The","average","of","1,","2,","3,","4,","5","is:","3") | ||
ASSERT(test1 ~= test1_expected) | ||
|
||
var/list/test2 = splittext(test_text, " ", 5) | ||
var/test2_expected = list("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") | ||
ASSERT(test3 ~= test3_expected) | ||
|
||
var/list/test4 = splittext(test_text, " ", 10, 20) | ||
var/test4_expected = list("ge","of","1,","2") | ||
ASSERT(test4 ~= test4_expected) | ||
|
||
var/list/test5 = splittext(test_text, " ", 10, 20, 1) | ||
var/test5_expected = list("ge"," ","of"," ","1,"," ","2") | ||
ASSERT(test5 ~= test5_expected) | ||
|
||
//it's regex time | ||
var/test6 = splittext(test_text, regex(@"\d")) | ||
var/test6_expected = list("The average of ",", ",", ",", ",", "," is: ","") | ||
ASSERT(test6 ~= test6_expected) | ||
|
||
var/test7 = splittext(test_text, regex(@"\d"), 5, 30) | ||
var/test7_expected = list("average of ",", ",", ",", ",", "," ") | ||
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"," ") | ||
ASSERT(test8 ~= test8_expected) |
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