mani-language / Mani

Máni ... an awesome, super simple programming language!
https://mani-language.github.io/
Mozilla Public License 2.0
28 stars 7 forks source link

Added testing for error messages #92 #95

Closed Kalekdan closed 5 years ago

Kalekdan commented 5 years ago

Name: Tests for error messages About: Redirected all calls to System.out.err through a new function which will store the latest error message. This allows for testing that a specific error message was thrown

Is your PR related to a feature request or Bug report? If applicable, please list feature request number or bug report ID.

92

Describe your PR A clear and concise description of what your pull request is changing or adding.

Adds testing for error messages to assert they are thrown as expected

Describe intended use A clear and concise description of the intended use of the feature. Along with example code.

Whenever displaying an error message using System.err.println(errMsg), instead use Mani.printAndStoreError(errMsg). This will still print the error message but will also store the latest message so it can be verified by tests.

Is it in the form of a library

crazywolf132 commented 5 years ago

Looks good to me. Just one thing though.

Maybe we make another Exception class for general errors, or we leverage the already existing one? Maybe this could also be a way to stop using System.err.println? I don't know if it would work here or not. Just an idea.

Merge when ready.