Skip to content

Commit

Permalink
add tests for utils:math/vector/dot
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAfroOfDoom committed Dec 20, 2023
1 parent b50c5f8 commit 8be0e56
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
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 score #utils:math.vector.dot math.1 run data get storage utils:math.vector.dot out 100
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 score #utils:math.vector.dot math.1 run data get storage utils:math.vector.dot out 100
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 score #utils:math.vector.dot math.1 run data get storage utils:math.vector.dot out 100
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
39 changes: 39 additions & 0 deletions datapacks/omega-flowey/data/utils/tests/math/vector/dot.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# @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
scoreboard players reset *
function omega-flowey:setup

# cases
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

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

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

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

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

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

0 comments on commit 8be0e56

Please sign in to comment.