Skip to content

Conversation

@SkySpiral7
Copy link

Hey I found your repo for testing Red. It's simple and does what I want but is outdated and has a bug. This repo is abandoned but I'm contributing changes for the sake of others. This PR has no functional change and it's purpose is to reach out to see if you'll allow some changes (and also there shouldn't be trailing spaces, I mean honestly).

In addition to this PR my fork has a few more changes:

  • Bug fix: fixed test count when running a dir
  • Feature: assert-equals prints values when fails

Which are in their own branches if you want to have tiny PRs. Or you could just merge my master to your master. I haven't tagged anything. I also noticed that you have a redundant branch named "develop".

In the mean time I'll be trying to figure out how to update RedUnit to the latest version of Red.

@SkySpiral7
Copy link
Author

SkySpiral7 commented Jan 4, 2024

I'm done with all my updates on my fork. Each potential PR has its own branch:

  • formatting: this current PR
  • fixTestCount: bug I mentioned above. In you repo's master when a directory is run it shows the wrong test count.
  • showFailEqualValues: feature I mentioned above. When assert-equals fails it will now print out both types and values to make it easier to see what's wrong.
  • recentRed: is compatible with a more recent version of red. Tested with red-13jan24-4b95ca192 which is the current latest.
  • startsWithTest: test methods MUST now start with "test". Doc was updated with stronger wording to reflect this. This enforces a standard which reduces methods accidentally being run as tests.
  • macroSupport: tests are now allowed to use macros (such as #include). This change is a work around for a red bug: do string should execute macros (like do file does) red/red#5464 if that is fixed then this change won't be needed (but doesn't hurt).
  • master: has all the above changes

My commit history of these could be cleaned up: each of the branches are expecting a certain order rather than stand alone. I can rewrite history on request but my repo meets my needs.

@SkySpiral7
Copy link
Author

I guess I'm using this PR for a change log of how my fork has diverged.

New feature branch named handleAll: setup/tests can't kill the runner. Mark a failure instead.

Here's my raw notes dump on why the old version wasn't working and why mine does.

old:
do can throw or cause-error or return. return can be value, none, error, or unset
try converts error into return and thus can be either throw or return. return can be value, none, error, or unset
result won't set if throw
result can be return's value/error/none but unset causes error
attempt converts error into return and thus can be either throw or return. return can be value or none
so here's every possible flow:
test throws, try throws, result: unset, attempt throws, was-error: unset, everything dies from throw
   was-error: none? attempt [result: try [do "throw 5"]]
   throws => (unset? :was-error) and (unset? :result)
   limitation: it should instead handle this
test cause-error, try returns error, result: error, attempt returns error, was-error: false
   was-error: none? attempt [result: try [do "/"]]
   returns => (not was-error) and (error? result)
   bug: was-error should be true
test returns value/error, try returns value/error, result: value/error, attempt returns value/error, was-error: false
   was-error: none? attempt [result: try [do "5"]]
   returns => (not was-error) and (result == 5)
   correct
test returns unset, try returns unset, result: unset which cause-error, attempt returns none, was-error: true, everything dies when checking result
   was-error: none? attempt [result: try [do "unset 'a"]]
   returns => was-error and (unset? :result)
   bug: should handle this
test returns none, try returns none, result: none, attempt returns none, was-error: true
   was-error: none? attempt [result: try [do "none"]]
   returns => was-error and (none? :result)
   ~correct: was-error should be false. only currently "works" because of weird unless check

mine:
do can throw or cause-error or return. return can be value, none, error, or unset
do's return is ignored. if it returned then the block returns none
try/all converts throw and cause-error into return (as error)
result can only be none or error
was-error is true if do threw or cause-error. was-error is false if do returned at all
so here's every possible flow:
test throws, try converts to error, result: error, was-error: true
   was-error: error? result: try/all[do "throw 5" none]
   returns => was-error and (error? result)
   correct
test cause-error, try converts to error, result: error, was-error: true
   was-error: error? result: try/all[do "/" none]
   returns => was-error and (error? result)
   correct
test returns value/error, try returns none, result: none, was-error: false
   was-error: error? result: try/all[do "5" none]
   returns => (not was-error) and (none? result)
   correct
test returns unset, try returns none, result: none, was-error: false
   was-error: error? result: try/all[do "unset 'a" none]
   returns => (not was-error) and (none? result)
   correct
test returns none, try returns none, result: none, was-error: false
   was-error: error? result: try/all[do "none" none]
   returns => (not was-error) and (none? result)
   correct

(included in master branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant