|
| 1 | +package io.github.douira.glsl_transformer.ast.query; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.*; |
| 4 | + |
| 5 | +import org.junit.jupiter.api.Test; |
| 6 | + |
| 7 | +public class RootSupplierTest { |
| 8 | + // test that the pre-made root suppliers do the right things |
| 9 | + @Test |
| 10 | + public void testRootSuppliers() { |
| 11 | + var root1 = RootSupplier.EXACT_UNORDERED.get(); |
| 12 | + assertNull(root1.externalDeclarationIndex); |
| 13 | + assertThrows(IllegalStateException.class, () -> root1.getPrefixIdentifierIndex()); |
| 14 | + assertNotNull(root1.identifierIndex); |
| 15 | + assertNotNull(root1.nodeIndex); |
| 16 | + assertThrows(IllegalStateException.class, () -> root1.getPrefixExternalDeclarationIndex()); |
| 17 | + |
| 18 | + var root2 = RootSupplier.PREFIX_UNORDERED.get(); |
| 19 | + assertNull(root2.externalDeclarationIndex); |
| 20 | + assertNotNull(root2.getPrefixIdentifierIndex()); |
| 21 | + assertNotNull(root2.identifierIndex); |
| 22 | + assertNotNull(root2.nodeIndex); |
| 23 | + assertThrows(IllegalStateException.class, () -> root2.getPrefixExternalDeclarationIndex()); |
| 24 | + |
| 25 | + var root3 = RootSupplier.EXACT_UNORDERED_ED_EXACT.get(); |
| 26 | + assertNotNull(root3.externalDeclarationIndex); |
| 27 | + assertThrows(IllegalStateException.class, () -> root3.getPrefixIdentifierIndex()); |
| 28 | + assertNotNull(root3.identifierIndex); |
| 29 | + assertNotNull(root3.nodeIndex); |
| 30 | + assertThrows(IllegalStateException.class, () -> root3.getPrefixExternalDeclarationIndex()); |
| 31 | + |
| 32 | + var root4 = RootSupplier.PREFIX_UNORDERED_ED_EXACT.get(); |
| 33 | + assertNotNull(root4.externalDeclarationIndex); |
| 34 | + assertNotNull(root4.getPrefixIdentifierIndex()); |
| 35 | + assertNotNull(root4.identifierIndex); |
| 36 | + assertNotNull(root4.nodeIndex); |
| 37 | + assertThrows(IllegalStateException.class, () -> root4.getPrefixExternalDeclarationIndex()); |
| 38 | + |
| 39 | + var root5 = RootSupplier.PREFIX_UNORDERED_ED_PREFIX.get(); |
| 40 | + assertNotNull(root5.externalDeclarationIndex); |
| 41 | + assertNotNull(root5.getPrefixIdentifierIndex()); |
| 42 | + assertNotNull(root5.identifierIndex); |
| 43 | + assertNotNull(root5.nodeIndex); |
| 44 | + assertNotNull(root5.getPrefixExternalDeclarationIndex()); |
| 45 | + } |
| 46 | +} |
0 commit comments