private void CheckExpandMacro(String text, String[] expected, String message) { ProgramLine target = ProgramLine.Parse(text); IEnumerable <ProgramLine> result = target.ExpandMacro(); CheckProgramLines(result, expected, message); }
private void DoCheck(String[] sourceText, Boolean success, String message) { IEnumerable <ProgramLine> parsedLines = sourceText.Select((text) => ProgramLine.Parse(text)); try { ProgramChecker.Check(parsedLines); Assert.IsTrue(success, message); } catch (Casl2SimulatorException) { Assert.IsFalse(success, message); } }
private void CheckGenerateLiteralDc(String text, String expected, String message) { ProgramLine target = ProgramLine.Parse(text); LabelTable lblTable = new LabelTable(); ProgramLine generatedLine = target.GenerateLiteralDc(lblTable); if (generatedLine == null) { Assert.IsNull(expected, message); } else { String actual = generatedLine.Text; Assert.AreEqual(expected, actual, message); } }
public void SetLabelOffset() { ProgramLine instructionLine = ProgramLine.Parse("LBL001 LD GR1,GR2"); LabelTable lblTable = new LabelTable(); instructionLine.RegisterLabel(lblTable); MemoryOffset offsetSet = new MemoryOffset(0xABCD); instructionLine.SetLabelOffset(lblTable, offsetSet); LabelDefinition labelDef = lblTable.GetDefinitionFor(instructionLine.Label); MemoryOffset offsetGot = labelDef.RelOffset; MemoryOffsetTest.Check( offsetSet, offsetGot, "SetLabelOffset() で設定したラベルのオフセットが取得できる"); }
private void CheckParse( String text, Boolean success, Label expectedLabel, String expectedMnemonic, String message) { ProgramLine actual = ProgramLine.Parse(text); if (!success) { Assert.IsNotNull(actual.ErrorMessage, "ErrorMessage: " + message); Assert.IsNull(actual.Label, "Label: " + message); } else { Assert.IsNull(actual.ErrorMessage, "ErrorMessage: " + message); LabelTest.Check(expectedLabel, actual.Label, "Label: " + message); } CheckInstruction(actual, expectedMnemonic, "Instruction: " + message); }
public void GenerateCode() { ProgramLine instructionLine = ProgramLine.Parse(" LD GR1,GR2"); CheckGenerateCode( instructionLine, WordTest.MakeArray(0x1412), "命令行 => その命令のコードを生成する"); ProgramLine commentLine = ProgramLine.Parse("; コメント行"); CheckGenerateCode( commentLine, WordTest.MakeArray(), "コメント行 => コードを生成しない"); ProgramLine errorLine = ProgramLine.Parse(" 未定義命令"); CheckGenerateCode( errorLine, WordTest.MakeArray(), "エラー行 => コードを生成しない"); }