Search in sources :

Example 76 with Property

use of com.pholser.junit.quickcheck.Property in project emuRox by rossdrew.

the class Mos6502CompilerTest method testIndirectYInstructions.

@Property
public void testIndirectYInstructions(@InRange(min = "0", max = "255") int byteValue) {
    final String hexByte = Integer.toHexString(byteValue);
    OpCode.streamOf(AddressingMode.INDIRECT_Y).forEach((opcode) -> {
        final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " (" + VALUE_PREFIX + hexByte + "),Y");
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        assertArrayEquals(new int[] { opcode.getByteValue(), byteValue }, bytes);
    });
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Property(com.pholser.junit.quickcheck.Property)

Example 77 with Property

use of com.pholser.junit.quickcheck.Property in project emuRox by rossdrew.

the class Mos6502Properties method testValidStartup.

@Property(trials = 100)
public void testValidStartup(@InRange(min = "0", max = "255") int memHi, @InRange(min = "0", max = "255") int memLo) {
    memory = new SimpleMemory();
    memory.setByteAt(0xFFFC, memHi);
    memory.setByteAt(0xFFFD, memLo);
    processor = new Mos6502(memory);
    processor.reset();
    Registers registers = processor.getRegisters();
    // PC Set to location pointed to by mem[FFFC:FFFD]
    assertEquals(memHi, registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI));
    // ...
    assertEquals(memLo, registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW));
    // Status flags reset
    assertEquals(0x34, registers.getRegister(Registers.Register.STATUS_FLAGS));
    // Stack Pointer at top of stack
    assertEquals(0xFF, registers.getRegister(Registers.Register.STACK_POINTER_HI));
    // All cleared
    assertEquals(0, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(0, registers.getRegister(Registers.Register.X_INDEX));
    assertEquals(0, registers.getRegister(Registers.Register.Y_INDEX));
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Property(com.pholser.junit.quickcheck.Property)

Example 78 with Property

use of com.pholser.junit.quickcheck.Property in project emuRox by rossdrew.

the class Mos6502Properties method testValidImmediateADC.

@Property(trials = 100)
public void testValidImmediateADC(@InRange(min = "0", max = "255") int value) {
    Program program = new Program().with(LDA_I, value);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step();
    Registers registers = processor.getRegisters();
    assertEquals(value, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(program.getLength(), registers.getPC());
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Property(com.pholser.junit.quickcheck.Property)

Example 79 with Property

use of com.pholser.junit.quickcheck.Property in project beam by apache.

the class AvroUtilsTest method avroToBeamRoundTrip.

@Property(trials = 1000)
@SuppressWarnings("unchecked")
public void avroToBeamRoundTrip(@From(RecordSchemaGenerator.class) org.apache.avro.Schema avroSchema) {
    Schema schema = AvroUtils.toBeamSchema(avroSchema);
    Iterable iterable = new RandomData(avroSchema, 10);
    List<GenericRecord> records = Lists.newArrayList((Iterable<GenericRecord>) iterable);
    for (GenericRecord record : records) {
        Row row = AvroUtils.toBeamRowStrict(record, schema);
        GenericRecord out = AvroUtils.toGenericRecord(row, avroSchema);
        assertEquals(record, out);
    }
}
Also used : RandomData(org.apache.avro.RandomData) Schema(org.apache.beam.sdk.schemas.Schema) Row(org.apache.beam.sdk.values.Row) GenericRecord(org.apache.avro.generic.GenericRecord) Property(com.pholser.junit.quickcheck.Property)

Example 80 with Property

use of com.pholser.junit.quickcheck.Property in project beam by apache.

the class AvroUtilsTest method supportsAnyAvroSchema.

@Property(trials = 1000)
@SuppressWarnings("unchecked")
public void supportsAnyAvroSchema(@From(RecordSchemaGenerator.class) org.apache.avro.Schema avroSchema) {
    Schema schema = AvroUtils.toBeamSchema(avroSchema);
    Iterable iterable = new RandomData(avroSchema, 10);
    List<GenericRecord> records = Lists.newArrayList((Iterable<GenericRecord>) iterable);
    for (GenericRecord record : records) {
        AvroUtils.toBeamRowStrict(record, schema);
    }
}
Also used : RandomData(org.apache.avro.RandomData) Schema(org.apache.beam.sdk.schemas.Schema) GenericRecord(org.apache.avro.generic.GenericRecord) Property(com.pholser.junit.quickcheck.Property)

Aggregations

Property (com.pholser.junit.quickcheck.Property)82 Matchers.hasProperty (org.hamcrest.Matchers.hasProperty)15 Program (com.rox.emu.processor.mos6502.util.Program)12 Role (ai.grakn.concept.Role)11 Label (ai.grakn.concept.Label)10 MetaSchema.isMetaLabel (ai.grakn.util.Schema.MetaSchema.isMetaLabel)10 Mos6502Compiler (com.rox.emu.processor.mos6502.util.Mos6502Compiler)10 SchemaConcept (ai.grakn.concept.SchemaConcept)9 RelationshipType (ai.grakn.concept.RelationshipType)8 AttributeType (ai.grakn.concept.AttributeType)7 VarProperty (ai.grakn.graql.admin.VarProperty)5 Ignore (org.junit.Ignore)5 Relationship (ai.grakn.concept.Relationship)4 Calendar (java.util.Calendar)4 Schema (org.apache.beam.sdk.schemas.Schema)4 ConceptId (ai.grakn.concept.ConceptId)3 Entity (ai.grakn.concept.Entity)3 EntityType (ai.grakn.concept.EntityType)3 Type (ai.grakn.concept.Type)3 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)3