-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more unit tests for
utils:math
and omega-flowey:reset
/`omega-…
…flowey:setup` (#34) - also updates `packtest_runner` to latest version so we can use latest `packtest` features
- Loading branch information
1 parent
b50c5f8
commit afb1cc9
Showing
8 changed files
with
123 additions
and
24 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
16 changes: 16 additions & 0 deletions
16
datapacks/omega-flowey/data/omega-flowey/tests/reset/should_wipe_scores.mcfunction
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,16 @@ | ||
# @batch omega-flowey:setup | ||
|
||
## should wipe any preexisting scores | ||
|
||
scoreboard objectives add some.objective dummy | ||
scoreboard players set #omega-flowey:reset math.0 1 | ||
scoreboard players set #omega-flowey:reset some.objective -124 | ||
assert score #omega-flowey:reset math.0 matches 1 | ||
assert score #omega-flowey:reset some.objective matches -124 | ||
function omega-flowey:reset | ||
|
||
execute store success score #omega-flowey:reset math.1 run scoreboard players get #omega-flowey:reset math.0 | ||
assert score #omega-flowey:reset math.1 matches 0 | ||
|
||
execute store success score #omega-flowey:reset math.1 run scoreboard players get #omega-flowey:reset some.objective | ||
assert score #omega-flowey:reset math.1 matches 0 |
20 changes: 20 additions & 0 deletions
20
datapacks/omega-flowey/data/omega-flowey/tests/setup/should_add_teams.mcfunction
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,20 @@ | ||
# @batch omega-flowey:setup | ||
|
||
## should add the `player` team | ||
function omega-flowey:reset | ||
|
||
team remove player | ||
|
||
# create an entity with a group id | ||
summon minecraft:pig ~ ~ ~ { Tags: ["omega-flowey", "test.setup.should-add-teams"], DeathLootTable: empty, NoAI: 1, PersistenceRequired: 1, } | ||
|
||
# should not be able to join team that doesn't exist | ||
execute store success score #omega-flowey:setup math.0 as @e[tag=test.setup.should-add-teams] run team join player | ||
assert score #omega-flowey:setup math.0 matches 0 | ||
|
||
# add the team | ||
function omega-flowey:setup | ||
|
||
# should be able to join team that exists | ||
execute store success score #omega-flowey:setup math.0 as @e[tag=test.setup.should-add-teams] run team join player | ||
assert score #omega-flowey:setup math.0 matches 1 |
20 changes: 20 additions & 0 deletions
20
datapacks/omega-flowey/data/omega-flowey/tests/setup/should_reset_group_ids.mcfunction
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,20 @@ | ||
# @batch omega-flowey:setup | ||
|
||
## should wipe any preexisting scores | ||
|
||
function omega-flowey:reset | ||
|
||
# create an entity with a group id | ||
summon minecraft:marker ~ ~ ~ {Tags:["omega-flowey","groupable","test.setup.should-reset-group-ids"]} | ||
|
||
assert score #group.id.next group.id matches 0 | ||
execute as @e[tag=test.setup.should-reset-group-ids] run function entity:group/set | ||
assert score #group.id.next group.id matches 1 | ||
|
||
# killing `groupable` entities should not immediately reset #group.id.next | ||
kill @e[tag=test.setup.should-reset-group-ids] | ||
assert score #group.id.next group.id matches 1 | ||
|
||
function omega-flowey:setup | ||
|
||
assert score #group.id.next group.id matches 0 |
22 changes: 11 additions & 11 deletions
22
datapacks/omega-flowey/data/utils/functions/math/vector/dot_macro.mcfunction
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,15 +1,15 @@ | ||
scoreboard players set @s math.0 0 | ||
scoreboard players set #utils:math.vector.dot math.0 0 | ||
|
||
$execute store result storage utils:math.vector.dot out float 1 run data get storage utils:math.vector.dot u.x $(x) | ||
execute store result score @s math.1 run data get storage utils:math.vector.dot out 100 | ||
scoreboard players operation @s math.0 += @s math.1 | ||
$execute store result storage utils:math.vector.dot out float $(x) run data get storage utils:math.vector.dot u.x 100 | ||
execute store result score #utils:math.vector.dot math.1 run data get storage utils:math.vector.dot out | ||
scoreboard players operation #utils:math.vector.dot math.0 += #utils:math.vector.dot math.1 | ||
|
||
$execute store result storage utils:math.vector.dot out float 1 run data get storage utils:math.vector.dot u.y $(y) | ||
execute store result score @s math.1 run data get storage utils:math.vector.dot out 100 | ||
scoreboard players operation @s math.0 += @s math.1 | ||
$execute store result storage utils:math.vector.dot out float $(y) run data get storage utils:math.vector.dot u.y 100 | ||
execute store result score #utils:math.vector.dot math.1 run data get storage utils:math.vector.dot out | ||
scoreboard players operation #utils:math.vector.dot math.0 += #utils:math.vector.dot math.1 | ||
|
||
$execute store result storage utils:math.vector.dot out float 1 run data get storage utils:math.vector.dot u.z $(z) | ||
execute store result score @s math.1 run data get storage utils:math.vector.dot out 100 | ||
scoreboard players operation @s math.0 += @s math.1 | ||
$execute store result storage utils:math.vector.dot out float $(z) run data get storage utils:math.vector.dot u.z 100 | ||
execute store result score #utils:math.vector.dot math.1 run data get storage utils:math.vector.dot out | ||
scoreboard players operation #utils:math.vector.dot math.0 += #utils:math.vector.dot math.1 | ||
|
||
execute store result storage utils:math.vector.dot out int 1 run scoreboard players get @s math.0 | ||
execute store result storage utils:math.vector.dot out int 1 run scoreboard players get #utils:math.vector.dot math.0 |
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
50 changes: 50 additions & 0 deletions
50
datapacks/omega-flowey/data/utils/tests/math/vector/dot.mcfunction
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,50 @@ | ||
# @batch utils:math | ||
|
||
# setup | ||
data remove storage utils:math.vector.dot u | ||
data remove storage utils:math.vector.dot v | ||
data remove storage utils:math.vector.dot out | ||
function omega-flowey:reset | ||
|
||
## cases | ||
# 0-vectors | ||
data merge storage utils:math.vector.dot { u: { x: 0, y: 0, z: 0 }, v: { x: 0, y: 0, z: 0 } } | ||
function utils:math/vector/dot | ||
execute store result score #utils:math.vector.dot math.0 run data get storage utils:math.vector.dot out | ||
assert score #utils:math.vector.dot math.0 matches 0 | ||
|
||
# mismatched axes -> 0 | ||
data merge storage utils:math.vector.dot { u: { x: 1, y: 0, z: 0 }, v: { x: 0, y: 1, z: 0 } } | ||
function utils:math/vector/dot | ||
execute store result score #utils:math.vector.dot math.0 run data get storage utils:math.vector.dot out | ||
assert score #utils:math.vector.dot math.0 matches 0 | ||
|
||
# single axis | ||
data merge storage utils:math.vector.dot { u: { x: 1, y: 0, z: 0 }, v: { x: 1, y: 0, z: 0 } } | ||
function utils:math/vector/dot | ||
execute store result score #utils:math.vector.dot math.0 run data get storage utils:math.vector.dot out | ||
assert score #utils:math.vector.dot math.0 matches 100 | ||
|
||
# negative values | ||
data merge storage utils:math.vector.dot { u: { x: -1, y: 0, z: 0 }, v: { x: 1, y: 0, z: 0 } } | ||
function utils:math/vector/dot | ||
execute store result score #utils:math.vector.dot math.0 run data get storage utils:math.vector.dot out | ||
assert score #utils:math.vector.dot math.0 matches -100 | ||
|
||
# positive + negative values | ||
data merge storage utils:math.vector.dot { u: { x: 2, y: 0, z: 5 }, v: { x: 1, y: 0, z: -1 } } | ||
function utils:math/vector/dot | ||
execute store result score #utils:math.vector.dot math.0 run data get storage utils:math.vector.dot out | ||
assert score #utils:math.vector.dot math.0 matches -300 | ||
|
||
# full vectors | ||
data merge storage utils:math.vector.dot { u: { x: 1, y: 2, z: 3 }, v: { x: 4, y: 5, z: 6 } } | ||
function utils:math/vector/dot | ||
execute store result score #utils:math.vector.dot math.0 run data get storage utils:math.vector.dot out | ||
assert score #utils:math.vector.dot math.0 matches 3200 | ||
|
||
# supports decimal values up to 100th place | ||
data merge storage utils:math.vector.dot { u: { x: 1.5, y: 2.1, z: 3.12 }, v: { x: 3, y: 5, z: 7 } } | ||
function utils:math/vector/dot | ||
execute store result score #utils:math.vector.dot math.0 run data get storage utils:math.vector.dot out | ||
assert score #utils:math.vector.dot math.0 matches 3684 |