-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08325b5
commit d2a812b
Showing
5 changed files
with
41 additions
and
1 deletion.
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 |
---|---|---|
@@ -1 +1,13 @@ | ||
test_suite_pass(); | ||
/// _toArray | ||
test_start("_toArray", "Converts a list to an array"); | ||
|
||
var list = ds_list_create(); | ||
ds_list_add(1, 2, 3, 4, 5); | ||
|
||
var arr = _toArray(list); | ||
|
||
for (var i = 0; i < _length(arr); i++) { | ||
assert_equal(list[| i], arr[i]); | ||
} | ||
|
||
test_end(); |
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 @@ | ||
test_suite_pass(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
/// @desc Converts the given ds_list to an array | ||
/// @param list | ||
/// Note: If the given list is of size 0, this will return undefined. | ||
|
||
var list = argument0; | ||
var listSize = ds_list_size(list); | ||
var array; | ||
array[0] = undefined; | ||
|
||
for (var i = listSize - 1; i >= 0; i--) { | ||
array[i] = list[| i]; | ||
} | ||
|
||
if (is_undefined(array[0])) { | ||
return undefined; | ||
} | ||
|
||
return array; |