Minres / CoreDSL

Xtext project to parse CoreDSL files
Apache License 2.0
16 stars 3 forks source link

Analyzer Tests (Round 2) #78

Closed AtomCrafty closed 1 year ago

AtomCrafty commented 1 year ago

Implements a set of new test helpers and rewrites one of the existing test classes to use them. A test case using this framework looks like this:

'''
// test program code
'''
.testProgram()
.diagnosticsOnly() // optional
.expectError(IssueCodes.Error1)
.expectError(IssueCodes.Error2)
.expectWarning(IssueCodes.Warning1)
.run();

Notes:

AtomCrafty commented 1 year ago

Update: Added the option to specify the line number an issue is expected on and made the console output a bit nicer to look at.

========================================
      duplicateIsaStateElement1 2
========================================
 1| InstructionSet A {
 2|   architectural_state {
 3|     int x;
 4|   }
 5| }
 6| InstructionSet B extends A {
 7|   architectural_state {
 8|     int x;
 9|   }
10| }

Issues:
  WARNING: com.minres.coredsl.DuplicateIsaStateElement [line 6] (ISA parameter x has been declared multiple times (in A, B))
  ERROR: com.minres.coredsl.DuplicateIsaStateElement [line 8] (An identifier with the name x has already been declared)
Expected:
  WARNING: com.minres.coredsl.DuplicateIsaStateElement [line 6]
  ERROR: com.minres.coredsl.DuplicateIsaStateElement [line 8]