From 54969782c572ddb54eabe7d38559f6928043fc28 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Wed, 1 Nov 2023 09:20:47 +0000 Subject: [PATCH 1/5] Add 'with custom model data' test. --- .../expressions/ExprItemWithCustomModelData.sk | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/test/skript/tests/syntaxes/expressions/ExprItemWithCustomModelData.sk diff --git a/src/test/skript/tests/syntaxes/expressions/ExprItemWithCustomModelData.sk b/src/test/skript/tests/syntaxes/expressions/ExprItemWithCustomModelData.sk new file mode 100644 index 00000000000..41ce0a88ea1 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprItemWithCustomModelData.sk @@ -0,0 +1,13 @@ +test "item with custom model data": + set {_i} to stone + assert the custom model data of {_i} is 0 with "default model data failed" + set {_i} to stone with custom model data 5 + assert the custom model data of {_i} is 5 with "simple model data set failed" + set {_i} to stone with custom model data -1 + assert the custom model data of {_i} is -1 with "negative model data set failed" + set {_i} to {_i} with custom model data 2 + assert the custom model data of {_i} is 2 with "existing item model data set failed" + set {_i} to {_i} with custom model data 3.3 + assert the custom model data of {_i} is 3 with "decimal item model data set failed" + set {_i} to {_i} with custom model data 3.999 + assert the custom model data of {_i} is 3 with "close decimal item model data set failed" From f1e487c4784879f25a66d30649c30fb479f61cc1 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Wed, 1 Nov 2023 09:32:19 +0000 Subject: [PATCH 2/5] Add 'amount of items' test. --- .../syntaxes/expressions/ExprAmountOfItems.sk | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk diff --git a/src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk b/src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk new file mode 100644 index 00000000000..21987c83e87 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk @@ -0,0 +1,14 @@ +test "amount of items": + set {_inventory} to a barrel inventory named "test" + assert the amount of stone in {_inventory} is 0 with "default amount failed" + add stone to {_inventory} + assert the amount of stone in {_inventory} is 1 with "single amount failed" + add stone named "bread" to {_inventory} + assert the amount of stone in {_inventory} is 2 with "different named items amount failed" + add 100 of iron ingot to {_inventory} + assert the amount of stone in {_inventory} is 2 with "add different item amount failed" + assert the amount of iron ingot in {_inventory} is 100 with "add 100 item amount failed" + remove stone from {_inventory} + assert the amount of stone in {_inventory} is 1 with "removed one amount failed" + remove stone from {_inventory} + assert the amount of stone in {_inventory} is 0 with "removed all amount failed" From 987fe4cb3f83c49df39671a7619810bc22e58591 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Wed, 1 Nov 2023 09:41:56 +0000 Subject: [PATCH 3/5] Add 'items in' test. --- .../tests/syntaxes/expressions/ExprItemsIn.sk | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk diff --git a/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk b/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk new file mode 100644 index 00000000000..b9ee8d6401b --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk @@ -0,0 +1,24 @@ +test "items in (inventory)": + set {_inventory} to a barrel inventory named "test" + add stone to {_inventory} + add stone named "bread" to {_inventory} + add 100 of iron ingot to {_inventory} + loop items in {_inventory}: + if loop-value is stone: + continue + else if loop-value is iron ingot: + continue + else: + assert true is false with "unexpected item in the inventory area: %loop-value%" + set {_list::*} to items in {_inventory} + assert size of {_list::*} is 4 with "size of items in failed: %size of {_list::*}%" + assert {_list::1} is stone with "first item failed: %{_list::1}%" + assert {_list::2} is stone named "bread" with "second item failed: %{_list::2}%" + assert {_list::3} is 64 of iron ingot with "third item failed: %{_list::3}%" + assert {_list::4} is 36 of iron ingot with "split fourth item failed: %{_list::4}%" + remove stone from {_inventory} + set {_list::*} to items in {_inventory} + assert size of {_list::*} is 3 with "size of second items in failed: %size of {_list::*}%" + assert {_list::1} is stone named "bread" with "new first item failed: %{_list::1}%" + assert {_list::2} is 64 of iron ingot with "new second item failed: %{_list::2}%" + assert {_list::3} is 36 of iron ingot with "new third item failed: %{_list::3}%" From 441e7164139fe2c70bc64828c7f2e4b93ba87338 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Thu, 2 Nov 2023 09:42:26 +0000 Subject: [PATCH 4/5] Make safe for 1.13.2. --- src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk | 2 +- .../tests/syntaxes/expressions/ExprItemWithCustomModelData.sk | 2 +- src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk b/src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk index 21987c83e87..9e40ff707ca 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprAmountOfItems.sk @@ -1,5 +1,5 @@ test "amount of items": - set {_inventory} to a barrel inventory named "test" + set {_inventory} to a hopper inventory named "test" assert the amount of stone in {_inventory} is 0 with "default amount failed" add stone to {_inventory} assert the amount of stone in {_inventory} is 1 with "single amount failed" diff --git a/src/test/skript/tests/syntaxes/expressions/ExprItemWithCustomModelData.sk b/src/test/skript/tests/syntaxes/expressions/ExprItemWithCustomModelData.sk index 41ce0a88ea1..098cda9abee 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprItemWithCustomModelData.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprItemWithCustomModelData.sk @@ -1,4 +1,4 @@ -test "item with custom model data": +test "item with custom model data" when minecraft version is not "1.13.2": set {_i} to stone assert the custom model data of {_i} is 0 with "default model data failed" set {_i} to stone with custom model data 5 diff --git a/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk b/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk index b9ee8d6401b..9e547f028b6 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk @@ -1,5 +1,5 @@ test "items in (inventory)": - set {_inventory} to a barrel inventory named "test" + set {_inventory} to a hopper inventory named "test" add stone to {_inventory} add stone named "bread" to {_inventory} add 100 of iron ingot to {_inventory} From 067612b613a7ff944f9379cdc4305ce02b54fa93 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Wed, 1 May 2024 06:23:57 +0100 Subject: [PATCH 5/5] Update src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> --- .../tests/syntaxes/expressions/ExprItemsIn.sk | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk b/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk index 4c35f86165b..a18bef586af 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprItemsIn.sk @@ -12,17 +12,17 @@ test "items in (inventory)": else: assert true is false with "unexpected item in the inventory area: %loop-value%" set {_list::*} to items in {_inventory} - assert size of {_list::*} is 4 with "size of items in failed: %size of {_list::*}%" - assert {_list::1} is stone with "first item failed: %{_list::1}%" - assert {_list::2} is stone named "bread" with "second item failed: %{_list::2}%" - assert {_list::3} is 64 of iron ingot with "third item failed: %{_list::3}%" - assert {_list::4} is 36 of iron ingot with "split fourth item failed: %{_list::4}%" + assert size of {_list::*} is 4 with "size of items in failed" + assert {_list::1} is stone with "first item failed" + assert {_list::2} is stone named "bread" with "second item failed" + assert {_list::3} is 64 of iron ingot with "third item failed" + assert {_list::4} is 36 of iron ingot with "split fourth item failed" remove stone from {_inventory} set {_list::*} to items in {_inventory} - assert size of {_list::*} is 3 with "size of second items in failed: %size of {_list::*}%" - assert {_list::1} is stone named "bread" with "new first item failed: %{_list::1}%" - assert {_list::2} is 64 of iron ingot with "new second item failed: %{_list::2}%" - assert {_list::3} is 36 of iron ingot with "new third item failed: %{_list::3}%" + assert size of {_list::*} is 3 with "size of second items in failed" + assert {_list::1} is stone named "bread" with "new first item failed" + assert {_list::2} is 64 of iron ingot with "new second item failed" + assert {_list::3} is 36 of iron ingot with "new third item failed" test "filtering ExprItemsIn": set {_world} to random world out of all worlds