Search in sources :

Example 1 with Sequence

use of de.prob.translator.types.Sequence in project probparsers by bendisposto.

the class TestTranslator method testTranslateEmptySequence.

@Test
public void testTranslateEmptySequence() throws Exception {
    Sequence s = (Sequence) Translator.translate("[]");
    assertTrue(s.size() == 0);
}
Also used : Sequence(de.prob.translator.types.Sequence) Test(org.junit.Test)

Example 2 with Sequence

use of de.prob.translator.types.Sequence in project probparsers by bendisposto.

the class TranslatingVisitor method caseASequenceExtensionExpression.

@Override
public void caseASequenceExtensionExpression(ASequenceExtensionExpression node) {
    List<BObject> s = new ArrayList<BObject>();
    for (PExpression e : node.getExpression()) {
        e.apply(this);
        s.add(this.getResult());
    }
    this.setResult(new Sequence(s));
}
Also used : BObject(de.prob.translator.types.BObject) ArrayList(java.util.ArrayList) Sequence(de.prob.translator.types.Sequence) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 3 with Sequence

use of de.prob.translator.types.Sequence in project probparsers by bendisposto.

the class TestTranslator method testTranslateSequence.

@Test
public void testTranslateSequence() throws Exception {
    Sequence s = (Sequence) Translator.translate("[1,2,3]");
    assertTrue(s.size() == 3);
    for (int i = 1; i <= s.size(); i++) {
        assertTrue(s.get(i).equals(Number.build("" + (i))));
    }
}
Also used : Sequence(de.prob.translator.types.Sequence) Test(org.junit.Test)

Example 4 with Sequence

use of de.prob.translator.types.Sequence in project probparsers by bendisposto.

the class TestTranslator method testTranslateRecordWithSequenceValues.

@Test
public void testTranslateRecordWithSequenceValues() throws Exception {
    Record o = (Record) Translator.translate("rec(key1:[1,2,3])");
    Sequence a = (Sequence) o.get("key1");
    assertTrue(a.contains(Number.build(1)));
}
Also used : Record(de.prob.translator.types.Record) Sequence(de.prob.translator.types.Sequence) Test(org.junit.Test)

Aggregations

Sequence (de.prob.translator.types.Sequence)4 Test (org.junit.Test)3 PExpression (de.be4.classicalb.core.parser.node.PExpression)1 BObject (de.prob.translator.types.BObject)1 Record (de.prob.translator.types.Record)1 ArrayList (java.util.ArrayList)1