Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/juandac/monty_test


https://github.com/juandac/monty_test

Last synced: about 7 hours ago
JSON representation

Awesome Lists containing this project

README

        

# Test for monty
> Unit test for monty project

## Install

1. Clone the repo inside your project.
```console
git clone https://github.com/JuanDAC/monty_test.git
```

## Create a new unittest
The unittest is compose by 2 files, and `*.m` file and
`expected-*` output.

The first must be in the root directory in the path `bytecodes/.m`
and the second must be in the `test/expected-out/expected-`

the code and the output must have the same name. But the first one with the
suffix `.m` and the second one with the prefix `expected-`

### Example
for the demo file `000.m` the expected file must be `expected-000`
and the path distributions must be
```console
foo@bar[monty]$ tree .
.
├── bytecodes
│   ├── 000.m <- Monty code 000.m
│   └── README.md
├── main.c
├── makefile
├── monty.h
├── README.md
└── test
├── expected-out
│   └── expected-000 <- Expected output for 000.m
├── makefile
├── README.md
├── test <- compilated program
├── test-all <- script-for-unit-tests
└── tmp
└── stdout-000 <- temporal-file-for-000.m
...
```

## How to use

* Move to the folder.
```
cd monty_test
```

There are 2 ways to run the test-all script. The first one
is without arguments

### Run without args
```console
foo@bar$ ./test-all
NO ARGS
NO ARGS
0-add.m: OK
0-comments.m: OK
0-div.m: OK
0-mul.m: OK
0-nop.m: OK
0-pchar.m: FAILED.
0-pint.m: OK
```

r { color: Red }
m { color: Magenta }
g { color: Green }

It will show the files and the status code.

- OK: Expected result.
- FAILED: It is not the expected result.
- NO_REF: There is no file to be compared.

If the output and the expected are equals the code should
be OK

If the output and the expected are diferents. The code
should be FAILED.

If the expected is not found The code sould be NO_REF.

### Run with args
If you run the command with a `` as argument
the script will search this file in the bytecode folder
and show
- `ARGS` in the first line
- The file name and the test code in the second line
- A horizonal line
- _`[GOT]`_ output of the `` througt your program
- The *Output* of program
- _`[EXPECTED]`_
- Expected output

```console
foo@bar$ ./test-all 2-pupa.m
ARGS
2-pupa.m: OK
------------------
[GOT]
3
2
1
[EXPECTED]
3
2
1
------------------
```