1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 13:55:55 +03:00
Commit Graph

206 Commits

Author SHA1 Message Date
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
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
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
Ben Harris
7df7eeecbf step6: Test loading of a large (>255 byte) file earlier than before.
I just introduced a bug in the BBC BASIC implementation meaning that
'load-file' was broken on files over 255 bytes long, and it was only
caught by the optional test of 'time-ms' in step A.  This change brings
forward the relevant part of that test so the failure can be detected
earlier and more obviously, at the same time as the other tests of
'load-file'.
2019-05-27 22:32:16 +01:00
Nicolas Boulenguez
8c0d5c4d72 test recursive definitions in let*
Detected while attempting to rewrite let* with fn*.
2019-05-25 19:20:06 +02:00
Nicolas Boulenguez
6db6cf38b7 lib/tests: report parsing errors, move threading out of steps
When testing `foo.mal`, it makes sense to report parsing errors in
`foo.mal`.

Move tests of `->` and `->>` from `tests/step8_macros.mal` to
`tests/lib/theading.mal`.

Add `lib/trivial.mal`.
2019-05-19 19:20:20 +02:00
Nicolas Boulenguez
83665b4fda lib/: add tests, fix detected problems, improve implementations
equality.mal:
- fix typos
- let and2 and or2 always return booleans
- when looping in sequences, compare lengths only once
- empty? instead of an equality test
- when looping on a keys, do not check if a contains the current key
- change the `cond` logic: when a is a sequence and b a map, return
  false instead of delegating to scalar-equal?.
- add tests

memoize.mal:
- make explicit that the function name must be kept
- fix typo in tests

protocols.mal:
- document
- add a function mapping an object to its type
- add default types for remaining built-in MAL values
- let defprotocol return the new protocol instead of last method
- set the right profile for abstract methods, improving error messages
- replace incomplete example with lots of tests

pprint:
- escape parenthesis in expected test results

