1
1
mirror of https://github.com/kanaka/mal.git synced 2024-07-14 17:10:30 +03:00
Commit Graph

245 Commits

Author SHA1 Message Date
Joel Martin
8a19f60386 Move implementations into impls/ dir
- Reorder README to have implementation list after "learning tool"
  bullet.

- This also moves tests/ and libs/ into impls. It would be preferrable
  to have these directories at the top level.  However, this causes
  difficulties with the wasm implementations which need pre-open
  directories and have trouble with paths starting with "../../". So
  in lieu of that, symlink those directories to the top-level.

- Move the run_argv_test.sh script into the tests directory for
  general hygiene.
2020-02-10 23:50:16 -06:00
Ali Mohammad Pur
306ba5eb43
Add test for atoms "leaking" out of let* binds
(hopefully) closes #490
2020-01-16 00:55:12 +03:30
Joel Martin
b75dc79a8d tests: remove atom metadata test.
This was a commented out test I added early as something that might be
interesting even though Clojure does not support it. However, I hadn't
thought through it fully. Most objects are cloned when meta-data is
added. It is weird to clone an atom because then you have two
references that can diverge (i.e. they are different atoms but start
out pointing to the same underlying object). But mutating an atom is
the wrong behavior too i.e. with-meta would be a pseudo form of
reset! just for the metadata part.
2019-12-17 14:49:15 -06:00
Andrew Wason
a124b32269 Add a test that eval is in root scope and that newly defined symbols can be found in nested scopes. 2019-12-11 15:43:23 -05:00
Dov Murik
0fa01f40a9 tests: step8: Verify nth doesn't throw on nil elements 2019-10-31 01:06:46 +02:00
Ben Harris
0d17edb428 step 6: Test reading strings containing bare newlines.
The official regexps permit bare newlines in strings, and the mal
implementation currently contains one.
2019-08-21 20:50:48 +01:00
Aasim Kandrikar
57ccbb5e47 step 4: Test (if nil 1) returns nil
Certain implementations like the one I wrote can get this wrong.
2019-08-07 12:59:09 +05:30
Joel Martin
0c24028216 make: fix catch of undefined plain symbol
The _error function was returning an empty string which meant that in
the try*/catch* implementation, the lack of result was preventing
foreach from being used as a "let" form and because of that it was
skipping the catch* handling path.
2019-07-31 12:17:17 -05:00
Joel Martin
a4ff3ec9a6
Merge pull request #359 from bjh21/bjh21-unterminated-strings
New test for reading an unterminated string that nonetheless ends with a quotation mark
2019-07-31 09:24:08 -05:00
Joel Martin
ff4e5f1600 Fix second-order self-hosting.
The `_map?` function was introduced when transitioning the macro
property being stored in metadata to uinsg a regular map with
a special key. The `_map?` function causes issues in a few places but
the biggest issue is that it breaks the `_macro?` function for the
second order self-hosted mal instance. The `_macro?` function contains
a `(map? x)` call that returns false resulting in the `_macro?` call
returning false.  I'll push something later that fixes this and also
that activates second order self-hosted tests so we can catch this
sort of issue in the future.
2019-07-29 17:58:11 -05:00
Joel Martin
38daa6955b
Merge pull request #387 from asarhaddon/test-macroexpand-no-quasiquote
test macroexpand without assuming that quasiquote is a special form
2019-07-29 17:53:55 -05:00
Nicolas Boulenguez
e6d41de4d5 load-file: accept empty file or final comment, return nil
Let `load-file` append a new line in case last line contains a
comment.

Also append `nil` so that the return value is predictible. Remove the
existing explicit `nil` from existing sources.

Adapt documentation and tests.
2019-07-28 13:08:05 +02:00
Ben Harris
a94c795da6 Merge branch 'master' into bjh21-unterminated-strings
This should fix ocaml.
2019-07-26 00:08:48 +01:00
Joel Martin
77fd710cab Regress test of deferrables. Fix dart, factor.
Add a regression run to Travis that enables hard deferrables but
omits optionals so that we can test to make sure that all the
requirements are met for self-hosting in stepA.

