Add test driver. Three passing tests in a Falderal test suite.
Cat's Eye Technologies
8 years ago
13 | 13 |
You need an Erlang compiler at least at language version 4.4 to compile
|
14 | 14 |
`granolam.erl`. This program was developed with OTP/R8B, so that is the
|
15 | 15 |
recommended platform for using it, although more recent versions should
|
16 | |
work as well.
|
|
16 |
work as well. (It has recently been tested with R17.)
|
17 | 17 |
|
18 | 18 |
To build the `granolam` module, run the script `make.sh`.
|
19 | 19 |
|
20 | |
After the module is built, run the script `granolam` in the `bin` directory
|
21 | |
to start a GraNoLa/M shell.
|
|
20 |
After the module is built, run the script `granolam_shell` in the `bin`
|
|
21 |
directory to start a GraNoLa/M shell.
|
|
22 |
|
|
23 |
Or you can run `bin/granolam` _filename_ to run a GraNoLa/M program
|
|
24 |
written in a text file on the filesystem. This uses `escript`, so you
|
|
25 |
don't have to build the module first. But you need `realpath`.
|
22 | 26 |
|
23 | 27 |
To run the built-in test cases, start an Erlang shell and run
|
24 | 28 |
|
|
0 |
#!/bin/sh
|
|
1 |
|
|
2 |
THIS=`realpath $0`
|
|
3 |
escript `dirname $THIS`/../src/granolam.erl $*
|
119 | 119 |
* `bejadoz` - input a graph (in GraNoLa/M syntax) and push it on the stack
|
120 | 120 |
|
121 | 121 |
Tests
|
|
122 |
-----
|
122 | 123 |
|
123 | 124 |
-> Functionality "Interpret GraNoLa/M Program" is implemented by
|
124 | |
-> shell command "bin/granolam %(test-body-file)"
|
|
125 |
-> shell command "bin/granolam %(test-body-file) | head --bytes=60"
|
125 | 126 |
|
126 | 127 |
-> Tests for functionality "Interpret GraNoLa/M Program"
|
127 | 128 |
|
|
129 |
Here are some tests. They all loop infinitely, so we only look at the
|
|
130 |
first 60 bytes of output.
|
|
131 |
|
128 | 132 |
| a=^#cthulhu(b=^uwaming(^a))
|
129 | |
= ??
|
|
133 |
= ^cthulhu ^cthulhu ^cthulhu ^cthulhu ^cthulhu ^cthulhu ^cthul
|
130 | 134 |
|
131 | 135 |
| a=^whebong(b=^uwaming(^a))
|
132 | |
= ??
|
|
136 |
= a=^whebong(b=^uwaming(^a)) a=^whebong(b=^uwaming(^a)) a=^whe
|
133 | 137 |
|
134 | 138 |
| a=^0hello(b=^@hello(c=^taug(d=^uwaming(^a))))
|
135 | |
= ??
|
|
139 |
= embed=stack(hello())() embed=hello(hello())() embed=hello(he
|
136 | 140 |
|
137 | |
| a=^1hello(b=^uwaming(end=() hello=(world())))
|
138 | |
= ??
|
139 | |
|
140 | |
| a=^sajalom(b=^#d(c=^bimodang(^a))
|
141 | |
= ??
|
142 | |
|
143 | |
| d(e=^#sakura(f=^uwaming(g=^ubewic()))))
|
144 | |
= ??
|
145 | |
|
146 | |
| a=^sajalom(b=^bejadoz(c=^soduv(^a d())))
|
147 | |
= ??
|
|
141 |
The other tests in the suite in the code don't seem to work. Pity.
|
|
0 |
a=^#cthulhu(b=^uwaming(^a))
|
|
0 |
a=^whebong(b=^uwaming(^a))
|
|
0 |
a=^0hello(b=^@hello(c=^taug(d=^uwaming(^a))))
|
|
0 |
a=^1hello(b=^uwaming(end=() hello=(world())))
|
0 | |
#!/usr/bin/env escript
|
1 | |
%% -*- erlang -*-
|
2 | |
|
3 | 0 |
-module(granolam).
|
4 | 1 |
-vsn('2002.0314'). % This work is a part of the public domain.
|
5 | 2 |
|
|
117 | 114 |
%% Script Interface ------------------------------------------------------
|
118 | 115 |
|
119 | 116 |
main([N]) ->
|
120 | |
{ok, b} = file:read_file(N),run(binary_to_list(b)).
|
|
117 |
{ok,B} = file:read_file(N),run(binary_to_list(B)).
|