[kanaka]
- explain in lib/README.md how to run tests/lib/*.
- rename folds to reducers and composition to threading
- move fib and sumdown from lib/ to tests/
2019-05-18 01:52:13 +02:00
Nicolas Boulenguez
4924fac100 lib/ split: fix forgotten paths in test/perf*.mal. 2019-05-18 01:52:13 +02:00
Nicolas Boulenguez
a1805b96af Move tests of lib/ and new tests of core.mal to tests/lib/.
Partial translation of examples from lib/ to new tests.

Correct test of memoize.

`reduce`, `foldr`, `every?`, `some` and `and` were previously not
tested in tests/step*.mal. Tests them in `tests/lib/` instead.
2019-05-18 01:52:13 +02:00
Nicolas Boulenguez
bf6647fbb3 Fix style issues in lib/.
This diff is best viewed without space differences.
2019-05-18 01:52:13 +02:00
Nicolas Boulenguez
3e9b89d4b5 Prepare move of reusable code to lib/.
Changes creating huge diffs, like file splits, have been delayed for
readability .
Also fix description of `and`.
2019-05-18 01:52:13 +02:00
Nicolas Boulenguez
e1d579a969 tests: wait gensym in stepA to test and macro 2019-05-18 01:52:12 +02:00
Nicolas Boulenguez
840faeb26d core.mal: add and test right fold 2019-05-18 01:52:12 +02:00
Nicolas Boulenguez
e044a11ab1 core.mal: test each non trivial recursion 2019-05-18 01:52:12 +02:00
Joel Martin
976e03b912
Merge pull request #378 from asarhaddon/test-macro-not-changing-function
Test that defining a macro does not mutate an existing function.
2019-05-15 08:17:59 -07:00
Nicolas Boulenguez
c714889a98 Move test that macro do not mutate functions as optional in stepA 2019-05-15 06:19:02 +02:00
Nicolas Boulenguez
d1a5100ea9 test macro/functions: ignore results of preliminary definitions 2019-05-15 05:10:11 +02:00
Joel Martin
bf5cba817e
Merge pull request #376 from bjh21/bjh21-withmeta-empty
step A: Test that metadata doesn't break empty collections.
2019-05-14 17:25:35 -07:00
Ben Harris
bfb315c852 step A: Test that metadata doesn't break empty collections.
In the BBC BASIC implementation, the empty list, vector, and hash-mapp
are distinguished values and detected by their address.  Adding metadata
to them makes a copy, and then they don't work properly any more.
2019-05-14 23:28:13 +01:00
Ben Harris
3b1a665234 step A: Add a mandatory test that 'string?' etc are defined.
Self-hosting currently requires that these functions be defined so
that the mal implementation can pass them through.  This test
minimally ensures that.
2019-05-14 22:22:39 +01:00
Nicolas Boulenguez
5f905bacfd Test that defining a macro does not mutate an existing function. 2019-05-14 19:03:14 +02:00
Joel Martin
edc9b5dedd
Merge pull request #372 from bjh21/bjh21-empty-hashmap
step1: Test that an empty hashmap can pass through read and print.
2019-05-13 15:31:45 -07:00
Ben Harris
f7983f7235 step1: More systematic testing of empty collections.
Now we test empty lists, vectors, and hash-maps, all with and without a
space between the opening and closing bracket.
2019-05-13 21:53:43 +01:00
Ben Harris
f0338adf8f step1: Test that an empty hashmap can pass through read and print.
My BBC BASIC implementation currently fails this.
2019-05-12 13:58:53 +01:00
Nicolas Boulenguez
14ab099cea gensym: hide the counter in an environment, define inc in stepA.
tests: check that `inc` is present in stepA.
nasm: split lines in mal_startup_string for readability.
objpascal: remove obsolete .orig file
swift: remove an unneeded line in template
swift4: remove duplicate definition of `or` macro
2019-05-11 16:37:26 +02:00
Ben Harris
5d75930ae8 step 7 test: Add test of 'concat' on a single vector.
I thought I'd accidentally made it just return that vector, but it
turned out I hadn't.  Still, it seems like a plausible mistake to
make.
2019-05-07 23:48:06 +01:00
Ben Harris
ae0427fbbc step 8 test: Check a corner case of cons/rest on vectors that I got wrong.
In the BBC BASIC implementation, lists and vectors are essentially the
same, and are only distinguished by a flag on the head node.  This makes
it cheap to convert between lists and vectors, but it does require a
little care to ensure that a vector doesn't escape where it shouldn't.
The new test checks for a case where I'd got this wrong:

(rest (cons 10 [11 12]))

Here the 'cons' returns a list, but the tail of the list is just the
original vector (complete with vector flag), so a naïve implementation
of 'rest' can end up returning that vector instead of an equivalent
list.  The test proves that it doesn't.
2019-05-07 23:48:06 +01:00
Joel Martin
90ca848565 rpython,rust,swift4,ts: fix empty list handling.
In these implementations there is no empty list check before
macroexpansion and so empty lists from step8 onwards produce a crash
or other misbehavior.

Also, add a test to step8 to test empty list again (first time it's
tested is in step2).
2019-05-07 16:43:12 -05:00
Ben Harris
20b2a2442b step 7 test: Correct a heading to match contents.
'first' and 'rest' applied to vectors are now tested in step 8, not step 7.
2019-05-06 12:45:54 +01:00
Ben Harris
64c11d81a0 step9: Don't use vectors in a non-deferrable test.
According to the guide, vectors are deferrable until step A, so use
(nth () 1) in place of (nth [] 1) as a form that will generate an error.
2019-05-06 12:45:53 +01:00
Ben Harris
1fcac410b3 step9: Make test of throwing a hash-map deferrable.
According to the guide, hash-maps are deferrable until step A.
2019-05-06 12:45:53 +01:00
Ben Harris
e7f9404b40 Step 6: Make tests of '*ARGV*' deferrable.
The Guide says that '*ARGV*' is deferrable at step 6.
2019-04-20 18:49:29 +01:00
Ben Harris
0c04a99f91 Mark step 4 tests that use strings as deferrable.
Strings are deferrable until step 6, so tests of string functionality at
step 4 should be marked as deferrable.  A couple of tests just use
strings as convenient constants to return or print.  In those cases,
replace the strings with integers rather than deferring the whole test.
2019-04-09 21:46:31 +01:00
Nicolas Boulenguez
fc7f8a4b00 Move test of eval builtin to step6. Fix nim implementation.
The test makes more sense in step6.
Thanks to kanaka for the read-string suggestion.

Introduction of tail call optimization in step5 was making let* affect
the parent environment. This was partially fixed in later steps.

Introduction of macros in step8 was breaking the evaluation of an
empty list. This was fixed by step 9 but never backported.
2019-02-03 15:31:00 +01:00
Nicolas Boulenguez
d12bf4787c In step6, test that eval uses Repl not Env. I have not managed to test this before step7 quotes. 2019-02-02 20:32:15 +01:00
Nicolas Boulenguez
78c71a51ad In step1, test non-numbers starting with a dash. 2019-01-29 14:24:13 +01:00
Joel Martin
a68c26aff8 lua: update to version 5.2
- Update to support the new behavior of varargs and table.pack/unpack
  in lua 5.2
- Bump up the stack overflow test since lua 5.2 seems to support much
  larger stacks before overflow.
- Fix a latent issue in if forms where false in the 4th position would
  result in nil returned. Add a new test to catch this in the future.
2019-01-28 13:31:28 -06:00