Skip to content
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

Refactor tests to make them more readable #9

Open
wants to merge 1 commit into
base: 1.20.2-dev
Choose a base branch
from
Open
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
59 changes: 34 additions & 25 deletions data/moxlib/functions/z_spec/data/array/join.mcfunction
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
data merge storage moxlib:api/data/array/join {target:["Hello", ", ", "world", "!"],separator:""}
data modify storage moxlib:test/it describes set value "An array joined with a blank separator"

function moxlib:api/data/array/join
data merge storage moxlib:api/data/array/join {target:["Hello", ", ", "world", "!"],separator:""}

data modify storage moxlib:test/it describes set value "An array joined with a blank separator"
data modify storage moxlib:test/it expects set value "Hello, world!"
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output
function moxlib:api/data/array/join

function moxlib:api/test/perform
data modify storage moxlib:test/it expects set value "Hello, world!"
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

data merge storage moxlib:api/data/array/join {target:["a","b","c","d"],separator:","}
function moxlib:api/test/perform

function moxlib:api/data/array/join

data modify storage moxlib:test/it describes set value "An array joined with a single character separator"
data modify storage moxlib:test/it expects set value "a,b,c,d"
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

function moxlib:api/test/perform
data merge storage moxlib:api/data/array/join {target:["a","b","c","d"],separator:","}

data merge storage moxlib:api/data/array/join {target:["foo","bar","baz","qux"],separator:", "}
function moxlib:api/data/array/join

data modify storage moxlib:test/it expects set value "a,b,c,d"
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

function moxlib:api/test/perform

function moxlib:api/data/array/join

data modify storage moxlib:test/it describes set value "An array joined with a multi-character separator"
data modify storage moxlib:test/it expects set value "foo, bar, baz, qux"
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

function moxlib:api/test/perform
data merge storage moxlib:api/data/array/join {target:["foo","bar","baz","qux"],separator:", "}

data merge storage moxlib:api/data/array/join {target:["42"],separator:":"}
function moxlib:api/data/array/join

data modify storage moxlib:test/it expects set value "foo, bar, baz, qux"
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

function moxlib:api/test/perform

function moxlib:api/data/array/join

data modify storage moxlib:test/it describes set value "An array with only one entry being joined"
data modify storage moxlib:test/it expects set value "42"
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

function moxlib:api/test/perform
data merge storage moxlib:api/data/array/join {target:["42"],separator:":"}

data merge storage moxlib:api/data/array/join {target:[],separator:"!"}
function moxlib:api/data/array/join

data modify storage moxlib:test/it expects set value "42"
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

function moxlib:api/test/perform

function moxlib:api/data/array/join

data modify storage moxlib:test/it describes set value "An empty array being joined"
data modify storage moxlib:test/it expects set value ""
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

data merge storage moxlib:api/data/array/join {target:[],separator:"!"}

function moxlib:api/data/array/join

data modify storage moxlib:test/it expects set value ""
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/join output

function moxlib:api/test/perform
11 changes: 6 additions & 5 deletions data/moxlib/functions/z_spec/data/array/pick.mcfunction
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
data modify storage moxlib:api/data/array/pick target set value [1,1,1,1]
data modify storage moxlib:test/it describes set value "Successfully picking an item from an array"

function moxlib:api/data/array/pick
data modify storage moxlib:api/data/array/pick target set value [1,1,1,1]

data modify storage moxlib:test/it describes set value "Successfully picking an item from an array"
data modify storage moxlib:test/it expects set value 1
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/pick output
function moxlib:api/data/array/pick

data modify storage moxlib:test/it expects set value 1
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/pick output

function moxlib:api/test/perform
35 changes: 20 additions & 15 deletions data/moxlib/functions/z_spec/data/array/reverse.mcfunction
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
data merge storage moxlib:api/data/array/reverse {target:["Hello", ", ", "world", "!"]}
data modify storage moxlib:test/it describes set value "An array reversed"

function moxlib:api/data/array/reverse
data merge storage moxlib:api/data/array/reverse {target:["Hello", ", ", "world", "!"]}

data modify storage moxlib:test/it describes set value "An array reversed"
data modify storage moxlib:test/it expects set value ["!", "world", ", ", "Hello"]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/reverse output
function moxlib:api/data/array/reverse

function moxlib:api/test/perform
data modify storage moxlib:test/it expects set value ["!", "world", ", ", "Hello"]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/reverse output

data merge storage moxlib:api/data/array/reverse {target:["foo"]}
function moxlib:api/test/perform

