1
1
mirror of https://github.com/kanaka/mal.git synced 2024-08-16 17:20:23 +03:00
Commit Graph

245 Commits

Author SHA1 Message Date
Ben Harris
583ed47b91 Merge branch 'master' into bjh21-unterminated-strings 2019-05-27 22:36:38 +01: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
3d352522ba test: when testing macroexpand, do not assume that quasiquote is a special
This allows to test rewritting quasiquote as a macro, and should
change nothing else in theory.
2019-05-25 19:15:00 +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
Ben Harris
c0669bc1da Merge branch 'master' into bjh21-unterminated-strings 2019-05-16 10:14:33 +01: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
ca89606b63 step1: More tests of backslashes in strings.
These check that "\\" is correctly read, and also that the
implementation can correctly handle a large number of backslashes in
succession.
2019-05-13 22:45:18 +01:00
Ben Harris
d35721f8ca step1: Extra tests of incorrectly-terminated strings.
My initial Inform 7 implementation failed these, but passed the other
one.
2019-05-13 22:45:18 +01: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
Joel Martin
4aa0ebdf47 Error on unterminated strings.
Add a step1 test to make sure that implementations are properly
throwing an error on unclosed strings.

Fix 47 implementations and update the guide to note the correct
behavior.
2019-01-25 16:16:06 -06:00
Joel Martin
7aaf054b0a tests/step3_env: don't assume def! is lexical. 2019-01-04 17:05:49 -06:00
Joel Martin
dd7a4f55f3 Test uncaught throw, catchless try* . Fix 46 impls.
Fixes made to: ada, c, chuck, clojure, coffee, common-lisp, cpp,
crystal, d, dart, elm, erlang, es6, factor, fsharp, gnu-smalltalk,
groovy, guile, haxe, hy, js, livescript, matlab, miniMAL, nasm, nim,
objc, objpascal, ocaml, perl, perl6, php, plsql, ps, python, r,
rpython, ruby, scheme, swift3, tcl, ts, vb, vimscript, wasm, yorick.

Catchless try* test is an optional test. Not all implementations
support catchless try* but a number were fixed so they at least don't
crash on catchless try*.
2018-12-12 14:18:26 -06:00
Joel Martin
f6f5d4f2a3 runtest.py: process output/errors as regex match.
Update output test data to be regex compatible.
2018-11-30 14:57:45 -06:00
Joel Martin
6da59ec2f4 perf: fix perf3 to show total iters instead of / 3
The run-fn-for function was originally name run-fn and was hard-coded
to run for 3 seconds. I forgot to replace the 3 with the max-secs
variable. However, given that some implementations have less than
1 iteration per second, I'm just going to drop that division and
report the iterations per max-seconds so that for the slowest
implementations we have some relative comparison instead of all of
them just reporting 0.

Thanks to Tim Morgan for discovering this bug:
699f0ad23a
2018-07-16 09:34:37 -05:00
Joel Martin
b26c8329c8
Merge pull request #324 from seven1m/add-not-test-for-nil
Test that (not nil) returns true
2018-07-12 15:44:10 -07:00
Joel Martin
bbd62dc97c tests/stepA: allow time-ms result to be signed.
In Java the time-ms value was negative. This actually still works fine
because arithmetic comparison is still correct. So allow signed
time-ms results.
2018-07-12 14:24:14 -05:00
Tim Morgan
e2352e739b Test that (not nil) returns true 2018-07-08 22:21:01 -05:00
Ben Dudson
f86d275f08 Fix bug in map: should pass args as list
This appeared only for variadic function which is used in EVAL.

Added a test to step 9 to catch this earlier.
2017-12-29 22:47:16 +00:00
Ben Dudson
40eb57d65c Fix bug in concat, add test to step 7
Concatenating multiple empty lists resulted in a return
which should be empty but was not checked.

(concat (list) (list))
-> ()

