Minestom/jcstress-tests/src/jcstress/java/net/minestom/server/tag/TagPathTest.java

43 lines
1.1 KiB
Java

package net.minestom.server.tag;
import org.jglrxavpok.hephaistos.nbt.NBT;
import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.L_Result;
import java.util.Map;
import static org.openjdk.jcstress.annotations.Expect.ACCEPTABLE;
@JCStressTest
@Outcome(id = "tag", expect = ACCEPTABLE)
@Outcome(id = "tag_path", expect = ACCEPTABLE)
@State
public class TagPathTest {
private static final Tag<Integer> TAG = Tag.Integer("path");
private static final Tag<Integer> TAG_PATH = Tag.Integer("key").path("path");
private final TagHandler handler = TagHandler.newHandler();
@Actor
public void actor1() {
handler.setTag(TAG, 1);
}
@Actor
public void actor2() {
handler.setTag(TAG_PATH, 5);
}
@Arbiter
public void arbiter(L_Result r) {
var compound = handler.asCompound();
if (compound.equals(NBT.Compound(Map.of("path", NBT.Int(1))))) {
r.r1 = "tag";
} else if (compound.equals(NBT.Compound(Map.of("path", NBT.Compound(Map.of("key", NBT.Int(5))))))) {
r.r1 = "tag_path";
} else {
r.r1 = compound;
}
}
}