function moxlib:api/data/array/reverse

data modify storage moxlib:test/it describes set value "An array with one element reversed"
data modify storage moxlib:test/it expects set value ["foo"]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/reverse output

function moxlib:api/test/perform
data merge storage moxlib:api/data/array/reverse {target:["foo"]}

data merge storage moxlib:api/data/array/reverse {target:[]}
function moxlib:api/data/array/reverse

data modify storage moxlib:test/it expects set value ["foo"]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/reverse output

function moxlib:api/test/perform

function moxlib:api/data/array/reverse

data modify storage moxlib:test/it describes set value "An array with no elements reversed"
data modify storage moxlib:test/it expects set value []
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/reverse output

data merge storage moxlib:api/data/array/reverse {target:[]}

function moxlib:api/data/array/reverse

data modify storage moxlib:test/it expects set value []
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/reverse output

function moxlib:api/test/perform
55 changes: 31 additions & 24 deletions data/moxlib/functions/z_spec/data/array/sample.mcfunction
Original file line number Diff line number Diff line change
@@ -1,43 +1,50 @@
data modify storage moxlib:api/data/array/sample target set value [1,1,1,1,1]
data modify storage moxlib:api/data/array/sample amount set value 1
data modify storage moxlib:test/it describes set value "Successfully sampling an item from an array"

function moxlib:api/data/array/sample
data modify storage moxlib:api/data/array/sample target set value [1,1,1,1,1]
data modify storage moxlib:api/data/array/sample amount set value 1

data modify storage moxlib:test/it describes set value "Successfully sampling an item from an array"
data modify storage moxlib:test/it expects set value [1]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/sample output
function moxlib:api/data/array/sample

function moxlib:api/test/perform
data modify storage moxlib:test/it expects set value [1]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/sample output

data modify storage moxlib:api/data/array/sample target set value [42,42,42,42,42]
data modify storage moxlib:api/data/array/sample amount set value 3
function moxlib:api/test/perform

function moxlib:api/data/array/sample

data modify storage moxlib:test/it describes set value "Successfully sampling multiple items from an array"
data modify storage moxlib:test/it expects set value [42,42,42]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/sample output

function moxlib:api/test/perform
data modify storage moxlib:api/data/array/sample target set value [42,42,42,42,42]
data modify storage moxlib:api/data/array/sample amount set value 3

function moxlib:api/data/array/sample

data modify storage moxlib:api/data/array/sample target set value [69,69,69]
data modify storage moxlib:api/data/array/sample amount set value 0
data modify storage moxlib:test/it expects set value [42,42,42]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/sample output

function moxlib:api/test/perform

function moxlib:api/data/array/sample

data modify storage moxlib:test/it describes set value "Successfully sampling no items from an array"
data modify storage moxlib:test/it expects set value []
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/sample output

function moxlib:api/test/perform
data modify storage moxlib:api/data/array/sample target set value [69,69,69]
data modify storage moxlib:api/data/array/sample amount set value 0

function moxlib:api/data/array/sample

data modify storage moxlib:api/data/array/sample target set value [17,17]
data modify storage moxlib:api/data/array/sample amount set value 4
data modify storage moxlib:test/it expects set value []
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/sample output

function moxlib:api/test/perform

function moxlib:api/data/array/sample

data modify storage moxlib:test/it describes set value "Trying to sample too many items from an array"
data modify storage moxlib:test/it expects set value [17,17]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/sample output

data modify storage moxlib:api/data/array/sample target set value [17,17]
data modify storage moxlib:api/data/array/sample amount set value 4

function moxlib:api/data/array/sample

data modify storage moxlib:test/it expects set value [17,17]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/sample output

function moxlib:api/test/perform
87 changes: 49 additions & 38 deletions data/moxlib/functions/z_spec/data/array/slice.mcfunction
Original file line number Diff line number Diff line change
@@ -1,67 +1,78 @@
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:test/it describes set value "An array sliced with no start or end"

function moxlib:api/data/array/slice
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]

data modify storage moxlib:test/it describes set value "An array sliced with no start or end"
data modify storage moxlib:test/it expects set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output
function moxlib:api/data/array/slice

function moxlib:api/test/perform
data modify storage moxlib:test/it expects set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice start set value 2
function moxlib:api/test/perform

function moxlib:api/data/array/slice

data modify storage moxlib:test/it describes set value "An array sliced with no end"
data modify storage moxlib:test/it expects set value [3,4,5,6,7,8,9]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