Test added to step 7 to catch, since this appeared in
self-hosting step 8 in the -> macro expansion.
2017-12-29 22:47:10 +00:00
Ben Dudson
89f7cef6dc Adding test to step7 for quasiquote
Handling of the last element of the AST
is tested by having an unquote as the last element.
2017-12-29 22:46:52 +00:00
Joel Martin
393d1140a3 tests: move number?, fn? and macro? to optional 2017-11-01 21:56:29 -05:00
Vasilij Schneidermann
2ff47a342f Fix typo 2017-10-23 17:15:42 +02:00
Dov Murik
69edbad782 tests: Use a real user-defined function when testing fn? and macro? 2017-10-14 12:20:53 +00:00
Dov Murik
59436f1a12 Add number?, fn?, macro? in stepA - tests and process guide
Ref #298
2017-10-09 20:23:39 +00:00
Dov Murik
8e59b7151b tests: Add test for unescaping "\\n" in step4
Several implementations fail when unescaping "\\n" in their reader
module because string-wide replacements of the two chars '\' and 'n' by
a newline char will replace the last two chars.
2017-09-28 07:38:23 -05:00
Dov Murik
55c2524201 tests: Add test cases in step4 and step9 2017-07-20 11:36:36 +00:00
Joel Martin
a112da51b4 Merge pull request #260 from def-/master
Update to Nim 0.17.0
2017-05-23 13:48:51 -05:00
Dennis Felsing
4603f2a931 Update to Nim 0.17.0 2017-05-23 19:07:34 +02:00
Joel Martin
681ce637b6 Deprecate tests/docker/Dockerfile 2017-05-23 11:04:32 -05:00
Joel Martin
b3658328e4 Merge branch 'master' of github.com:kanaka/mal 2016-10-31 17:41:58 -05:00
Joel Martin
37d75dc6dd Basic: pass required tests. Printer fix.
Also, move dissoc and hashmap equality tests to optional/soft since
they aren't actually needed for self-hosting.
2016-10-28 22:02:59 -05:00
Joel Martin
4e7d8a1bcf Basic: fix step6 arg test. Gensym. Misc cleanup.
- Strip linefeeds in run_argv_test.sh so that step6 arg test passes
  for basic.
- Add gensym and convert or macro.
- Add gitignore entries for transpiled basic sources.
- Add conj/seq stubs so that step4 self-host loads (if non-step4
  functions are commented out in core.mal)
- Bump up Z% value space by 256 spaces (1K)
- Remove old qb2cbm.sh
2016-10-28 00:09:56 -05:00
Vasilij Schneidermann
3c7b63d2e1 Ensure assoc updates maps properly 2016-10-24 22:50:15 +02:00
Joel Martin
70f29a2b3c Basic: step8 basics. Fix def!, let*, concat, scalars.
- Move apply logic in swap! to APPLY function in types and use that
  for macroexpand
- Abort def! if error before updating the environment
- let* wasn't properly saving A2% for the final eval. Also, the
  environment release check should be against the top-level EVAL env,
  not the root repl env.
- (concat (list) ...) was broken so fix it to ignore empty lists that
  aren't in the trailing position.
- nil, false and true in the reader were always being returned as
  references (with an ref cnt) but we have the assumption that
  references (14) are not ref cnt'd and are always part of a compound
  type so fix the reader to just return the interned addresses.
2016-10-06 22:22:57 -05:00
Joel Martin
9e8f521118 Basic: step7 basics, reader macros. step1,3 tests.
Also:
- Add some step1 and step3 tests that were discovered during Basic
  development.
- Move PR_MEMORY* to debug.in.bas
- Simplify Makefile deps
- Fix freeing in steps4-7 when error at deeper level
  i.e. (prn (abc))
- add SLICE function to support concat implementation.
2016-09-21 23:27:12 -05:00
Joel Martin
b7b1787f83 Basic: step2 basics. Vectors and hash-maps.
Adjust step2 tests to keep values within 2 byte int range.
2016-09-10 22:13:27 -05:00
Joel Martin
5e38bc9922 Fix step4 case sensitivity test. 2016-08-24 17:48:56 -05:00
Joel Martin
a7ed71b9e2 tests: additional tests based on PowerShell impl
- step1: empty list and vector
- step4: special forms case-sensitivity
- step9: apply with an empty list/vector
2016-08-24 17:39:24 -05:00
Dov Murik
eb63e565f3 tests: Verify case sensitivity of names and strings 2016-06-13 01:11:41 -04:00
Dov Murik
d3c401c1e8 tests: Test *ARGV* is set correctly in step 6
Add new mini test harness run_argv_test.sh to run the Mal interpreter
with different command-line arguments and test the stdout of that
process.

