Search in sources :

Example 41 with MethodType

use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.

the class Test212_or_170_MethodTypes method testMI.

@Test
public void testMI() {
    int count = 0;
    for (MethodType mt : dataSet) {
        MethodType base = mBase(mt);
        //mC(mNoFwd(mBase))
        MethodType res = _mI(mNoFwd(base));
        if (mNoFwd(base).equals(base)) {
            continue;
        }
        if (res == null) {
            continue;
        }
        count += 1;
    }
    //mI need read to start. read return prevents fwd parameters
    assert count == 0;
    System.out.println(count);
}
Also used : MethodType(ast.Ast.MethodType) Test(org.junit.Test)

Example 42 with MethodType

use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.

the class Test212_or_170_MethodTypes method testMvpNoFwdSwap.

@Test
public void testMvpNoFwdSwap() {
    int countA = 0;
    int countB = 0;
    for (MethodType mt : dataSet) {
        MethodType base = mBase(mt);
        //test mVp(mNoFwd(mBase)) == mNoFwd(mVp(mBase))
        {
            MethodType v1 = _mVp(mNoFwd(base), 1);
            MethodType v2 = _mVp(base, 1);
            if (v2 != null) {
                v2 = mNoFwd(v2);
            }
            //v2 ok implies v1 ok
            assert v2 == null || v1 != null;
            //not assert v1==null ||v2!=null;//v1 ok imples v2 ok
            assert v2 == null || v1.equals(v2) : mtToS(v1) + " " + mtToS(v2);
            if (v1 != null && v2 != null) {
                countA += 1;
            }
        }
        {
            MethodType v1 = _mVp(mNoFwd(base), 2);
            MethodType v2 = _mVp(base, 2);
            if (v2 != null) {
                v2 = mNoFwd(v2);
            }
            //v2 ok implies v1 ok
            assert v2 == null || v1 != null;
            //not assert v1==null ||v2!=null;//v1 ok imples v2 ok
            assert v2 == null || v1.equals(v2) : mtToS(v1) + " " + mtToS(v2);
            if (v1 != null && v2 != null) {
                countB += 1;
            }
        }
    }
    System.out.println(countA);
    System.out.println(countB);
}
Also used : MethodType(ast.Ast.MethodType) Test(org.junit.Test)

Example 43 with MethodType

use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.

the class Test212_or_170_MethodTypes method recLeft.

MethodType recLeft(MethodType mt) {
    List<Type> newTs = mt.getTs().subList(1, mt.getTs().size());
    Mdf mdf = mt.getTs().get(0).getMdf();
    if (TypeManipulation.fwd_or_fwdP_in(mdf)) {
        return null;
    }
    return mt.withMdf(mdf).withTs(newTs);
}
Also used : Type(ast.Ast.Type) MethodType(ast.Ast.MethodType) Mdf(ast.Ast.Mdf)

Example 44 with MethodType

use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.

the class Test212_or_170_MethodTypes method test1.

@Test
public void test1() {
    assert dataSet.size() == 170 : dataSet.size();
    //Lent,ImmutableFwd->ImmutablePFwd
    Type _t = Path.Any().toImmNT();
    MethodType proto = new MethodType(true, Mdf.Capsule, Arrays.asList(_t.withMdf(Mdf.Mutable), _t.withMdf(Mdf.ImmutableFwd)), _t.withMdf(Mdf.ImmutablePFwd), Collections.emptyList());
    proto = _mVp(proto, 1);
    System.out.println(mtToS(proto));
}
Also used : MethodType(ast.Ast.MethodType) Type(ast.Ast.Type) MethodType(ast.Ast.MethodType) Test(org.junit.Test)

Example 45 with MethodType

use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.

the class Test212_or_170_MethodTypes method checkOne.

void checkOne(MethodType mt0, MethodType mt1) {
    List<MethodType> list0 = AlternativeMethodTypes.types(mt0);
    List<MethodType> list1 = AlternativeMethodTypes.types(mt1);
    for (MethodType mt1i : list1) {
        assert list0.stream().anyMatch(mt0i -> TypeSystem._methMdfTSubtype(mt0i, mt1i)) : "\n" + mtToS(mt0) + "\n" + mtToS(mt1) + "\n" + mtToS(mt1i) + "\n" + mtsToS(list0);
    }
}
Also used : MethodType(ast.Ast.MethodType)

Aggregations

MethodType (ast.Ast.MethodType)48 Type (ast.Ast.Type)32 MethodWithType (ast.ExpCore.ClassB.MethodWithType)25 Mdf (ast.Ast.Mdf)14 MethodSelector (ast.Ast.MethodSelector)14 ArrayList (java.util.ArrayList)14 Path (ast.Ast.Path)10 ExpCore (ast.ExpCore)9 List (java.util.List)9 Collections (java.util.Collections)8 Functions (auxiliaryGrammar.Functions)7 Test (org.junit.Test)7 Doc (ast.Ast.Doc)6 MethodWithType (ast.Expression.ClassB.MethodWithType)6 HashMap (java.util.HashMap)6 Program (programReduction.Program)6 Ast (ast.Ast)5 ClassB (ast.ExpCore.ClassB)5 Member (ast.ExpCore.ClassB.Member)5 Optional (java.util.Optional)5