use of de.prob.translator.types.Record in project probparsers by bendisposto.
the class TestTranslator method testTranslateRecordWithSetValues.
@Test
public void testTranslateRecordWithSetValues() throws Exception {
Record o = (Record) Translator.translate("rec(key1:{1,2,3}, key2:{a,b})");
Set a = (Set) o.get("key1");
assertTrue(a.contains(Number.build(1)));
}
use of de.prob.translator.types.Record in project probparsers by bendisposto.
the class TestTranslator method testTranslateRecord.
@Test
public void testTranslateRecord() throws Exception {
Record o = (Record) Translator.translate("rec(key1:1, key2:2)");
assertTrue(o.containsKey("key1"));
assertTrue(o.containsKey("key2"));
assertFalse(o.containsKey("key3"));
}
use of de.prob.translator.types.Record 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)));
}
use of de.prob.translator.types.Record in project probparsers by bendisposto.
the class TranslatingVisitor method caseARecExpression.
@Override
public void caseARecExpression(ARecExpression node) {
Map<java.lang.String, BObject> s = Record.newStorage();
// TODO or make the record immutable after filling it
for (PRecEntry e : node.getEntries()) {
e.apply(this);
RecordEntry entry = (RecordEntry) this.getResult();
s.put(entry.getKey().getValue(), entry.getValue());
}
this.setResult(new Record(s));
}
Aggregations