Merge pull request #223 from wasamasa/better-elisp-eval
[jackhill/mal.git] / README.md
CommitLineData
60154d24
JM
1# mal - Make a Lisp
2
f9e6bb80
JM
3[![Build Status](https://travis-ci.org/kanaka/mal.svg?branch=master)](https://travis-ci.org/kanaka/mal)
4
bcddc3e4
JM
5## Description
6
27696157 7Mal is a Clojure inspired Lisp interpreter.
b76aa73b 8
a7081401 9Mal is implemented in 55 languages:
bcddc3e4 10
6faafa00 11* Ada
8c7587af 12* GNU awk
edc3b064 13* Bash shell
bcddc3e4 14* C
73fc9366 15* C++
edc3b064
JM
16* C#
17* Clojure
891c3f3b 18* CoffeeScript
6c4dede1 19* Crystal
f82cb965 20* D
bb526975 21* Elixir
e0b7f668 22* Emacs Lisp
2cc3804b 23* Erlang
88e934b6 24* ES6 (ECMAScript 6 / ECMAScript 2015)
6f78381f 25* F#
0fe47e88 26* Factor
96032890 27* Forth
1771ab50 28* Go
7ab0f63e 29* Groovy
7c6882f2 30* GNU Guile
b76aa73b 31* Haskell
33dec7af 32* Haxe
61f69fba 33* Io
bcddc3e4 34* Java
39381792
JM
35* JavaScript ([Online Demo](http://kanaka.github.io/mal))
36* Julia
53c2ea70 37* Kotlin
9d42904e 38* Lua
bcddc3e4
JM
39* GNU Make
40* mal itself
8a9d0a8a 41* MATLAB
1218ce98 42* [miniMAL](https://github.com/kanaka/miniMAL)
a2cd0a3a 43* Nim
0067158f 44* Object Pascal
7cae6e6f 45* Objective C
bc6448bc 46* OCaml
6301e0b6 47* Perl
a7081401 48* Perl 6
edc3b064 49* PHP
b88bb764
JM
50* PL/pgSQL (Postgres)
51* PL/SQL (Oracle)
edc3b064
JM
52* Postscript
53* Python
23e38cd2 54* RPython
9b3362e8 55* R
f5223195 56* Racket
8adb0827 57* Ruby
abdd56eb 58* Rust
821930db 59* Scala
8b142f08 60* Swift
ea1395aa 61* Swift 3
54d9903c 62* Tcl
36e91db4 63* VHDL
50a964ce 64* Vimscript
ee7cd585 65* Visual Basic.NET
bcddc3e4
JM
66
67
bd08422d
JM
68Mal is a learning tool. See the [make-a-lisp process
69guide](process/guide.md). Each implementation of mal is separated into
7011 incremental, self-contained (and testable) steps that demonstrate
71core concepts of Lisp. The last step is capable of self-hosting
72(running the mal implementation of mal).
bcddc3e4
JM
73
74The mal (make a lisp) steps are:
75
0f4ca9d1
JM
76* [step0_repl](process/guide.md#step0)
77* [step1_read_print](process/guide.md#step1)
78* [step2_eval](process/guide.md#step2)
79* [step3_env](process/guide.md#step3)
80* [step4_if_fn_do](process/guide.md#step4)
81* [step5_tco](process/guide.md#step5)
82* [step6_file](process/guide.md#step6)
83* [step7_quote](process/guide.md#step7)
84* [step8_macros](process/guide.md#step8)
85* [step9_try](process/guide.md#step9)
90f618cb 86* [stepA_mal](process/guide.md#stepA)
bcddc3e4
JM
87
88
89Mal was presented publicly for the first time in a lightning talk at
90Clojure West 2014 (unfortunately there is no video). See
dede32ba
JM
91examples/clojurewest2014.mal for the presentation that was given at the
92conference (yes the presentation is a mal program). At Midwest.io
932015, Joel Martin gave a presentation on Mal titled "Achievement
94Unlocked: A Better Path to Language Learning".
95[Video](https://www.youtube.com/watch?v=lgyOAiRtZGw),
96[Slides](http://kanaka.github.io/midwest.io.mal/).
60154d24 97
144f2b6a 98If you are interesting in creating a mal implementation (or just
bd62ff74 99interested in using mal for something), please drop by the #mal
144f2b6a
JM
100channel on freenode. In addition to the [make-a-lisp process
101guide](process/guide.md) there is also a [mal/make-a-lisp
102FAQ](docs/FAQ.md) where I attempt to answer some common questions.
103
60154d24
JM
104## Building/running implementations
105
5b207de7
JM
106The simplest way to run any given implementation is to use docker.
107Every implementation has a docker image pre-built with language
108dependencies installed. You can launch the REPL using a convenience
109target in the top level Makefile (where IMPL is the implementation
110directory name and stepX is the step to run):
111
112```
113make DOCKERIZE=1 "repl^IMPL^stepX"
114 # OR stepA is the default step:
115make DOCKERIZE=1 "repl^IMPL"
116```
117
118
6faafa00
CM
119### Ada
120
7b458a65
JM
121*The Ada implementation was created by [Chris Moore](https://github.com/zmower)*
122
123The Ada implementation was developed with GNAT 4.9 on debian. It also
124compiles unchanged on windows if you have windows versions of git,
125GNAT and (optionally) make. There are no external dependencies
126(readline not implemented).
6faafa00
CM
127
128```
129cd ada
130make
131./stepX_YYY
132```
133
8c7587af
MK
134### GNU awk
135
4c58cd4e 136*The GNU awk implementation was created by [Miutsuru kariya](https://github.com/kariya-mitsuru)*
390d5829 137
8c7587af
MK
138The GNU awk implementation of mal has been tested with GNU awk 4.1.1.
139
140```
141cd gawk
142gawk -O -f stepX_YYY.awk
143```
144
bcddc3e4 145### Bash 4
60154d24
JM
146
147```
148cd bash
149bash stepX_YYY.sh
150```
151
bcddc3e4 152### C
60154d24 153
01c97316 154The C implementation of mal requires the following libraries (lib and
6b3ecaa7
DM
155header packages): glib, libffi6, libgc, and either the libedit or GNU readline
156library.
54c75382 157
60154d24
JM
158```
159cd c
160make
161./stepX_YYY
162```
163
73fc9366
JM
164### C++
165
a848d783
JM
166*The C++ implementation was created by [Stephen Thirlwall (sdt)](https://github.com/sdt)*
167
73fc9366
JM
168The C++ implementation of mal requires g++-4.9 or clang++-3.5 and
169a readline compatible library to build. See the `cpp/README.md` for
170more details:
171
172```
173cd cpp
174make
175 # OR
176make CXX=clang++-3.5
177./stepX_YYY
178```
179
180
9b1563a3 181### C# ###
edc3b064
JM
182
183The C# implementation of mal has been tested on Linux using the Mono
184C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are
185required to build and run the C# implementation.
186
187```
188cd cs
189make
ee7cd585 190mono ./stepX_YYY.exe
edc3b064
JM
191```
192
193
bcddc3e4 194### Clojure
60154d24 195
aa716df6
JM
196For the most part the Clojure implementation requires Clojure 1.5,
197however, to pass all tests, Clojure 1.8.0-RC4 is required.
198
60154d24
JM
199```
200cd clojure
201lein with-profile +stepX trampoline run
202```
203
891c3f3b
JM
204### CoffeeScript
205
206```
207sudo npm install -g coffee-script
208cd coffee
209coffee ./stepX_YYY
210```
211
58b84dd5 212### Crystal
213
6427adea 214*The Crystal implementation of mal was created by [Linda_pp](https://github.com/rhysd)*
6c4dede1 215
492144ce 216The Crystal implementation of mal has been tested with Crystal 0.17.4.
6c4dede1 217
58b84dd5 218```
219cd crystal
220crystal run ./stepX_YYY.cr
6c4dede1
JM
221 # OR
222make # needed to run tests
223./stepX_YYY
58b84dd5 224```
225
f82cb965
DM
226### D
227
228*The D implementation was created by [Dov Murik](https://github.com/dubek)*
229
230The D implementation of mal was tested with GDC 4.8. It requires the GNU
231readline library.
232
233```
234cd d
235make
236./stepX_YYY
237```
238
e0b7f668
VS
239### Emacs Lisp
240
241*The Emacs Lisp implementation was created by [Vasilij Schneidermann](https://github.com/wasamasa)*
242
243The Emacs Lisp implementation of mal has been tested with Emacs 24.3
244and 24.5. While there is very basic readline editing (`<backspace>`
245and `C-d` work, `C-c` cancels the process), it is recommended to use
246`rlwrap`.
247
248```
249cd elisp
250emacs -Q --batch --load stepX_YYY.el
251# with full readline support
252rlwrap emacs -Q --batch --load stepX_YYY.el
253```
254
bb526975 255### Elixir
256
257*The Elixir implementation was created by [Martin Ek (ekmartin)](https://github.com/ekmartin)*
258
259The Elixir implementation of mal has been tested with Elixir 1.0.5.
260
261```
262cd elixir
df2ca97b 263mix stepX_YYY
264# Or with readline/line editing functionality:
bb526975 265iex -S mix stepX_YYY
266```
267
2cc3804b
NF
268### Erlang
269
425ef3d7
JM
270*The Erlang implementation was created by [Nathan Fiedler (nlfiedler)](https://github.com/nlfiedler)*
271
82484631
JM
272The Erlang implementation of mal requires [Erlang/OTP R17](http://www.erlang.org/download.html)
273and [rebar](https://github.com/rebar/rebar) to build.
2cc3804b
NF
274
275```
276cd erlang
425ef3d7
JM
277make
278 # OR
279MAL_STEP=stepX_YYY rebar compile escriptize # build individual step
2cc3804b
NF
280./stepX_YYY
281```
282
88e934b6
JM
283### ES6 (ECMAScript 6 / ECMAScript 2015)
284
285The ES6 implementation uses the [babel](https://babeljs.io) compiler
286to generate ES5 compatible JavaScript. The generated code has been
287tested with Node 0.12.4.
288
289```
290cd es6
291make
292node build/stepX_YYY.js
293```
294
295
6f78381f
PS
296### F# ###
297
298*The F# implementation was created by [Peter Stephens (pstephens)](https://github.com/pstephens)*
299
300The F# implementation of mal has been tested on Linux using the Mono
301F# compiler (fsharpc) and the Mono runtime (version 3.12.1). The mono C#
206a1657 302compiler (mcs) is also necessary to compile the readline dependency. All are
6f78381f
PS
303required to build and run the F# implementation.
304
305```
306cd fsharp
307make
308mono ./stepX_YYY.exe
309```
310
5a53c643
JL
311### Factor
312
44c8a524 313*The Factor implementation was created by [Jordan Lewis (jordanlewis)](https://github.com/jordanlewis)*
5a53c643 314
0fe47e88 315The Factor implementation of mal has been tested with Factor 0.97
07eb827b 316([factorcode.org](http://factorcode.org)).
0fe47e88 317
5a53c643
JL
318```
319cd factor
199b1ce7 320FACTOR_ROOTS=. factor -run=stepX_YYY
5a53c643
JL
321```
322
96032890
C
323### Forth
324
a848d783
JM
325*The Forth implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
326
96032890
C
327```
328cd forth
329gforth stepX_YYY.fs
330```
331
1771ab50
JM
332### Go
333
0fe47e88 334The Go implementation of mal requires that go is installed on on the
fd888612
JM
335path. The implementation has been tested with Go 1.3.1.
336
1771ab50
JM
337```
338cd go
339make
340./stepX_YYY
341```
342
343
7ab0f63e
JM
344### Groovy
345
346The Groovy implementation of mal requires Groovy to run and has been
347tested with Groovy 1.8.6.
348
349```
350cd groovy
351make
352groovy ./stepX_YYY.groovy
353```
354
5a9cda80
JM
355### GNU Guile 2.1+
356
357*The Guile implementation was created by [Mu Lei (NalaGinrut)](https://github.com/NalaGinrut).*
358
359```
360cd guile
361guile -L ./ stepX_YYY.scm
362```
7ab0f63e 363
b76aa73b
JM
364### Haskell
365
2988d38e 366Install the Haskell compiler (ghc/ghci), the Haskell platform and
5400d4bf
JM
367either the editline package (BSD) or the readline package (GPL). On
368Ubuntu these packages are: ghc, haskell-platform,
369libghc-readline-dev/libghc-editline-dev
b76aa73b
JM
370
371```
372cd haskell
373make
374./stepX_YYY
375```
376
33dec7af
JM
377### Haxe
378
379The Haxe implementation of mal requires Haxe version 3.2 to compile.
380Four different Haxe targets are supported: Neko, Python, C++, and
381JavaScript.
382
383```
384cd haxe
385# Neko
386make all-neko
387neko ./stepX_YYY.n
388# Python
389make all-python
390python3 ./stepX_YYY.py
391# C++
392make all-cpp
393./cpp/stepX_YYY
394# JavaScript
395make all-js
396node ./stepX_YYY.js
397```
398
61f69fba
DM
399### Io
400
401*The Io implementation was created by [Dov Murik](https://github.com/dubek)*
402
403The Io implementation of mal has been tested with Io version 20110905.
404
405```
406cd io
407io ./stepX_YYY.io
408```
b76aa73b 409
bcddc3e4 410### Java 1.7
60154d24 411
01c97316
JM
412The Java implementation of mal requires maven2 to build.
413
60154d24
JM
414```
415cd java
416mvn compile
417mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY
418 # OR
419mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS"
420```
421
39381792 422### JavaScript/Node
60154d24
JM
423
424```
425cd js
54c75382 426npm update
60154d24
JM
427node stepX_YYY.js
428```
429
39381792
JM
430### Julia
431
82484631 432The Julia implementation of mal requires Julia 0.4.
39381792
JM
433
434```
435cd julia
436julia stepX_YYY.jl
437```
438
53c2ea70
JFI
439### Kotlin
440
441*The Kotlin implementation was created by [Javier Fernandez-Ivern](https://github.com/ivern)*
442
75787d77 443The Kotlin implementation of mal has been tested with Kotlin 1.0.
53c2ea70
JFI
444
445```
446cd kotlin
447make
448java -jar stepX_YYY.jar
449```
450
9d42904e
JM
451### Lua
452
8a9d0a8a 453Running the Lua implementation of mal requires lua 5.1 or later,
9d42904e
JM
454luarocks and the lua-rex-pcre library installed.
455
456```
457cd lua
458make # to build and link linenoise.so
459./stepX_YYY.lua
460```
461
bcddc3e4 462### Mal
60154d24
JM
463
464Running the mal implementation of mal involves running stepA of one of
465the other implementations and passing the mal step to run as a command
5d446bd8 466line argument.
60154d24
JM
467
468```
469cd IMPL
470IMPL_STEPA_CMD ../mal/stepX_YYY.mal
471
472```
473
bcddc3e4 474### GNU Make 3.81
60154d24
JM
475
476```
477cd make
478make -f stepX_YYY.mk
479```
480
de69b639 481### Nim 0.11.0
a2cd0a3a 482
a848d783
JM
483*The Nim implementation was created by [Dennis Felsing (def-)](https://github.com/def-)*
484
de69b639 485Running the Nim implementation of mal requires Nim 0.11.0 or later.
a2cd0a3a 486
487```
488cd nim
489make
490 # OR
491nimble build
492./stepX_YYY
493```
494
0067158f
JM
495### Object Pascal
496
497The Object Pascal implementation of mal has been built and tested on
498Linux using the Free Pascal compiler version 2.6.2 and 2.6.4.
499
500```
501cd objpascal
502make
503./stepX_YYY
504```
505
7cae6e6f
JM
506### Objective C
507
508The Objective C implementation of mal has been built and tested on
2faae94c
JM
509Linux using clang/LLVM 3.6. It has also been built and tested on OS
510X using XCode 7.
7cae6e6f
JM
511
512```
513cd objc
514make
515./stepX_YYY
516```
517
bc6448bc
C
518### OCaml 4.01.0
519
a848d783
JM
520*The OCaml implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
521
bc6448bc
C
522```
523cd ocaml
524make
525./stepX_YYY
526```
527
8a9d0a8a
JM
528### MATLAB
529
530The MATLAB implementation of mal has been tested with MATLAB version
531R2014a on Linux. Note that MATLAB is a commercial product. It should
532be fairly simple to support GNU Octave once it support classdef object
533syntax.
534
535```
536cd matlab
537./stepX_YYY
538matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;"
539 # OR with command line arguments
540matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"
541```
542
1218ce98
JM
543### miniMAL
544
545[miniMAL](https://github.com/kanaka/miniMAL) is small Lisp interpreter
546implemented in less than 1024 bytes of JavaScript. To run the miniMAL
547implementation of mal you need to download/install the miniMAL
548interpreter (which requires Node.js).
549```
1218ce98 550cd miniMAL
478fd9ce
JM
551# Download miniMAL and dependencies
552npm install
553export PATH=`pwd`/node_modules/minimal-lisp/:$PATH
554# Now run mal implementation in miniMAL
1218ce98
JM
555miniMAL ./stepX_YYY
556```
557
9b1563a3 558### Perl 5.8
9e5b2151
JM
559
560For readline line editing support, install Term::ReadLine::Perl or
561Term::ReadLine::Gnu from CPAN.
562
563```
564cd perl
565perl stepX_YYY.pl
566```
567
a7081401
HÖS
568### Perl 6
569
570*The Perl 6 implementation was created by [Hinrik Örn Sigurðsson](https://github.com/hinrik)*
571
572The Perl 6 implementation was tested on Rakudo Perl 6 2016.04.
573
574```
575cd perl6
576perl6 stepX_YYY.pl
577```
9e5b2151 578
bcddc3e4 579### PHP 5.3
60154d24 580
01c97316
JM
581The PHP implementation of mal requires the php command line interface
582to run.
583
60154d24
JM
584```
585cd php
586php stepX_YYY.php
587```
588
bcddc3e4 589### Postscript Level 2/3
60154d24 590
01c97316
JM
591The Postscript implementation of mal requires ghostscript to run. It
592has been tested with ghostscript 9.10.
593
60154d24
JM
594```
595cd ps
fa64b741 596gs -q -dNODISPLAY -I./ stepX_YYY.ps
60154d24
JM
597```
598
b25bf8d8
JM
599### PL/pgSQL (Postgres SQL Procedural Language)
600
b88bb764
JM
601The PL/pgSQL implementation of mal requires a running Postgres server
602(the "kanaka/mal-test-plpgsql" docker image automatically starts
603a Postgres server). The implementation connects to the Postgres server
604and create a database named "mal" to store tables and stored
605procedures. The wrapper script uses the psql command to connect to the
606server and defaults to the user "postgres" but this can be overridden
607with the PSQL_USER environment variable. A password can be specified
608using the PGPASSWORD environment variable. The implementation has been
609tested with Postgres 9.4.
b25bf8d8
JM
610
611```
612cd plpgsql
613./wrap.sh stepX_YYY.sql
b88bb764
JM
614 # OR
615PSQL_USER=myuser PGPASSWORD=mypass ./wrap.sh stepX_YYY.sql
616```
617
618### PL/SQL (Oracle SQL Procedural Language)
619
620The PL/pgSQL implementation of mal requires a running Oracle DB
621server (the "kanaka/mal-test-plsql" docker image automatically
622starts an Oracle Express server). The implementation connects to the
623Oracle server to create types, tables and stored procedures. The
624default SQL*Plus logon value (username/password@connect_identifier) is
625"system/oracle" but this can be overridden with the ORACLE_LOGON
626environment variable. The implementation has been tested with Oracle
627Express Edition 11g Release 2. Note that any SQL*Plus connection
628warnings (user password expiration, etc) will interfere with the
629ability of the wrapper script to communicate with the DB.
630
631```
632cd plsql
633./wrap.sh stepX_YYY.sql
634 # OR
635ORACLE_LOGON=myuser/mypass@ORCL ./wrap.sh stepX_YYY.sql
b25bf8d8
JM
636```
637
23e38cd2 638### Python (2.X or 3.X)
60154d24
JM
639
640```
641cd python
642python stepX_YYY.py
643```
8adb0827 644
23e38cd2
JM
645### RPython
646
647You must have [rpython](https://rpython.readthedocs.org/) on your path
648(included with [pypy](https://bitbucket.org/pypy/pypy/)).
649
650```
651cd rpython
4e8d7c28 652make # this takes a very long time
23e38cd2
JM
653./stepX_YYY
654```
655
9b3362e8
JM
656### R
657
658The R implementation of mal requires R (r-base-core) to run.
659
660```
661cd r
9d42904e 662make libs # to download and build rdyncall
f5223195
JM
663Rscript stepX_YYY.r
664```
665
666### Racket (5.3)
667
668The Racket implementation of mal requires the Racket
669compiler/interpreter to run.
670
671```
672cd racket
3796240a 673./stepX_YYY.rkt
9b3362e8
JM
674```
675
107d9694 676### Ruby (1.9+)
8adb0827
JM
677
678```
679cd ruby
680ruby stepX_YYY.rb
681```
592eb5cf 682
9106a221 683### Rust (1.0.0 nightly)
abdd56eb
JM
684
685The rust implementation of mal requires the rust compiler and build
686tool (cargo) to build.
687
688```
689cd rust
bbeb1b87 690cargo run --release --bin stepX_YYY
abdd56eb
JM
691```
692
821930db
JM
693### Scala ###
694
695Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
696
697```
698cd scala
699sbt 'run-main stepX_YYY'
700 # OR
701sbt compile
702scala -classpath target/scala*/classes stepX_YYY
703```
704
2539e6af
KR
705### Swift
706
a848d783
JM
707*The Swift implementation was created by [Keith Rollin](https://github.com/keith-rollin)*
708
e31349f6
KR
709The Swift implementation of mal requires the Swift 2.0 compiler (XCode
7107.0) to build. Older versions will not work due to changes in the
711language and standard library.
8b142f08 712
2539e6af
KR
713```
714cd swift
715make
716./stepX_YYY
717```
718
ea1395aa
JM
719### Swift 3
720
721The Swift 3 implementation of mal requires the Swift 3.0 compiler. It
722has been tested with the development version of the Swift 3 from
7232016-02-08.
724
725```
726cd swift3
727make
728./stepX_YYY
729```
730
54d9903c
DM
731### Tcl 8.6
732
733*The Tcl implementation was created by [Dov Murik](https://github.com/dubek)*
734
735The Tcl implementation of mal requires Tcl 8.6 to run. For readline line
736editing support, install tclreadline.
737
738```
739cd tcl
740tclsh ./stepX_YYY.tcl
741```
742
36e91db4
DM
743### VHDL
744
745*The VHDL implementation was created by [Dov Murik](https://github.com/dubek)*
746
747The VHDL implementation of mal has been tested with GHDL 0.29.
748
749```
750cd vhdl
751make
752./run_vhdl.sh ./stepX_YYY
753```
754
50a964ce
DM
755### Vimscript
756
757*The Vimscript implementation was created by [Dov Murik](https://github.com/dubek)*
758
759The Vimscript implementation of mal requires Vim to run. It has been tested
760with Vim 7.4.
761
762```
763cd vimscript
764./run_vimscript.sh ./stepX_YYY.vim
765```
766
ee7cd585
JM
767### Visual Basic.NET ###
768
769The VB.NET implementation of mal has been tested on Linux using the Mono
770VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
771required to build and run the VB.NET implementation.
772
773```
774cd vb
775make
776mono ./stepX_YYY.exe
777```
778
779
780
592eb5cf
JM
781## Running tests
782
294aba2c
JM
783### Functional tests
784
eaa6ceb4 785The are over 600 generic functional tests (for all implementations)
294aba2c
JM
786in the `tests/` directory. Each step has a corresponding test file
787containing tests specific to that step. The `runtest.py` test harness
bd62ff74
JM
788launches a Mal step implementation and then feeds the tests one at
789a time to the implementation and compares the output/return value to
790the expected output/return value.
592eb5cf
JM
791
792To simplify the process of running tests, a top level Makefile is
793provided with convenient test targets.
794
795* To run all the tests across all implementations (be prepared to wait):
796
797```
798make test
799```
800
801* To run all tests against a single implementation:
802
803```
e5737b08 804make "test^IMPL"
592eb5cf
JM
805
806# e.g.
e5737b08
SL
807make "test^clojure"
808make "test^js"
592eb5cf
JM
809```
810
811* To run tests for a single step against all implementations:
812
813```
e5737b08 814make "test^stepX"
592eb5cf
JM
815
816# e.g.
e5737b08
SL
817make "test^step2"
818make "test^step7"
592eb5cf
JM
819```
820
4c58cd4e 821* To run tests for a specific step against a single implementation:
592eb5cf
JM
822
823```
e5737b08 824make "test^IMPL^stepX"
592eb5cf
JM
825
826# e.g
e5737b08
SL
827make "test^ruby^step3"
828make "test^ps^step4"
592eb5cf 829```
fd888612 830
294aba2c
JM
831### Self-hosted functional tests
832
833* To run the functional tests in self-hosted mode, you specify `mal`
834 as the test implementation and use the `MAL_IMPL` make variable
835 to change the underlying host language (default is JavaScript):
836```
e5737b08 837make MAL_IMPL=IMPL "test^mal^step2"
294aba2c
JM
838
839# e.g.
e5737b08
SL
840make "test^mal^step2" # js is default
841make MAL_IMPL=ruby "test^mal^step2"
842make MAL_IMPL=python "test^mal^step2"
294aba2c
JM
843```
844
854cf2a6
DM
845### Starting the REPL
846
847* To start the REPL of an implementation in a specific step:
848
849```
850make "repl^IMPL^stepX"
851
852# e.g
853make "repl^ruby^step3"
854make "repl^ps^step4"
855```
856
857* If you omit the step, then `stepA` is used:
858
859```
860make "repl^IMPL"
861
862# e.g
863make "repl^ruby"
864make "repl^ps"
865```
866
867* To start the REPL of the self-hosted implementation, specify `mal` as the
868 REPL implementation and use the `MAL_IMPL` make variable to change the
869 underlying host language (default is JavaScript):
870```
871make MAL_IMPL=IMPL "repl^mal^stepX"
872
873# e.g.
874make "repl^mal^step2" # js is default
875make MAL_IMPL=ruby "repl^mal^step2"
876make MAL_IMPL=python "repl^mal"
877```
294aba2c
JM
878
879### Performance tests
880
8569b2af
JM
881Warning: These performance tests are neither statistically valid nor
882comprehensive; runtime performance is a not a primary goal of mal. If
883you draw any serious conclusions from these performance tests, then
884please contact me about some amazing oceanfront property in Kansas
885that I'm willing to sell you for cheap.
886
294aba2c
JM
887* To run performance tests against a single implementation:
888```
e5737b08 889make "perf^IMPL"
294aba2c
JM
890
891# e.g.
e5737b08 892make "perf^js"
294aba2c
JM
893```
894
895* To run performance tests against all implementations:
896```
e5737b08 897make "perf"
294aba2c
JM
898```
899
900### Generating language statistics
901
4c58cd4e 902* To report line and byte statistics for a single implementation:
294aba2c 903```
e5737b08 904make "stats^IMPL"
294aba2c
JM
905
906# e.g.
e5737b08 907make "stats^js"
294aba2c
JM
908```
909
4c58cd4e 910* To report line and bytes statistics for general Lisp code (env, core
294aba2c
JM
911 and stepA):
912```
e5737b08 913make "stats-lisp^IMPL"
294aba2c
JM
914
915# e.g.
e5737b08 916make "stats-lisp^js"
294aba2c
JM
917```
918
5b207de7 919## Dockerized testing
75363567 920
5b207de7
JM
921Every implementation directory contains a Dockerfile to create
922a docker image containing all the dependencies for that
923implementation. In addition, the top-level Makefile contains support
924for running the tests target (and perf, stats, repl, etc) within
925a docker container for that implementation by passing *"DOCKERIZE=1"*
926on the make command line. For example:
75363567 927
75363567 928```
5b207de7 929make DOCKERIZE=1 "test^js^step3"
75363567
JM
930```
931
5b207de7
JM
932Existing implementations already have docker images built and pushed
933to the docker registry. However, if
934you wish to build or rebuild a docker image locally, the toplevel
935Makefile provides a rule for building docker images:
936
75363567 937```
5b207de7
JM
938make "docker-build^IMPL"
939```
940
75363567
JM
941
942**Notes**:
5b207de7
JM
943* Docker images are named *"kanaka/mal-test-IMPL"*
944* JVM-based language implementations (Groovy, Java, Clojure, Scala):
945 you will probably need to run these implementations once manually
946 first (make DOCKERIZE=1 "repl^IMPL")before you can run tests because
947 runtime dependencies need to be downloaded to avoid the tests timing
948 out. These dependencies are download to dot-files in the /mal
949 directory so they will persist between runs.
75363567 950
294aba2c 951
fd888612
JM
952## License
953
954Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public
955License 2.0). See LICENSE.txt for more details.