Skip to content

Commit 333b5fb

Browse files
Moderockysovdeeth
andauthored
Add tests for item syntaxes. (#6164)
* Add 'with custom model data' test. * Add 'amount of items' test. * Add 'items in' test. * Make safe for 1.13.2. * Update src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> --------- Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
1 parent 6ee4628 commit 333b5fb

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
test "amount of items":
2+
set {_inventory} to a hopper inventory named "test"
3+
assert the amount of stone in {_inventory} is 0 with "default amount failed"
4+
add stone to {_inventory}
5+
assert the amount of stone in {_inventory} is 1 with "single amount failed"
6+
add stone named "bread" to {_inventory}
7+
assert the amount of stone in {_inventory} is 2 with "different named items amount failed"
8+
add 100 of iron ingot to {_inventory}
9+
assert the amount of stone in {_inventory} is 2 with "add different item amount failed"
10+
assert the amount of iron ingot in {_inventory} is 100 with "add 100 item amount failed"
11+
remove stone from {_inventory}
12+
assert the amount of stone in {_inventory} is 1 with "removed one amount failed"
13+
remove stone from {_inventory}
14+
assert the amount of stone in {_inventory} is 0 with "removed all amount failed"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
test "item with custom model data" when minecraft version is not "1.13.2":
2+
set {_i} to stone
3+
assert the custom model data of {_i} is 0 with "default model data failed"
4+
set {_i} to stone with custom model data 5
5+
assert the custom model data of {_i} is 5 with "simple model data set failed"
6+
set {_i} to stone with custom model data -1
7+
assert the custom model data of {_i} is -1 with "negative model data set failed"
8+
set {_i} to {_i} with custom model data 2
9+
assert the custom model data of {_i} is 2 with "existing item model data set failed"
10+
set {_i} to {_i} with custom model data 3.3
11+
assert the custom model data of {_i} is 3 with "decimal item model data set failed"
12+
set {_i} to {_i} with custom model data 3.999
13+
assert the custom model data of {_i} is 3 with "close decimal item model data set failed"

src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
2+
test "items in (inventory)":
3+
set {_inventory} to a hopper inventory named "test"
4+
add stone to {_inventory}
5+
add stone named "bread" to {_inventory}
6+
add 100 of iron ingot to {_inventory}
7+
loop items in {_inventory}:
8+
if loop-value is stone:
9+
continue
10+
else if loop-value is iron ingot:
11+
continue
12+
else:
13+
assert true is false with "unexpected item in the inventory area: %loop-value%"
14+
set {_list::*} to items in {_inventory}
15+
assert size of {_list::*} is 4 with "size of items in failed"
16+
assert {_list::1} is stone with "first item failed"
17+
assert {_list::2} is stone named "bread" with "second item failed"
18+
assert {_list::3} is 64 of iron ingot with "third item failed"
19+
assert {_list::4} is 36 of iron ingot with "split fourth item failed"
20+
remove stone from {_inventory}
21+
set {_list::*} to items in {_inventory}
22+
assert size of {_list::*} is 3 with "size of second items in failed"
23+
assert {_list::1} is stone named "bread" with "new first item failed"
24+
assert {_list::2} is 64 of iron ingot with "new second item failed"
25+
assert {_list::3} is 36 of iron ingot with "new third item failed"
26+
127
test "filtering ExprItemsIn":
228
set {_world} to random world out of all worlds
329
set block at spawn of {_world} to chest
@@ -19,3 +45,4 @@ test "unfiltered ExprItemsIn":
1945
set slot 3 of {_inv} to bucket
2046
assert all items in inventory {_inv} are dirt, stone or bucket with "found correct items with ExprItemsIn##get"
2147
assert (all items in inventory {_inv} where [true is true]) are dirt, stone or bucket with "found correct items with ExprItemsIn##iterator"
48+

0 commit comments

Comments
 (0)