public void Build_Success() { Casl2Program subProgram = Casl2Program.MakeForUnitTest( "SUB", TestUtils.MakeArray( "ADDSUB START", " ADDA GR1,GR2", " RET", " END")); Casl2Program mainProgram = Casl2Program.MakeForUnitTest( "MAIN", TestUtils.MakeArray( "MAIN START", " CALL ADDSUB", " RET", " END")); Casl2Project project = Casl2Project.MakeForUnitTest(subProgram, mainProgram); project.Programs.SelectItem(mainProgram); MemoryAddress expectedLoadAddress = MemoryAddress.Zero; MemoryAddress expectedExecStartAddress = new MemoryAddress(2); Word[] expectedWords = WordTest.MakeArray( // Sub 0x2412, // ADDA GR1,GR2 0x8100, // RET // Main 0x8000, 0x0000, // CALL ADDSUB 0x8100); // RET ExecutableModule expected = new ExecutableModule(expectedLoadAddress, expectedExecStartAddress, expectedWords); CheckBuild(project, expected, "ビルド成功 => 実行可能モジュールが生成される"); }
public void Assemble_MachineInstructions_2x() { CheckGenerateCode( TestUtils.MakeArray( "ENTRY START", " ADDA GR7,#FEDC,GR6", " SUBA GR5,#BA98,GR4", " ADDL GR3,#7654,GR2", " SUBL GR1,#3210,GR7", " ADDA GR1,GR2", " SUBA GR3,GR4", " ADDL GR5,GR6", " SUBL GR7,GR1", " END"), WordTest.MakeArray( 0x2076, 0xFEDC, // ADDA r,adr,x 0x2154, 0xBA98, // SUBA r,adr,x 0x2232, 0x7654, // ADDL r,adr,x 0x2317, 0x3210, // SUBL r,adr,x 0x2412, // ADDA r1,r2 0x2534, // SUBA r1,r2 0x2656, // ADDL r1,r2 0x2771), // SUBL r1,r2 "オペコードが 2x の機械語命令"); }
private void CheckFetch(UInt16 expectedContents, UInt16 expectedPr, String message) { Word word = Fetcher.Fetch(m_pr, m_memory); WordTest.Check(word, expectedContents, "Contents: " + message); CpuRegisterTest.Check(m_pr, expectedPr, "PR: " + message); }
public void Execute() { Word[] program = WordTest.MakeArray( // 処理: GR1 中の '1' のビットの個数を数える。 // 出力: GR0: GR1 中の '1' のビットの個数。 0x1010, 0x000F, // 0000: LD GR1,DATA,0 ; 0x2522, // 0002: SUBA GR2,GR2 ; Count = 0 0x3411, // 0003: AND GR1,GR1 ; 全部のビットが '0'? 0x6300, 0x000D, // 0004: JZE RETURN ; 全部のビットが '0' なら終了 0x1222, 0x0001, // 0006: MORE LAD GR2,1,GR2 ; Count = Count + 1 0x1201, 0xffff, // 0008: LAD GR0,-1,GR1 ; 最下位の '1' のビット 1 個を 0x3410, // 000A: AND GR1,GR0 ; '0' に変える。 0x6200, 0x0006, // 000B: JNZ MORE ; '1' のビットが残っていれば繰返し 0x1402, // 000D: RETURN LD GR0,GR2 ; GR0 = Count 0x8100, // 000E: RET ; 呼び出しプログラムへ戻る。 0x1234 // 000F: DATA DC 0x1234 ; 0001 0010 0011 0100 => '1' は 5 つ ); ExecutableModule exeModule = new ExecutableModule(LoadAddress, StartAddress, program); CheckExecute(exeModule, true, "指定の実行可能モジュールを実行する"); const UInt16 Expected = 5; Word actualWord = m_cpu.RegisterSet.GR[0].Value; WordTest.Check(actualWord, Expected, "GR0: GR1 中の '1' のビットの個数"); }
public void GenerateCode() { Word[] expectedWords = WordTest.MakeArray(0x0000); ICodeGeneratorTest.CheckGenerateCode( m_target, expectedWords, "あどでラベルのアドレスに置き換えるために、値が 0x0000 の語が追加される"); }
private void CheckGenerateCode(Int32 value, UInt16 expected, String message) { HexaDecimalConstant target = new HexaDecimalConstant(value); Word[] expectedWords = WordTest.MakeArray(expected); ICodeGeneratorTest.CheckGenerateCode(target, expectedWords, message); }
public void Execute_UndefinedInstruction() { Word[] program = WordTest.MakeArray( 0xff00 // 未定義命令 ); CheckExecute(program, false, "未定義命令で例外が発生する"); }
public ActionResult DeleteConfirmed(int id) { WordTest wordTest = db.WordTests.Find(id); db.WordTests.Remove(wordTest); db.SaveChanges(); return(RedirectToAction("Index")); }
public void GenerateCode() { CheckGenerateCode( m_rAdrXOrR1R2_RAdrX, WordTest.MakeArray(0x1012, 0xabcd), "r,adr,x or r1,r2 で r,adr,x の場合: opcode=0x10, r/r1=1, x/r2=2, adr=0xabcd"); CheckGenerateCode( m_rAdrXOrR1R2_R1R2, WordTest.MakeArray(0x1434), "r,adr,x or r1,r2 で r1,r2 の場合: opcode=0x14, r/r1=3, x/r2=4, adr=なし"); }
private void CheckShiftResult( Alu.ShiftMethod shiftMethod, UInt16 ui16Val, UInt16 count, UInt16 expected, String message) { Word word1 = new Word(ui16Val); Word word2 = new Word(count); UInt16 notUsed; Word resultWord = shiftMethod(word1, word2, out notUsed); WordTest.Check(resultWord, expected, message); }
public void Add_Value() { const Int16 One = 1; const Int16 Two = 2; const Int16 Three = 3; CheckAdd_Value(One, WordTest.MakeArray(One), "1 語目"); CheckAdd_Value(Two, WordTest.MakeArray(One, Two), "2 語目"); CheckAdd_Value(Three, WordTest.MakeArray(One, Two, Three), "3 語目"); }
private void CheckArithmeticOp( Int16 i16Val1, Int16 i16Val2, Int16 expectedResult, Boolean expectedOverflow, String message) { Word word1 = new Word(i16Val1); Word word2 = new Word(i16Val2); Boolean actualOverflow; Word resultWord = m_operationMethodToTest(word1, word2, out actualOverflow); WordTest.Check(resultWord, expectedResult, "Result: " + message); Assert.AreEqual(expectedOverflow, actualOverflow, "Overflow: " + message); }
public void GenerateCode() { const UInt16 Adr = 0xABCD; RegisterOperand DontCareRegister = RegisterOperandTest.GR1; RAdrXOperand target = RAdrXOperand.MakeForUnitTest( DontCareRegister, AdrXOperand.MakeForUnitTest(new HexaDecimalConstant(Adr), DontCareRegister)); Word[] expectedWords = WordTest.MakeArray(Adr); ICodeGeneratorTest.CheckGenerateCode(target, expectedWords, "adr の値がコードとして生成される"); }
private Tests InsertWordTestToDB(WordTest wordTest) { var numQuestions = wordTest.TestQuestions.Count; var newTest = new Tests() { AuthorID = UsersService.currentUser.id, Name = wordTest.TestName, NumToPassFive = numQuestions, NumToPassFour = (int)Math.Round(numQuestions * 0.75), NumToPassThree = (int)Math.Round(numQuestions * 0.5, MidpointRounding.AwayFromZero), PassTime = wordTest.TestPassTime, QuestionTime = 0 }; MainClass.db.Tests.Add(newTest); MainClass.db.SaveChanges(); foreach (var q in wordTest.TestQuestions) { var newQuestion = new Questions() { Text = q.QuestionText, TestID = newTest.id }; MainClass.db.Questions.Add(newQuestion); MainClass.db.SaveChanges(); foreach (var op in q.OptionsList) { if (!op.Contains(" (+)")) { MainClass.db.Options.Add(new Models.Options() { QuestionID = newQuestion.id, Text = op, }); } else { var newAnswer = new Models.Options() { Text = op.Replace(" (+)", ""), QuestionID = newQuestion.id }; MainClass.db.Options.Add(newAnswer); MainClass.db.SaveChanges(); newQuestion.AnswerID = newAnswer.id; MainClass.db.SaveChanges(); } } } return(newTest); }
public void GenerateCode() { const UInt16 LabelPlaceHolder = 0x0000; ICodeGeneratorTest.CheckGenerateCode( m_constants, WordTest.MakeArray( DecimalValue, HexaDecimalValue, LabelPlaceHolder, AValue, BValue, CValue), "それぞれの Constant のコードが順に生成される"); }
public void Assemble_MachineInstructions_Fx() { CheckGenerateCode( TestUtils.MakeArray( "ENTRY START", " SVC #ABCD,GR3", " END"), WordTest.MakeArray( 0xF003, 0xABCD), // CALL adr,x "オペコードが Fx の機械語命令"); }
private void CheckReadWrite(UInt16 ui16Addr, Word wordWrite, String message) { // 書き込んだ語が読み出せること。 Word wordAddr = new Word(ui16Addr); m_memory.Write(wordAddr, wordWrite); Word wordRead = m_memory.Read(wordAddr); WordTest.Check(wordWrite, wordRead, message); }
public void Assemble_MachineInstructions_0x() { CheckGenerateCode( TestUtils.MakeArray( "ENTRY START", " NOP", " END"), WordTest.MakeArray( 0x0000), // NOP "オペコードが 0x の機械語命令"); }
private void CheckGenerateCode(Int32 wordCountValue, String message) { AsmDsInstruction target = MakeTarget(wordCountValue); const Label DefinedLabel = null; RelocatableModule relModule = new RelocatableModule(); target.GenerateCode(DefinedLabel, relModule); // 確保する語数分の 0 の語が追加される。 Word[] expectedWords = WordTest.MakeCountArray(Word.Zero, wordCountValue); RelocatableModuleTest.CheckWords(relModule, expectedWords, message); }
public ActionResult Edit([Bind(Include = "WordTestID,FWtestID,FWordID,Result,TImeSkip,TestAppearance")] WordTest wordTest) { if (ModelState.IsValid) { db.Entry(wordTest).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FWordID = new SelectList(db.Wordutopias, "WordID", "Word", wordTest.FWordID); ViewBag.FWtestID = new SelectList(db.WTests, "WTestID", "TNote", wordTest.FWtestID); return(View(wordTest)); }
public void Assemble_MachineInstructions_8x() { CheckGenerateCode( TestUtils.MakeArray( "ENTRY START", " CALL #9ABC,GR2", " RET", " END"), WordTest.MakeArray( 0x8002, 0x9ABC, // CALL adr,x 0x8100), // RET "オペコードが 8x の機械語命令"); }
public void Assemble_MachineInstructions_7x() { CheckGenerateCode( TestUtils.MakeArray( "ENTRY START", " PUSH #89AB,GR5", " POP GR6", " END"), WordTest.MakeArray( 0x7005, 0x89AB, // PUSH adr,x 0x7160), // POP r "オペコードが 7x の機械語命令"); }
public void Indexer_Value() { MemoryOffset Index = MemoryOffset.Zero; m_words.Add(Word.Zero); Word wordSet = new Word(0x1234); m_words[Index] = wordSet; Word wordGot = m_words[Index]; WordTest.Check(wordSet, wordGot, "設定した値が取得できる"); }
public void CheckRegister(UInt16 xR2Field, Boolean success, UInt16 expected, String message) { try { OperandHandler target = OperandHandler.Register; Word r2 = target.GetOperand(xR2Field, m_registerSet, m_memory); Assert.IsTrue(success, message); WordTest.Check(r2, expected, message); } catch (Casl2SimulatorException) { Assert.IsFalse(success, message); } }
// GET: WordTest/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WordTest wordTest = db.WordTests.Find(id); if (wordTest == null) { return(HttpNotFound()); } return(View(wordTest)); }
public void GenerateCode() { CheckGenerateCode( " !1Aa~", WordTest.MakeArray(0x0020, 0x0021, 0x0031, 0x0041, 0x0061, 0x007E), "間隔、記号、数字、英大文字、英小文字、7 ビットの最後の文字 '~'"); CheckGenerateCode( @"\¥", WordTest.MakeArray(0x005C, 0x005C), "バックスラッシュと円記号、JISX0201 だと どちらも 0x005C"); CheckGenerateCode( "。アァ", WordTest.MakeArray(0x00A1, 0x00B1, 0x00A7), "半角かな"); }
public void CheckEffectiveAddress(UInt16 xR2Field, Boolean success, UInt16 expected, String message) { m_registerSet.PR.Value = NextAddress; try { OperandHandler target = OperandHandler.EffectiveAddress; Word effectiveAddress = target.GetOperand(xR2Field, m_registerSet, m_memory); Assert.IsTrue(success, message); WordTest.Check(effectiveAddress, expected, message); } catch (Casl2SimulatorException) { Assert.IsFalse(success, message); } }
// GET: WordTest/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WordTest wordTest = db.WordTests.Find(id); if (wordTest == null) { return(HttpNotFound()); } ViewBag.FWordID = new SelectList(db.Wordutopias, "WordID", "Word", wordTest.FWordID); ViewBag.FWtestID = new SelectList(db.WTests, "WTestID", "TNote", wordTest.FWtestID); return(View(wordTest)); }
public void Assemble_MachineInstructions_4x() { CheckGenerateCode( TestUtils.MakeArray( "ENTRY START", " CPA GR0,#01EF,GR7", " CPL GR2,#23CD,GR5", " CPA GR1,GR6", " CPL GR3,GR4", " END"), WordTest.MakeArray( 0x4007, 0x01EF, // CPA r,adr,x 0x4125, 0x23CD, // CPL r,adr,x 0x4416, // CPA r1,r2 0x4534), // CPL r1,r2 "オペコードが 4x の機械語命令"); }
public void Assemble_MachineInstructions_5x() { CheckGenerateCode( TestUtils.MakeArray( "ENTRY START", " SLA GR7,#7654,GR6", " SRA GR5,#5432,GR4", " SLL GR3,#3210,GR2", " SRL GR1,#10FE,GR7", " END"), WordTest.MakeArray( 0x5076, 0x7654, // SLA r,adr,x 0x5154, 0x5432, // SRA r,adr,x 0x5232, 0x3210, // SLL r,adr,x 0x5317, 0x10FE), // SRL r,adr,x "オペコードが 5x の機械語命令"); }
// Use this for initialization void Start() { wordStatus = 1; WordCreat002 = GameObject.Find("WordCreat"); WTest002 = WordCreat002.GetComponent<WordTest>(); W_Timecount = GameObject.Find("TimeCount"); W_timetest = W_Timecount.GetComponent<TimeTest>(); ControlBridge = GameObject.Find("控制橋"); controlbar01 = ControlBridge.GetComponent<ControlBar>(); testWordChild = this.gameObject.GetComponentInChildren<testWordObj>(); }