An open API service indexing awesome lists of open source software.

https://github.com/rickbarretto/artcism

{Art}cism is an Exercism runner for the Arturo Programming Language
https://github.com/rickbarretto/artcism

arturo arturo-language arturo-package exercism learning learning-by-doing

Last synced: 3 months ago
JSON representation

{Art}cism is an Exercism runner for the Arturo Programming Language

Awesome Lists containing this project

README

          


{Art}cism


{Art}cism is an Exercism runner for the

Arturo Programming language




Arturo logo
Arturo logo

## Trying {Art}cism

**Installation**

```
arturo -p install artcism
```

**Running**

```
artcism
```

### Testing code

A real example of tests:

```art
import {artcism}!

describe "simple append" [

it "will fail" [
expects.be: 'equal? [[a] [b]]
]

it "keeps the order" [
concat: debug.fmt: "Debugging: |value|" [a] ++ [b c d]
expects [equal? [a b c d] concat]
]
]

suite "append `:string`s" [

it "results in :string" [
expects.be: 'string? @[to :literal "Art" ++ "uro"]
]

it ":char appending results in :string" [
expects.be: 'string? @['H' ++ 'i' ]
]

it "works with :char" [
expects.be: 'equal? @["Artur" ++ "o" "Artur" ++ 'o']
]

test "Arturo can be generated from :string and :char appending" [
assert.with: 'equal? @["Arturo" "Art" ++ "uro"]
]
]

describe "append magic-method" [

define :container [
init: method [ initial ][ this\_block: [] ++ initial ]
append: method [ value ][ append this\_block value ]
]

it "should work for magic-methods" [
container: to :container [[]]!

expects.be: 'equal? @[[1 2] do -> container\append [1 2]]
]

]
```

This will show you:

```json
{
"version": 2,
"status": "fail",
"tests": [
{
"name": "will fail",
"status": "fail",
"message": "[equal? [a] [b]]",
"output": "",
"test_code": "[\n expects\n .be:\n 'equal?\n [\n [\n a\n ]\n [\n b\n ]\n ]\n]\n"
},
{
"name": "keeps the order",
"status": "pass",
"message": "[equal? [a b c d] concat]",
"output": "Debugging: [a b c d] :block\n",
"test_code": "[\n concat:\n debug\n .fmt:\n \"Debugging: |value|\"\n [\n a\n ]\n ++\n [\n b\n c\n d\n ]\n expects\n [\n equal?\n [\n a\n b\n c\n d\n ]\n concat\n ]\n]\n"
},
{
"name": "results in :string",
"status": "fail",
"message": "[string? 'Arturo]",
"output": "",
"test_code": "[\n expects\n .be:\n 'string?\n @\n [\n to\n :literal\n \"Art\"\n ++\n \"uro\"\n ]\n]\n"
},
{
"name": ":char appending results in :string",
"status": "pass",
"message": "[string? \"Hi\"]",
"output": "",
"test_code": "[\n expects\n .be:\n 'string?\n @\n [\n 'H'\n ++\n 'i'\n ]\n]\n"
},
{
"name": "works with :char",
"status": "pass",
"message": "[equal? \"Arturo\" \"Arturo\"]",
"output": "",
"test_code": "[\n expects\n .be:\n 'equal?\n @\n [\n \"Artur\"\n ++\n \"o\"\n \"Artur\"\n ++\n 'o'\n ]\n]\n"
},
{
"name": "Arturo can be generated from :string and :char appending",
"status": "pass",
"message": "[equal? \"Arturo\" \"Arturo\"]",
"output": "",
"test_code": "[\n assert\n .with:\n 'equal?\n @\n [\n \"Arturo\"\n \"Art\"\n ++\n \"uro\"\n ]\n]\n"
},
{
"name": "should work for magic-methods",
"status": "pass",
"message": "[equal? [1 2] [1 2]]",
"output": "",
"test_code": "[\n container:\n to\n :container\n [\n [\n\n ]\n ]\n !\n expects\n .be:\n 'equal?\n @\n [\n [\n 1\n 2\n ]\n do\n ->\n container\\append\n [\n 1\n 2\n ]\n ]\n]\n"
}
]
}
```

## Documentation

### *Compatibility*

{Art}cism has syntax compatibility with [`unitt`](unitt.pkgr.art) and uses it behind the scenes, but artcism is not fully compatible with `unitt`.

{Art}cism was intented to be used for single files, with single assertions tests and no terminal output at all.

This is not mean to be used for CI/CD Actions neither as unit-test library, use `unitt` instead for those purposes. Any `unitt`'s output is cleared after calling `artcism`.

### *Rpec-ish API*

- `describe: $[description :string tests :block]`:
Groups tests around some feature.
- `it: $[description :string, testCase :block]`:
The test case itself, you need to pass a clear description to it,
And the logic that you're trying to assert.
- `.skip :logical`:
Skips tests for some condition.
Will just skip if no condition is provided.
- `expects: $[condition :block]`:
A function that is only available inside the `it`/`test` case,
makes an assertion given the `condition`.
- `.to :literal` (or `.be`)
Uses some function to evaluate the statement.
This helps to show the function name on display,
instead of a `true`/`false`.

### *XUnit-ish API*

- `test: $[description :string, testCase :block]`:
The same as `it`.
- `.skip :logical`
- `assert: $[condition :block]`:
The same as `expects`
- `.with`
The same as `.to` and `.be`
- `suite: $[description :string tests :block]`:
The same as `describe`.

> [!WARNING]
> Never import this lib as `.lean`, or this will break the current code. This happens due to the nature of Arturo (being concatenative), and the way we importings are working right now. This may change in future.