The main Makefile will automatically run the new harness whenever step 6
is tested (either directly or during REGRESS=1 of a more advanced step).
2016-05-11 11:31:04 -04:00
Joel Martin
c4dd3eb8c4 Merge pull request #210 from dubek/test-slurp-newline
tests: Test slurp captures final newline in step6
2016-05-10 12:41:44 -05:00
Dov Murik
2cd015e56a tests: Test slurp captures final newline in step6 2016-05-10 12:36:06 -04:00
Joel Martin
a1eb30fcc9 Use more common spelling of deferrable.
Deferable is apprently a less common but correct spelling.
2016-05-10 10:26:39 -05:00
Joel Martin
46e2568944 Makefile/runtest/tests: deferable/optional options
- tests/*: marked with deferable and optional runtest flags. Some
  moving around of tests within different sections to more closely
  align with the guide.
- runtest.py has --deferable/--no-deferable and
  --optional/--no-optional to control whether tests marked as
  deferable and optional are tested.
- Makefile: DEFERABLE and OPTIONAL top level flags to be passed to
  runtest when running tests.
- Also, fix problems in java quoting revealed by step7 test changes.
2016-05-09 21:14:15 -05:00
Joel Martin
c3a87f5174 tests: make throw of non-strings optional/soft. 2016-05-02 23:37:15 -05:00
Joel Martin
a26c2568b9 tests: move empty list test from step3 to step2. 2016-04-02 17:50:07 -05:00
Dov Murik
2318398419 tests: Add test for literal empty list in step3 2016-03-27 22:16:55 -04:00
Joel Martin
dca6b58578 Tests: move step5 non-TCO tests to per impl.
- Remove most of the step5 excludes in the Makefile except for ones
  which don't have TCO capability at all (or the implementation is too
  slow): bash, make, mal, matlab.

- Make perf_EXCLUDES consistent with other excludes.

- Add a print-FOO target which prints the resolved value of Makefile
  variable FOO. For example, `make print-IMPLS` to print the list of
  implementations.
2016-03-14 23:39:21 -05:00
Joel Martin
0067158f6d Object Pascal: full implementation. Test cleanup.
- Move vector related step4 and step6 tests to optional.
- Fix two step9 tests that weren't checking return value.
2016-03-13 17:12:01 -05:00
Joel Martin
077cdf6ff2 Merge pull request #184 from dubek/mal-time-ms
mal: Add time-ms to core; add tests for time-ms
2016-03-09 14:18:07 -06:00
Dov Murik
05ad2bf6cd ruby: concat should not modify its argument 2016-03-09 14:23:13 -05:00
Dov Murik
44c9a7d8be mal: Add time-ms to core; add tests for time-ms 2016-03-09 13:09:11 -05:00
Joel Martin
de3f3ed1ff tests/step3: test def! within let*. Fix groovy build. 2016-03-07 22:25:30 -06:00
Joel Martin
a61be4d37d bash: fix negative nums, more complex test.
Issue #178
2016-02-26 21:00:14 -06:00
Dov Murik
2c1eb1af68 ocaml: fix negative numbers handling 2016-02-25 17:39:32 -08:00
Joel Martin
8e32dbb6aa groovy, java, scala: add seq/string?.
Issue #166.

Also, add keyword? step9 test on zero length strings.
2016-02-12 09:59:39 -06:00
Joel Martin
329b6db3cf Add seq and string? tests.
Issue #166
2016-02-11 09:17:49 -06:00
Joel Martin
17946efbad Haxe, Julia, miniMAL: self-hosting fixes.
- Haxe: correctly set *ARGV*
- Julia: fix map function concatenation of results
- miniMAL: fix (= 'abc nil) and add test in step7 to catch it.
2016-02-05 13:27:30 -06:00
Dov Murik
4e284171ed tests: Add tests for (first nil) and (rest nil) 2016-02-03 21:23:45 -05:00
Joel Martin
35ea7a9ec7 Remove soft around nested equality tests
Related to issue #123
2016-02-01 15:10:12 -06:00
Dov Murik
163964afe1 tests: verify list/vector equality in hash-map values
This is still in the soft-tests section of tests/step9_try.mal.

Issues: #116, #123
2016-02-01 11:06:00 -05:00
Dov Murik
6205526a91 tests: Verify extra args (after &) are in a mal list
step4: before TCO
step9: after TCO and bypass TCO using `apply`
2016-01-29 21:37:30 -05:00
Dov Murik
a16bb08f51 python: Fix equality of unicode/normal strings in Python 2.x 2016-01-27 13:02:14 -05:00
Joel Martin
9bca0b57e3 tests: make macro result evaluation mandatory. 2016-01-26 14:21:05 -06:00
Dov Murik
718f8e4d6c tests/stepA: add gensym and clean or macro tests 2016-01-22 23:47:51 -05:00
Dov Murik
a193b2c470 tests/step8: remove and macro tests, add ->> macro tests
1. `gensym` isn't yet available in step8
2. `and` tests are very slow in some implementations
3. ->> macro is more complex
4. moved core.mal to the end so it won't override the builtin `or` macro
2016-01-22 23:47:50 -05:00
Joel Martin
6523be9f1a Add macro result eval test.
Test to cover bug https://github.com/kanaka/mal/issues/142
2016-01-20 15:28:55 -06:00
Dov Murik
627bd6f766 process, tests: move atoms implementation from stepA to step6 2016-01-06 14:33:55 +02:00
Dov Murik
3dcaa6ce43 js: Fix exception in `(nil) 2015-12-28 10:22:58 +02:00
Dov Murik
c4cd270022 tests: Add str and pr-str tests in step4 and step9
Specifically test serializing nil, empty collections and `str` of
collections.  The Mal implementation is *not* identical to Clojure for
these cases.
2015-12-17 22:01:31 +02:00