Skip to content

Literal Number Max+Min Values #8008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev/feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/LitDoubleMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.njol.skript.test.runner;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@NoDoc
public class LitDoubleMaxValue extends SimpleLiteral<Double> {

static {
if (TestMode.ENABLED) {
Skript.registerExpression(LitDoubleMaxValue.class, Double.class, ExpressionType.SIMPLE, "double max[imum] value");
}
}

public LitDoubleMaxValue() {
super(Double.MAX_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "double max value";
}

}
36 changes: 36 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/LitDoubleMinValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.njol.skript.test.runner;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@NoDoc
public class LitDoubleMinValue extends SimpleLiteral<Double> {

static {
if (TestMode.ENABLED) {
Skript.registerExpression(LitDoubleMinValue.class, Double.class, ExpressionType.SIMPLE, "double min[imum] value");
}
}

public LitDoubleMinValue() {
super(Double.MIN_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "double min value";
}

}
36 changes: 36 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/LitFloatMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.njol.skript.test.runner;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@NoDoc
public class LitFloatMaxValue extends SimpleLiteral<Float> {

static {
if (TestMode.ENABLED) {
Skript.registerExpression(LitFloatMaxValue.class, Float.class, ExpressionType.SIMPLE, "float max[imum] value");
}
}

public LitFloatMaxValue() {
super(Float.MAX_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "float max value";
}

}
36 changes: 36 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/LitFloatMinValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.njol.skript.test.runner;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@NoDoc
public class LitFloatMinValue extends SimpleLiteral<Float> {

static {
if (TestMode.ENABLED) {
Skript.registerExpression(LitFloatMinValue.class, Float.class, ExpressionType.SIMPLE, "float min[imum] value");
}
}

public LitFloatMinValue() {
super(Float.MIN_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "float min value";
}

}
36 changes: 36 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/LitIntMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.njol.skript.test.runner;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@NoDoc
public class LitIntMaxValue extends SimpleLiteral<Integer> {

static {
if (TestMode.ENABLED) {
Skript.registerExpression(LitIntMaxValue.class, Integer.class, ExpressionType.SIMPLE, "integer max[imum] value");
}
}

public LitIntMaxValue() {
super(Integer.MAX_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "integer max value";
}

}
36 changes: 36 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/LitIntMinValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.njol.skript.test.runner;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@NoDoc
public class LitIntMinValue extends SimpleLiteral<Integer> {

static {
if (TestMode.ENABLED) {
Skript.registerExpression(LitIntMinValue.class, Integer.class, ExpressionType.SIMPLE, "integer min[imum] value");
}
}

public LitIntMinValue() {
super(Integer.MIN_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "integer min value";
}

}
36 changes: 36 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/LitLongMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.njol.skript.test.runner;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@NoDoc
public class LitLongMaxValue extends SimpleLiteral<Long> {

static {
if (TestMode.ENABLED) {
Skript.registerExpression(LitLongMaxValue.class, Long.class, ExpressionType.SIMPLE, "long max[imum] value");
}
}

public LitLongMaxValue() {
super(Long.MAX_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "long max value";
}

}
36 changes: 36 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/LitLongMinValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.njol.skript.test.runner;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@NoDoc
public class LitLongMinValue extends SimpleLiteral<Long> {

static {
if (TestMode.ENABLED) {
Skript.registerExpression(LitLongMinValue.class, Long.class, ExpressionType.SIMPLE, "long min[imum] value");
}
}

public LitLongMinValue() {
super(Long.MIN_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "long min value";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ test "domestication":
subtract infinity value from max domestication level of {_e}
assert max domestication level of {_e} is 1 with "infinity value should result in 1 when subtracted from the max domestication level of a horse"
set max domestication level of {_e} to infinity value # set is done last so the domestication level tests can also go to infinity
assert max domestication level of {_e} is 2147483647 with "infinity value should set the max domestication level of a horse to the max integer value"
assert max domestication level of {_e} is integer max value with "infinity value should set the max domestication level of a horse to the max integer value"

add infinity value to domestication level of {_e}
assert domestication level of {_e} is 1 with "infinity value shouldn't affect the domestication level of a horse when added"
subtract infinity value from domestication level of {_e}
assert domestication level of {_e} is 1 with "infinity value should result in 1 when subtracted from the domestication level of a horse"
set domestication level of {_e} to infinity value
assert domestication level of {_e} is 2147483647 with "infinity value should set the domestication level of a horse to the max integer value"
assert domestication level of {_e} is integer max value with "infinity value should set the domestication level of a horse to the max integer value"

# NaN values
add NaN value to max domestication level of {_e}
assert max domestication level of {_e} is 2147483647 with "NaN value should result in 2147483647 when added to the max domestication level of a horse"
assert max domestication level of {_e} is integer max value with "NaN value should result in integer max value when added to the max domestication level of a horse"
set max domestication level of {_e} to NaN value
assert max domestication level of {_e} is 1 with "NaN value should result in 1 when used to set the max domestication level of a horse"
subtract NaN value from max domestication level of {_e}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test "loot table seed":
set loot seed of {_pig} to NaN value
assert the loot seed of {_pig} is 0 with "NaN value entity loot seed set failed"
set loot seed of {_pig} to infinity value
assert the loot seed of {_pig} is 9223372036854775807 with "infinity value entity loot seed set failed"
assert the loot seed of {_pig} is long max value with "infinity value entity loot seed set failed"

delete entity within {_pig}

Expand All @@ -43,6 +43,6 @@ test "loot table seed":
set loot seed of test-block to NaN value
assert the loot seed of test-block is 0 with "NaN value block loot seed set failed"
set loot seed of test-block to infinity value
assert the loot seed of test-block is 9223372036854775807 with "infinity value block loot seed set failed"
assert the loot seed of test-block is long max value with "infinity value block loot seed set failed"

set test-block to {_pastBlock}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ test "remaining air":
assert remaining air of {_e} is 0 seconds with "removing did not limit to 0 seconds"

add 10 years to remaining air of {_e}
assert ticks of remaining air of {_e} is 2147483647 with "adding did not limit to max int value"
assert ticks of remaining air of {_e} is integer max value with "adding did not limit to max int value"

delete the entity within {_e}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ test "line width":
assert line width of {_td} is 200 with "failed to reset line width"

set line width of {_td} to infinity value
assert line width of {_td} is 2147483647 with "failed to set line width"
assert line width of {_td} is integer max value with "failed to set line width"

delete entity within {_td}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test "worldborder warning distance":
set {_max} to 2147483647
set {_max} to integer max value
set {_border} to worldborder of world("world")
reset worldborder of world("world")
assert worldborder warning distance of {_border} is 5 with "Default worldborder warning distance is not 5"
Expand Down