From abd09764d492d4460b08f47e45555edc1ebafb3d Mon Sep 17 00:00:00 2001 From: Ryan Worcester Date: Sun, 17 Dec 2023 22:14:07 -0600 Subject: [PATCH 1/2] trimmed all trailing spaces --- README.md | 6 +++--- docs/getting-started.md | 10 +++++----- examples/tests/poc-tests.red | 2 +- src/modules/assertions.red | 14 +++++++------- src/modules/general.red | 6 +++--- src/modules/internal.red | 36 ++++++++++++++++++------------------ 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index c38b4f6..380c828 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # RedUnit -RedUnit is a free, open source **unit testing framework** for **Red** language. +RedUnit is a free, open source **unit testing framework** for **Red** language. Inspired by xUnit, nUnit, PhpUnit and other similar libraries. ### Motivation The main reason is the possibility to building your own projects faster and easier. -The TDD (test driven-development) approach is now possible using the **RedUnit** tool, so you can eliminate bad cases at the early stage. +The TDD (test driven-development) approach is now possible using the **RedUnit** tool, so you can eliminate bad cases at the early stage. -## Docs +## Docs * [Getting started](docs/getting-started.md) - usage, assertions and error handling diff --git a/docs/getting-started.md b/docs/getting-started.md index 871d1fa..1043609 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -11,7 +11,7 @@ Version: **0.0.3** Test framework for running tests of Red language scripts. Inspired by *PhpUnit*, *xUnit*, *nUnit* and other similar libraries. **RedUnit** expects that you will give him a filepath (`file!`) to Red script with `object!`, which will contain test methods. -Each test method name should be started with word `test`. +Each test method name should be started with word `test`. Optionally `setup` method will be executed before each test separately (only if `object!` consist method with name `setup`). @@ -165,7 +165,7 @@ redunit/run %tests/poc-tests.red Console output: ```bash -./red-063-linux -s examples/run-one-file.red +./red-063-linux -s examples/run-one-file.red ┌────────────────┐ │ RedUnit v0.0.3 │ └────────────────┘ @@ -203,7 +203,7 @@ FF...F...F ### Caused by assertions (example 1) ```bash -./red-063-linux examples/run-directory.red +./red-063-linux examples/run-directory.red ┌────────────────┐ │ RedUnit v0.0.3 │ └────────────────┘ @@ -250,11 +250,11 @@ Time: 84.951 ms │ File : tests/poc-tests.red │ Method : test-replace-unregistered-name -Runtime error detected, but there was not any assertion dedicated for expecting error. +Runtime error detected, but there was not any assertion dedicated for expecting error. *** User Error: "Can not replace an unregistered object" *** Where: do -*** Stack: rejoin first last cause-error +*** Stack: rejoin first last cause-error ┌─ ─┐ │ Status: Failure │ diff --git a/examples/tests/poc-tests.red b/examples/tests/poc-tests.red index f9eba85..c9c06b8 100644 --- a/examples/tests/poc-tests.red +++ b/examples/tests/poc-tests.red @@ -40,7 +40,7 @@ context [ "Registering not allowed types will throw an error" ] [ not-allowed-types: [ - "string" + "string" ["list"] 1234 email@address.com diff --git a/src/modules/assertions.red b/src/modules/assertions.red index 3ca02d7..33b1f28 100644 --- a/src/modules/assertions.red +++ b/src/modules/assertions.red @@ -11,7 +11,7 @@ Red [ context [ assertions-count: 0 - + increment-assertion: does [ assertions-count: assertions-count + 1 ] @@ -24,7 +24,7 @@ context [ assert-true: func [ "Value is true?" - value[logic!] + value[logic!] ] [ increment-assertion unless value [ @@ -35,7 +35,7 @@ context [ assert-false: func [ "Value is false?" - value[logic!] + value[logic!] ] [ increment-assertion if value [ @@ -50,7 +50,7 @@ context [ ] [ increment-assertion different-data: not (strict-equal? expected actual) - + if different-data [ message: "Expected equivalent values, but they are different." fail-test message "equals" @@ -63,7 +63,7 @@ context [ ] [ increment-assertion same-data: strict-equal? expected actual - + if same-data [ message: "Expected different values, but they are equivalent." fail-test message "not-equals" @@ -76,7 +76,7 @@ context [ ] [ increment-assertion different-memory-location: not (same? expected actual) - + if different-memory-location [ message: "Expected identical values, regarding memory location, but they are different." fail-test message "identical" @@ -89,7 +89,7 @@ context [ ] [ increment-assertion identical-memory-location: same? expected actual - + if identical-memory-location [ message: "Expected different values, regarding memory location, but they are identical." fail-test message "not-identical" diff --git a/src/modules/general.red b/src/modules/general.red index 705b21f..2c70dea 100644 --- a/src/modules/general.red +++ b/src/modules/general.red @@ -26,19 +26,19 @@ context [ print-summary comment { - CLI exit code for continuous integration + CLI exit code for continuous integration (0 - success, 1 - failure) } quit-when-errors ] - set-test-filename-prefix: func [ + set-test-filename-prefix: func [ text[string!] ] [ prefix: text ] - set-test-filename-postfix: func [ + set-test-filename-postfix: func [ text[string!] ] [ postfix: text diff --git a/src/modules/internal.red b/src/modules/internal.red index d0f7bea..030d98d 100644 --- a/src/modules/internal.red +++ b/src/modules/internal.red @@ -52,7 +52,7 @@ context [ testable: do code run-object testable - + ; revert boot directory change-dir boot-dir ] @@ -61,7 +61,7 @@ context [ testable[object!] ] [ process-testable-methods testable - + started: now/time/precise/utc foreach test tests [ @@ -81,7 +81,7 @@ context [ setup-detected: false tests: copy [] - methods: words-of testable + methods: words-of testable foreach method methods [ method-name: to string! method @@ -115,8 +115,8 @@ context [ errors-before: length? errors - was-error: none? attempt [ - result: try [do test] + was-error: none? attempt [ + result: try [do test] ] unless none? result [ @@ -139,14 +139,14 @@ context [ ] errors-after: length? errors - + print-last-test-status errors-before errors-after ] /local print-last-test-status: func [ errors-before[integer!] errors-after[integer!] ][ - ; Disable time for printing the console output + ; Disable time for printing the console output printing-started: now/time/precise/utc either errors-before <> errors-after [ @@ -207,10 +207,10 @@ context [ keys: reflect errors 'words foreach key keys [ prin rejoin [ - key - newline - select errors key - newline + key + newline + select errors key + newline newline ] ] @@ -219,7 +219,7 @@ context [ ] [ print-cornered-header "Status: Success" ] - + print-execution-time print-counters ] @@ -245,8 +245,8 @@ context [ steps: (length? header) space: "" - loop steps [ - space: rejoin [space space-char] + loop steps [ + space: rejoin [space space-char] ] prin rejoin [ @@ -261,8 +261,8 @@ context [ error-count: (length? errors) prin rejoin [ - length? tests " tests" - ", " assertions-count " assertions" + length? tests " tests" + ", " assertions-count " assertions" ] if (error-count > 0) [ @@ -274,7 +274,7 @@ context [ ] - ;-- Returns EXIT CODE 1 - when there were some failed tests + ;-- Returns EXIT CODE 1 - when there were some failed tests /local quit-when-errors: does [ if (length? errors) > 0 [ quit-return 1 @@ -333,7 +333,7 @@ context [ pre-length: length? prefix post-length: length? postfix - + if filename-length < (pre-length + post-length) [ return false ] From 13b93967834f2f8bea051164e497c2a8f0675460 Mon Sep 17 00:00:00 2001 From: Ryan Worcester Date: Sun, 17 Dec 2023 22:24:48 -0600 Subject: [PATCH 2/2] also spaced a brace --- src/modules/internal.red | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/internal.red b/src/modules/internal.red index 030d98d..011fa88 100644 --- a/src/modules/internal.red +++ b/src/modules/internal.red @@ -145,7 +145,7 @@ context [ /local print-last-test-status: func [ errors-before[integer!] errors-after[integer!] - ][ + ] [ ; Disable time for printing the console output printing-started: now/time/precise/utc