language tests should test error location reporting
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.2k
- Forks
- 272
- PR merge metrics
- No merged PRs in 30d
Description
a valuable and relative easy improvement to our language tests (in org.nlogo.headless.lang) would be to test that error locations (in the user's source code) are reported correctly
(currently we only whether an error occurs, and whether the text of the error message is right)
both compiler and runtime errors should be supported
currently it's possible to write such tests in Scala; there are a few examples in TestErrorMessage, with code like:
val ex = intercept[nvm.ArgumentTypeException] { ... }
assertResult(...)(ex.instruction.token.text.toUpperCase)
though that doesn't fully illustrate what I'm envisioning because:
- it requires writing Scala code.
- it's only checking that the
instructionslot in the EngineException is right
both points would be addressed if we added syntax for this to our external DSL for language tests. currently testing for an error looks like e.g.:
O> let a 5 ask patches [ let a 6 ] => COMPILER ERROR There is already a local variable here called A
we might surround the error location with curly brackets, so modifying the example as follows:
O> let a 5 ask patches [ let {a} 6 ] => COMPILER ERROR There is already a local variable here called A
would make the testing framework report that the second a (as identified by character positions) is the location of the error.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the language tests in org.nlogo.headless.lang and the Scala examples in TestErrorMessage, then inspect the external DSL used for lines such as => COMPILER ERROR. Define how marked source locations are represented and checked by character position, covering both compiler and runtime errors. Done means DSL tests report the expected error location without requiring handwritten Scala.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- compilers, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100