Skip to content

Commit

Permalink
chore: extra test for component equality
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Oct 19, 2024
1 parent 8bfe454 commit af90deb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import net.fabricmc.loom.api.RemapConfigurationSettings
import net.fabricmc.loom.task.GenerateSourcesTask
import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RunGameTask
import org.gradle.configurationcache.extensions.capitalized

plugins {
alias(libs.plugins.loom)
Expand Down Expand Up @@ -90,7 +89,7 @@ fun createSecondarySet(name: String, action: Action<SourceSet> = Action { }): So
extendsFrom(setConfig)
}

loom.addRemapConfiguration("mod${name.capitalized()}") {
loom.addRemapConfiguration("mod${name.first().uppercase() + name.drop(1)}") {
sourceSet = set
targetConfigurationName = name
onCompileClasspath = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ void testSerializationEqualWhenWrappedNested(final Component input) {
assertJsonTreesEqual(serializedNative, serialized);
}

@TestOnComponents
void testComponentEquality(final Component input) {
final net.minecraft.network.chat.Component deepConverted = new NonWrappingComponentSerializer(BootstrappedTest::lookup).serialize(input);
final net.minecraft.network.chat.Component wrapped = this.asNativeWrapped(input);
final net.minecraft.network.chat.Component wrapped2 = this.asNativeWrapped(input);
assertEquals(wrapped, wrapped2, "two wrapped components should be equal");
assertEquals(deepConverted, wrapped, "deep should equal wrapped");
assertEquals(wrapped, deepConverted, "wrapped should equal deep");
}

private static void assertJsonTreesEqual(final JsonElement expected, final JsonElement actual) {
assertEquals(toStableString(expected), toStableString(actual));
}
Expand Down

0 comments on commit af90deb

Please sign in to comment.