Skip to content
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

Provide a crate::test::testcase() function for internal use #83

Open
phorward opened this issue Oct 26, 2022 · 2 comments
Open

Provide a crate::test::testcase() function for internal use #83

phorward opened this issue Oct 26, 2022 · 2 comments
Labels
help wanted Extra attention is needed tests

Comments

@phorward
Copy link
Member

phorward commented Oct 26, 2022

The existing function crate::test::testcase() is a great way to express tests, because a test-case can be expressed as one source file having 3 sections:

'Hello' _ Word
#---
#Hello World Hello Mars
#---
#("World, "Mars")

There are 2 to 3 sections separated by #---:

  1. Is the Tokay input source
  2. Is the input provided, or the expected output
  3. Is the expected output when input is provided

Currently, this implementation runs tokay in a separate process and modifies stdin, stdout and stderr to feed input. It would be nicer to let this work like crate::utils::run() which runs a program on a given source, but with redirected input and output.

@phorward phorward added help wanted Extra attention is needed tests labels Oct 26, 2022
@phorward
Copy link
Member Author

Playground for a possible solution: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1bee6b3dc7140e4b1a20e50c4c44bf7f

The &mut dyn io::Write must become part of Context or Runtime.

phorward added a commit to phorward/tokay that referenced this issue Nov 8, 2022
@phorward
Copy link
Member Author

Relates to #86

phorward added a commit that referenced this issue Nov 30, 2022
* Removing output/error from Runtime and Compiler

Intention is to solve #83 differently.

* Improving test::testcase() function

- Allows for direct code exposal
- Improved error reporting in assert_eq!()

* tests()-test runs all testcases in folder "tests/"

* testcase() using repl-mode

* test_expressions.tok with testmode:repl usage

* Some docs and testcase testcase ;-)

* Improving testcase

- Count and report line numbers
- Trim result lines

* Starting separated, topic-based tests

* Starting test substitution by test cases

* Fixing assignment operatins in brackets

* Substituting tests for assig-ops by testcase

* Tests for inline increment/decrement

* Renaming testcases and removing testcase calls

* Separating sequence tests, glob filter tests

* Adding prelude tests

* Improving testcase(), replacing whitespace test

* Moving unescaping tests into testcase

* Moving error test into testcase

* Substituting further tests from test.rs

* Replacing dict-tests by tests/dict.tok testcase

* Converting token_modifiers test into testcase

* Substitute language test-cases from test.rs

This is a nice milestone on the test conversion; Now only the builtin-tests are available in their particular modules.

* Moving list tests into list.tok testcase

* Moving str tests into str.tok testcase

* Rewrote token tests and fixed bug

Bug with pluralized character-classes, e.g. AsciiAlphabetics wasn't found, but Alphabetics due incomplete type distinguishing.

* Rewrote parselet testcases / ParseletRef::repr()

* Moving all remaining tests to separate testcases

* First version of tokay_tests!() macro

Macro generates [test]-functions from testcases in tests/*.tok which are evaluating during a `cargo test` run similar to the tests before.

Removed the `tests()` function with similar use-case but not running in parallel as well.

* Moving testcase to utils

* Removed bug #87 bypass in test `captures.tok`
@phorward phorward added the tokay label Feb 15, 2023
@phorward phorward removed the tokay label Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed tests
Projects
None yet
Development

No branches or pull requests

1 participant