Cleanup up some of the soft/deferrable/optional markings.
Deferrables are what will be needed eventually to self host but aren't
needed for the immediate next steps. Optional aren't even needed for
self-hosting but are nice things to have.

Also:
- Sync dart step9 and stepA with step8. Do not eval macroexpanded
  forms in macroexpand form.
- Fix stepA of factor which was missing some fixes from step9.
- Increase test timeouts in top-level Makefile for guile and io.
2019-07-24 23:48:29 -05:00
Dov Murik
748df6f7bd io: Fix unneeded escaping of forward slash
Instead of using Io's `asJson` method which escapes forward slashes,
implement our own string escaping code so it fits the Mal requirements.

The relevant step1 test was modified from soft to hard.
2019-07-23 10:23:11 +03:00
Dov Murik
b9d9e6754a tests: Add optional list and vector eqaulity tests 2019-07-21 13:14:07 +03:00
Nicolas Boulenguez
3af0639fca tests/lib: fix path in test-alias-hacks, use load-file-once 2019-07-18 17:52:41 +02:00
Nicolas Boulenguez
3b797cd5ec tests: non alphanumeric characters in input
Make: remove part of EVAL breaking # and $

step0: no MAL character must break the interpreter
       (soft) no printable ASCII character either

step1: no MAL character must break strings
       (soft) no printable ASCII character should break strings
       (soft) no character should break comments

step6: redo step1 tests for comments inside read-string, as new
       problem may occur with line breaks and escape characters of the host
       language.
2019-07-18 00:01:14 +02:00
Nicolas Boulenguez
77a0798f8a tests: remove commented test for 10th Fibonnacci number 2019-07-18 00:00:48 +02:00
Nicolas Boulenguez
8eed0a29ae tests: soft-tests for keywords (instead of comments) 2019-07-18 00:00:42 +02:00
Nicolas Boulenguez
77057e6920 tests: soft-test metadata for atoms 2019-07-18 00:00:29 +02:00
Nicolas Boulenguez
13e679cdde lib/load-file-once: basic support for multiple imports 2019-07-16 00:16:44 +02:00
Nicolas Boulenguez
4733821090 Merge remote-tracking branch 'remotes/kanaka/master' into improve-mal-impl-macro-no-meta 2019-07-15 19:49:33 +02:00
Nicolas Boulenguez
82bc78eb43 check that slurp works twice in a row. Fix rexx 2019-07-15 17:50:47 +02:00
Joel Martin
6fd3a0db02
Merge pull request #416 from bjh21/bjh21-equal-empty
step 4: Test that (= (list nil) (list)) returns false.
2019-07-15 00:01:16 -05:00
Nicolas Boulenguez
809d74cba7 Implement macros with maps instead of vectors.
Output of macros will probably be more readable.

Inline _macro_wrap and _unwrap for efficiency (there are less
primitive operations for maps than for vectors).

Basic check of `map?` and `macro?`. Swap them in order to simplify the
diff with cb9b0654.
2019-07-14 19:47:58 +02:00
Ben Harris
aeff9873de step 4: Test that (= (list nil) (list)) returns false.
Certain naïve implementations of '=' (like the one I just wrote) will
get this wrong.
2019-07-13 12:08:05 +01:00
Nicolas Boulenguez
28b63c0ca6 mal: implement macro without metadata
Support for metadata becomes optional.
Support for fn? becomes optional again, reverting 5e5d4892.
2019-07-09 14:16:27 +02:00
Nicolas Boulenguez
aac5cf7bf5 guile, scheme: fix fn? when metadata contains "ismacro"
Let `with-meta f m` create a function even if f is a macro, instead of
setting an "ismacro" metadata that is never used again (and breaks
self-hosting).

Also move the test for fn? from Optional to Deferrable, the function
is used for self-hosting.
2019-07-09 14:14:03 +02:00
Nicolas Boulenguez
b1a8dbd55f mal: rename macro? to _macro?. Also rename bool-and in lib/equality.mal. 2019-07-09 14:05:29 +02:00
Nicolas Boulenguez
26ced15b31 Remove gensym, inc and or from step files.
* Move `gensym` and `inc` from step files to `lib/trivial.mal`.
* Move `or` from step files to `lib/test_cascade.mal`.
  Shorten it because `(first ())` returns `nil`
