mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -04:00
command tests: properly validate stack
This commit is contained in:
parent
60906788cd
commit
517cf93681
@ -50,13 +50,13 @@ class MsgCommandIT {
|
||||
}
|
||||
|
||||
fun validateStack() {
|
||||
val node = createNode {
|
||||
assertEquals(it["msg"], "msg")
|
||||
assertEquals(it["targets"], NameEntityTarget("Bixilon"))
|
||||
assertEquals(it["message"], "hi there!")
|
||||
}
|
||||
var stack: CommandStack? = null
|
||||
val node = createNode { stack = it.copy() }
|
||||
|
||||
node.execute("msg Bixilon hi there!")
|
||||
assertEquals(stack!!["msg"], "msg")
|
||||
assertEquals(stack!!["targets"], NameEntityTarget("Bixilon"))
|
||||
assertEquals(stack!!["message"], "hi there!")
|
||||
}
|
||||
|
||||
fun redirectExecution() {
|
||||
@ -69,12 +69,14 @@ class MsgCommandIT {
|
||||
}
|
||||
|
||||
fun redirectStack() {
|
||||
val node = createNode {
|
||||
assertEquals(it["msg"], "redirect")
|
||||
assertEquals(it["targets"], NameEntityTarget("Bixilon"))
|
||||
assertEquals(it["message"], "hi there!")
|
||||
}
|
||||
var stack: CommandStack? = null
|
||||
val node = createNode { stack = it.copy() }
|
||||
|
||||
node.execute("redirect Bixilon hi there!")
|
||||
|
||||
|
||||
assertEquals(stack!!["msg"], "redirect")
|
||||
assertEquals(stack!!["targets"], NameEntityTarget("Bixilon"))
|
||||
assertEquals(stack!!["message"], "hi there!")
|
||||
}
|
||||
}
|
||||
|
@ -50,12 +50,13 @@ class TPCommandIT {
|
||||
}
|
||||
|
||||
fun relativeStack() {
|
||||
val node = createNode {
|
||||
assertEquals(it["tp"], "tp")
|
||||
assertEquals(it["target"], SelectorEntityTarget(TargetSelectors.SELF, emptyMap()))
|
||||
assertEquals(it["destination"], Vec3Coordinate(Coordinate(CoordinateRelatives.TILDE, 0.0f), Coordinate(CoordinateRelatives.TILDE, +10.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f)))
|
||||
}
|
||||
var stack: CommandStack? = null
|
||||
val node = createNode { stack = it.copy() }
|
||||
|
||||
node.execute("tp @s ~ ~10 ~")
|
||||
|
||||
assertEquals(stack!!["tp"], "tp")
|
||||
assertEquals(stack!!["target"], SelectorEntityTarget(TargetSelectors.SELF, emptyMap()))
|
||||
assertEquals(stack!!["destination"], Vec3Coordinate(Coordinate(CoordinateRelatives.TILDE, 0.0f), Coordinate(CoordinateRelatives.TILDE, +10.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f)))
|
||||
}
|
||||
}
|
||||
|
@ -68,4 +68,16 @@ class CommandStack(
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
|
||||
fun copy(): CommandStack {
|
||||
val stack = CommandStack(null, print)
|
||||
stack.stack += this.stack
|
||||
stack.executor = this.executor
|
||||
if (this::connection.isInitialized) {
|
||||
stack.connection = this.connection
|
||||
}
|
||||
|
||||
return stack
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user