From 48d0bbe8fca5d6535125ff013dcefdabc4f417c4 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Mon, 30 Dec 2024 07:57:10 +0000 Subject: [PATCH] Use tabs consistently with all other files. (#7330) * Use tabs consistently with all other files. * Two spaces? In the four space factory? * Finally, some good whitespace. --- .../ch/njol/skript/doc/DocumentationId.java | 5 +- .../ch/njol/skript/doc/RequiredPlugins.java | 7 +- .../ch/njol/skript/update/GithubChecker.java | 100 ++-- src/main/java/ch/njol/util/Math2.java | 66 +-- .../java/ch/njol/util/NotifyingReference.java | 78 ++- .../ch/njol/util/SynchronizedReference.java | 53 +- .../bukkit/loottables/LootContextWrapper.java | 2 +- src/test/skript/junit/-BellEventsPaper.sk | 4 +- src/test/skript/junit/-BellEventsSpigot.sk | 10 +- src/test/skript/junit/BellEvents.sk | 40 +- .../4988-function uuid multiple parameters.sk | 2 +- .../6288-event data priority pollution.sk | 4 +- .../6290-item-inventory-conflict.sk | 10 +- .../7279-create-uncreatable-inventory.sk | 2 +- .../regressions/pull-6361-function-param.sk | 14 +- .../tests/syntaxes/conditions/CondIsOfType.sk | 36 +- .../skript/tests/syntaxes/effects/EffDoIf.sk | 8 +- .../skript/tests/syntaxes/effects/EffPvP.sk | 10 +- .../syntaxes/expressions/ExprArithmetic.sk | 462 +++++++++--------- .../syntaxes/expressions/ExprInventory.sk | 18 +- .../tests/syntaxes/sections/EffSecSpawn.sk | 2 +- .../tests/syntaxes/sections/SecParse.sk | 14 +- .../tests/syntaxes/structures/StructParse.sk | 16 +- 23 files changed, 478 insertions(+), 485 deletions(-) diff --git a/src/main/java/ch/njol/skript/doc/DocumentationId.java b/src/main/java/ch/njol/skript/doc/DocumentationId.java index b425e60ee20..2929a1fe757 100644 --- a/src/main/java/ch/njol/skript/doc/DocumentationId.java +++ b/src/main/java/ch/njol/skript/doc/DocumentationId.java @@ -14,6 +14,7 @@ @Retention(RetentionPolicy.RUNTIME) @Documented public @interface DocumentationId { - - public String value(); + + public String value(); + } diff --git a/src/main/java/ch/njol/skript/doc/RequiredPlugins.java b/src/main/java/ch/njol/skript/doc/RequiredPlugins.java index 074a4e6bfd2..ce36a2639c1 100644 --- a/src/main/java/ch/njol/skript/doc/RequiredPlugins.java +++ b/src/main/java/ch/njol/skript/doc/RequiredPlugins.java @@ -10,12 +10,13 @@ * Provides a list of plugins other than Skript that the annotated * element requires to be used. Non-Spigot server software can be considered * to be plugins. - * + * */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface RequiredPlugins { - - String[] value(); + + String[] value(); + } diff --git a/src/main/java/ch/njol/skript/update/GithubChecker.java b/src/main/java/ch/njol/skript/update/GithubChecker.java index de844d455e1..49bbc96fbb1 100644 --- a/src/main/java/ch/njol/skript/update/GithubChecker.java +++ b/src/main/java/ch/njol/skript/update/GithubChecker.java @@ -15,63 +15,67 @@ * Uses Github API to check for updates. */ public class GithubChecker implements UpdateChecker { - + /** * Github API response for GSON deserialization. */ public static class ResponseEntry { + public String url; - public String assets_url; - public String upload_url; - public String html_url; - public int id; - public String tag_name; - public String target_commitish; - public String name; - public boolean draft; - - public boolean prerelease; - public String created_at; - public String published_at; - - public static class AssetsEntry { - public int size; - public int download_count; - public String browser_download_url; - } - - public List assets; - public String body; // Description of release - - @Override - public String toString() { - return tag_name; - } - - public static class Author { - public String login; - public int id; - } - - public Author author; + public String assets_url; + public String upload_url; + public String html_url; + public int id; + public String tag_name; + public String target_commitish; + public String name; + public boolean draft; + + public boolean prerelease; + public String created_at; + public String published_at; + + public static class AssetsEntry { + + public int size; + public int download_count; + public String browser_download_url; + + } + + public List assets; + public String body; // Description of release + + @Override + public String toString() { + return tag_name; + } + + public static class Author { + + public String login; + public int id; + + } + + public Author author; } - + /** * Used for deserializing Github API output. */ private final Gson gson; - + public GithubChecker() { this.gson = new Gson(); } - + private List deserialize(String str) { assert str != null : "Cannot deserialize null string"; - @SuppressWarnings("serial") Type listType = new TypeToken>() {}.getType(); List responses = gson.fromJson(str, listType); assert responses != null; - + return responses; } @@ -97,7 +101,7 @@ public CompletableFuture check(ReleaseManifest manifest, Release * Latest release in the channel we're using. */ ResponseEntry latest = null; - + /** * Current release, if found. */ @@ -107,32 +111,32 @@ public CompletableFuture check(ReleaseManifest manifest, Release for (ResponseEntry release : releases) { String name = release.tag_name; assert name != null; - + // Check if this is a suitable latest release if (latest == null && channel.check(name)) { latest = release; } - + // Check whether this is a current release if (manifest.id.equals(name)) { current = release; break; // Update can't be older than current release } } - + if (latest == null) { return null; // No updates for this channel available } - + if (current != null && latest.id == current.id) { return null; // Already running latest in this channel } - + // Validate the latest release if (latest.assets.isEmpty()) { return null; // Update not (yet?) downloadable } - + try { String name = latest.tag_name; assert name != null; @@ -146,7 +150,7 @@ public CompletableFuture check(ReleaseManifest manifest, Release } else { download = new URL(latest.assets.get(0).browser_download_url); } - + return new UpdateManifest(name, createdAt, patchNotes, download); } catch (MalformedURLException e) { throw new RuntimeException(e); @@ -155,5 +159,5 @@ public CompletableFuture check(ReleaseManifest manifest, Release assert future != null; return future; } - + } diff --git a/src/main/java/ch/njol/util/Math2.java b/src/main/java/ch/njol/util/Math2.java index 04e222f7698..40073193d86 100644 --- a/src/main/java/ch/njol/util/Math2.java +++ b/src/main/java/ch/njol/util/Math2.java @@ -14,9 +14,9 @@ */ @ApiStatus.Internal public final class Math2 { - + private Math2() {} - + /** * Fits an int into the given interval. The method's behaviour when min > max is unspecified. * @@ -26,7 +26,7 @@ public static int fit(int min, int value, int max) { assert min <= max : min + "," + value + "," + max; return Math.min(Math.max(value, min), max); } - + /** * Fits a long into the given interval. The method's behaviour when min > max is unspecified. * @@ -46,17 +46,17 @@ public static float fit(float min, float value, float max) { assert min <= max : min + "," + value + "," + max; return Math.min(Math.max(value, min), max); } - + /** * Fits a double into the given interval. The method's behaviour when min > max is unspecified. - * + * * @return A double in between min and max */ public static double fit(double min, double value, double max) { assert min <= max : min + "," + value + "," + max; return Math.min(Math.max(value, min), max); } - + /** * Modulo that returns positive values even for negative arguments. * @@ -65,7 +65,7 @@ public static double fit(double min, double value, double max) { public static int mod(int value, int mod) { return (value % mod + mod) % mod; } - + /** * Modulo that returns positive values even for negative arguments. * @@ -74,7 +74,7 @@ public static int mod(int value, int mod) { public static long mod(long value, long mod) { return (value % mod + mod) % mod; } - + /** * Modulo that returns positive values even for negative arguments. * @@ -83,7 +83,7 @@ public static long mod(long value, long mod) { public static float mod(float value, float mod) { return (value % mod + mod) % mod; } - + /** * Modulo that returns positive values even for negative arguments. * @@ -92,42 +92,42 @@ public static float mod(float value, float mod) { public static double mod(double value, double mod) { return (value % mod + mod) % mod; } - + /** * Ceils the given float and returns the result as an int. */ public static int ceil(float value) { return (int) Math.ceil(value - Skript.EPSILON); } - + /** * Rounds the given float (where .5 is rounded up) and returns the result as an int. */ public static int round(float value) { return (int) Math.round(value + Skript.EPSILON); } - + /** * Floors the given double and returns the result as a long. */ public static long floor(double value) { return (long) Math.floor(value + Skript.EPSILON); } - + /** * Ceils the given double and returns the result as a long. */ public static long ceil(double value) { return (long) Math.ceil(value - Skript.EPSILON); } - + /** * Rounds the given double (where .5 is rounded up) and returns the result as a long. */ public static long round(double value) { return Math.round(value + Skript.EPSILON); } - + /** * Guarantees a float is neither NaN nor infinite. * Useful for situations when safe floats are required. @@ -151,100 +151,100 @@ public static long addClamped(long x, long y) { return Long.MAX_VALUE; return result; } - + public static long multiplyClamped(long x, long y) { long result = x * y; long ax = Math.abs(x); long ay = Math.abs(y); // Logic extracted from Math#multiplyExact to avoid having to catch an expensive exception - if (((ax | ay) >>> 31 != 0) && (((y != 0) && (result / y != x)) || (x == Long.MIN_VALUE && y == -1))) + if (((ax | ay) >>> 31 != 0) && (((y != 0) && (result / y != x)) || (x == Long.MIN_VALUE && y == -1))) // If either x or y is negative return the min value, otherwise return the max value - return x < 0 == y < 0 ? Long.MAX_VALUE : Long.MIN_VALUE; + return x < 0 == y < 0 ? Long.MAX_VALUE : Long.MIN_VALUE; return result; } - + @Deprecated @ScheduledForRemoval public static int floorI(double value) { return (int) Math.floor(value + Skript.EPSILON); } - + @Deprecated @ScheduledForRemoval public static int ceilI(double value) { return (int) Math.ceil(value - Skript.EPSILON); } - + // Change signature to return int instead of removing. @Deprecated @ScheduledForRemoval public static long floor(float value) { return (long) Math.floor(value + Skript.EPSILON); } - + @Deprecated @ScheduledForRemoval public static int min(int a, int b, int c) { return Math.min(a, Math.min(b, c)); } - + @Deprecated @ScheduledForRemoval public static int min(int... numbers) { if (numbers.length == 0) return 0; - + return Arrays.stream(numbers) .min() .getAsInt(); } - + @Deprecated @ScheduledForRemoval public static int max(int a, int b, int c) { return Math.max(a, Math.max(b, c)); } - + @Deprecated @ScheduledForRemoval public static int max(int... numbers) { if (numbers.length == 0) return 0; - + return Arrays.stream(numbers) .max() .getAsInt(); } - + @Deprecated @ScheduledForRemoval public static double min(double a, double b, double c) { return Math.min(a, Math.min(b, c)); } - + @Deprecated @ScheduledForRemoval public static double min(double... numbers) { if (numbers.length == 0) return Double.NaN; - + return Arrays.stream(numbers) .min() .getAsDouble(); } - + @Deprecated @ScheduledForRemoval public static double max(double a, double b, double c) { return Math.max(a, Math.max(b, c)); } - + @Deprecated @ScheduledForRemoval public static double max(double... numbers) { if (numbers.length == 0) return Double.NaN; - + return Arrays.stream(numbers) .max() .getAsDouble(); diff --git a/src/main/java/ch/njol/util/NotifyingReference.java b/src/main/java/ch/njol/util/NotifyingReference.java index 127a72d39c2..bca7b91b509 100644 --- a/src/main/java/ch/njol/util/NotifyingReference.java +++ b/src/main/java/ch/njol/util/NotifyingReference.java @@ -2,47 +2,39 @@ import org.jetbrains.annotations.Nullable; -/** - * @author Peter G�ttinger - * - */ -public class NotifyingReference -{ - @Nullable - private volatile V value; - private final boolean notifyAll; - - public NotifyingReference(@Nullable V value, boolean notifyAll) - { - this.value = value; - this.notifyAll = notifyAll; - } - - public NotifyingReference(@Nullable V value) - { - this.value = value; - this.notifyAll = true; - } - - public NotifyingReference() - { - this.value = null; - this.notifyAll = true; - } - - @Nullable - public synchronized V get() - { - return this.value; - } - - public synchronized void set(@Nullable V newValue) - { - this.value = newValue; - if (this.notifyAll) { - notifyAll(); - } else { - notify(); - } - } +public class NotifyingReference { + + @Nullable + private volatile V value; + private final boolean notifyAll; + + public NotifyingReference(@Nullable V value, boolean notifyAll) { + this.value = value; + this.notifyAll = notifyAll; + } + + public NotifyingReference(@Nullable V value) { + this.value = value; + this.notifyAll = true; + } + + public NotifyingReference() { + this.value = null; + this.notifyAll = true; + } + + @Nullable + public synchronized V get() { + return this.value; + } + + public synchronized void set(@Nullable V newValue) { + this.value = newValue; + if (this.notifyAll) { + notifyAll(); + } else { + notify(); + } + } + } diff --git a/src/main/java/ch/njol/util/SynchronizedReference.java b/src/main/java/ch/njol/util/SynchronizedReference.java index 6786a0dac45..b21484e86c1 100644 --- a/src/main/java/ch/njol/util/SynchronizedReference.java +++ b/src/main/java/ch/njol/util/SynchronizedReference.java @@ -2,32 +2,27 @@ import org.jetbrains.annotations.Nullable; -/** - * @author Peter G�ttinger - * - */ -public class SynchronizedReference -{ - @Nullable - private volatile V value; - - public SynchronizedReference(@Nullable V initialValue) - { - this.value = initialValue; - } - - public SynchronizedReference() {} - - @Nullable - public final V get() - { - assert (Thread.holdsLock(this)); - return this.value; - } - - public final void set(@Nullable V newValue) - { - assert (Thread.holdsLock(this)); - this.value = newValue; - } -} \ No newline at end of file +public class SynchronizedReference { + + @Nullable + private volatile V value; + + public SynchronizedReference(@Nullable V initialValue) { + this.value = initialValue; + } + + public SynchronizedReference() { + } + + @Nullable + public final V get() { + assert (Thread.holdsLock(this)); + return this.value; + } + + public final void set(@Nullable V newValue) { + assert (Thread.holdsLock(this)); + this.value = newValue; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java index e2afc7ed2c3..35aa234d49d 100644 --- a/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java @@ -23,7 +23,7 @@ public class LootContextWrapper { * @param location the location of the LootContext. */ public LootContextWrapper(@NotNull Location location) { - this.location = location; + this.location = location; } /** diff --git a/src/test/skript/junit/-BellEventsPaper.sk b/src/test/skript/junit/-BellEventsPaper.sk index 61afbd566f5..bc36739064b 100644 --- a/src/test/skript/junit/-BellEventsPaper.sk +++ b/src/test/skript/junit/-BellEventsPaper.sk @@ -1,5 +1,5 @@ # This file contains events we can run on Paper 1.16.5+ on bell ringing: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" - complete objective "bell rings" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" + junit test is "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" + complete objective "bell rings" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" diff --git a/src/test/skript/junit/-BellEventsSpigot.sk b/src/test/skript/junit/-BellEventsSpigot.sk index cf33b09aff5..65ba0e256f7 100644 --- a/src/test/skript/junit/-BellEventsSpigot.sk +++ b/src/test/skript/junit/-BellEventsSpigot.sk @@ -1,10 +1,10 @@ # This file contains tests we can run on Spigot 1.19.4+ on bell ringing: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" - complete objective "bell rings" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" + junit test is "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" + complete objective "bell rings" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" on bell resonating: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" - complete objective "bell resonates" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" - assert size of event-entities is greater than or equal to 1 with "bell did not reveal the pillager" + junit test is "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" + complete objective "bell resonates" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" + assert size of event-entities is greater than or equal to 1 with "bell did not reveal the pillager" diff --git a/src/test/skript/junit/BellEvents.sk b/src/test/skript/junit/BellEvents.sk index 2d7597ef4b2..29c9ad47738 100644 --- a/src/test/skript/junit/BellEvents.sk +++ b/src/test/skript/junit/BellEvents.sk @@ -1,25 +1,25 @@ test "BellEventsTest" when running JUnit: - set {_slashIndex} to last index of "/" in "%script%.sk" - if {_slashIndex} is -1: # try \ separator (Windows) - set {_slashIndex} to last index of "\" in "%script%.sk" - set {_parent} to substring of "%script%.sk" from 0 to {_slashIndex} + set {_slashIndex} to last index of "/" in "%script%.sk" + if {_slashIndex} is -1: # try \ separator (Windows) + set {_slashIndex} to last index of "\" in "%script%.sk" + set {_parent} to substring of "%script%.sk" from 0 to {_slashIndex} - if running below minecraft "1.19.4": - complete objective "bell resonates" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" - if running below minecraft "1.16.5": - complete objective "bell rings" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" - else: - load script "%{_parent}%-BellEventsPaper.sk" - else: - load script "%{_parent}%-BellEventsSpigot.sk" + if running below minecraft "1.19.4": + complete objective "bell resonates" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" + if running below minecraft "1.16.5": + complete objective "bell rings" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" + else: + load script "%{_parent}%-BellEventsPaper.sk" + else: + load script "%{_parent}%-BellEventsSpigot.sk" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" completes "bell resonates" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" completes "bell rings" + ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" completes "bell resonates" + ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.BellEventsTest" completes "bell rings" on script unload: - set {_slashIndex} to last index of "/" in "%script%.sk" - if {_slashIndex} is -1: # try \ separator (Windows) - set {_slashIndex} to last index of "\" in "%script%.sk" - set {_parent} to substring of "%script%.sk" from 0 to {_slashIndex} - disable script "%{_parent}%BellEventsSpigot.sk" - disable script "%{_parent}%BellEventsPaper.sk" + set {_slashIndex} to last index of "/" in "%script%.sk" + if {_slashIndex} is -1: # try \ separator (Windows) + set {_slashIndex} to last index of "\" in "%script%.sk" + set {_parent} to substring of "%script%.sk" from 0 to {_slashIndex} + disable script "%{_parent}%BellEventsSpigot.sk" + disable script "%{_parent}%BellEventsPaper.sk" diff --git a/src/test/skript/tests/regressions/4988-function uuid multiple parameters.sk b/src/test/skript/tests/regressions/4988-function uuid multiple parameters.sk index 891acea46c5..8689089c36c 100644 --- a/src/test/skript/tests/regressions/4988-function uuid multiple parameters.sk +++ b/src/test/skript/tests/regressions/4988-function uuid multiple parameters.sk @@ -2,7 +2,7 @@ # The exact function from the issue local function test(uuid: string, s: string) :: boolean: if {_uuid} is set: - if {_s} is set: + if {_s} is set: return true return false diff --git a/src/test/skript/tests/regressions/6288-event data priority pollution.sk b/src/test/skript/tests/regressions/6288-event data priority pollution.sk index 3de238ca724..2da0df2c53d 100644 --- a/src/test/skript/tests/regressions/6288-event data priority pollution.sk +++ b/src/test/skript/tests/regressions/6288-event data priority pollution.sk @@ -1,5 +1,5 @@ on join with priority lowest: - stop + stop every 10 seconds: - stop + stop diff --git a/src/test/skript/tests/regressions/6290-item-inventory-conflict.sk b/src/test/skript/tests/regressions/6290-item-inventory-conflict.sk index 38b2d328cb9..9d3a50794f1 100644 --- a/src/test/skript/tests/regressions/6290-item-inventory-conflict.sk +++ b/src/test/skript/tests/regressions/6290-item-inventory-conflict.sk @@ -1,6 +1,6 @@ test "item inventory conflict": - parse: - loop all players: - loop all items in the loop-player's inventory: - set {_item} to loop-item - assert parse logs are not set with "failed to parse loop" + parse: + loop all players: + loop all items in the loop-player's inventory: + set {_item} to loop-item + assert parse logs are not set with "failed to parse loop" diff --git a/src/test/skript/tests/regressions/7279-create-uncreatable-inventory.sk b/src/test/skript/tests/regressions/7279-create-uncreatable-inventory.sk index 623669f4ed3..b39fca8fbb1 100644 --- a/src/test/skript/tests/regressions/7279-create-uncreatable-inventory.sk +++ b/src/test/skript/tests/regressions/7279-create-uncreatable-inventory.sk @@ -4,7 +4,7 @@ test "create un-creatable inventory": assert composter inventory named "BOB" is set to fail with "This should fail, cannot create a player inventory" # Test creating inventory types which can be created - assert chest inventory named "BOB" is set with "Should be able to create a named chest inventory" + assert chest inventory named "BOB" is set with "Should be able to create a named chest inventory" assert hopper inventory named "Mr Hopper" is set with "Should be able to create a named hopper inventory" # Test opening an inventory type which cannot be created diff --git a/src/test/skript/tests/regressions/pull-6361-function-param.sk b/src/test/skript/tests/regressions/pull-6361-function-param.sk index 81ef44a8d98..f0bc5bfd4ef 100644 --- a/src/test/skript/tests/regressions/pull-6361-function-param.sk +++ b/src/test/skript/tests/regressions/pull-6361-function-param.sk @@ -20,7 +20,7 @@ function test_English(test: text) :: text: - return {_test} + return {_test} function test_Arabic(تجربة: text) :: text: return {_تجربة} @@ -38,9 +38,9 @@ function test_German(prüfen: text) :: text: return {_prüfen} test "function parameter names": - assert test_English("text") = "text" with "Function 'test_English' failed function parameter name test" - assert test_Arabic("text") = "text" with "Function 'test_Arabic' failed function parameter name test" - assert test_Japanese("text") = "text" with "Function 'test_Japanese' failed function parameter name test" - assert test_Greek("text") = "text" with "Function 'test_Greek' failed function parameter name test" - assert test_Thai("text") = "text" with "Function 'test_Thai' failed function parameter name test" - assert test_German("text") = "text" with "Function 'test_German' failed function parameter name test" \ No newline at end of file + assert test_English("text") = "text" with "Function 'test_English' failed function parameter name test" + assert test_Arabic("text") = "text" with "Function 'test_Arabic' failed function parameter name test" + assert test_Japanese("text") = "text" with "Function 'test_Japanese' failed function parameter name test" + assert test_Greek("text") = "text" with "Function 'test_Greek' failed function parameter name test" + assert test_Thai("text") = "text" with "Function 'test_Thai' failed function parameter name test" + assert test_German("text") = "text" with "Function 'test_German' failed function parameter name test" diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsOfType.sk b/src/test/skript/tests/syntaxes/conditions/CondIsOfType.sk index c4a7ce6e5e1..5a0d2e2c1a1 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsOfType.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsOfType.sk @@ -17,23 +17,23 @@ test "item is of type condition": assert ender pearl is of type plain ender pearl with "ender pearl isn't of type plain ender pearl" test "entity is of type condition": - spawn zombie at spawn of "world" - assert last spawned zombie is of type zombie with "zombie isn't of type zombie" - assert last spawned zombie is not of type ghast with "zombie isn't of type ghast" - set {_zombie} to last spawned zombie - assert {_zombie} is of type zombie with "zombie in a variable isn't of type zombie" - delete last spawned zombie + spawn zombie at spawn of "world" + assert last spawned zombie is of type zombie with "zombie isn't of type zombie" + assert last spawned zombie is not of type ghast with "zombie isn't of type ghast" + set {_zombie} to last spawned zombie + assert {_zombie} is of type zombie with "zombie in a variable isn't of type zombie" + delete last spawned zombie - spawn armor stand at spawn of "world" - assert last spawned armor stand is of type armor stand with "armor stand isn't of type armor stand" - assert last spawned armor stand is not of type ghast with "armor stand isn't of type ghast" - set {_armor-stand} to last spawned armor stand - assert {_armor-stand} is of type armor stand with "armor stand in a variable isn't of type armor stand" - delete last spawned armor stand + spawn armor stand at spawn of "world" + assert last spawned armor stand is of type armor stand with "armor stand isn't of type armor stand" + assert last spawned armor stand is not of type ghast with "armor stand isn't of type ghast" + set {_armor-stand} to last spawned armor stand + assert {_armor-stand} is of type armor stand with "armor stand in a variable isn't of type armor stand" + delete last spawned armor stand - spawn enderpearl at spawn of "world" - assert last spawned enderpearl is of type ender pearl with "enderpearl isn't of type enderpearl" - assert last spawned enderpearl is not of type ghast with "enderpearl isn't of type ghast" - set {_enderpearl} to last spawned enderpearl - assert {_enderpearl} is of type ender pearl with "enderpearl in a variable isn't of type enderpearl" - delete last spawned enderpearl + spawn enderpearl at spawn of "world" + assert last spawned enderpearl is of type ender pearl with "enderpearl isn't of type enderpearl" + assert last spawned enderpearl is not of type ghast with "enderpearl isn't of type ghast" + set {_enderpearl} to last spawned enderpearl + assert {_enderpearl} is of type ender pearl with "enderpearl in a variable isn't of type enderpearl" + delete last spawned enderpearl diff --git a/src/test/skript/tests/syntaxes/effects/EffDoIf.sk b/src/test/skript/tests/syntaxes/effects/EffDoIf.sk index da17471d8d5..b9637ed3332 100644 --- a/src/test/skript/tests/syntaxes/effects/EffDoIf.sk +++ b/src/test/skript/tests/syntaxes/effects/EffDoIf.sk @@ -1,6 +1,6 @@ test "do if": - set {_false} to false if 1 is 1 - assert {_false} is false with "Do if didn't run when it should have" + set {_false} to false if 1 is 1 + assert {_false} is false with "Do if didn't run when it should have" - set {_unset} to true if 1 is 2 - assert {_unset} is not set with "Do if ran when it shouldn't have" + set {_unset} to true if 1 is 2 + assert {_unset} is not set with "Do if ran when it shouldn't have" diff --git a/src/test/skript/tests/syntaxes/effects/EffPvP.sk b/src/test/skript/tests/syntaxes/effects/EffPvP.sk index bb41b776670..37cee2ea12f 100644 --- a/src/test/skript/tests/syntaxes/effects/EffPvP.sk +++ b/src/test/skript/tests/syntaxes/effects/EffPvP.sk @@ -1,6 +1,6 @@ test "pvp effect": - set {_world} to first element out of all worlds - disable pvp in {_world} - assert pvp is disabled in {_world} with "PvP was not disabled" - enable pvp in {_world} - assert pvp is enabled in {_world} with "PvP was not enabled" + set {_world} to first element out of all worlds + disable pvp in {_world} + assert pvp is disabled in {_world} with "PvP was not disabled" + enable pvp in {_world} + assert pvp is enabled in {_world} with "PvP was not enabled" diff --git a/src/test/skript/tests/syntaxes/expressions/ExprArithmetic.sk b/src/test/skript/tests/syntaxes/expressions/ExprArithmetic.sk index ef17ec0d979..5a81450c29d 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprArithmetic.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprArithmetic.sk @@ -1,247 +1,247 @@ test "number - number operations": - # --Addition/Subtraction-- - - assert (1 + 1) is (2) with "1 + 1 is not 2" - assert (2 + 2) is (4) with "2 + 2 is not 4" - assert (3 - 3) is (0) with "3 - 3 is not 0" - assert (4 - 2) is (2) with "4 - 2 is not 2" - assert (5 + 1) is (6) with "5 + 1 is not 6" - assert (6 - -2) is (8) with "6 - -2 is not 8" - assert (4-(40)) is (-36) with "4 - 40 is not -36" - - # --Multiplication-- - - assert (1*5) is (5) with "1 * 5 is not 5" - assert (2*5) is (10) with "2 * 5 is not 10" - assert (3*-5) is (-15) with "3 * -5 is not 15" - assert (4*0) is (0) with "4 * 0 is not 0" - assert (5*infinity value) is (infinity value) with "5 * infinity is not infinity" - - # --Division-- - - assert (1/5) is (0.2) with "1 / 5 is not 0.2" - assert (2/5) is (0.4) with "2 / 5 is not 0.4" - assert (3/-5) is (-0.6) with "3 / -5 is not -0.6" - assert (4/0) is (infinity value) with "4 / 0 is not infinity" - assert (5/0) is (infinity value) with "5 / 0 is not infinity" - assert isNaN(0/0) is true with "0 / 0 is not NaN" - assert (5/2.5) is (2) with "5 / 2.5 is not 2" - - # --Exponents-- - - assert (1^5) is (1) with "1 ^ 5 is not 1" - assert (2^5) is (32) with "2 ^ 5 is not 32" - assert (3^-5) is (0.00411522633) with "3 ^ -5 is not 0.00411522633" - assert (4^0) is (1) with "4 ^ 0 is not 1" - assert (5^0) is (1) with "5 ^ 0 is not 1" - assert (0^0) is (1) with "0 ^ 0 is not 1" - assert (5^2.5) - 55.901 < 0.001 with "5 ^ 2.5 is not 55.9" - - # --Order of Operations-- - - assert (1 + 2 - 1 * 3) is (0) with "1 + 2 - 1 * 3 is not 0" - assert (1 + 2 - 1 / 2 * 3 ) is (1.5) with "1 + 2 - 1 / 2 * 3 is not 1.5" - assert (1 + (2) - 1 / (2) * 3) is (1.5) with "1 + (2) - 1 / (2) * 3 is not 1.5" - assert (1 + (2 - 1 / 2) * 3) is (5.5) with "1 + (2 - 1 / 2) * 3 is not 5.5" - assert (1 + 2 - 1 / 2 * 3 + 4 - 5 * 6 / 2 ) is (-9.5) with "1 + 2 - 1 / 2 * 3 + 4 - 5 * 6 / 2 is not -9.5" - assert (1 + (1 - 2) * 3) is (-2) with "1 + (1 - 2) * 3 is not -2" - - # --Edge Cases-- - - assert (0^99999) is (0) with "0^99999 is not 0" - assert (1 + 2.3 + 3.01) is (6.31) with "1 + 2.3 + 3.01 is not 6.31" - assert (0.1 + 0.1 + 0.1) is (0.30000000000000004) with "0.1 + 0.1 + 0.1 is not 0.30000000000000004" - assert (1/-infinity value) is (-0) with "1/-infinity value is not -0" - - - # --Standard Operations-- - - set {_x} to 1 - set {_y} to 2 - set {_z} to 3 - assert ({_x}) is (1) with "{_x} is not 1" - assert ({_y}) is (2) with "{_y} is not 2" - assert ({_z}) is (3) with "{_z} is not 3" - assert ({_x} + {_y} + {_z}) is (6) with "1 + 2 + 3 is not 6" - assert ({_x} + {_y} - {_z}) is (0) with "1 + 2 - 3 is not 0" - assert ({_x} + {_y} * {_z}) is (7) with "1 + 2 * 3 is not 7" - assert ({_x} + {_y} / {_z}) is (1.6666666666666667) with "1 + 2 / 3 is not 1.6666666666666667" - assert ({_x} + {_y} ^ {_z}) is (9) with "1 + 2 ^ 3 is not 9" - assert ({_x} - {_y} + {_z}) is (2) with "1 - 2 + 3 is not 2" - assert ({_x} - {_y} - {_z}) is (-4) with "1 - 2 - 3 is not -4" - assert ({_x} - {_y} * {_z}) is (-5) with "1 - 2 * 3 is not -5" - assert ({_x} - {_y} / {_z}) is (0.3333333333333333) with "1 - 2 / 3 is not 0.3333333333333333" - assert ({_x} - {_y} ^ {_z}) is (-7) with "1 - 2 ^ 3 is not -7" - assert ({_x} * {_y} + {_z}) is (5) with "1 * 2 + 3 is not 5" - assert ({_x} * {_y} - {_z}) is (-1) with "1 * 2 - 3 is not -1" - assert ({_x} * {_y} * {_z}) is (6) with "1 * 2 * 3 is not 6" - assert ({_x} * {_y} / {_z}) is (0.6666666666666666) with "1 * 2 / 3 is not 0.6666666666666666" - assert ({_x} * {_y} ^ {_z}) is (8) with "1 * 2 ^ 3 is not 8" - assert ({_x} / {_y} + {_z}) is (3.5) with "1 / 2 + 3 is not 3.5" - assert ({_x} / {_y} - {_z}) is (-2.5) with "1 / 2 - 3 is not -2.5" - assert ({_x} / {_y} * {_z}) is (1.5) with "1 / 2 * 3 is not 1.5" - assert ({_x} / {_y} / {_z}) is (0.16666666666666666) with "1 / 2 / 3 is not 0.16666666666666666" - assert ({_x} / {_y} ^ {_z}) is (0.125) with "1 / 2 ^ 3 is not 0.125" - assert ({_x} ^ {_y} + {_z}) is (4) with "1 ^ 2 + 3 is not 4" - assert ({_x} ^ {_y} - {_z}) is (-2) with "1 ^ 2 - 3 is not -2" - assert ({_x} ^ {_y} * {_z}) is (3) with "1 ^ 2 * 3 is not 3" - assert ({_x} ^ {_y} / {_z}) is (0.3333333333333333) with "1 ^ 2 / 3 is not 0.3333333333333333" - assert ({_x} ^ {_y} ^ {_z}) is (1) with "1 ^ 2 ^ 3 is not 1" - - # --Non-Numbers-- - - set {_x} to 1 - set {_y} to {_} - set {_z} to 3 - - assert ({_y} / 3) is (0) with " / 3 is not 0" - assert ({_x}) is (1) with "{_x} is not 1" - assert ({_y} + 1 + 1) is (2) with " + 1 + 1 is not 2" - assert (1 + {_y} + 1) is (2) with "1 + + 1 is not 2" - assert ({_z}) is (3) with "{_z} is not 3" - assert ({_x} + {_y} + {_z}) is (4) with "1 + + 3 is not 4" - assert ({_x} + {_y} - {_z}) is (-2) with "1 + - 3 is not -2" - assert ({_x} + {_y} * {_z}) is (1) with "1 + * 3 is not 1" - assert ({_x} + {_y} / {_z}) is (1) with "1 + / 3 is not 1" - assert ({_x} + {_y} ^ {_z}) is (1) with "1 + ^ 3 is not 1" - assert ({_x} - {_y} + {_z}) is (4) with "1 - + 3 is not 4" - assert ({_x} - {_y} - {_z}) is (-2) with "1 - - 3 is not -2" - assert ({_x} - {_y} * {_z}) is (1) with "1 - * 3 is not 1" - assert ({_x} - {_y} / {_z}) is (1) with "1 - / 3 is not 1" - assert ({_x} - {_y} ^ {_z}) is (1) with "1 - ^ 3 is not 1" - assert ({_x} * {_y} + {_z}) is (3) with "1 * + 3 is not 3" - assert ({_x} * {_y} - {_z}) is (-3) with "1 * - 3 is not -3" - assert ({_x} * {_y} * {_z}) is (0) with "1 * * 3 is not 0" - assert ({_x} * {_y} / {_z}) is (0) with "1 * / 3 is not 0" - assert ({_x} * {_y} ^ {_z}) is (0) with "1 * ^ 3 is not 0" - assert ({_x} / {_y} + {_z}) is (infinity value) with "1 / + 3 is not infinity" - assert ({_x} / {_y} - {_z}) is (infinity value) with "1 / - 3 is not infinity" - assert ({_x} / {_y} * {_z}) is (infinity value) with "1 / * 3 is not infinity" - assert ({_x} / {_y} / {_z}) is (infinity value) with "1 / / 3 is not infinity" - assert ({_x} / {_y} ^ {_z}) is (infinity value) with "1 / ^ 3 is not infinity" - assert ({_x} ^ {_y} + {_z}) is (4) with "1 ^ + 3 is not 4" - assert ({_x} ^ {_y} - {_z}) is (-2) with "1 ^ - 3 is not -2" - assert ({_x} ^ {_y} * {_z}) is (3) with "1 ^ * 3 is not 3" - assert ({_x} ^ {_y} / {_z}) is (0.333333333333) with "1 ^ / 3 is not 0.333333333333" - assert ({_x} ^ {_y} ^ {_z}) is (1) with "1 ^ ^ 3 is not 1" - - # --Difference-- - assert (difference between 1 and 2) is (1) with "difference between 1 and 2 is not 1" - assert (difference between 2 and 1) is (1) with "difference between 2 and 1 is not 1" - assert (difference between 1 and 1) is (0) with "difference between 1 and 1 is not 0" - assert (difference between 1 and 0) is (1) with "difference between 1 and 0 is not 1" - assert (difference between 0 and 1) is (1) with "difference between 0 and 1 is not 1" - assert (difference between 0 and 0) is (0) with "difference between 0 and 0 is not 0" - assert (difference between 1 and infinity value) is (infinity value) with "difference between 1 and infinity is not infinity" - assert (difference between infinity value and 1) is (infinity value) with "difference between infinity and 1 is not infinity" - assert isNaN(difference between infinity value and infinity value) is true with "difference between infinity and infinity is not NaN" - assert isNaN(difference between 1 and NaN value) is true with "difference between 1 and NaN is not NaN" - assert isNaN(difference between NaN value and 1) is true with "difference between NaN and 1 is not NaN" - assert isNaN(difference between NaN value and NaN value) is true with "difference between NaN and NaN is not NaN" + # --Addition/Subtraction-- + + assert (1 + 1) is (2) with "1 + 1 is not 2" + assert (2 + 2) is (4) with "2 + 2 is not 4" + assert (3 - 3) is (0) with "3 - 3 is not 0" + assert (4 - 2) is (2) with "4 - 2 is not 2" + assert (5 + 1) is (6) with "5 + 1 is not 6" + assert (6 - -2) is (8) with "6 - -2 is not 8" + assert (4-(40)) is (-36) with "4 - 40 is not -36" + + # --Multiplication-- + + assert (1*5) is (5) with "1 * 5 is not 5" + assert (2*5) is (10) with "2 * 5 is not 10" + assert (3*-5) is (-15) with "3 * -5 is not 15" + assert (4*0) is (0) with "4 * 0 is not 0" + assert (5*infinity value) is (infinity value) with "5 * infinity is not infinity" + + # --Division-- + + assert (1/5) is (0.2) with "1 / 5 is not 0.2" + assert (2/5) is (0.4) with "2 / 5 is not 0.4" + assert (3/-5) is (-0.6) with "3 / -5 is not -0.6" + assert (4/0) is (infinity value) with "4 / 0 is not infinity" + assert (5/0) is (infinity value) with "5 / 0 is not infinity" + assert isNaN(0/0) is true with "0 / 0 is not NaN" + assert (5/2.5) is (2) with "5 / 2.5 is not 2" + + # --Exponents-- + + assert (1^5) is (1) with "1 ^ 5 is not 1" + assert (2^5) is (32) with "2 ^ 5 is not 32" + assert (3^-5) is (0.00411522633) with "3 ^ -5 is not 0.00411522633" + assert (4^0) is (1) with "4 ^ 0 is not 1" + assert (5^0) is (1) with "5 ^ 0 is not 1" + assert (0^0) is (1) with "0 ^ 0 is not 1" + assert (5^2.5) - 55.901 < 0.001 with "5 ^ 2.5 is not 55.9" + + # --Order of Operations-- + + assert (1 + 2 - 1 * 3) is (0) with "1 + 2 - 1 * 3 is not 0" + assert (1 + 2 - 1 / 2 * 3 ) is (1.5) with "1 + 2 - 1 / 2 * 3 is not 1.5" + assert (1 + (2) - 1 / (2) * 3) is (1.5) with "1 + (2) - 1 / (2) * 3 is not 1.5" + assert (1 + (2 - 1 / 2) * 3) is (5.5) with "1 + (2 - 1 / 2) * 3 is not 5.5" + assert (1 + 2 - 1 / 2 * 3 + 4 - 5 * 6 / 2 ) is (-9.5) with "1 + 2 - 1 / 2 * 3 + 4 - 5 * 6 / 2 is not -9.5" + assert (1 + (1 - 2) * 3) is (-2) with "1 + (1 - 2) * 3 is not -2" + + # --Edge Cases-- + + assert (0^99999) is (0) with "0^99999 is not 0" + assert (1 + 2.3 + 3.01) is (6.31) with "1 + 2.3 + 3.01 is not 6.31" + assert (0.1 + 0.1 + 0.1) is (0.30000000000000004) with "0.1 + 0.1 + 0.1 is not 0.30000000000000004" + assert (1/-infinity value) is (-0) with "1/-infinity value is not -0" + + + # --Standard Operations-- + + set {_x} to 1 + set {_y} to 2 + set {_z} to 3 + assert ({_x}) is (1) with "{_x} is not 1" + assert ({_y}) is (2) with "{_y} is not 2" + assert ({_z}) is (3) with "{_z} is not 3" + assert ({_x} + {_y} + {_z}) is (6) with "1 + 2 + 3 is not 6" + assert ({_x} + {_y} - {_z}) is (0) with "1 + 2 - 3 is not 0" + assert ({_x} + {_y} * {_z}) is (7) with "1 + 2 * 3 is not 7" + assert ({_x} + {_y} / {_z}) is (1.6666666666666667) with "1 + 2 / 3 is not 1.6666666666666667" + assert ({_x} + {_y} ^ {_z}) is (9) with "1 + 2 ^ 3 is not 9" + assert ({_x} - {_y} + {_z}) is (2) with "1 - 2 + 3 is not 2" + assert ({_x} - {_y} - {_z}) is (-4) with "1 - 2 - 3 is not -4" + assert ({_x} - {_y} * {_z}) is (-5) with "1 - 2 * 3 is not -5" + assert ({_x} - {_y} / {_z}) is (0.3333333333333333) with "1 - 2 / 3 is not 0.3333333333333333" + assert ({_x} - {_y} ^ {_z}) is (-7) with "1 - 2 ^ 3 is not -7" + assert ({_x} * {_y} + {_z}) is (5) with "1 * 2 + 3 is not 5" + assert ({_x} * {_y} - {_z}) is (-1) with "1 * 2 - 3 is not -1" + assert ({_x} * {_y} * {_z}) is (6) with "1 * 2 * 3 is not 6" + assert ({_x} * {_y} / {_z}) is (0.6666666666666666) with "1 * 2 / 3 is not 0.6666666666666666" + assert ({_x} * {_y} ^ {_z}) is (8) with "1 * 2 ^ 3 is not 8" + assert ({_x} / {_y} + {_z}) is (3.5) with "1 / 2 + 3 is not 3.5" + assert ({_x} / {_y} - {_z}) is (-2.5) with "1 / 2 - 3 is not -2.5" + assert ({_x} / {_y} * {_z}) is (1.5) with "1 / 2 * 3 is not 1.5" + assert ({_x} / {_y} / {_z}) is (0.16666666666666666) with "1 / 2 / 3 is not 0.16666666666666666" + assert ({_x} / {_y} ^ {_z}) is (0.125) with "1 / 2 ^ 3 is not 0.125" + assert ({_x} ^ {_y} + {_z}) is (4) with "1 ^ 2 + 3 is not 4" + assert ({_x} ^ {_y} - {_z}) is (-2) with "1 ^ 2 - 3 is not -2" + assert ({_x} ^ {_y} * {_z}) is (3) with "1 ^ 2 * 3 is not 3" + assert ({_x} ^ {_y} / {_z}) is (0.3333333333333333) with "1 ^ 2 / 3 is not 0.3333333333333333" + assert ({_x} ^ {_y} ^ {_z}) is (1) with "1 ^ 2 ^ 3 is not 1" + + # --Non-Numbers-- + + set {_x} to 1 + set {_y} to {_} + set {_z} to 3 + + assert ({_y} / 3) is (0) with " / 3 is not 0" + assert ({_x}) is (1) with "{_x} is not 1" + assert ({_y} + 1 + 1) is (2) with " + 1 + 1 is not 2" + assert (1 + {_y} + 1) is (2) with "1 + + 1 is not 2" + assert ({_z}) is (3) with "{_z} is not 3" + assert ({_x} + {_y} + {_z}) is (4) with "1 + + 3 is not 4" + assert ({_x} + {_y} - {_z}) is (-2) with "1 + - 3 is not -2" + assert ({_x} + {_y} * {_z}) is (1) with "1 + * 3 is not 1" + assert ({_x} + {_y} / {_z}) is (1) with "1 + / 3 is not 1" + assert ({_x} + {_y} ^ {_z}) is (1) with "1 + ^ 3 is not 1" + assert ({_x} - {_y} + {_z}) is (4) with "1 - + 3 is not 4" + assert ({_x} - {_y} - {_z}) is (-2) with "1 - - 3 is not -2" + assert ({_x} - {_y} * {_z}) is (1) with "1 - * 3 is not 1" + assert ({_x} - {_y} / {_z}) is (1) with "1 - / 3 is not 1" + assert ({_x} - {_y} ^ {_z}) is (1) with "1 - ^ 3 is not 1" + assert ({_x} * {_y} + {_z}) is (3) with "1 * + 3 is not 3" + assert ({_x} * {_y} - {_z}) is (-3) with "1 * - 3 is not -3" + assert ({_x} * {_y} * {_z}) is (0) with "1 * * 3 is not 0" + assert ({_x} * {_y} / {_z}) is (0) with "1 * / 3 is not 0" + assert ({_x} * {_y} ^ {_z}) is (0) with "1 * ^ 3 is not 0" + assert ({_x} / {_y} + {_z}) is (infinity value) with "1 / + 3 is not infinity" + assert ({_x} / {_y} - {_z}) is (infinity value) with "1 / - 3 is not infinity" + assert ({_x} / {_y} * {_z}) is (infinity value) with "1 / * 3 is not infinity" + assert ({_x} / {_y} / {_z}) is (infinity value) with "1 / / 3 is not infinity" + assert ({_x} / {_y} ^ {_z}) is (infinity value) with "1 / ^ 3 is not infinity" + assert ({_x} ^ {_y} + {_z}) is (4) with "1 ^ + 3 is not 4" + assert ({_x} ^ {_y} - {_z}) is (-2) with "1 ^ - 3 is not -2" + assert ({_x} ^ {_y} * {_z}) is (3) with "1 ^ * 3 is not 3" + assert ({_x} ^ {_y} / {_z}) is (0.333333333333) with "1 ^ / 3 is not 0.333333333333" + assert ({_x} ^ {_y} ^ {_z}) is (1) with "1 ^ ^ 3 is not 1" + + # --Difference-- + assert (difference between 1 and 2) is (1) with "difference between 1 and 2 is not 1" + assert (difference between 2 and 1) is (1) with "difference between 2 and 1 is not 1" + assert (difference between 1 and 1) is (0) with "difference between 1 and 1 is not 0" + assert (difference between 1 and 0) is (1) with "difference between 1 and 0 is not 1" + assert (difference between 0 and 1) is (1) with "difference between 0 and 1 is not 1" + assert (difference between 0 and 0) is (0) with "difference between 0 and 0 is not 0" + assert (difference between 1 and infinity value) is (infinity value) with "difference between 1 and infinity is not infinity" + assert (difference between infinity value and 1) is (infinity value) with "difference between infinity and 1 is not infinity" + assert isNaN(difference between infinity value and infinity value) is true with "difference between infinity and infinity is not NaN" + assert isNaN(difference between 1 and NaN value) is true with "difference between 1 and NaN is not NaN" + assert isNaN(difference between NaN value and 1) is true with "difference between NaN and 1 is not NaN" + assert isNaN(difference between NaN value and NaN value) is true with "difference between NaN and NaN is not NaN" test "vector - vector operations": - # --Addition/Subtraction-- - set {_v1} to vector(1, 2, 3) - set {_v2} to vector(4, 5, 6) - - assert ({_v1} + {_v2}) is (vector(5, 7, 9)) with "{_v1} + {_v2} is not vector(5, 7, 9)" - assert ({_v1} - {_v2}) is (vector(-3, -3, -3)) with "{_v1} - {_v2} is not vector(-3, -3, -3)" - assert ({_v1} * {_v2}) is (vector(4, 10, 18)) with "{_v1} * {_v2} is not vector(4, 10, 18)" - assert ({_v1} / {_v2}) is (vector(0.25, 0.4, 0.5)) with "{_v1} / {_v2} is not vector(0.25, 0.4, 0.5)" - - # --Zero Vectors-- - - set {_v1} to vector(0,0,0) - set {_v2} to vector(1,2,3) - assert ({_v1} + {_v2}) is (vector(1, 2, 3)) with "vector(0,0,0) + vector(1,2,3) is not vector(1, 2, 3)" - assert ({_v1} - {_v2}) is (vector(-1, -2, -3)) with "vector(0,0,0) - vector(1,2,3) is not vector(-1, -2, -3)" - assert ({_v1} * {_v2}) is (vector(0, 0, 0)) with "vector(0,0,0) * vector(1,2,3) is not vector(0, 0, 0)" - assert ({_v1} / {_v2}) is (vector(0, 0, 0)) with "vector(0,0,0) / vector(1,2,3) is not vector(0, 0, 0)" - assert ({_v2} + {_v1}) is (vector(1, 2, 3)) with "vector(1,2,3) + vector(0,0,0) is not vector(1, 2, 3)" - assert ({_v2} - {_v1}) is (vector(1, 2, 3)) with "vector(1,2,3) - vector(0,0,0) is not vector(1, 2, 3)" - assert ({_v2} * {_v1}) is (vector(0, 0, 0)) with "vector(1,2,3) * vector(0,0,0) is not vector(0, 0, 0)" - assert vector_equals(({_v2} / {_v1}), infinity value, infinity value, infinity value) is true with "vector(1,2,3) / vector(0,0,0) is not vector(infinity, infinity, infinity)" - - # --Non-Vectors-- - set {_v1} to vector(1, 2, 3) - set {_v2} to "test" - assert ({_v1} + {_v2}) is not set with "vector plus string is set" - assert ({_v1} - {_v2}) is not set with "vector minus string is set" - assert ({_v1} * {_v2}) is not set with "vector multiplied by string is set" - assert ({_v1} / {_v2}) is not set with "vector divided by string is set" - assert ({_v2} + {_v1}) is not set with "string plus vector is set" - assert ({_v2} - {_v1}) is not set with "string minus vector is set" - assert ({_v2} * {_v1}) is not set with "string multiplied by vector is set" - assert ({_v2} / {_v1}) is not set with "string divided by vector is set" - - # --Edge Cases-- - set {_v1} to vector(1, infinity value, 3) - set {_v2} to vector(4, 5, NaN value) - assert vector_equals(({_v1} + {_v2}), 5, infinity value, NaN value) is true with "vector(1, infinity, 3) + vector(4, 5, NaN) is not vector(5, infinity, NaN)" - assert vector_equals(({_v1} - {_v2}), -3, infinity value, NaN value) is true with "vector(1, infinity, 3) - vector(4, 5, NaN) is not vector(-3, infinity, NaN)" - assert vector_equals(({_v1} * {_v2}), 4, infinity value, NaN value) is true with "vector(1, infinity, 3) * vector(4, 5, NaN) is not vector(4, infinity, NaN)" - assert vector_equals(({_v1} / {_v2}), 0.25, infinity value, NaN value) is true with "vector(1, infinity, 3) / vector(4, 5, NaN) is not vector(0.25, infinity, NaN)" - assert vector_equals(({_v2} + {_v1}), 5, infinity value, NaN value) is true with "vector(4, 5, NaN) + vector(1, infinity, 3) is not vector(5, infinity, NaN)" - assert vector_equals(({_v2} - {_v1}), 3, -infinity value, NaN value) is true with "vector(4, 5, NaN) - vector(1, infinity, 3) is not vector(3, -infinity, NaN)" - assert vector_equals(({_v2} * {_v1}), 4, infinity value, NaN value) is true with "vector(4, 5, NaN) * vector(1, infinity, 3) is not vector(4, infinity, NaN)" - assert vector_equals(({_v2} / {_v1}), 4, 0, NaN value) is true with "vector(4, 5, NaN) / vector(1, infinity, 3) is not vector(4, 0, NaN)" - - # --Difference-- - - set {_v1} to vector(1, 2, 3) - set {_v2} to vector(4, 5, 6) - assert (difference between {_v1} and {_v2}) is (vector(3, 3, 3)) with "difference between vector(1,2,3) and vector(4,5,6) is not vector(3, 3, 3)" - assert (difference between {_v2} and {_v1}) is (vector(3, 3, 3)) with "difference between vector(4,5,6) and vector(1,2,3) is not vector(3, 3, 3)" - assert (difference between {_v1} and {_v1}) is (vector(0, 0, 0)) with "difference between vector(1,2,3) and vector(1,2,3) is not vector(0, 0, 0)" - assert (difference between {_v1} and vector(0,0,0)) is (vector(1, 2, 3)) with "difference between vector(1,2,3) and vector(0,0,0) is not vector(1, 2, 3)" - assert (difference between vector(0,0,0) and {_v1}) is (vector(1, 2, 3)) with "difference between vector(0,0,0) and {_v1} is not vector(1, 2, 3)" - assert vector_equals(difference between {_v1} and vector(infinity value, -infinity value, NaN value), infinity value, infinity value, NaN value) is true with "difference between vector(1,2,3) and vector(infinity, -infinity, NaN) is not vector(infinity, infinity, NaN)" + # --Addition/Subtraction-- + set {_v1} to vector(1, 2, 3) + set {_v2} to vector(4, 5, 6) + + assert ({_v1} + {_v2}) is (vector(5, 7, 9)) with "{_v1} + {_v2} is not vector(5, 7, 9)" + assert ({_v1} - {_v2}) is (vector(-3, -3, -3)) with "{_v1} - {_v2} is not vector(-3, -3, -3)" + assert ({_v1} * {_v2}) is (vector(4, 10, 18)) with "{_v1} * {_v2} is not vector(4, 10, 18)" + assert ({_v1} / {_v2}) is (vector(0.25, 0.4, 0.5)) with "{_v1} / {_v2} is not vector(0.25, 0.4, 0.5)" + + # --Zero Vectors-- + + set {_v1} to vector(0,0,0) + set {_v2} to vector(1,2,3) + assert ({_v1} + {_v2}) is (vector(1, 2, 3)) with "vector(0,0,0) + vector(1,2,3) is not vector(1, 2, 3)" + assert ({_v1} - {_v2}) is (vector(-1, -2, -3)) with "vector(0,0,0) - vector(1,2,3) is not vector(-1, -2, -3)" + assert ({_v1} * {_v2}) is (vector(0, 0, 0)) with "vector(0,0,0) * vector(1,2,3) is not vector(0, 0, 0)" + assert ({_v1} / {_v2}) is (vector(0, 0, 0)) with "vector(0,0,0) / vector(1,2,3) is not vector(0, 0, 0)" + assert ({_v2} + {_v1}) is (vector(1, 2, 3)) with "vector(1,2,3) + vector(0,0,0) is not vector(1, 2, 3)" + assert ({_v2} - {_v1}) is (vector(1, 2, 3)) with "vector(1,2,3) - vector(0,0,0) is not vector(1, 2, 3)" + assert ({_v2} * {_v1}) is (vector(0, 0, 0)) with "vector(1,2,3) * vector(0,0,0) is not vector(0, 0, 0)" + assert vector_equals(({_v2} / {_v1}), infinity value, infinity value, infinity value) is true with "vector(1,2,3) / vector(0,0,0) is not vector(infinity, infinity, infinity)" + + # --Non-Vectors-- + set {_v1} to vector(1, 2, 3) + set {_v2} to "test" + assert ({_v1} + {_v2}) is not set with "vector plus string is set" + assert ({_v1} - {_v2}) is not set with "vector minus string is set" + assert ({_v1} * {_v2}) is not set with "vector multiplied by string is set" + assert ({_v1} / {_v2}) is not set with "vector divided by string is set" + assert ({_v2} + {_v1}) is not set with "string plus vector is set" + assert ({_v2} - {_v1}) is not set with "string minus vector is set" + assert ({_v2} * {_v1}) is not set with "string multiplied by vector is set" + assert ({_v2} / {_v1}) is not set with "string divided by vector is set" + + # --Edge Cases-- + set {_v1} to vector(1, infinity value, 3) + set {_v2} to vector(4, 5, NaN value) + assert vector_equals(({_v1} + {_v2}), 5, infinity value, NaN value) is true with "vector(1, infinity, 3) + vector(4, 5, NaN) is not vector(5, infinity, NaN)" + assert vector_equals(({_v1} - {_v2}), -3, infinity value, NaN value) is true with "vector(1, infinity, 3) - vector(4, 5, NaN) is not vector(-3, infinity, NaN)" + assert vector_equals(({_v1} * {_v2}), 4, infinity value, NaN value) is true with "vector(1, infinity, 3) * vector(4, 5, NaN) is not vector(4, infinity, NaN)" + assert vector_equals(({_v1} / {_v2}), 0.25, infinity value, NaN value) is true with "vector(1, infinity, 3) / vector(4, 5, NaN) is not vector(0.25, infinity, NaN)" + assert vector_equals(({_v2} + {_v1}), 5, infinity value, NaN value) is true with "vector(4, 5, NaN) + vector(1, infinity, 3) is not vector(5, infinity, NaN)" + assert vector_equals(({_v2} - {_v1}), 3, -infinity value, NaN value) is true with "vector(4, 5, NaN) - vector(1, infinity, 3) is not vector(3, -infinity, NaN)" + assert vector_equals(({_v2} * {_v1}), 4, infinity value, NaN value) is true with "vector(4, 5, NaN) * vector(1, infinity, 3) is not vector(4, infinity, NaN)" + assert vector_equals(({_v2} / {_v1}), 4, 0, NaN value) is true with "vector(4, 5, NaN) / vector(1, infinity, 3) is not vector(4, 0, NaN)" + + # --Difference-- + + set {_v1} to vector(1, 2, 3) + set {_v2} to vector(4, 5, 6) + assert (difference between {_v1} and {_v2}) is (vector(3, 3, 3)) with "difference between vector(1,2,3) and vector(4,5,6) is not vector(3, 3, 3)" + assert (difference between {_v2} and {_v1}) is (vector(3, 3, 3)) with "difference between vector(4,5,6) and vector(1,2,3) is not vector(3, 3, 3)" + assert (difference between {_v1} and {_v1}) is (vector(0, 0, 0)) with "difference between vector(1,2,3) and vector(1,2,3) is not vector(0, 0, 0)" + assert (difference between {_v1} and vector(0,0,0)) is (vector(1, 2, 3)) with "difference between vector(1,2,3) and vector(0,0,0) is not vector(1, 2, 3)" + assert (difference between vector(0,0,0) and {_v1}) is (vector(1, 2, 3)) with "difference between vector(0,0,0) and {_v1} is not vector(1, 2, 3)" + assert vector_equals(difference between {_v1} and vector(infinity value, -infinity value, NaN value), infinity value, infinity value, NaN value) is true with "difference between vector(1,2,3) and vector(infinity, -infinity, NaN) is not vector(infinity, infinity, NaN)" test "number - vector operations": - set {_v1} to vector(1, 2, 3) - set {_v2} to 2 - assert ({_v1} + 2) is not set with "vector plus number is set" - assert ({_v1} - 2) is not set with "vector minus number is set" - assert ({_v1} * 2) is (vector(2, 4, 6)) with "vector(1,2,3) * 2 is not vector(2, 4, 6)" - assert ({_v1} / 2) is (vector(0.5, 1, 1.5)) with "vector(1,2,3) / 2 is not vector(0.5, 1, 1.5)" - assert ({_v1} ^ 2) is not set with "vector to the power of a number is set" - assert ({_v1} * 0) is (vector(0, 0, 0)) with "vector(1,2,3) * 0 is not vector(0, 0, 0)" - assert vector_equals(({_v1} / 0), infinity value, infinity value, infinity value) is true with "vector(1,2,3) / 0 is not vector(infinity, infinity, infinity)" - assert vector_equals(({_v1} * -infinity value), -infinity value, -infinity value, -infinity value) is true with "vector(1,2,3) * -infinity is not vector(-infinity, -infinity, -infinity)" - assert vector_equals(({_v1} / -infinity value), -0, -0, -0) is true with "vector(1,2,3) / -infinity value is not vector(-0, -0, -0)" - assert vector_equals(({_v1} * NaN value), NaN value, NaN value, NaN value) is true with "vector(1,2,3) * NaN is not vector(NaN, NaN, NaN)" - assert vector_equals(({_v1} / NaN value), NaN value, NaN value, NaN value) is true with "vector(1,2,3) / NaN is not vector(NaN, NaN, NaN)" + set {_v1} to vector(1, 2, 3) + set {_v2} to 2 + assert ({_v1} + 2) is not set with "vector plus number is set" + assert ({_v1} - 2) is not set with "vector minus number is set" + assert ({_v1} * 2) is (vector(2, 4, 6)) with "vector(1,2,3) * 2 is not vector(2, 4, 6)" + assert ({_v1} / 2) is (vector(0.5, 1, 1.5)) with "vector(1,2,3) / 2 is not vector(0.5, 1, 1.5)" + assert ({_v1} ^ 2) is not set with "vector to the power of a number is set" + assert ({_v1} * 0) is (vector(0, 0, 0)) with "vector(1,2,3) * 0 is not vector(0, 0, 0)" + assert vector_equals(({_v1} / 0), infinity value, infinity value, infinity value) is true with "vector(1,2,3) / 0 is not vector(infinity, infinity, infinity)" + assert vector_equals(({_v1} * -infinity value), -infinity value, -infinity value, -infinity value) is true with "vector(1,2,3) * -infinity is not vector(-infinity, -infinity, -infinity)" + assert vector_equals(({_v1} / -infinity value), -0, -0, -0) is true with "vector(1,2,3) / -infinity value is not vector(-0, -0, -0)" + assert vector_equals(({_v1} * NaN value), NaN value, NaN value, NaN value) is true with "vector(1,2,3) * NaN is not vector(NaN, NaN, NaN)" + assert vector_equals(({_v1} / NaN value), NaN value, NaN value, NaN value) is true with "vector(1,2,3) / NaN is not vector(NaN, NaN, NaN)" test "timespan arithmetic": - set {_t1} to 1 second - set {_t2} to 2 seconds - assert ({_t1} + {_t2}) is (3 seconds) with "1 second + 2 seconds is not 3 seconds" - assert ({_t1} - {_t2}) is (0 seconds) with "1 second - 2 seconds is not 0 seconds" - assert ({_t1} * 2) is (2 seconds) with "1 second * 2 is not 2 seconds" - assert ({_t1} / 2) is (0.5 seconds) with "1 second / 2 is not 0.5 seconds" + set {_t1} to 1 second + set {_t2} to 2 seconds + assert ({_t1} + {_t2}) is (3 seconds) with "1 second + 2 seconds is not 3 seconds" + assert ({_t1} - {_t2}) is (0 seconds) with "1 second - 2 seconds is not 0 seconds" + assert ({_t1} * 2) is (2 seconds) with "1 second * 2 is not 2 seconds" + assert ({_t1} / 2) is (0.5 seconds) with "1 second / 2 is not 0.5 seconds" - assert (2 * {_t1}) is (2 seconds) with "2 * 1 second is not 2 seconds" - assert (2 / {_t1}) is not set with "number divided by timespan is set" + assert (2 * {_t1}) is (2 seconds) with "2 * 1 second is not 2 seconds" + assert (2 / {_t1}) is not set with "number divided by timespan is set" - assert ({_t1} + 2) is not set with "timespan plus number is set" + assert ({_t1} + 2) is not set with "timespan plus number is set" - assert {_t1} / {_t2} is 0.5 with "timespan / timespan failed" - assert {_t1} / 1 tick is 20 with "timespan / timespan of different units failed" - assert 0 seconds / {_t2} is 0 with "0 timespan / timespan failed" - assert {_t1} / 0 seconds is infinity value with "timespan / 0 timespan failed" - assert isNaN(0 seconds / 0 ticks) is true with "0 timespan / 0 timespan failed", expected NaN value, got (0 seconds / 0 ticks) + assert {_t1} / {_t2} is 0.5 with "timespan / timespan failed" + assert {_t1} / 1 tick is 20 with "timespan / timespan of different units failed" + assert 0 seconds / {_t2} is 0 with "0 timespan / timespan failed" + assert {_t1} / 0 seconds is infinity value with "timespan / 0 timespan failed" + assert isNaN(0 seconds / 0 ticks) is true with "0 timespan / 0 timespan failed", expected NaN value, got (0 seconds / 0 ticks) test "date arithmetic": - set {_d1} to now - set {_d2} to 1 day before {_d1} - assert ({_d1} + {_d2}) is not set with "" - - assert ({_d1} + 1 day) is (1 day after {_d1}) with "now + 1 day is not 1 day from now" - assert ({_d1} - 1 day) is (1 day before {_d1}) with "now - 1 day is not 1 day ago" - assert ({_d1} + 1 week) is (1 week after {_d1}) with "now + 1 week is not 1 week from now" - assert ({_d1} - 1 week) is (1 week before {_d1}) with "now - 1 week is not 1 week ago" - assert ({_d1} + 1) is not set with "" + set {_d1} to now + set {_d2} to 1 day before {_d1} + assert ({_d1} + {_d2}) is not set with "" + + assert ({_d1} + 1 day) is (1 day after {_d1}) with "now + 1 day is not 1 day from now" + assert ({_d1} - 1 day) is (1 day before {_d1}) with "now - 1 day is not 1 day ago" + assert ({_d1} + 1 week) is (1 week after {_d1}) with "now + 1 week is not 1 week from now" + assert ({_d1} - 1 week) is (1 week before {_d1}) with "now - 1 week is not 1 week ago" + assert ({_d1} + 1) is not set with "" local function vector_equals(vec: vector, x: number, y: number, z: number) :: boolean: return false if component_equals((x of {_vec}), {_x}) is false diff --git a/src/test/skript/tests/syntaxes/expressions/ExprInventory.sk b/src/test/skript/tests/syntaxes/expressions/ExprInventory.sk index b4165f8eddd..038c41fac5b 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprInventory.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprInventory.sk @@ -1,12 +1,12 @@ test "item inventory": - set {_shulker} to any shulker box - assert inventory of {_shulker} is set with "Failed to get shulker inventory" - set slot 1 of inventory of {_shulker} to dirt - assert slot 1 of inventory of {_shulker} is dirt with "Failed to set slot in shulker inventory" + set {_shulker} to any shulker box + assert inventory of {_shulker} is set with "Failed to get shulker inventory" + set slot 1 of inventory of {_shulker} to dirt + assert slot 1 of inventory of {_shulker} is dirt with "Failed to set slot in shulker inventory" - set {_chest} to chest - assert inventory of {_chest} is set with "Failed to get chest inventory" - set slot 1 of inventory of {_chest} to dirt - assert slot 1 of inventory of {_chest} is dirt with "Failed to set slot in chest inventory" + set {_chest} to chest + assert inventory of {_chest} is set with "Failed to get chest inventory" + set slot 1 of inventory of {_chest} to dirt + assert slot 1 of inventory of {_chest} is dirt with "Failed to set slot in chest inventory" - assert inventory of dirt is not set with "Inventory was found for an item without an inventory" + assert inventory of dirt is not set with "Inventory was found for an item without an inventory" diff --git a/src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk b/src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk index f19fdcd50c2..696a24ca888 100644 --- a/src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk +++ b/src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk @@ -88,7 +88,7 @@ test "spawn entities": add "falling powder snow" to {_entities::*} if running minecraft "1.20.0": - add "camel" and "sniffer" to {_entities::*} + add "camel" and "sniffer" to {_entities::*} if running minecraft "1.20.6": add "armadillo" to {_entities::*} if running minecraft "1.21": diff --git a/src/test/skript/tests/syntaxes/sections/SecParse.sk b/src/test/skript/tests/syntaxes/sections/SecParse.sk index 4478e781ff3..99ed6ec8041 100644 --- a/src/test/skript/tests/syntaxes/sections/SecParse.sk +++ b/src/test/skript/tests/syntaxes/sections/SecParse.sk @@ -1,8 +1,8 @@ test "parsing section": - parse: - parse: - # intentionally empty to cause an error - assert last parse logs contain "A parse section must contain code" with "Parse section didn't return expected error" - parse: - set {_x} to {_y} # valid code - assert last parse logs is not set with "Parse section contained errors when code was valid" + parse: + parse: + # intentionally empty to cause an error + assert last parse logs contain "A parse section must contain code" with "Parse section didn't return expected error" + parse: + set {_x} to {_y} # valid code + assert last parse logs is not set with "Parse section contained errors when code was valid" diff --git a/src/test/skript/tests/syntaxes/structures/StructParse.sk b/src/test/skript/tests/syntaxes/structures/StructParse.sk index 5b249535d36..33d5973a1c0 100644 --- a/src/test/skript/tests/syntaxes/structures/StructParse.sk +++ b/src/test/skript/tests/syntaxes/structures/StructParse.sk @@ -1,11 +1,11 @@ parse: - results: {StructParse::parse::*} - code: - parse: - results: "oops" - code: - on script load: - broadcast "hi" + results: {StructParse::parse::*} + code: + parse: + results: "oops" + code: + on script load: + broadcast "hi" test "StructParse": - assert {StructParse::parse::*} contains """oops"" cannot be set to strings" with "StructParse error not found" \ No newline at end of file + assert {StructParse::parse::*} contains """oops"" cannot be set to strings" with "StructParse error not found"