mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-18 02:06:43 +00:00
More operand/dw tests (#228)
This commit is contained in:
parent
fe299fe061
commit
73dc9b1dca
@ -1,24 +0,0 @@
|
|||||||
package net.simon987.mar.server.assembly;
|
|
||||||
|
|
||||||
import net.simon987.mar.server.FakeConfiguration;
|
|
||||||
import net.simon987.mar.server.IServerConfiguration;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class DWTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestSemiColonInString() {
|
|
||||||
|
|
||||||
IServerConfiguration configuration = new FakeConfiguration();
|
|
||||||
|
|
||||||
configuration.setInt("memory_size", 1000);
|
|
||||||
configuration.setInt("org_offset", 400);
|
|
||||||
|
|
||||||
Assembler assembler = new Assembler(new DefaultInstructionSet(), new DefaultRegisterSet(), configuration);
|
|
||||||
|
|
||||||
AssemblyResult ar = assembler.parse("DW \";\"");
|
|
||||||
assertEquals(0, ar.exceptions.size());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,11 @@
|
|||||||
package net.simon987.mar.server.assembly;
|
package net.simon987.mar.server.assembly;
|
||||||
|
|
||||||
|
import net.simon987.mar.server.FakeConfiguration;
|
||||||
|
import net.simon987.mar.server.IServerConfiguration;
|
||||||
import net.simon987.mar.server.TestExecutionResult;
|
import net.simon987.mar.server.TestExecutionResult;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class DwDirectiveTest {
|
public class DwDirectiveTest {
|
||||||
@Test
|
@Test
|
||||||
@ -20,4 +21,42 @@ public class DwDirectiveTest {
|
|||||||
assertTrue(res.ar.exceptions.isEmpty());
|
assertTrue(res.ar.exceptions.isEmpty());
|
||||||
assertEquals('H', res.regValue("A"));
|
assertEquals('H', res.regValue("A"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void semiColonInString() {
|
||||||
|
String code = "DW \";\"";
|
||||||
|
|
||||||
|
TestExecutionResult res = TestHelper.executeCode(code);
|
||||||
|
|
||||||
|
assertTrue(res.ar.exceptions.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nullEscape() {
|
||||||
|
String code = "DW \"\\0\\0\"";
|
||||||
|
|
||||||
|
TestExecutionResult res = TestHelper.executeCode(code);
|
||||||
|
|
||||||
|
assertTrue(res.ar.exceptions.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void unicode1() {
|
||||||
|
String code = "DW \"\\u0123\"";
|
||||||
|
|
||||||
|
TestExecutionResult res = TestHelper.executeCode(code);
|
||||||
|
|
||||||
|
assertTrue(res.ar.exceptions.isEmpty());
|
||||||
|
assertEquals(0x0123 ,res.memValue(res.ar.origin));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void escapeQuote() {
|
||||||
|
String code = "DW \"\\\"\"";
|
||||||
|
|
||||||
|
TestExecutionResult res = TestHelper.executeCode(code);
|
||||||
|
|
||||||
|
assertTrue(res.ar.exceptions.isEmpty());
|
||||||
|
assertEquals('"' ,res.memValue(res.ar.origin));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,4 +150,20 @@ public class OperandTest {
|
|||||||
try{ new Operand("[A+A+]", labels, registerSet, 0); } catch (InvalidOperandException ignored){}
|
try{ new Operand("[A+A+]", labels, registerSet, 0); } catch (InvalidOperandException ignored){}
|
||||||
try{ new Operand("[A+[1]]", labels, registerSet, 0); } catch (InvalidOperandException ignored){}
|
try{ new Operand("[A+[1]]", labels, registerSet, 0); } catch (InvalidOperandException ignored){}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void octalLiteral() throws Exception {
|
||||||
|
Operand op = new Operand("0600", new HashMap<>(), new DefaultRegisterSet(), 0);
|
||||||
|
assertEquals(OperandType.IMMEDIATE16, op.getType());
|
||||||
|
assertEquals(Operand.IMMEDIATE_VALUE, op.getValue());
|
||||||
|
assertEquals(384, op.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void binaryLiteral() throws Exception {
|
||||||
|
Operand op = new Operand("0b1000", new HashMap<>(), new DefaultRegisterSet(), 0);
|
||||||
|
assertEquals(OperandType.IMMEDIATE16, op.getType());
|
||||||
|
assertEquals(Operand.IMMEDIATE_VALUE, op.getValue());
|
||||||
|
assertEquals(0b1000, op.getData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user