* Update process and tests accordingly (not the figures yet).
2019-07-09 14:05:29 +02:00
Ben Harris
5b30912762 Merge branch 'master' into bjh21-unterminated-strings 2019-07-08 21:33:58 +01:00
Ben Harris
7260b29879
Merge branch 'master' into bjh21-php-hashmap 2019-07-08 21:26:30 +01:00
Joel Martin
95958bb29d
Merge pull request #413 from bjh21/bjh21-nontrivial-hashmap
step 1: Test a hash-map with more than one entry.
2019-07-08 10:08:50 -05:00
Joel Martin
8236bed763
Merge pull request #411 from bjh21/bjh21-nested-collections
step 1: Test reading some simple nested collections.
2019-07-08 09:53:08 -05:00
Joel Martin
e118d60124
Merge pull request #407 from asarhaddon/ada.2-updates
Test that macros use closures like functions. Fix ada.2 accordingly.
2019-07-08 09:50:11 -05:00
Ben Harris
80512fcc84 steps 1 and 9: Test that hash-map keys stay as strings.
Specifically, test that when "1" is used as a hash-map key, it is
represented as a string when printed (step 1) and when returned by
'keys' (step 9).  PHP used to get both of these wrong.
2019-07-07 18:36:07 +01:00
Ben Harris
e69f0ea3d4 step 1: Explain intention behind regexp magic in non-trivial hash-map test.
[skip travis]
2019-07-07 13:43:54 +01:00
Ben Harris
d6383c83d2 step 1: Fix non-trivial hash-map test on PHP.
It seems that the PHP implementation converts integer-like strings as
hash-map keys into integers, so {"1" 1} becomes {1 1}.  I don't know if
that's a bug, but it's certainly not the bug I was trying to test for.
Use different keys to avoid this problem.
2019-07-07 13:35:04 +01:00
Ben Harris
876e6545c2 step 1: Test a hash-map with more than one entry.
All the existing tests in step 1 use empty or single-element hash-maps.
That avoids any dependency on the ordering of printed hash-maps, but it
does mean that some code paths (e.g. printing the space between hash-map
elements) aren't tested.  Add a test that creates a three-element
hash-map and uses some regexp trickery to check that all the right keys
and values come out.
2019-07-07 11:21:37 +01:00
Ben Harris
beeffb021c step 1: Test reading some simple nested collections.
These tests are intended to catch the cases where the routine for
reading a list, vector, or hashmap fails to consume the trailing token
(')', ']', or '}' as the case may be) from the input.  None of the
existing step 1 tests detected this, and I only found it by playing
around in the REPL.
2019-07-07 10:09:01 +01:00
Chris McCormick
d0efab8745 Added alias hacks from frock to lib. See #321.
Thanks @asarhaddon for your guidance.
2019-07-01 16:06:20 +08:00
Nicolas Boulenguez
a688720499 Test that macros use closures 2019-06-30 23:37:16 +02:00
Ben Harris
312b7ca900 Merge branch 'master' into bjh21-unterminated-strings
This should fix the C and D implementations.
2019-06-12 17:04:43 +01:00
Joel Martin
4aa1c85b88 travis_trigger.sh: Support .com and env var tokens 2019-05-30 22:50:20 -05:00
Joel Martin
108d07a2ab Travis: travis_trigger.sh script. 2019-05-30 22:16:46 -05:00
Ben Harris
ab2c4deca9 Merge branch 'master' into bjh21-unterminated-strings
Ada now passes all string-reading tests.
2019-05-28 20:00:29 +01:00
Joel Martin
97e1fd50a1
Merge pull request #388 from bjh21/bjh21-large-files-step6
step6: Test loading of a large (>255 byte) file earlier than before.
2019-05-28 13:30:27 -04:00
Nicolas Boulenguez
8734e2eb01 Test mutual recursion in let* without vectors, which are deferrable.
Thanks to bjh21 for spotting this inconsistency.
2019-05-28 16:36:21 +02:00
Nicolas Boulenguez
8150202bed Test mutual recursion in let* 2019-05-28 15:18:57 +02:00