git @ Cat's Eye Technologies GraNoLa-M / 21d0cb9
Add test driver. Three passing tests in a Falderal test suite. Cat's Eye Technologies 8 years ago
8 changed file(s) with 25 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
1313 You need an Erlang compiler at least at language version 4.4 to compile
1414 `granolam.erl`. This program was developed with OTP/R8B, so that is the
1515 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.)
1717
1818 To build the `granolam` module, run the script `make.sh`.
1919
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`.
2226
2327 To run the built-in test cases, start an Erlang shell and run
2428
0 #!/bin/sh
1
2 THIS=`realpath $0`
3 escript `dirname $THIS`/../src/granolam.erl $*
119119 * `bejadoz` - input a graph (in GraNoLa/M syntax) and push it on the stack
120120
121121 Tests
122 -----
122123
123124 -> 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"
125126
126127 -> Tests for functionality "Interpret GraNoLa/M Program"
127128
129 Here are some tests. They all loop infinitely, so we only look at the
130 first 60 bytes of output.
131
128132 | a=^#cthulhu(b=^uwaming(^a))
129 = ??
133 = ^cthulhu ^cthulhu ^cthulhu ^cthulhu ^cthulhu ^cthulhu ^cthul
130134
131135 | a=^whebong(b=^uwaming(^a))
132 = ??
136 = a=^whebong(b=^uwaming(^a)) a=^whebong(b=^uwaming(^a)) a=^whe
133137
134138 | a=^0hello(b=^@hello(c=^taug(d=^uwaming(^a))))
135 = ??
139 = embed=stack(hello())() embed=hello(hello())() embed=hello(he
136140
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
30 -module(granolam).
41 -vsn('2002.0314'). % This work is a part of the public domain.
52
117114 %% Script Interface ------------------------------------------------------
118115
119116 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)).