function moxlib:api/test/perform
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice start set value 2

function moxlib:api/data/array/slice

data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice end set value 7
data modify storage moxlib:test/it expects set value [3,4,5,6,7,8,9]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

function moxlib:api/test/perform

function moxlib:api/data/array/slice

data modify storage moxlib:test/it describes set value "An array sliced with no start"
data modify storage moxlib:test/it expects set value [1,2,3,4,5,6,7]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

function moxlib:api/test/perform
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice end set value 7

data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice start set value 4
data modify storage moxlib:api/data/array/slice end set value 7
function moxlib:api/data/array/slice

data modify storage moxlib:test/it expects set value [1,2,3,4,5,6,7]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

function moxlib:api/test/perform

function moxlib:api/data/array/slice

data modify storage moxlib:test/it describes set value "A slice operation"
data modify storage moxlib:test/it expects set value [5,6,7]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

function moxlib:api/test/perform
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice start set value 4
data modify storage moxlib:api/data/array/slice end set value 7

function moxlib:api/data/array/slice

data modify storage moxlib:test/it expects set value [5,6,7]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice start set value 4
data modify storage moxlib:api/data/array/slice end set value 4
function moxlib:api/test/perform

function moxlib:api/data/array/slice

data modify storage moxlib:test/it describes set value "A slice operation with zero magnitude"
data modify storage moxlib:test/it expects set value []
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

function moxlib:api/test/perform
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice start set value 4
data modify storage moxlib:api/data/array/slice end set value 4

data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice start set value 4
data modify storage moxlib:api/data/array/slice end set value 2
function moxlib:api/data/array/slice

data modify storage moxlib:test/it expects set value []
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output

function moxlib:api/test/perform

function moxlib:api/data/array/slice

data modify storage moxlib:test/it describes set value "A slice operation with the end less than the start"
data modify storage moxlib:test/it expects set value {success:0b,error:"End cannot be less than start"}
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice {}

data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9]
data modify storage moxlib:api/data/array/slice start set value 4
data modify storage moxlib:api/data/array/slice end set value 2

function moxlib:api/data/array/slice

data modify storage moxlib:test/it expects set value {success:0b,error:"End cannot be less than start"}
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice {}

function moxlib:api/test/perform
29 changes: 16 additions & 13 deletions data/moxlib/functions/z_spec/data/collect.mcfunction
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
data modify storage moxlib:api/data/collect target set value [{collect:true,data:"foo"},{collect:false,data:"bar"},{collect:false,data:"baz"},{collect:true,data:"qux"}]
data modify storage moxlib:api/data/collect key set value {collect:true}
data modify storage moxlib:test/it describes set value "Correctly collecting elements"

function moxlib:api/data/collect
data modify storage moxlib:api/data/collect target set value [{collect:true,data:"foo"},{collect:false,data:"bar"},{collect:false,data:"baz"},{collect:true,data:"qux"}]
data modify storage moxlib:api/data/collect key set value {collect:true}

data modify storage moxlib:test/it describes set value "Correctly collecting elements"
data modify storage moxlib:test/it expects set value [{collect:true,data:"foo"},{collect:true,data:"qux"}]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/collect output.match
function moxlib:api/data/collect

function moxlib:api/test/perform
data modify storage moxlib:test/it expects set value [{collect:true,data:"foo"},{collect:true,data:"qux"}]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/collect output.match

data modify storage moxlib:api/data/collect target set value [{collect:true,data:"foo"},{collect:false,data:"bar"},{collect:false,data:"baz"},{collect:true,data:"qux"}]
data modify storage moxlib:api/data/collect key set value {collect:true}
function moxlib:api/test/perform

function moxlib:api/data/collect

data modify storage moxlib:test/it describes set value "Correctly not collecting elements"
data modify storage moxlib:test/it expects set value [{collect:false,data:"bar"},{collect:false,data:"baz"}]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/collect output.remain

function moxlib:api/test/perform
data modify storage moxlib:api/data/collect target set value [{collect:true,data:"foo"},{collect:false,data:"bar"},{collect:false,data:"baz"},{collect:true,data:"qux"}]
data modify storage moxlib:api/data/collect key set value {collect:true}

function moxlib:api/data/collect

data modify storage moxlib:test/it expects set value [{collect:false,data:"bar"},{collect:false,data:"baz"}]
data modify storage moxlib:test/it receives set from storage moxlib:api/data/collect output.remain

function moxlib:api/test/perform
Loading