-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from aksiome/bitwise-tests
✅ Bitwise module tests
- Loading branch information
Showing
21 changed files
with
118 additions
and
132 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
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: 8 additions & 8 deletions
16
datapacks/Bookshelf/data/bs.bitwise/functions/bit_length/group_1.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,8 +1,8 @@ | ||
execute if score $bitwise.bit_length.n bs.in matches 0 run return run scoreboard players set $bitwise.bit_length bs.out 0 | ||
execute if score $bitwise.bit_length.n bs.in matches 1 run return run scoreboard players set $bitwise.bit_length bs.out 1 | ||
execute if score $bitwise.bit_length.n bs.in matches 2..3 run return run scoreboard players set $bitwise.bit_length bs.out 2 | ||
execute if score $bitwise.bit_length.n bs.in matches 4..7 run return run scoreboard players set $bitwise.bit_length bs.out 3 | ||
execute if score $bitwise.bit_length.n bs.in matches 8..15 run return run scoreboard players set $bitwise.bit_length bs.out 4 | ||
execute if score $bitwise.bit_length.n bs.in matches 16..31 run return run scoreboard players set $bitwise.bit_length bs.out 5 | ||
execute if score $bitwise.bit_length.n bs.in matches 32..63 run return run scoreboard players set $bitwise.bit_length bs.out 6 | ||
execute if score $bitwise.bit_length.n bs.in matches 64..127 run return run scoreboard players set $bitwise.bit_length bs.out 7 | ||
execute if score #bitwise.bit_length bs.data matches 0 run return run scoreboard players set $bitwise.bit_length bs.out 0 | ||
execute if score #bitwise.bit_length bs.data matches 1 run return run scoreboard players set $bitwise.bit_length bs.out 1 | ||
execute if score #bitwise.bit_length bs.data matches 2..3 run return run scoreboard players set $bitwise.bit_length bs.out 2 | ||
execute if score #bitwise.bit_length bs.data matches 4..7 run return run scoreboard players set $bitwise.bit_length bs.out 3 | ||
execute if score #bitwise.bit_length bs.data matches 8..15 run return run scoreboard players set $bitwise.bit_length bs.out 4 | ||
execute if score #bitwise.bit_length bs.data matches 16..31 run return run scoreboard players set $bitwise.bit_length bs.out 5 | ||
execute if score #bitwise.bit_length bs.data matches 32..63 run return run scoreboard players set $bitwise.bit_length bs.out 6 | ||
execute if score #bitwise.bit_length bs.data matches 64..127 run return run scoreboard players set $bitwise.bit_length bs.out 7 |
16 changes: 8 additions & 8 deletions
16
datapacks/Bookshelf/data/bs.bitwise/functions/bit_length/group_2.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,8 +1,8 @@ | ||
execute if score $bitwise.bit_length.n bs.in matches 128..255 run return run scoreboard players set $bitwise.bit_length bs.out 8 | ||
execute if score $bitwise.bit_length.n bs.in matches 256..511 run return run scoreboard players set $bitwise.bit_length bs.out 9 | ||
execute if score $bitwise.bit_length.n bs.in matches 512..1023 run return run scoreboard players set $bitwise.bit_length bs.out 10 | ||
execute if score $bitwise.bit_length.n bs.in matches 1024..2047 run return run scoreboard players set $bitwise.bit_length bs.out 11 | ||
execute if score $bitwise.bit_length.n bs.in matches 2048..4095 run return run scoreboard players set $bitwise.bit_length bs.out 12 | ||
execute if score $bitwise.bit_length.n bs.in matches 4096..8191 run return run scoreboard players set $bitwise.bit_length bs.out 13 | ||
execute if score $bitwise.bit_length.n bs.in matches 8192..16383 run return run scoreboard players set $bitwise.bit_length bs.out 14 | ||
execute if score $bitwise.bit_length.n bs.in matches 16384..32767 run return run scoreboard players set $bitwise.bit_length bs.out 15 | ||
execute if score #bitwise.bit_length bs.data matches 128..255 run return run scoreboard players set $bitwise.bit_length bs.out 8 | ||
execute if score #bitwise.bit_length bs.data matches 256..511 run return run scoreboard players set $bitwise.bit_length bs.out 9 | ||
execute if score #bitwise.bit_length bs.data matches 512..1023 run return run scoreboard players set $bitwise.bit_length bs.out 10 | ||
execute if score #bitwise.bit_length bs.data matches 1024..2047 run return run scoreboard players set $bitwise.bit_length bs.out 11 | ||
execute if score #bitwise.bit_length bs.data matches 2048..4095 run return run scoreboard players set $bitwise.bit_length bs.out 12 | ||
execute if score #bitwise.bit_length bs.data matches 4096..8191 run return run scoreboard players set $bitwise.bit_length bs.out 13 | ||
execute if score #bitwise.bit_length bs.data matches 8192..16383 run return run scoreboard players set $bitwise.bit_length bs.out 14 | ||
execute if score #bitwise.bit_length bs.data matches 16384..32767 run return run scoreboard players set $bitwise.bit_length bs.out 15 |
16 changes: 8 additions & 8 deletions
16
datapacks/Bookshelf/data/bs.bitwise/functions/bit_length/group_3.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,8 +1,8 @@ | ||
execute if score $bitwise.bit_length.n bs.in matches 32768..65535 run return run scoreboard players set $bitwise.bit_length bs.out 16 | ||
execute if score $bitwise.bit_length.n bs.in matches 65536..131071 run return run scoreboard players set $bitwise.bit_length bs.out 17 | ||
execute if score $bitwise.bit_length.n bs.in matches 131072..262143 run return run scoreboard players set $bitwise.bit_length bs.out 18 | ||
execute if score $bitwise.bit_length.n bs.in matches 262144..524287 run return run scoreboard players set $bitwise.bit_length bs.out 19 | ||
execute if score $bitwise.bit_length.n bs.in matches 524288..1048575 run return run scoreboard players set $bitwise.bit_length bs.out 20 | ||
execute if score $bitwise.bit_length.n bs.in matches 1048576..2097151 run return run scoreboard players set $bitwise.bit_length bs.out 21 | ||
execute if score $bitwise.bit_length.n bs.in matches 2097152..4194303 run return run scoreboard players set $bitwise.bit_length bs.out 22 | ||
execute if score $bitwise.bit_length.n bs.in matches 4194304..8388607 run return run scoreboard players set $bitwise.bit_length bs.out 23 | ||
execute if score #bitwise.bit_length bs.data matches 32768..65535 run return run scoreboard players set $bitwise.bit_length bs.out 16 | ||
execute if score #bitwise.bit_length bs.data matches 65536..131071 run return run scoreboard players set $bitwise.bit_length bs.out 17 | ||
execute if score #bitwise.bit_length bs.data matches 131072..262143 run return run scoreboard players set $bitwise.bit_length bs.out 18 | ||
execute if score #bitwise.bit_length bs.data matches 262144..524287 run return run scoreboard players set $bitwise.bit_length bs.out 19 | ||
execute if score #bitwise.bit_length bs.data matches 524288..1048575 run return run scoreboard players set $bitwise.bit_length bs.out 20 | ||
execute if score #bitwise.bit_length bs.data matches 1048576..2097151 run return run scoreboard players set $bitwise.bit_length bs.out 21 | ||
execute if score #bitwise.bit_length bs.data matches 2097152..4194303 run return run scoreboard players set $bitwise.bit_length bs.out 22 | ||
execute if score #bitwise.bit_length bs.data matches 4194304..8388607 run return run scoreboard players set $bitwise.bit_length bs.out 23 |
16 changes: 8 additions & 8 deletions
16
datapacks/Bookshelf/data/bs.bitwise/functions/bit_length/group_4.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,8 +1,8 @@ | ||
execute if score $bitwise.bit_length.n bs.in matches 8388608..16777215 run return run scoreboard players set $bitwise.bit_length bs.out 24 | ||
execute if score $bitwise.bit_length.n bs.in matches 16777216..33554431 run return run scoreboard players set $bitwise.bit_length bs.out 25 | ||
execute if score $bitwise.bit_length.n bs.in matches 33554432..67108863 run return run scoreboard players set $bitwise.bit_length bs.out 26 | ||
execute if score $bitwise.bit_length.n bs.in matches 67108864..134217727 run return run scoreboard players set $bitwise.bit_length bs.out 27 | ||
execute if score $bitwise.bit_length.n bs.in matches 134217728..268435455 run return run scoreboard players set $bitwise.bit_length bs.out 28 | ||
execute if score $bitwise.bit_length.n bs.in matches 268435456..536870911 run return run scoreboard players set $bitwise.bit_length bs.out 29 | ||
execute if score $bitwise.bit_length.n bs.in matches 536870912..1073741823 run return run scoreboard players set $bitwise.bit_length bs.out 30 | ||
execute if score $bitwise.bit_length.n bs.in matches 1073741824.. run return run scoreboard players set $bitwise.bit_length bs.out 31 | ||
execute if score #bitwise.bit_length bs.data matches 8388608..16777215 run return run scoreboard players set $bitwise.bit_length bs.out 24 | ||
execute if score #bitwise.bit_length bs.data matches 16777216..33554431 run return run scoreboard players set $bitwise.bit_length bs.out 25 | ||
execute if score #bitwise.bit_length bs.data matches 33554432..67108863 run return run scoreboard players set $bitwise.bit_length bs.out 26 | ||
execute if score #bitwise.bit_length bs.data matches 67108864..134217727 run return run scoreboard players set $bitwise.bit_length bs.out 27 | ||
execute if score #bitwise.bit_length bs.data matches 134217728..268435455 run return run scoreboard players set $bitwise.bit_length bs.out 28 | ||
execute if score #bitwise.bit_length bs.data matches 268435456..536870911 run return run scoreboard players set $bitwise.bit_length bs.out 29 | ||
execute if score #bitwise.bit_length bs.data matches 536870912..1073741823 run return run scoreboard players set $bitwise.bit_length bs.out 30 | ||
execute if score #bitwise.bit_length bs.data matches 1073741824.. run return run scoreboard players set $bitwise.bit_length bs.out 31 |
8 changes: 0 additions & 8 deletions
8
datapacks/Bookshelf/data/bs.bitwise/functions/msb/group_1.mcfunction
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
datapacks/Bookshelf/data/bs.bitwise/functions/msb/group_2.mcfunction
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
datapacks/Bookshelf/data/bs.bitwise/functions/msb/group_3.mcfunction
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
datapacks/Bookshelf/data/bs.bitwise/functions/msb/group_4.mcfunction
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
datapacks/Bookshelf/data/bs.bitwise/functions/msb/msb.mcfunction
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
# And operator returns correct values | ||
# @batch bs.bitwise | ||
|
||
scoreboard players set $bitwise.and.a bs.in -9 | ||
scoreboard players set $bitwise.and.b bs.in 57 | ||
function #bs.bitwise:and | ||
assert score $bitwise.and bs.out matches 49 | ||
|
||
scoreboard players set $bitwise.and.a bs.in 1234567890 | ||
scoreboard players set $bitwise.and.b bs.in 123456 | ||
function #bs.bitwise:and | ||
assert score $bitwise.and bs.out matches 576 |
10 changes: 10 additions & 0 deletions
10
datapacks/Bookshelf/data/bs.bitwise/tests/bit_count.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,10 @@ | ||
# Bit count returns correct values | ||
# @batch bs.bitwise | ||
|
||
scoreboard players set $bitwise.bit_count.n bs.in -1568 | ||
function #bs.bitwise:bit_count | ||
assert score $bitwise.bit_count bs.out matches 3 | ||
|
||
scoreboard players set $bitwise.bit_count.n bs.in 174653179 | ||
function #bs.bitwise:bit_count | ||
assert score $bitwise.bit_count bs.out matches 19 |
10 changes: 10 additions & 0 deletions
10
datapacks/Bookshelf/data/bs.bitwise/tests/bit_length.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,10 @@ | ||
# Bit length returns correct values | ||
# @batch bs.bitwise | ||
|
||
scoreboard players set $bitwise.bit_length.n bs.in -1568 | ||
function #bs.bitwise:bit_length | ||
assert score $bitwise.bit_length bs.out matches 11 | ||
|
||
scoreboard players set $bitwise.bit_length.n bs.in 174653179 | ||
function #bs.bitwise:bit_length | ||
assert score $bitwise.bit_length bs.out matches 28 |
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,10 @@ | ||
# Not operator returns correct values | ||
# @batch bs.bitwise | ||
|
||
scoreboard players set $bitwise.not.n bs.in 123456 | ||
function #bs.bitwise:not | ||
assert score $bitwise.not bs.out matches -123457 | ||
|
||
scoreboard players set $bitwise.not.n bs.in -197364158 | ||
function #bs.bitwise:not | ||
assert score $bitwise.not bs.out matches 197364157 |
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,12 @@ | ||
# Or operator returns correct values | ||
# @batch bs.bitwise | ||
|
||
scoreboard players set $bitwise.or.a bs.in -9 | ||
scoreboard players set $bitwise.or.b bs.in 57 | ||
function #bs.bitwise:or | ||
assert score $bitwise.or bs.out matches -1 | ||
|
||
scoreboard players set $bitwise.or.a bs.in 1234567890 | ||
scoreboard players set $bitwise.or.b bs.in 123456 | ||
function #bs.bitwise:or | ||
assert score $bitwise.or bs.out matches 1234690770 |
10 changes: 10 additions & 0 deletions
10
datapacks/Bookshelf/data/bs.bitwise/tests/two_complement.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,10 @@ | ||
# Two complement returns correct values | ||
# @batch bs.bitwise | ||
|
||
scoreboard players set $bitwise.two_complement.n bs.in 123456 | ||
function #bs.bitwise:two_complement | ||
assert score $bitwise.two_complement bs.out matches 123456 | ||
|
||
scoreboard players set $bitwise.two_complement.n bs.in -197364158 | ||
function #bs.bitwise:two_complement | ||
assert score $bitwise.two_complement bs.out matches 1950119490 |
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,12 @@ | ||
# Xor operator returns correct values | ||
# @batch bs.bitwise | ||
|
||
scoreboard players set $bitwise.xor.a bs.in -9 | ||
scoreboard players set $bitwise.xor.b bs.in 57 | ||
function #bs.bitwise:xor | ||
assert score $bitwise.xor bs.out matches -50 | ||
|
||
scoreboard players set $bitwise.xor.a bs.in 1234567890 | ||
scoreboard players set $bitwise.xor.b bs.in 123456 | ||
function #bs.bitwise:xor | ||
assert score $bitwise.xor bs.out matches 1234690194 |
Oops, something went wrong.