Make parchment layer test also test the parameter after being reordered (#483)
* Make parchment mappings layer test also test the parameter after being reordered. * Switch to using hashCode
This commit is contained in:
		
							parent
							
								
									08f055489b
								
							
						
					
					
						commit
						0633b170fa
					
				
					 2 changed files with 15 additions and 2 deletions
				
			
		|  | @ -30,8 +30,11 @@ import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec | |||
| import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingsProcessor | ||||
| import net.fabricmc.loom.configuration.providers.mappings.MappingContext | ||||
| import net.fabricmc.loom.configuration.providers.mappings.MappingLayer | ||||
| import net.fabricmc.loom.configuration.providers.mappings.MappingNamespace | ||||
| import net.fabricmc.loom.configuration.providers.mappings.MappingsProvider | ||||
| import net.fabricmc.loom.configuration.providers.mappings.MappingsSpec | ||||
| import net.fabricmc.mappingio.adapter.MappingDstNsReorder | ||||
| import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch | ||||
| import net.fabricmc.mappingio.format.Tiny2Writer | ||||
| import net.fabricmc.mappingio.tree.MemoryMappingTree | ||||
| import org.gradle.api.logging.Logger | ||||
|  | @ -89,6 +92,14 @@ abstract class LayeredMappingsSpecification extends Specification implements Lay | |||
|         return sw.toString() | ||||
|     } | ||||
| 
 | ||||
|     MemoryMappingTree reorder(MemoryMappingTree mappingTree) { | ||||
|         def reorderedMappings = new MemoryMappingTree() | ||||
|         def nsReorder = new MappingDstNsReorder(reorderedMappings, Collections.singletonList(MappingNamespace.NAMED.stringValue())) | ||||
|         def nsSwitch = new MappingSourceNsSwitch(nsReorder, MappingNamespace.INTERMEDIARY.stringValue(), true) | ||||
|         mappingTree.accept(nsSwitch) | ||||
|         return reorderedMappings | ||||
|     } | ||||
| 
 | ||||
|     @CompileStatic | ||||
|     class TestMappingContext implements MappingContext { | ||||
|         @Override | ||||
|  |  | |||
|  | @ -38,16 +38,18 @@ class ParchmentMappingLayerTest extends LayeredMappingsSpecification { | |||
|             def mappings = getLayeredMappings( | ||||
|                     new IntermediaryMappingsSpec(), | ||||
|                     new MojangMappingsSpec(), | ||||
|                     new ParchmentMappingsSpec(PARCHMENT_NOTATION, false) | ||||
|                     new ParchmentMappingsSpec(PARCHMENT_NOTATION, true) | ||||
|             ) | ||||
|             def tiny = getTiny(mappings) | ||||
|             def reorderedMappings = reorder(mappings) | ||||
|         then: | ||||
|             mappings.srcNamespace == "named" | ||||
|             mappings.dstNamespaces == ["intermediary", "official"] | ||||
|             mappings.classes.size() == 5747 | ||||
|             mappings.classes[0].srcName.hashCode() == -1112444138 // MojMap name, just check the hash | ||||
|             mappings.classes[0].getDstName(0) == "net/minecraft/class_2573" | ||||
|             mappings.classes[0].methods[0].args[0].srcName == "pStack" | ||||
|             mappings.classes[0].methods[0].args[0].srcName.hashCode() == 109757064 | ||||
|             reorderedMappings.getClass("net/minecraft/class_2573").getMethod("method_10913", "(Lnet/minecraft/class_1799;Lnet/minecraft/class_1767;)V").args.size() > 0 | ||||
|     } | ||||
| 
 | ||||
|     def "Read parchment mappings remove prefix" () { | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue