diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-03-02 14:49:45 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-03-02 14:49:45 +0000 |
| commit | 28049a39ca32332a01c4dd1857384372c10b464f (patch) | |
| tree | 33905d501ca33f195c092e87f3878276eab4a6d9 /src/test/java | |
| parent | b0e20892050231c8be885c4c18e666a4c0c7c244 (diff) | |
Directly test effect subsitution
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/types/TypeSubstitutionTests.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/types/TypeSubstitutionTests.java b/src/test/java/org/shedlang/compiler/types/TypeSubstitutionTests.java index 2e2bd08e..210e4c18 100644 --- a/src/test/java/org/shedlang/compiler/types/TypeSubstitutionTests.java +++ b/src/test/java/org/shedlang/compiler/types/TypeSubstitutionTests.java @@ -14,6 +14,34 @@ public class TypeSubstitutionTests { private static final SimpleStructType STRUCT_TYPE_2 = Types.struct(NAMESPACE_NAME, "Struct2"); @Test + public void substitutingEffectParamDoesNothingIfEffectParamIsNotInSubstitutionMap() { + var typeSubstitutionMap = TypeSubstitutionMap.of( + Map.entry(EffectParam.forStructType(STRUCT_TYPE, "E"), Effects.IO) + ); + + var result = TypeSubstitution.substituteEffect( + EffectParam.forStructType(STRUCT_TYPE_2, "E"), + typeSubstitutionMap + ); + + assertThat(result, equalTo(EffectParam.forStructType(STRUCT_TYPE_2, "E"))); + } + + @Test + public void substitutingEffectParamChangesEffectParamToCorrespondingEffect() { + var typeSubstitutionMap = TypeSubstitutionMap.of( + Map.entry(EffectParam.forStructType(STRUCT_TYPE, "E"), Effects.IO) + ); + + var result = TypeSubstitution.substituteEffect( + EffectParam.forStructType(STRUCT_TYPE, "E"), + typeSubstitutionMap + ); + + assertThat(result, equalTo(Effects.IO)); + } + + @Test public void substitutingBoolDoesNothing() { var typeSubstitutionMap = TypeSubstitutionMap.of( Map.entry(TypeParam.forStructType(STRUCT_TYPE, "T"), Types.INT) |
