Search in sources :

Example 41 with Property

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

the class Mos6502CompilerTest method testZeroPageYInstructions.

@Property
public void testZeroPageYInstructions(@InRange(min = "0", max = "255") int byteValue) {
    final String hexByte = Integer.toHexString(byteValue);
    OpCode.streamOf(AddressingMode.ZERO_PAGE_Y).forEach((opcode) -> {
        final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " " + VALUE_PREFIX + hexByte + ",Y");
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        assertArrayEquals("Output for '" + opcode.toString() + "' was wrong.", 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 42 with Property

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

the class Mos6502CompilerTest method testAbsoluteXInstructions.

@Property
public void testAbsoluteXInstructions(@InRange(min = "256", max = "65535") int wordValue) {
    final String hexWord = Integer.toHexString(wordValue);
    final int highByte = (wordValue >> 8) & 0xFF;
    final int lowByte = wordValue & 0xFF;
    OpCode.streamOf(AddressingMode.ABSOLUTE_X).forEach((opcode) -> {
        final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " " + VALUE_PREFIX + hexWord + ",X");
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        assertArrayEquals("Output for '" + opcode.toString() + " 0x" + hexWord + "' was wrong.", new int[] { opcode.getByteValue(), highByte, lowByte }, 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 43 with Property

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

the class Mos6502CompilerTest method testIndirectXInstructions.

@Property
public void testIndirectXInstructions(@InRange(min = "0", max = "255") int byteValue) {
    final String hexByte = Integer.toHexString(byteValue);
    OpCode.streamOf(AddressingMode.INDIRECT_X).forEach((opcode) -> {
        final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " (" + VALUE_PREFIX + hexByte + ",X)");
        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 44 with Property

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

the class Mos6502Properties method testInvalidImmediateADC.

@Property(trials = 100)
public void testInvalidImmediateADC(@When(satisfies = "#_ < 0 || #_ > 255") int value) {
    Program program = new Program().with(LDA_I, value);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step();
    Registers registers = processor.getRegisters();
    assertNotEquals(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 45 with Property

use of com.pholser.junit.quickcheck.Property in project MaterialDateTimePicker by wdullaer.

the class DefaultDateRangeLimiterPropertyTest method setToNearestShouldBeInSelectableDays.

@Property
public void setToNearestShouldBeInSelectableDays(@InRange(min = "01/01/1900", max = "12/31/2099", format = "MM/dd/yyyy") Date date, @InRange(min = "01/01/1900", max = "12/31/2099", format = "MM/dd/yyyy") Date[] dates) {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();
    Calendar day = Calendar.getInstance();
    day.setTime(date);
    Calendar[] selectables = datesToCalendars(dates);
    limiter.setSelectableDays(selectables);
    // selectableDays are manipulated a bit by the limiter
    selectables = limiter.getSelectableDays();
    // selectables == null when the input is empty
    if (selectables == null)
        Assert.assertEquals(day.getTimeInMillis(), limiter.setToNearestDate(day).getTimeInMillis());
    else
        Assert.assertTrue(Arrays.asList(selectables).contains(limiter.setToNearestDate(day)));
}
Also used : Calendar(java.util.Calendar) 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