Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58935a2
commit e3f7713
Showing
27 changed files
with
373 additions
and
413 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
name: test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
strategy: | ||
matrix: | ||
ENGINE_VERSION: [5.3.0, 5.4.0, 5.5.0, 5.6.0, latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: test | ||
run: docker-compose up --exit-code-from sut |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: "3.6" | ||
|
||
services: | ||
sut: | ||
build: | ||
context: ./test | ||
args: | ||
ENGINE_VERSION: ${ENGINE_VERSION:-5.6.0} | ||
user: root | ||
volumes: | ||
- "./:/root/.minetest/worlds/world/worldmods/blockexchange/" | ||
- "world_data:/root/.minetest/worlds/world" | ||
- "./test/world.mt:/root/.minetest/worlds/world/world.mt" | ||
- "./test/minetest.conf:/minetest.conf" | ||
ports: | ||
- "30000:30000/udp" | ||
|
||
volumes: | ||
world_data: {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
name = blockexchange | ||
optional_depends = worldedit,areas,monitoring,vacuum | ||
optional_depends = worldedit,areas,monitoring,vacuum,mtt | ||
min_protocol = 37 |
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,18 @@ | ||
|
||
|
||
mtt.register("clip_area test", function(callback) | ||
local clip_pos1 = { x=10, y=10, z=10 } | ||
local clip_pos2 = { x=20, y=30, z=40 } | ||
local pos1 = { x=9, y=11, z=20 } | ||
local pos2 = { x=21, y=30, z=40 } | ||
|
||
local clipped_pos1, clipped_pos2 = blockexchange.clip_area(clip_pos1, clip_pos2, pos1, pos2) | ||
assert(10 == clipped_pos1.x) | ||
assert(11 == clipped_pos1.y) | ||
assert(20 == clipped_pos1.z) | ||
assert(20 == clipped_pos2.x) | ||
assert(30 == clipped_pos2.y) | ||
assert(40 == clipped_pos2.z) | ||
|
||
callback() | ||
end) |
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,30 @@ | ||
mtt.register("blockexchange.get_base_pos, returns proper positive coordinates", function(callback) | ||
local pos = blockexchange.get_base_pos({x=0, y=0, z=0}, {x=5, y=1, z=0}) | ||
assert(pos) | ||
assert(0 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
pos = blockexchange.get_base_pos({x=0, y=0, z=0}, {x=5, y=16, z=0}) | ||
assert(pos) | ||
assert(0 == pos.x) | ||
assert(16 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
callback() | ||
end) | ||
|
||
mtt.register("blockexchange.get_base_pos, returns proper negative coordinates", function(callback) | ||
local pos = blockexchange.get_base_pos({x=0, y=0, z=0}, {x=-5, y=0, z=0}) | ||
assert(pos) | ||
assert(-16 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
pos = blockexchange.get_base_pos({x=0, y=0, z=0}, {x=-5, y=-17, z=0}) | ||
assert(pos) | ||
assert(-16 == pos.x) | ||
assert(-32 == pos.y) | ||
assert(0 == pos.z) | ||
callback() | ||
end) |
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,137 @@ | ||
mtt.register("blockexchange.iterator, returns proper positive coordinates", function(callback) | ||
local origin = { x=0, y=0, z=0 } | ||
local pos1 = { x=0, y=0, z=0 } | ||
local pos2 = { x=17, y=0, z=0 } | ||
|
||
local it = blockexchange.iterator(origin, pos1, pos2) | ||
local abs_pos, pos, progress = it() | ||
assert(pos) | ||
assert(0 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
assert(0.5 == progress) | ||
|
||
assert(abs_pos) | ||
assert(0 == abs_pos.x) | ||
assert(0 == abs_pos.y) | ||
assert(0 == abs_pos.z) | ||
|
||
abs_pos, pos, progress = it() | ||
assert(pos) | ||
assert(16 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
assert(1 == progress) | ||
|
||
assert(pos) | ||
assert(16 == abs_pos.x) | ||
assert(0 == abs_pos.y) | ||
assert(0 == abs_pos.z) | ||
|
||
abs_pos, pos = it() | ||
assert(not pos) | ||
assert(not abs_pos) | ||
callback() | ||
end) | ||
|
||
mtt.register("blockexchange.iterator, returns proper positive coordinates with modified origin", function(callback) | ||
local origin = { x=10, y=0, z=0 } | ||
local pos1 = { x=11, y=0, z=0 } | ||
local pos2 = { x=27, y=0, z=0 } | ||
|
||
local it = blockexchange.iterator(origin, pos1, pos2) | ||
local abs_pos, pos = it() | ||
assert(pos) | ||
assert(0 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
assert(abs_pos) | ||
assert(10 == abs_pos.x) | ||
assert(0 == abs_pos.y) | ||
assert(0 == abs_pos.z) | ||
|
||
abs_pos, pos = it() | ||
assert(pos) | ||
assert(16 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
assert(abs_pos) | ||
assert(26 == abs_pos.x) | ||
assert(0 == abs_pos.y) | ||
assert(0 == abs_pos.z) | ||
|
||
abs_pos, pos = it() | ||
assert(not pos) | ||
assert(not abs_pos) | ||
callback() | ||
end) | ||
|
||
mtt.register("blockexchange.iterator, returns proper negative coordinates", function(callback) | ||
local origin = { x=0, y=0, z=0 } | ||
local pos1 = { x=-5, y=0, z=0 } | ||
local pos2 = { x=5, y=0, z=0 } | ||
|
||
local it = blockexchange.iterator(origin, pos1, pos2) | ||
local abs_pos, pos = it() | ||
assert(pos) | ||
assert(-16 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
assert(abs_pos) | ||
assert(-16 == abs_pos.x) | ||
assert(0 == abs_pos.y) | ||
assert(0 == abs_pos.z) | ||
|
||
abs_pos, pos = it() | ||
assert(pos) | ||
assert(0 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
assert(abs_pos) | ||
assert(0 == abs_pos.x) | ||
assert(0 == abs_pos.y) | ||
assert(0 == abs_pos.z) | ||
|
||
abs_pos, pos = it() | ||
assert(not pos) | ||
assert(not abs_pos) | ||
callback() | ||
end) | ||
|
||
mtt.register("blockexchange.iterator, returns proper negative coordinates with modified origin", function(callback) | ||
local origin = { x=-1, y=0, z=0 } | ||
local pos1 = { x=-5, y=0, z=0 } | ||
local pos2 = { x=5, y=0, z=0 } | ||
|
||
local it = blockexchange.iterator(origin, pos1, pos2) | ||
local abs_pos, pos = it() | ||
assert(pos) | ||
assert(-16 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
assert(abs_pos) | ||
assert(-17 == abs_pos.x) | ||
assert(0 == abs_pos.y) | ||
assert(0 == abs_pos.z) | ||
|
||
abs_pos, pos = it() | ||
assert(pos) | ||
assert(0 == pos.x) | ||
assert(0 == pos.y) | ||
assert(0 == pos.z) | ||
|
||
assert(abs_pos) | ||
assert(-1 == abs_pos.x) | ||
assert(0 == abs_pos.y) | ||
assert(0 == abs_pos.z) | ||
|
||
abs_pos, pos = it() | ||
assert(not pos) | ||
assert(not abs_pos) | ||
callback() | ||
end) |
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,29 @@ | ||
|
||
mtt.register("promise test, smoke test", function(callback) | ||
assert(Promise) | ||
|
||
local p = Promise.new(function(resolve) | ||
resolve(1) | ||
end) | ||
|
||
p:next(function(v) | ||
return Promise.new(function(resolve) | ||
resolve(v + 1) | ||
end) | ||
end):next(function(v) | ||
assert(v == 2) | ||
callback() | ||
end) | ||
end) | ||
|
||
|
||
mtt.register("promise test, bool value test", function(callback) | ||
local p = Promise.new(function(resolve) | ||
resolve(false) | ||
end) | ||
|
||
p:next(function(v) | ||
assert(not v) | ||
callback() | ||
end) | ||
end) |
Oops, something went wrong.