Skip to content

Commit

Permalink
Working on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Eforen committed May 21, 2023
1 parent eb0b520 commit 24da206
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
11 changes: 10 additions & 1 deletion KANBAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [Done 02/25/2023](#done-02252023)
- [Done 2023/03/08](#done-20230308)
- [Done 2023/05/20](#done-20230520)
- [Done 2023/05/21](#done-20230521)
- [Next Commit (Eforen)](#next-commit-eforen)
- [Working On](#working-on)
- [Working on (Eforen)](#working-on-eforen)
Expand Down Expand Up @@ -57,7 +58,6 @@
* [KUICK][PARSER] Write Test for J Type Instruction `JAL`
* [KUICK][PARSER] Rewrite tests to take in string and output AST
## Done 2023/05/20
### Next Commit (Eforen)
* [KUICK][PARSER] Implement Pseudo Instruction: `nop`
* [KUICK][PARSER] Implement Pseudo Instruction: `neg`
* [KUICK][PARSER] Implement Pseudo Instruction: `seqz`
Expand All @@ -71,9 +71,18 @@
* [KUICK][PARSER] Implement Pseudo Instruction: `bltz`
* [KUICK][PARSER] Implement Pseudo Instruction: `bgtz`

## Done 2023/05/21
### Next Commit (Eforen)

# Working On
## Working on (Eforen)
* [KIUCK][PARSER] Implement Pseudo Instructions
* [KIUCK][PARSER][TEST] Pseudo Instruction `beqz`
* [KIUCK][PARSER][TEST] Pseudo Instruction `bnez`
* [KIUCK][PARSER][TEST] Pseudo Instruction `blez`
* [KIUCK][PARSER][TEST] Pseudo Instruction `bgez`
* [KIUCK][PARSER][TEST] Pseudo Instruction `bltz`
* [KIUCK][PARSER][TEST] Pseudo Instruction `bgtz`
* [KANBAN][KIUCK][PARSER] Add Tasks for remaining Pseudo Instruction implementations
* Confirm that all the tests for the previous Pseudo Instruction implementations exist (Rushed atm)

Expand Down
51 changes: 48 additions & 3 deletions src/Kore.Kuick.Tests/Parser/TestPsudoInstructions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,62 @@ namespace Kore.Kuick.Tests.Parser {
class TestPsudoInstructions {

// Test Pseudo Instructions in code generator.
/*
* [KUICK][PARSER] Implement Pseudo Instruction: `nop`
* [KUICK][PARSER] Implement Pseudo Instruction: `neg`
* [KUICK][PARSER] Implement Pseudo Instruction: `snez`
* [KUICK][PARSER] Implement Pseudo Instruction: `sltz`
* [KUICK][PARSER] Implement Pseudo Instruction: `sgtz`
* [KUICK][PARSER] Implement Pseudo Instruction: `beqz`
* [KUICK][PARSER] Implement Pseudo Instruction: `bnez`
* [KUICK][PARSER] Implement Pseudo Instruction: `blez`
* [KUICK][PARSER] Implement Pseudo Instruction: `bgez`
* [KUICK][PARSER] Implement Pseudo Instruction: `bltz`
* [KUICK][PARSER] Implement Pseudo Instruction: `bgtz`
* [KUICK][PARSER] Implement Pseudo Instruction: `seqz`
*/
[Test]
[TestCase("nop", "addi x0, x0, 0", "No operation")]
[TestCase("neg x1, x2", "sub x1, x0, x2", "Two's complement negation")]
[TestCase("neg x2, x1", "sub x2, x0, x1", "Two's complement negation")]
[TestCase("neg x3, x3", "sub x3, x0, x3", "Two's complement negation")]
[TestCase("negw x1, x2", "subw x1, x0, x2", "Two's complement word negation")]
[TestCase("negw x2, x1", "subw x2, x0, x1", "Two's complement word negation")]
[TestCase("negw x3, x3", "subw x3, x0, x3", "Two's complement word negation")]
// TODO: RV64I
// [TestCase("negw x1, x2", "subw x1, x0, x2", "Two's complement word negation")]
// [TestCase("negw x2, x1", "subw x2, x0, x1", "Two's complement word negation")]
// [TestCase("negw x3, x3", "subw x3, x0, x3", "Two's complement word negation")]
///////////////////////////////////////////////////////////////////////////////
[TestCase("snez x1, x2", "sltu x1, x0, x2", "Set if not equal zero")]
[TestCase("snez x2, x1", "sltu x2, x0, x1", "Set if not equal zero")]
[TestCase("snez x3, x3", "sltu x3, x0, x3", "Set if not equal zero")]
[TestCase("sltz x1, x2", "slt x1, x2, x0", "Set if less than zero")]
[TestCase("sltz x2, x1", "slt x2, x1, x0", "Set if less than zero")]
[TestCase("sltz x3, x3", "slt x3, x3, x0", "Set if less than zero")]
[TestCase("sgtz x1, x2", "slt x1, x0, x2", "Set if greater than zero")]
[TestCase("sgtz x2, x1", "slt x2, x0, x1", "Set if greater than zero")]
[TestCase("sgtz x3, x3", "slt x3, x0, x3", "Set if greater than zero")]
///////////////////////////////////////////////////////////////////////////////
[TestCase("beqz x1, 0x00000003", "beq x1, x0, 0x00000003", "Branch if equal zero")]
[TestCase("beqz x2, 0x00000002", "beq x2, x0, 0x00000002", "Branch if equal zero")]
[TestCase("beqz x3, 0x00000001", "beq x3, x0, 0x00000001", "Branch if equal zero")]
[TestCase("bnez x1, 0x00000003", "bne x1, x0, 0x00000003", "Branch if not equal zero")]
[TestCase("bnez x2, 0x00000002", "bne x2, x0, 0x00000002", "Branch if not equal zero")]
[TestCase("bnez x3, 0x00000001", "bne x3, x0, 0x00000001", "Branch if not equal zero")]
[TestCase("blez x1, 0x00000003", "bge x0, x1, 0x00000003", "Branch if less than or equal zero")]
[TestCase("blez x2, 0x00000002", "bge x0, x2, 0x00000002", "Branch if less than or equal zero")]
[TestCase("blez x3, 0x00000001", "bge x0, x3, 0x00000001", "Branch if less than or equal zero")]
[TestCase("bgez x1, 0x00000003", "bge x1, x0, 0x00000003", "Branch if greater than or equal zero")]
[TestCase("bgez x2, 0x00000002", "bge x2, x0, 0x00000002", "Branch if greater than or equal zero")]
[TestCase("bgez x3, 0x00000001", "bge x3, x0, 0x00000001", "Branch if greater than or equal zero")]
[TestCase("bltz x1, 0x00000003", "blt x1, x0, 0x00000003", "Branch if less than zero")]
[TestCase("bltz x2, 0x00000002", "blt x2, x0, 0x00000002", "Branch if less than zero")]
[TestCase("bltz x3, 0x00000001", "blt x0, x3, 0x00000001", "Branch if less than zero")]
[TestCase("bgtz x1, 0x00000003", "blt x0, x1, 0x00000003", "Branch if greater than zero")]
[TestCase("bgtz x2, 0x00000002", "blt x0, x2, 0x00000002", "Branch if greater than zero")]
///////////////////////////////////////////////////////////////////////////////

public void PseudoInstructions(string pseudoInstruction, string trueInstruction, string description) {

// Setup the lexer and parse the input into tokens
Expand Down

0 comments on commit 24da206

Please sign in to comment.