-
Notifications
You must be signed in to change notification settings - Fork 215
Create test-word.factor #2484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Create test-word.factor #2484
Conversation
was unsure as to where to put it, so I put it in |
Just out of curiosity, what is your use case for this? It looks similar to the interface for writing unit tests in a way. |
Yeah, I agree it’s similar to a unit test but not quite. It could be used
as a building block for property testing if factor supported that.
Right now it’s just a useful tool that I often use when writing words.
Here’s another [example], I have 5 different implementations of `xor` and
want to make sure they all work as expected. So I generate all possible
inputs with `all-selections` and then use `test-word` on the different
implementations.
[example]:
https://forward-lang.github.io/forward/blog/X-VHDL-forth.html#_test_script
```
{ f t } 2 all-selections
[ xor1 ] test-word .
```
…On Thu, 12 Aug 2021 at 20:06, timor ***@***.***> wrote:
Just out of curiosity, what is your use case for this? It looks similar to
the interface for writing unit tests in a way.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2484 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATPZO7KKKM7XR4XJ45D5CC3T4QEQPANCNFSM5CBIAPZA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Maybe this should be added to the test vocab then? |
Well... perhaps, if that’s ok with you :)
…On Thu, 12 Aug 2021 at 21:24, timor ***@***.***> wrote:
Maybe this should be added to the test vocab then?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2484 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATPZO7MRPWOEWCDHA5AM5DTT4QNVNANCNFSM5CBIAPZA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
If it doesn’t test, we shouldn’t call it test-word, but I’m not opposed to
more words that are useful for people.
…On Thu, Aug 12, 2021 at 12:25 PM Bruno-366 ***@***.***> wrote:
Well... perhaps, if that’s ok with you :)
On Thu, 12 Aug 2021 at 21:24, timor ***@***.***> wrote:
> Maybe this should be added to the test vocab then?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#2484 (comment)>, or
> unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/ATPZO7MRPWOEWCDHA5AM5DTT4QNVNANCNFSM5CBIAPZA
>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <
https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675
>
> or Android
> <
https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email
>
> .
>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2484 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF5A736IMQKW3UEGBPPELT4QN27ANCNFSM5CBIAPZA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Yeah it doesn’t test in the conventional sense that it compares with an
expected output, but I couldn’t come up with a better name haha
On Thu, 12 Aug 2021 at 21:29, John Benediktsson ***@***.***>
wrote:
… If it doesn’t test, we shouldn’t call it test-word, but I’m not opposed to
more words that are useful for people.
On Thu, Aug 12, 2021 at 12:25 PM Bruno-366 ***@***.***> wrote:
> Well... perhaps, if that’s ok with you :)
>
> On Thu, 12 Aug 2021 at 21:24, timor ***@***.***> wrote:
>
> > Maybe this should be added to the test vocab then?
> >
> > —
> > You are receiving this because you authored the thread.
> > Reply to this email directly, view it on GitHub
> > <#2484 (comment)>,
or
> > unsubscribe
> > <
>
https://github.com/notifications/unsubscribe-auth/ATPZO7MRPWOEWCDHA5AM5DTT4QNVNANCNFSM5CBIAPZA
> >
> > .
> > Triage notifications on the go with GitHub Mobile for iOS
> > <
>
https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675
> >
> > or Android
> > <
>
https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email
> >
> > .
> >
>
> —
>
>
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#2484 (comment)>, or
> unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAAF5A736IMQKW3UEGBPPELT4QN27ANCNFSM5CBIAPZA
>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <
https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675
>
> or Android
> <
https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email
>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2484 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATPZO7MF5A7LKMGEIACUEIDT4QOIZANCNFSM5CBIAPZA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Ah sorry. I was under the impression that you use it for unit testing in the end. |
I'm going to add one more word that I wrote some time ago, its a bit similar. |
The help still has "before-word" but the actual word is "before-after". To me, this is a good tool for visualizing results when you don't really know what you want and are exploring (otherwise, unit tests are superior because they are silent when they work and check results) |
Yeah that actually sounds good.
I’m going to try to see if I can implement some kind of property testing
using the stack-checker
<https://docs.factorcode.org/content/vocab-stack-checker.html> and perhaps
math.combinatorics
<https://docs.factorcode.org/content/vocab-math.combinatorics.html>.
The idea is to generate a decent subset of the inputs a word could possibly
accept.
I think the usefulness of gather-results would increase by a lot then.
…On Fri, 13 Aug 2021 at 09:43, Jon Harper ***@***.***> wrote:
The help still has "before-word" but the actual word is "before-after".
What about "visualize-results" or "gather-results" instead of "test-word" ?
And "gather-intermediates" for "before-after" ?
To me, this is a good tool for visualizing results when you don't really
know what you want and are exploring (otherwise, unit tests are superior
because they are silent when they work and check results)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2484 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATPZO7K6FNGCHNIAQ4JQ45DT4TEKVANCNFSM5CBIAPZA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Hmm, the property-based testing seems to be harder than I expected. [ xor ] infer in>> length I can use the above to figure out if a word is unary, binary or ternary (ie how many inputs it takes). { 1 2 3 4 5 } 1 all-selections . ! for unary number words
{ 1 2 3 4 5 } 2 all-selections . ! for binary number words There's three obstacles I don't know how to solve:
{ 0 "a" } 2 all-selections So the above problem was how to generate possible inputs, while taking into account situations where stack order matters
[ xor ] infer in>> ! outputs an array containing the strings "x" "x" "x" could be anything, not necessarily a number, and I think this has to do with the fact that factor is dynamically typed.
Summary: my guess is that from the stack effect of a word, there isn't an easy way to generate possible inputs for that word, |
Could you replace "quote" with "quotation" in the documentation? |
these seem to be extension of
|
@razetime sounds good to me! |
description:
Executes a quote with inputs, preserving inputs and outputs
Takes a quote and a seq containing inputs for the quote
Returns a seq containing the inputs as well as any produced output
Useful for checking the behaviour of words under different inputs
example:
output: